provider-step-usage-v1-0-0
Sum measured OpenCode step_finish token totals with replay deduplication and fail-closed validation.
- License 许可
- MIT
- 所属仓库
- djimit/djimitflo
- 最近更新
- 2026-11-15
- Stars
- ★ 2
- Forks
- 0
01 前言 Front Matter
- name
- provider-step-usage-v1-0-0
- author
- Codex under explicit operator implementation mandate
- version
- 1.0.0
- description
- Sum measured OpenCode step_finish token totals with replay deduplication and fail-closed validation.
- allowed-tools
- Bash
- disallowed-tools
- Network
02 资源文件 3
- 脚本run.mjs2.5 KB
- 脚本run.test.mjs2.7 KB
- 参考文档skill.contract.json1.1 KB
03 SKILL.md 正文
Provider step usage
Candidate executable asset for independent review. Not registered, approved, activated, or generated by the unsuccessful DjimitFlo factory run. This package was implemented by Codex under an explicit operator mandate; it conveys no execution authority.
Provenance: independently checked OpenCode proof task
deployed-provider-opencode-proof-20261101-r2 recorded 7101 tokens although its
step totals summed to 13941. The example below is synthetic numeric reconstruction;
no provider payloads or credentials are included. This package does not patch the
runtime adapter or claim to measure cost, energy, task success, or completeness of a
stream. It measures only the supplied step records.
Contract and execution
Run node run.mjs with a JSON object on stdin containing exactly events_json, a
string of newline-delimited JSON events. Output is {tokens,steps}. Run verification
with node --test run.test.mjs. No network, credentials, shell evaluation, or external
dependencies are used. Bash is declared solely for the existing governed invocation
interface; content cannot add commands or permissions.
Only OpenCode type: "step_finish" records with part.id and
part.tokens.total are measured. Totals must be explicit nonnegative safe integers.
Repeated part IDs with identical totals and session/message scope count once;
conflicting repeats fail. Missing stable part IDs fail rather than using array position
or timestamps. Other valid typed event objects are ignored. Invalid JSON, malformed
records, missing measurements, unsafe sums, or ambiguous totals fail with exit code 1,
no stdout result, and a payload-free error code on stderr. Explicit measured zero
is valid; unknown usage is never converted to zero.
Input and decoded events are each bounded to 262144 UTF-8 bytes (the entire stdin JSON envelope must fit). Blank lines are allowed. A partial stream is not evidence of full-run usage; callers must independently establish completeness and provider semantics before attributing this total to a run.
Example
Input: {"events_json":"{\"type\":\"step_finish\",\"part\":{\"id\":\"a\",\"tokens\":{\"total\":6840}}}\n{\"type\":\"step_finish\",\"part\":{\"id\":\"b\",\"tokens\":{\"total\":7101}}}"}
Output: {"tokens":13941,"steps":2}
Version changes must create a new immutable package and follow existing review and promotion gates. Do not infer approval from these local tests or from this document.
04 同仓库更多 Skills
writing-tests
Guidelines for writing, organizing, and maintaining tests in the opencode-swarm repository. Covers framework rules (bun:test), mock isolation, CI pipeline structure, file placement, and anti-patterns that break cross-platform CI. Load this skill before writing or modifying any test file.
worktree-retry-cleanup
Protocol for cleaning parallel-coder worktree lanes before retry. Triggered before re-dispatching any task that already has a lane (completed, denied, cancelled, or failed).
swarm
Cross-agent swarm-mode behavior model — a higher-rigor workflow using parallel investigation, independent reviewer validation, and critic challenge, plus the mandatory implementation closeout gate. Runtime adapters (.claude, .agents) add execution-specific notes and command wiring.
swarm-pr-subscribe
Monitor a pull request after creation and act autonomously on pushed PR activity. Use when subscribing to a PR after opening it, when asked to watch, babysit, or autofix a PR until merge, or when a <pr-activity> wake message or [pr-monitor:...] advisory arrives for a subscribed PR. Owns event triage (fix / ask / skip), bounded-retry escalation, and terminal-state cleanup.
swarm-pr-review
Run a graph-guided, tool-augmented Swarm PR review using context packing, parallel exploration, triggered plugin micro-lanes, independent reviewer validation, critic challenge, and metrics writeback. Use for deep pull request review with low false-positive tolerance and high recall.
swarm-pr-feedback
Ingest and resolve known pull request feedback with skeptical source verification. Use when addressing pasted PR feedback, GitHub review comments or threads, requested changes, CI/check failures, merge conflicts, stale PR branches, or PR follow-up work that must close all known issues without dropping findings. Supports multi-round bot reviews (the repository's bot posts a new review after every push) via the iterative pattern documented in the body. Stage A (structural pre-checks) and Stage B (reviewer + test_engineer) gates and the reviewer + critic closeout gate are MANDATORY for any change made as part of this process.