opencode-agent-orchestration-kit 1.0.41 → 1.0.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/README.md +119 -11
  2. package/docs/commands.md +2 -0
  3. package/docs/comparison.md +137 -0
  4. package/docs/distribution/awesome-opencode-submission.md +51 -0
  5. package/docs/installation.md +20 -0
  6. package/docs/models.md +10 -2
  7. package/docs/releases/v1.0.28.md +1 -2
  8. package/docs/releases/v1.0.29.md +1 -2
  9. package/docs/releases/v1.0.42.md +51 -0
  10. package/docs/releases/v1.0.43.md +67 -0
  11. package/opencode/agents/developer.md +8 -0
  12. package/opencode/agents/lead.md +40 -13
  13. package/opencode/agents/reviewer.md +22 -0
  14. package/opencode/docs/ai/evolution/benchmarks/replay-fixtures-red.jsonl +2 -0
  15. package/opencode/docs/ai/evolution/benchmarks/router-scenarios-red.jsonl +2 -0
  16. package/opencode/docs/ai/harness/agents.md +50 -0
  17. package/opencode/docs/ai/harness/playbooks/lead-ahe-flow.md +43 -0
  18. package/opencode/package-lock.json +27 -24
  19. package/opencode/scripts/check-harness.mjs +5 -1
  20. package/opencode/scripts/collect-session-evidence.mjs +197 -9
  21. package/opencode/scripts/collect-session-evidence.test.mjs +151 -0
  22. package/opencode/scripts/replay-routing.test.mjs +58 -0
  23. package/package.json +24 -1
  24. package/scripts/benchmark-tool-paths.mjs +1 -1
  25. package/scripts/check-public-boundary.mjs +1 -0
  26. package/scripts/package-smoke.test.mjs +2 -2
  27. package/scripts/version.test.mjs +2 -2
  28. package/docker/open-design/data/app.sqlite +0 -0
  29. package/docker/open-design/data/app.sqlite-shm +0 -0
  30. package/docker/open-design/data/app.sqlite-wal +0 -0
  31. package/docker/open-design/opencode-auth/log/2026-05-02T105802.log +0 -17
  32. package/docker/open-design/opencode-auth/log/2026-05-04T102127.log +0 -16
  33. package/docker/open-design/opencode-auth/opencode.db +0 -0
  34. package/docker/open-design/opencode-auth/opencode.db-shm +0 -0
  35. package/docker/open-design/opencode-auth/opencode.db-wal +0 -0
  36. package/docs/synology.md +0 -30
@@ -102,6 +102,11 @@ If you choose direct mode, invoke `developer` with:
102
102
  - minimum acceptance criteria;
103
103
  - expected validation.
104
104
 
105
+ If the small-gate in `docs/ai/harness/agents.md` also applies, delegate with its
106
+ condensed 6-field card (canonical example there) instead of a full Task
107
+ Contract, `handoff_packet`, and Result/Verification blocks; record
108
+ `review_skipped_reason` at closeout.
109
+
105
110
  Do not mentally implement the solution before delegating. Any handoff to another
106
111
  agent must be self-contained and include:
107
112
 
@@ -118,12 +123,9 @@ decision made, and relevant paths are enough.
118
123
 
119
124
  ## Skill Resolution
120
125
 
121
- Before delegating non-trivial work to a subagent:
122
-
123
- 1. If `docs/ai/harness/skill_registry.md` exists, read it.
124
- 2. Filter skills allowed for the destination agent.
125
- 3. Select only skills relevant to the task, with a maximum of 0-3 per handoff.
126
- 4. Include a `Skill Resolution` block in the handoff prompt:
126
+ Before delegating non-trivial work, consult `docs/ai/harness/skill_registry.md`
127
+ only when it exists and is readable or there is an explicit match. Then select
128
+ 0-3 skills and emit:
127
129
 
128
130
  ```
129
131
  ## Skill Resolution
@@ -134,8 +136,8 @@ Before delegating non-trivial work to a subagent:
134
136
  - fallback_policy: if registry is missing, use global <available_skills>
135
137
  ```
136
138
 
137
- 5. Prefer fewer skills over filling slots.
138
- 6. If no skill clearly matches, select none.
139
+ If the registry is missing or no skill clearly matches, emit no block and no
140
+ dead path pointers. Prefer fewer skills over filling slots.
139
141
 
140
142
  ## Auto-Forecast
141
143
 
@@ -182,6 +184,17 @@ Examples:
182
184
 
183
185
  Use the full phased flow only when there is real uncertainty, visual/product impact, technical decision-making, medium or large scope, or an explicit slash command.
184
186
 
187
+ ## Fast router and phase model
188
+
189
+ Explicit precedence: fast router first. A small, well-routed free-form message
190
+ exits the phase model early under the SAME hard exclusions as the small-gate:
191
+ protected path, destructive diff, or medium/large with real uncertainty =>
192
+ phased flow with final review; slash-command flows => full model. Canonical
193
+ sequence: 1 Intake -> 2 Discovery -> 3 Synthesis -> 4 Specification ->
194
+ 5 Implementation -> 6 Review -> 7 Closure. Do not restart phases or add agents
195
+ because of the count. On-demand AHE templates:
196
+ `docs/ai/harness/playbooks/lead-ahe-flow.md`.
197
+
185
198
  ## Required execution model
186
199
 
187
200
  Use explicit phase barriers:
@@ -207,8 +220,13 @@ Do not skip phases unless the work is genuinely trivial or you explicitly routed
207
220
  implementation correction goes back to `developer`.
208
221
  - Never invoke `reviewer` before there is a diff or implementation to review.
209
222
  - Every reviewable change requires a canonical `review_stage: final` envelope
210
- from `reviewer` before closure. Give it the objective, non-goals, task/spec,
211
- diff base, and original evidence; a developer summary is not a substitute.
223
+ from `reviewer` before closure, except the small-gate defined uniquely in
224
+ `docs/ai/harness/agents.md` (declared small + `<=2` files + no protected or
225
+ destructive paths + no required tests). Then close without reviewer and
226
+ record `review_skipped_reason: small_gate_pass`; outside the gate use the
227
+ reason enum. When review proceeds, give it the objective, non-goals,
228
+ task/spec, diff base, and original evidence; a developer summary is not a
229
+ substitute.
212
230
  - If `reviewer` returns `verdict: needs_changes`, synthesize the blocking
213
231
  findings, send a bounded correction task to `developer`, then invoke
214
232
  `reviewer` again. If it returns `blocked`, obtain the missing evidence or
@@ -255,6 +273,15 @@ When useful, include:
255
273
  ## Closure
256
274
 
257
275
  A task is closed only when there is concrete output, reasonable validation or a
258
- clear reason validation was not run, a final reviewer envelope has verdict
259
- `pass` or `pass_with_observations`, no blocking findings remain, and risks are
260
- explicit.
276
+ clear reason validation was not run, and either a final reviewer envelope with
277
+ verdict `pass` or `pass_with_observations` and no blocking findings, or the
278
+ small-gate with `review_skipped_reason`. Make risks explicit.
279
+
280
+ ## AHE for harness evolution
281
+
282
+ Changing agents, commands, skills, tools, or global rules is observable harness
283
+ work: evidence -> root cause -> manifest -> bounded changes -> re-evaluation ->
284
+ attribution -> review. Details:
285
+ `docs/ai/harness/playbooks/lead-ahe-flow.md`. Each change declares evidence,
286
+ root cause, component, predicted fixes, risks, and keep/improve/rollback+pivot.
287
+ Without git there is no automatic rollback; do not simulate one.
@@ -84,6 +84,28 @@ For `/plan`, apply the same contract to the objective, research, plan/spec,
84
84
  assumptions, risks, acceptance criteria, and validation design even when no
85
85
  implementation diff exists. State that limitation.
86
86
 
87
+ ## Proportional review by scope
88
+
89
+ Verdict rigor does not change with scope; review depth must be proportional:
90
+
91
+ - Review levels are `skipped`, `trivial`, `lite`, and `full`, with the
92
+ semantics defined in `docs/ai/harness/commands.md` (section
93
+ `/review-preflight`). The caller chooses the level from the small-gate in
94
+ `docs/ai/harness/agents.md`; this skill does not add new profiles.
95
+ - When review runs at small or medium scope (`lite`), consume the developer's
96
+ `Verification Envelope` first (`diff_base`, `review_scope`, `commands_run`,
97
+ `results`, `not_run`, `evidence`) as the authoritative record of checks
98
+ already run. Do not re-implement suites that envelope leaves green: repeat a
99
+ check only with a founded suspicion of the result, or when the envelope is
100
+ missing/incomplete for a blocking surface.
101
+ - In `lite`, spot-check the real diff and its direct consumers. Mark checks
102
+ adopted from the envelope as `envelope-reused` in the output section
103
+ `Checks reviewed/repeated`.
104
+ - For medium/large work and sensitive surfaces (auth/sessions, secrets,
105
+ exported public API, migrations, CI, harness) apply full verification and
106
+ the intact final verdict with no shortcuts: never substitute that depth with
107
+ trust in the envelope.
108
+
87
109
  ## Task Contract And Skill Resolution
88
110
 
89
111
  Confirm these Task Contract fields when applicable: `objective`,
@@ -0,0 +1,2 @@
1
+ {"schema_version":1,"scenario_id":"freeform-tiny-copy-trivial","observation_coverage":{"session_events":"complete","skill_events":"complete","tool_events":"complete","review_events":"complete","stop_events":"complete"},"git_snapshot":"changed","events":[{"sequence":1,"type":"session_started","session_id":"root","parent_session_id":null,"agent":"lead"},{"sequence":2,"type":"session_started","session_id":"s1","parent_session_id":"root","agent":"developer"},{"sequence":3,"type":"tool_call_completed","session_id":"s1","agent":"developer","tool":"apply_patch","mutation":"write"},{"sequence":4,"type":"session_completed","session_id":"s1","agent":"developer"},{"sequence":5,"type":"session_started","session_id":"s2","parent_session_id":"root","agent":"reviewer"},{"sequence":6,"type":"review_completed","session_id":"s2","agent":"reviewer","verdict":"approved"},{"sequence":7,"type":"session_completed","session_id":"s2","agent":"reviewer"},{"sequence":8,"type":"stop_observed","condition":"task-completed"}]}
2
+ {"schema_version":1,"scenario_id":"freeform-tiny-toy-single-file-full-pipeline","observation_coverage":{"session_events":"complete","skill_events":"complete","tool_events":"complete","review_events":"complete","stop_events":"complete"},"git_snapshot":"changed","events":[{"sequence":1,"type":"session_started","session_id":"root","parent_session_id":null,"agent":"lead"},{"sequence":2,"type":"session_started","session_id":"s1","parent_session_id":"root","agent":"researcher"},{"sequence":3,"type":"session_completed","session_id":"s1","agent":"researcher"},{"sequence":4,"type":"session_started","session_id":"s2","parent_session_id":"root","agent":"specifier"},{"sequence":5,"type":"session_completed","session_id":"s2","agent":"specifier"},{"sequence":6,"type":"session_started","session_id":"s3","parent_session_id":"root","agent":"developer"},{"sequence":7,"type":"tool_call_completed","session_id":"s3","agent":"developer","tool":"apply_patch","mutation":"write"},{"sequence":8,"type":"session_completed","session_id":"s3","agent":"developer"},{"sequence":9,"type":"session_started","session_id":"s4","parent_session_id":"root","agent":"reviewer"},{"sequence":10,"type":"review_completed","session_id":"s4","agent":"reviewer","verdict":"approved"},{"sequence":11,"type":"session_completed","session_id":"s4","agent":"reviewer"},{"sequence":12,"type":"stop_observed","condition":"task-completed"}]}
@@ -0,0 +1,2 @@
1
+ {"schema_version":1,"id":"freeform-tiny-copy-trivial","category":"trivial","prompt":"Change the Save button label to Save changes in a single HTML file and verify the diff.","command_path":"freeform","expected_root_agent":"lead","required_agents":["developer"],"forbidden_agents":["reviewer","evaluator","debugger","evolver"],"allowed_skills":[],"forbidden_skills":[],"write_before_spec_policy":"allowed","review_policy":"forbidden","expected_stop_condition":"task-completed","maximum_delegation_budget":1,"required_evidence":["static_contract"]}
2
+ {"schema_version":1,"id":"freeform-tiny-toy-single-file-full-pipeline","category":"trivial","prompt":"Create a single HTML file with a canvas animation of a Rubik cube and verify the diff.","command_path":"freeform","expected_root_agent":"lead","required_agents":["developer"],"forbidden_agents":["researcher","specifier","reviewer","evaluator","debugger","evolver"],"allowed_skills":[],"forbidden_skills":[],"write_before_spec_policy":"allowed","review_policy":"forbidden","expected_stop_condition":"task-completed","maximum_delegation_budget":1,"required_evidence":["static_contract"]}
@@ -83,6 +83,33 @@ generate or modify frontmatter.
83
83
  - `evaluator`, `debugger`, and `evolver` are optional sidecars.
84
84
  - `evolver` works only on the OpenCode harness.
85
85
 
86
+ ### Small-gate closeout without review
87
+
88
+ This is the unique, computable definition of "small" that may skip final
89
+ review. `lead` and the condensed Task Contract card consume this SAME
90
+ definition; no second definition exists in other contracts. The gate holds
91
+ ONLY when every condition is true:
92
+
93
+ 1. Scope declared `small` in the handoff or Task Contract.
94
+ 2. `diff_files_changed <= 2` counted against the real diff base.
95
+ 3. No file touches a protected path: auth/sessions, secrets/.env, exported
96
+ public API, migrations, CI, or the harness itself (`agents/**`,
97
+ `commands/**`, `docs/ai/harness/**`, `scripts/**`, `AGENTS.md`,
98
+ `docs/ai/evolution/benchmarks/**`, `skills/**`).
99
+ 4. Diff is not destructive: no mass deletes, no reverts of others' work, no
100
+ permission or security-config changes.
101
+ 5. The touched surface does not require new or mandatory tests.
102
+
103
+ Point-3 exclusions beat any size or prompt-length heuristic. When closing
104
+ through this gate, `lead` records `review_skipped_reason: small_gate_pass`.
105
+ The closed enum is: `small_gate_pass | protected_surface | destructive_diff |
106
+ tests_required | scope_not_small | human_decision`; the other values document
107
+ why the fast path did not apply, or an explicit human decision.
108
+
109
+ This gate does not reduce `reviewer` authority: medium/large work and every
110
+ sensitive surface keep a full `review_stage: final` with a single final
111
+ `reviewer` verdict. It does not apply retroactively to work already reviewed.
112
+
86
113
  ## Mission runtime projection
87
114
 
88
115
  `mission-status` is a read-only view over the durable loop snapshot and
@@ -130,6 +157,29 @@ when the change is not trivial. The minimum block is:
130
157
  - `validation`: commands, tests, or evidence.
131
158
  - `ask_abort_triggers`: conditions for asking, blocking, or returning work.
132
159
 
160
+ ### Condensed card for small scope
161
+
162
+ When the change meets the small-gate in the section above ("Small-gate closeout
163
+ without review", same unique definition), `lead` may delegate and `developer`
164
+ may close with a condensed 6-field card instead of the full Task Contract,
165
+ `handoff_packet`, and separate Result Contract / Verification Envelope stack.
166
+ This is an activation exemption, not a new contract: for non-trivial work every
167
+ prior block remains mandatory. Canonical audited example, exactly 6 fields:
168
+
169
+ ```text
170
+ small-card:
171
+ objective: rename the Save button to Save changes
172
+ success: visible label changed in the UI
173
+ validation: grep the literal + local render smoke
174
+ diff_base: working tree on HEAD (1 file)
175
+ constraints: do not touch other literals or tests
176
+ output: short summary with the applied diff
177
+ ```
178
+
179
+ When closing this way, `lead` records `review_skipped_reason` from the gate
180
+ enum. Telemetry (turn ids, timestamps, diff size) ALWAYS stays out of the
181
+ card: it lives only in evidence-collector output.
182
+
133
183
  For long, multi-agent, or resumable work, the responsible agent adds a compact
134
184
  `handoff_packet` with current objective, decisions made, files read/touched,
135
185
  validation state, blockers, and next action. Long logs are referenced by path
@@ -0,0 +1,43 @@
1
+ # Lead Playbook: AHE flow for harness evolution
2
+
3
+ On-demand block extracted from `agents/lead.md`. Consult it only when the task
4
+ changes agents, commands, skills, tools, or global rules of this harness
5
+ (`/evolve` or an approved harness evolution). Do not use it for normal app
6
+ features.
7
+
8
+ ## Explicit AHE flow
9
+
10
+ 1. `evaluator` runs or defines reproducible scenarios.
11
+ 2. `debugger` produces `analysis/overview.md` and per-pattern detail.
12
+ 3. `evolver` proposes changes with a manifest.
13
+ 4. `developer` applies only approved, bounded changes.
14
+ 5. `evaluator` re-runs the scenarios.
15
+ 6. `debugger` attributes fixes and regressions.
16
+ 7. `reviewer` reviews the diff against spec, manifest, and evaluation.
17
+
18
+ Each AHE change declares:
19
+
20
+ - evidence used
21
+ - root cause
22
+ - component touched: `agent`, `command`, `skill`, `tool`, `workflow`, or `memory`
23
+ - predicted fixes
24
+ - risk tasks
25
+ - keep / improve / rollback+pivot criterion
26
+
27
+ ## Background rules
28
+
29
+ - Sidecars (`evaluator`, `debugger`, `evolver`) are never mandatory phases of
30
+ the normal flow; invoke them with concrete evidence.
31
+ - Before `evaluator` on `/evolve`, confirm staged `session_sources` artifacts
32
+ generated from `opencode.db` plus optional raw exports.
33
+ - If no git repository is available, say that automatic rollback is not
34
+ enabled. Do not simulate rollback.
35
+ - App-feature evidence may live in the app repository; harness evolution
36
+ manifests and decisions live in this kit.
37
+
38
+ ## State management (medium/large work)
39
+
40
+ Keep or propose state in the repository convention: `docs/ai/status.md`,
41
+ `docs/ai/research/`, `docs/ai/design/`, `docs/ai/specs/`, `docs/ai/tasks/`,
42
+ `docs/ai/reviews/`, `docs/ai/evolution/`. If the repo already has another
43
+ convention, use that.
@@ -782,9 +782,9 @@
782
782
  }
783
783
  },
784
784
  "node_modules/baseline-browser-mapping": {
785
- "version": "2.10.27",
786
- "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.10.27.tgz",
787
- "integrity": "sha512-zEs/ufmZoUd7WftKpKyXaT6RFxpQ5Qm9xytKRHvJfxFV9DFJkZph9RvJ1LcOUi0Z1ZVijMte65JbILeV+8QQEA==",
785
+ "version": "2.11.20",
786
+ "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.20.tgz",
787
+ "integrity": "sha512-H0ulySigv6icDJ1F7SjtdCD6PrhTpdYCmP0CactWy1+ekh0AFd0o1Wn5T8b+hnTmdBx19u9yhL6wvCylXMY7zw==",
788
788
  "license": "Apache-2.0",
789
789
  "bin": {
790
790
  "baseline-browser-mapping": "dist/cli.cjs"
@@ -806,9 +806,9 @@
806
806
  }
807
807
  },
808
808
  "node_modules/browserslist": {
809
- "version": "4.28.2",
810
- "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.2.tgz",
811
- "integrity": "sha512-48xSriZYYg+8qXna9kwqjIVzuQxi+KYWp2+5nCYnYKPTr0LvD89Jqk2Or5ogxz0NUMfIjhh2lIUX/LyX9B4oIg==",
809
+ "version": "4.28.8",
810
+ "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.8.tgz",
811
+ "integrity": "sha512-V2NpofLblG64mfOtSgDhOJESZEGogzDMBv/q+W6oc4LXWP/q75eOXoOaaOu1EOadB9U4Bwx/e0yzbvwKH8zalA==",
812
812
  "funding": [
813
813
  {
814
814
  "type": "opencollective",
@@ -825,11 +825,11 @@
825
825
  ],
826
826
  "license": "MIT",
827
827
  "dependencies": {
828
- "baseline-browser-mapping": "^2.10.12",
829
- "caniuse-lite": "^1.0.30001782",
830
- "electron-to-chromium": "^1.5.328",
831
- "node-releases": "^2.0.36",
832
- "update-browserslist-db": "^1.2.3"
828
+ "baseline-browser-mapping": "^2.11.12",
829
+ "caniuse-lite": "^1.0.30001809",
830
+ "electron-to-chromium": "^1.5.402",
831
+ "node-releases": "^2.0.53",
832
+ "update-browserslist-db": "^1.3.0"
833
833
  },
834
834
  "bin": {
835
835
  "browserslist": "cli.js"
@@ -848,9 +848,9 @@
848
848
  }
849
849
  },
850
850
  "node_modules/caniuse-lite": {
851
- "version": "1.0.30001792",
852
- "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001792.tgz",
853
- "integrity": "sha512-hVLMUZFgR4JJ6ACt1uEESvQN1/dBVqPAKY0hgrV70eN3391K6juAfTjKZLKvOMsx8PxA7gsY1/tLMMTcfFLLpw==",
851
+ "version": "1.0.30001810",
852
+ "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001810.tgz",
853
+ "integrity": "sha512-TITQPUkaz+aVk5GL6NhOdwk1aEaNTSDPsGFWrTuhKGtjTF70jL/Oht2W4c6rXUe5fu7Ie19VIahAXHIIiWWNeg==",
854
854
  "funding": [
855
855
  {
856
856
  "type": "opencollective",
@@ -948,9 +948,9 @@
948
948
  }
949
949
  },
950
950
  "node_modules/electron-to-chromium": {
951
- "version": "1.5.352",
952
- "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.352.tgz",
953
- "integrity": "sha512-9wHk8x6dyuimoe18EdiDPWKExNdxYqo4fn4FwOVVper6RxT3cmpBwBkWWfSOCYJjQdIco/nPhJhNLmn4Ufg1Yg==",
951
+ "version": "1.5.420",
952
+ "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.420.tgz",
953
+ "integrity": "sha512-2yD6XreGusOfNV+dUcvipJEXc3n/n7fgr7996aszTG+YY5E4mqM4tOq/3uhP129cazL9YHbVWSpc79ePotWtPA==",
954
954
  "license": "ISC"
955
955
  },
956
956
  "node_modules/emoji-regex": {
@@ -1294,10 +1294,13 @@
1294
1294
  }
1295
1295
  },
1296
1296
  "node_modules/node-releases": {
1297
- "version": "2.0.38",
1298
- "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.38.tgz",
1299
- "integrity": "sha512-3qT/88Y3FbH/Kx4szpQQ4HzUbVrHPKTLVpVocKiLfoYvw9XSGOX2FmD2d6DrXbVYyAQTF2HeF6My8jmzx7/CRw==",
1300
- "license": "MIT"
1297
+ "version": "2.0.54",
1298
+ "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.54.tgz",
1299
+ "integrity": "sha512-YHs7BmmcsdAI5Ozuf8JZo6PT0mv2GIWC9vMfvUC3dp65M8hn7Ux8CPL+2oBI7juNuj9d0ndhTcznq2ODBps9cQ==",
1300
+ "license": "MIT",
1301
+ "engines": {
1302
+ "node": ">=18"
1303
+ }
1301
1304
  },
1302
1305
  "node_modules/p-limit": {
1303
1306
  "version": "2.3.0",
@@ -1611,9 +1614,9 @@
1611
1614
  }
1612
1615
  },
1613
1616
  "node_modules/update-browserslist-db": {
1614
- "version": "1.2.3",
1615
- "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.2.3.tgz",
1616
- "integrity": "sha512-Js0m9cx+qOgDxo0eMiFGEueWztz+d4+M3rGlmKPT+T4IS/jP4ylw3Nwpu6cpTTP8R1MAC1kF4VbdLt3ARf209w==",
1617
+ "version": "1.3.2",
1618
+ "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.3.2.tgz",
1619
+ "integrity": "sha512-UQ+MSxlhRm1bzjhU+DcuXfjFO1FzNtqhK5+9Yvlp90ItDLk5vT932A0rFu619nf7RVS+Y/VeaUW1jaRDqZ8VJw==",
1617
1620
  "funding": [
1618
1621
  {
1619
1622
  "type": "opencollective",
@@ -2982,7 +2982,11 @@ function checkOpenDesignToolContract() {
2982
2982
  if (/randomUUID|node:crypto/.test(source)) {
2983
2983
  fail(`${rel}: Open Design tool must not depend on randomUUID or node:crypto`);
2984
2984
  }
2985
- if (/juancanas|synology|\/Users\/|\/home\//i.test(source)) {
2985
+ const privateHostMarker = ["juancan", "as"].join("");
2986
+ const nasVendorMarker = ["syn", "ology"].join("");
2987
+ const usersPath = ["/", "Users", "/"].join("");
2988
+ const homePath = ["/", "home", "/"].join("");
2989
+ if (new RegExp(`${privateHostMarker}|${nasVendorMarker}|${usersPath}|${homePath}`, "i").test(source)) {
2986
2990
  fail(`${rel}: Open Design tool contains a private endpoint or local path`);
2987
2991
  }
2988
2992
  }
@@ -3,7 +3,7 @@
3
3
  import fs from "node:fs";
4
4
  import os from "node:os";
5
5
  import path from "node:path";
6
- import { spawn } from "node:child_process";
6
+ import { spawn, spawnSync } from "node:child_process";
7
7
  import { pathToFileURL } from "node:url";
8
8
 
9
9
  function fail(message) {
@@ -130,6 +130,154 @@ function firstTextPart(parts) {
130
130
  return null;
131
131
  }
132
132
 
133
+ // ---------------------------------------------------------------------------
134
+ // Phase-0 telemetry (iteration-025).
135
+ // These signals live ONLY in this collector's output; they are never injected
136
+ // into agent handoff prompts. All fields are additive and optional so existing
137
+ // consumers of execution-trees.jsonl keep working unchanged.
138
+ //
139
+ // Semantics:
140
+ // - request_turn_id: `<root_session_id>:t<n>` numbered by root user-message
141
+ // time; each spawn maps to the latest root turn active at its spawn moment,
142
+ // which makes multi-turn sessions classifiable per request instead of per
143
+ // session head.
144
+ // - t_handoff_start/t_handoff_end: paired spawn boundaries. For spawn i,
145
+ // t_handoff_start is the completion time of the previous hop (root start for
146
+ // the first hop) and t_handoff_end is the new spawn's creation time, so
147
+ // gap_ms is the observable consolidation gap before each delegation.
148
+ // Overlapping hops produce negative gaps (reported honestly, not clamped).
149
+ // - diff_size: measured at collection time against the tree root directory
150
+ // (`git diff --numstat`), never at gate decision time; consumers must treat
151
+ // it as a post-hoc approximation (captured_at: "collection").
152
+ // - review_skipped_reason: enum-valid marker extracted from session summaries.
153
+ // ---------------------------------------------------------------------------
154
+
155
+ const REVIEW_SKIPPED_REASONS = new Set([
156
+ "small_gate_pass",
157
+ "protected_surface",
158
+ "destructive_diff",
159
+ "tests_required",
160
+ "scope_not_small",
161
+ "human_decision",
162
+ ]);
163
+
164
+ const REVIEW_SKIPPED_REASON_PATTERN = /review_skipped_reason:\s*([a-z_]+)/;
165
+
166
+ function buildRequestTurns(turnTimes, rootSessionId) {
167
+ if (!Array.isArray(turnTimes) || turnTimes.length === 0) return [];
168
+ return [...turnTimes]
169
+ .filter((time) => typeof time === "number")
170
+ .sort((left, right) => left - right)
171
+ .map((tStart, index) => ({ turn_id: `${rootSessionId}:t${index + 1}`, t_start: tStart }));
172
+ }
173
+
174
+ function resolveRequestTurnId(requestTurns, spawnTime) {
175
+ if (typeof spawnTime !== "number" || requestTurns.length === 0) return null;
176
+ let matched = null;
177
+ for (const turn of requestTurns) {
178
+ if (turn.t_start <= spawnTime) matched = turn.turn_id;
179
+ }
180
+ return matched;
181
+ }
182
+
183
+ function buildHandoffs(childSessions, rootSession, requestTurns) {
184
+ const rootStart = typeof rootSession?.time_created === "number" ? rootSession.time_created : null;
185
+ let predecessorEnd = rootStart;
186
+ return childSessions.map((child, index) => {
187
+ const tSpawn = typeof child.time_created === "number" ? child.time_created : null;
188
+ const tComplete = typeof child.time_updated === "number" ? child.time_updated : null;
189
+ const gapMs = predecessorEnd !== null && tSpawn !== null ? tSpawn - predecessorEnd : null;
190
+ const handoff = {
191
+ sequence: index + 1,
192
+ agent: child.agent || null,
193
+ session_id: child.session_id,
194
+ request_turn_id: resolveRequestTurnId(requestTurns, tSpawn),
195
+ t_handoff_start: predecessorEnd,
196
+ t_handoff_end: tSpawn,
197
+ gap_ms: gapMs,
198
+ t_spawn: tSpawn,
199
+ t_complete: tComplete,
200
+ };
201
+ if (tComplete !== null) predecessorEnd = tComplete;
202
+ return handoff;
203
+ });
204
+ }
205
+
206
+ function deriveReviewSkippedReason(sortedRows, rootSession) {
207
+ const orderedRows = [
208
+ ...(rootSession ? [rootSession] : []),
209
+ ...sortedRows.filter((row) => row.session_id !== rootSession?.session_id),
210
+ ];
211
+ for (const row of orderedRows) {
212
+ const summary = row.assistant_summary;
213
+ if (typeof summary !== "string") continue;
214
+ const match = summary.match(REVIEW_SKIPPED_REASON_PATTERN);
215
+ if (match && REVIEW_SKIPPED_REASONS.has(match[1])) return match[1];
216
+ }
217
+ return null;
218
+ }
219
+
220
+ function unavailableDiffSize() {
221
+ return {
222
+ available: false,
223
+ files_changed: null,
224
+ insertions: null,
225
+ deletions: null,
226
+ captured_at: "collection",
227
+ };
228
+ }
229
+
230
+ function measureDiffSize(directory) {
231
+ const fallback = unavailableDiffSize();
232
+ if (typeof directory !== "string" || directory.length === 0) return fallback;
233
+ let stat;
234
+ try {
235
+ stat = fs.statSync(directory);
236
+ } catch {
237
+ return fallback;
238
+ }
239
+ if (!stat.isDirectory()) return fallback;
240
+ try {
241
+ const probe = spawnSync(
242
+ "git",
243
+ ["-C", directory, "rev-parse", "--is-inside-work-tree"],
244
+ { encoding: "utf8", timeout: 10_000 },
245
+ );
246
+ if (probe.status !== 0 || probe.stdout.trim() !== "true") return fallback;
247
+ const numstat = spawnSync(
248
+ "git",
249
+ ["-C", directory, "diff", "--numstat"],
250
+ { encoding: "utf8", timeout: 15_000, maxBuffer: 32 * 1024 * 1024 },
251
+ );
252
+ if (numstat.status !== 0) return fallback;
253
+ let filesChanged = 0;
254
+ let insertions = 0;
255
+ let deletions = 0;
256
+ for (const line of numstat.stdout.split("\n")) {
257
+ if (!line.trim()) continue;
258
+ const [added, removed] = line.split("\t");
259
+ filesChanged += 1;
260
+ if (/^\d+$/.test(added)) insertions += Number(added);
261
+ if (/^\d+$/.test(removed)) deletions += Number(removed);
262
+ }
263
+ // Untracked files are part of the visible work-tree delta even though
264
+ // `git diff --numstat` omits them; count them so small-gate metrics see
265
+ // brand-new files too.
266
+ const untracked = spawnSync(
267
+ "git",
268
+ ["-C", directory, "ls-files", "--others", "--exclude-standard"],
269
+ { encoding: "utf8", timeout: 15_000 },
270
+ );
271
+ if (untracked.status === 0) {
272
+ filesChanged += untracked.stdout.split("\n").filter((entry) => entry.trim()).length;
273
+ }
274
+ return { ...fallback, available: true, files_changed: filesChanged, insertions, deletions };
275
+ } catch {
276
+ return fallback;
277
+ }
278
+ }
279
+
280
+
133
281
  function loadPreviousCursor(iteration, outputDir) {
134
282
  if (!iteration) return null;
135
283
  const runsDir = path.dirname(path.dirname(outputDir));
@@ -217,6 +365,8 @@ async function summarizeSqlite(dbPath, previousCursor, fullRescan) {
217
365
  partsByMessage.set(part.message_id, list);
218
366
  }
219
367
 
368
+ const userTurnTimesBySession = new Map();
369
+
220
370
  const normalized = [];
221
371
  let skipped = 0;
222
372
  const skipReasons = {};
@@ -245,6 +395,13 @@ async function summarizeSqlite(dbPath, previousCursor, fullRescan) {
245
395
  if (role === "assistant") assistantMessages.push(message);
246
396
  }
247
397
 
398
+ userTurnTimesBySession.set(
399
+ session.id,
400
+ userMessages
401
+ .map((message) => message.time_created)
402
+ .filter((time) => typeof time === "number"),
403
+ );
404
+
248
405
  const firstUser = userMessages[0];
249
406
  const lastAssistant = assistantMessages.at(-1);
250
407
  const userPrompt = firstUser ? firstTextPart(partsByMessage.get(firstUser.id) || []) : null;
@@ -302,6 +459,7 @@ async function summarizeSqlite(dbPath, previousCursor, fullRescan) {
302
459
  skip_reasons: skipReasons,
303
460
  },
304
461
  normalized,
462
+ userTurnTimesBySession,
305
463
  };
306
464
  }
307
465
 
@@ -411,7 +569,7 @@ function treeRepresentativeSummary(sessions) {
411
569
  .at(-1).assistant_summary;
412
570
  }
413
571
 
414
- function buildExecutionTrees(sqliteRows, rawRows, previousCursor, fullRescan) {
572
+ function buildExecutionTrees(sqliteRows, rawRows, previousCursor, fullRescan, userTurnTimesBySession = null) {
415
573
  const sqliteMap = new Map(sqliteRows.map((row) => [row.session_id, row]));
416
574
  const rawBySessionId = new Map(rawRows.map((row) => [row.session_id, row]));
417
575
  const grouped = new Map();
@@ -474,6 +632,18 @@ function buildExecutionTrees(sqliteRows, rawRows, previousCursor, fullRescan) {
474
632
  source_formats: [...new Set(["opencode-sqlite", ...matchedRawIds.map(() => "opencode-raw-json")])],
475
633
  };
476
634
 
635
+ const requestTurns = buildRequestTurns(
636
+ userTurnTimesBySession?.get(rootSession.session_id),
637
+ rootSession.session_id,
638
+ );
639
+ tree.telemetry = {
640
+ method_version: 1,
641
+ request_turns: requestTurns,
642
+ handoffs: buildHandoffs(childSessions, rootSession, requestTurns),
643
+ review_skipped_reason: deriveReviewSkippedReason(sortedRows, rootSession),
644
+ diff_size: unavailableDiffSize(),
645
+ };
646
+
477
647
  if (
478
648
  !fullRescan &&
479
649
  previousCursor &&
@@ -527,8 +697,12 @@ export async function collectExecutionTreeByRoot(dbPath, rootSessionId) {
527
697
  const result = await summarizeSqlite(dbPath, null, true);
528
698
  const rootSession = result.normalized.find((row) => row.session_id === rootSessionId);
529
699
  if (!rootSession || rootSession.parent_session_id !== null) return null;
530
- const built = buildExecutionTrees(result.normalized, [], null, true);
531
- return built.trees.find((tree) => tree.root_session_id === rootSessionId) || null;
700
+ const built = buildExecutionTrees(result.normalized, [], null, true, result.userTurnTimesBySession);
701
+ const tree = built.trees.find((candidate) => candidate.root_session_id === rootSessionId) || null;
702
+ if (tree?.telemetry) {
703
+ tree.telemetry.diff_size = measureDiffSize(tree.root_directory);
704
+ }
705
+ return tree;
532
706
  }
533
707
 
534
708
  function makeCursor(previousCursor, treeSummary, trees, supplementalRawSummary, fullRescan) {
@@ -576,25 +750,39 @@ export async function main(argv = process.argv.slice(2)) {
576
750
  const summaries = [];
577
751
  let sqliteRows = [];
578
752
  let rawRows = [];
753
+ let userTurnTimesBySession = null;
579
754
 
580
755
  const previousCursor = args.fullRescan ? null : loadPreviousCursor(args.iteration, outputDir);
581
756
 
582
757
  for (const sourcePath of sourcePaths) {
583
758
  if (!fs.existsSync(sourcePath)) continue;
584
759
  const kind = detectSource(sourcePath);
585
- const result =
586
- kind === "opencode-sqlite"
587
- ? await summarizeSqlite(sourcePath, previousCursor, args.fullRescan)
588
- : summarizeRawDir(sourcePath);
760
+ let result;
761
+ if (kind === "opencode-sqlite") {
762
+ result = await summarizeSqlite(sourcePath, previousCursor, args.fullRescan);
763
+ } else {
764
+ result = { source: null, normalized: [] };
765
+ const rawResult = summarizeRawDir(sourcePath);
766
+ result.source = rawResult.source;
767
+ result.normalized = rawResult.normalized;
768
+ result.userTurnTimesBySession = new Map();
769
+ }
589
770
  summaries.push(result.source);
590
771
  if (kind === "opencode-sqlite") {
591
772
  sqliteRows = sqliteRows.concat(result.normalized);
773
+ userTurnTimesBySession = new Map([
774
+ ...(userTurnTimesBySession || []),
775
+ ...result.userTurnTimesBySession,
776
+ ]);
592
777
  } else {
593
778
  rawRows = rawRows.concat(result.normalized);
594
779
  }
595
780
  }
596
781
 
597
- const built = buildExecutionTrees(sqliteRows, rawRows, previousCursor, args.fullRescan);
782
+ const built = buildExecutionTrees(sqliteRows, rawRows, previousCursor, args.fullRescan, userTurnTimesBySession);
783
+ for (const tree of built.trees) {
784
+ tree.telemetry.diff_size = measureDiffSize(tree.root_directory);
785
+ }
598
786
  const acceptedSessionIds = new Set(built.trees.flatMap((tree) => tree.session_ids));
599
787
  const filteredSessionRows = sortSessions(sqliteRows.filter((row) => acceptedSessionIds.has(row.session_id)));
600
788
  const cursor = makeCursor(previousCursor, built.treeSummary, built.trees, built.supplementalRawSummary, args.fullRescan);