opencode-agent-orchestration-kit 1.1.1 → 1.2.1

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.
package/README.md CHANGED
@@ -398,8 +398,9 @@ OpenCode default model, small/title model, and per-agent overrides. It builds
398
398
  its provider list from OpenCode itself and reads the local model catalog from
399
399
  `opencode models --pure`, so it only shows providers configured in your
400
400
  OpenCode installation. Startup is cache-first; press `r` when you want an
401
- explicit remote catalog refresh through `--refresh`. It does not share a
402
- catalog with Pi.
401
+ explicit remote catalog refresh through `--refresh`. On OpenCode 2, which
402
+ removed both flags and already lists only providers with credentials, it reads
403
+ `opencode models` instead. It does not share a catalog with Pi.
403
404
 
404
405
  From this checkout, run:
405
406
 
@@ -425,7 +426,7 @@ After a tagged release is published, you can install the same CLI directly
425
426
  from GitHub without keeping a checkout:
426
427
 
427
428
  ```bash
428
- npm install --global "git+https://github.com/jcarlosrodicio/opencode-agent-orchestration-kit.git#v1.1.1"
429
+ npm install --global "git+https://github.com/jcarlosrodicio/opencode-agent-orchestration-kit.git#v1.2.1"
429
430
  oc-switch
430
431
  ```
431
432
 
@@ -445,7 +446,12 @@ global bin directory) on `PATH` if npm is configured with a user prefix.
445
446
  `r` explicitly refreshes OpenCode's catalog.
446
447
 
447
448
  The selected values are persisted in the OpenCode model-switcher state and in
448
- the managed model block of `.zshrc` or `.bashrc`.
449
+ the managed model block of `.zshrc` or `.bashrc`. On OpenCode 2, saving also
450
+ runs `opencode service restart` with the new values, because the background
451
+ service keeps the environment it started with; if the restart fails, the
452
+ values stay saved and `oc-switch` asks you to run that command yourself.
453
+ Terminals that were already open keep the old variables until you open a new
454
+ shell.
449
455
 
450
456
  Pi has its own independent `pi-switch`; its catalog comes only from Pi's
451
457
  `pi --list-models` command.
@@ -842,7 +848,7 @@ Validate only the canonical identity and current release note with:
842
848
 
843
849
  ```bash
844
850
  npm run check:version
845
- node scripts/version.mjs --check-tag v1.1.1
851
+ node scripts/version.mjs --check-tag v1.2.1
846
852
  ```
847
853
 
848
854
  Tag validation compares an explicitly supplied tag with the package identity.
package/docs/models.md CHANGED
@@ -34,7 +34,7 @@ oc-switch
34
34
  Once a release tag exists, a checkout is optional:
35
35
 
36
36
  ```bash
37
- npm install --global "git+https://github.com/jcarlosrodicio/opencode-agent-orchestration-kit.git#v1.1.1"
37
+ npm install --global "git+https://github.com/jcarlosrodicio/opencode-agent-orchestration-kit.git#v1.2.1"
38
38
  oc-switch
39
39
  ```
40
40
 
@@ -0,0 +1,79 @@
1
+ # v1.2.0 - Safe lifecycle and canonical release identity
2
+
3
+ This minor release ports three process changes from norma, OAK's sibling
4
+ harness, and clears the production dependency audit. The final review now
5
+ works in bounded rounds and treats a bar lowered to get to green as a
6
+ defect, developers get a policy for which tests to write, and nine
7
+ transitive advisories in the shipped OpenCode tool dependencies are fixed
8
+ with exact overrides.
9
+
10
+ ## Highlights
11
+
12
+ - **A weakened bar is a review finding.** `oak-adversarial-review` has
13
+ eleven dimensions. Dimension 10 covers a test made easier, a checker
14
+ silenced, a threshold moved or unfinished work: each one blocks unless the
15
+ task artifacts name it and quote the requirement behind it. Dimension 11
16
+ reports a test that only re-proves an existing one as should fix.
17
+ - **Review rounds.** A later round reads the previous report first, closes
18
+ each of its findings as resolved, still open or dismissed, and does not
19
+ raise them again. A finding names its class and every instance. A third
20
+ round that still blocks ends as `blocked`, and `/autonomous` treats it as
21
+ stop reason 6. The state-sync step appends each round to the review report
22
+ instead of overwriting it.
23
+ - **Pre-existing findings are reported apart** and never block or count as
24
+ blocking or unresolved. The `review` run event carries `round=` and
25
+ `pre_existing=`.
26
+ - **Which Tests to Write.** `test-driven-development` gains a test policy:
27
+ search before writing, one test per rule at the cheapest layer, one
28
+ representative case plus the edges that differ, a list of what not to
29
+ test, at most one regression test per bug, and the guarantees that are
30
+ always kept. A project's own policy in `AGENTS.md` wins. The developer's
31
+ Strict TDD rule points at it.
32
+ - **Clean dependency audit.** `npm audit --omit=dev` on `opencode/` reported
33
+ nine advisories (four critical, five high). Exact overrides fix them
34
+ without moving the pinned `@opencode-ai/plugin` 1.14.41, `@opentui/solid`
35
+ 0.2.5 or `solid-js` 1.9.12: `brace-expansion` 5.0.12, `seroval` and
36
+ `seroval-plugins` 1.6.8, `toml` 5.0.1 and `zod` 4.6.7. The supply-chain
37
+ contract and `docs/supply-chain.md` carry the new pins.
38
+ - The OpenCode 2 type workspace pins `@babel/core` 7.29.7, the same version
39
+ the shipped `opencode/package.json` already overrides.
40
+
41
+ ## Installation or upgrade
42
+
43
+ Install or upgrade the published CLI package:
44
+
45
+ ```bash
46
+ npm install --global opencode-agent-orchestration-kit@1.2.0
47
+ oak version
48
+ oak upgrade --dry-run
49
+ oak upgrade
50
+ ```
51
+
52
+ The npm installation exposes the CLIs but does not mutate OpenCode
53
+ configuration. `oak install` and `oak upgrade` remain separate, explicit
54
+ operations.
55
+
56
+ ## Migration
57
+
58
+ No migration is required. Existing harness configuration remains compatible.
59
+ `oak upgrade` refreshes the agent, command and skill files that changed. A
60
+ preserved target `opencode/package.json` or `package-lock.json` keeps its own
61
+ resolutions: merge the new overrides into it to get the audit fixes.
62
+
63
+ ## Validation performed
64
+
65
+ The public contract check, unit and script suite, typechecks for OpenCode 1
66
+ and OpenCode 2, compatibility and supply-chain checks, the production and
67
+ signature dependency audits, installation smoke and package smoke passed.
68
+ GitHub Actions Check and the OpenCode 1 and OpenCode 2 compatibility smokes
69
+ were green on the merged pull request before the release tag.
70
+
71
+ ## Public safety boundary
72
+
73
+ The public release excludes private OpenCode and Pi configuration, local
74
+ providers and MCP wiring, credentials, authentication files, provider URLs,
75
+ raw transcripts, private evidence, absolute machine-local paths, and runtime
76
+ state.
77
+
78
+ Boundary statement: no private config, no credentials, no provider URLs, no
79
+ raw transcripts, no machine-local paths.
@@ -0,0 +1,75 @@
1
+ # v1.2.1 - Safe lifecycle and canonical release identity
2
+
3
+ This patch release makes `oc-switch` work with OpenCode 2, makes `/loop` and
4
+ `/loop-status` find their state runtime in any project, and clears new
5
+ advisories in the dependency audit.
6
+
7
+ ## Highlights
8
+
9
+ - **`oc-switch` works with OpenCode 2.** OpenCode 2 removed the `--pure` and
10
+ `--refresh` flags of `opencode models`, so `oc-switch` could not load any
11
+ catalog and every provider showed as unavailable. It now detects the
12
+ OpenCode major version and, on OpenCode 2, reads `opencode models`, which
13
+ already lists only providers with credentials. OpenCode 1 keeps the
14
+ previous commands.
15
+ - **Saved models apply on OpenCode 2.** OpenCode 2 runs prompts through a
16
+ background service that keeps the environment it started with, so new
17
+ models had no effect until a manual restart. Saving now runs
18
+ `opencode service restart` with the new model variables. If the restart
19
+ fails, the models stay saved and `oc-switch` prints a warning that tells you
20
+ to run `opencode service restart` yourself.
21
+ - **`/loop` and `/loop-status` use the runtime in the OpenCode config
22
+ directory.** They called `scripts/loop-state.mjs` and
23
+ `scripts/mission-status.mjs` relative to the project, where those files do
24
+ not exist, and agents improvised their own state writer. Both commands now
25
+ resolve the scripts from
26
+ `${OPENCODE_CONFIG_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/opencode}`, and a
27
+ missing runtime stops the loop instead of being improvised. `lead` can now
28
+ run `/loop-status`, which its default deny rule blocked.
29
+ - **Dependency audit.** Exact overrides clear new advisories in the shipped
30
+ OpenCode tool dependencies: `effect` (GHSA-chp3-j5qr-2vfr), `glob`,
31
+ `minimatch` and `seroval`. The OpenCode 2 typecheck lockfile also takes
32
+ patched `ip-address`, `undici` and `http-cache-semantics` versions.
33
+ - **Release checks ignore a local CodeGraph index.** The public boundary scan
34
+ no longer fails on a `.codegraph/` directory, which is never packaged.
35
+
36
+ ## Installation or upgrade
37
+
38
+ Install or upgrade the published CLI package:
39
+
40
+ ```bash
41
+ npm install --global opencode-agent-orchestration-kit@1.2.1
42
+ oak version
43
+ oak upgrade --dry-run
44
+ oak upgrade
45
+ ```
46
+
47
+ The npm installation exposes the CLIs but does not mutate OpenCode
48
+ configuration. `oak install` and `oak upgrade` remain separate, explicit
49
+ operations. Run `oak upgrade` to get the new `/loop` and `/loop-status`
50
+ commands in your OpenCode configuration.
51
+
52
+ ## Migration
53
+
54
+ No migration is required. Existing harness configuration remains compatible.
55
+ On OpenCode 2, if you changed models with an earlier `oc-switch`, run
56
+ `opencode service restart` once from a new shell so the service picks them up.
57
+
58
+ ## Validation performed
59
+
60
+ The public contract check, unit and script suite, typechecks for OpenCode 1
61
+ and OpenCode 2, compatibility and supply-chain checks, installation smoke and
62
+ package smoke passed. `oc-switch` was also run against OpenCode 2.4.1: it
63
+ loaded the catalog, and after a save the restarted service ran prompts with
64
+ the saved provider instead of the one in the calling shell. GitHub
65
+ Actions Check was green on the merged pull request before the release tag.
66
+
67
+ ## Public safety boundary
68
+
69
+ The public release excludes private OpenCode and Pi configuration, local
70
+ providers and MCP wiring, credentials, authentication files, provider URLs,
71
+ raw transcripts, private evidence, absolute machine-local paths, and runtime
72
+ state.
73
+
74
+ Boundary statement: no private config, no credentials, no provider URLs, no
75
+ raw transcripts, no machine-local paths.
@@ -15,8 +15,12 @@ the immutable identifier consumed by the repository.
15
15
  | pnpm | 10.33.2 | exact version |
16
16
  | opencode-ai | 1.14.31 | exact version |
17
17
  | @babel/core override | 7.29.7 | exact version |
18
- | brace-expansion override | 5.0.9 | exact version |
19
- | uuid override | 14.0.0 | exact version |
18
+ | brace-expansion override | 5.0.12 | exact version |
19
+ | effect override | 4.0.7 | exact version |
20
+ | glob override | 14.0.2 | exact version |
21
+ | seroval override | 1.6.12 | exact version |
22
+ | seroval-plugins override | 1.6.12 | exact version |
23
+ | zod override | 4.6.7 | exact version |
20
24
  <!-- supply-chain-pins:end -->
21
25
 
22
26
  ## npm install and review contract
@@ -30,9 +34,22 @@ focused test. There is currently no exception.
30
34
 
31
35
  The exact overrides exist for reviewable reasons: `@babel/core` 7.29.7 removes
32
36
  the audited low-severity findings without an incompatible downgrade,
33
- `brace-expansion` 5.0.9 fixes GHSA-mh99-v99m-4gvg and GHSA-rgw5-rvv9-x895 in the transitive
34
- OpenTUI/Babel resolution, and `uuid` 14.0.0 preserves the already tested
35
- lockfile resolution. Change an override and regenerate the lockfile in the same
37
+ `brace-expansion` 5.0.12 fixes GHSA-mh99-v99m-4gvg, GHSA-rgw5-rvv9-x895,
38
+ GHSA-6j4f-fj2g-mc7p, GHSA-qhr7-859c-m2p7 and GHSA-q2hr-2g5m-vwhr in the transitive
39
+ OpenTUI/Babel resolution. `seroval` and `seroval-plugins` 1.6.12 fix
40
+ GHSA-p6vx-979v-rg4c, GHSA-jp82-f5mq-hwhp, GHSA-9wx9-5pv9-3349 and
41
+ GHSA-f86p-h4j2-7qgj under `solid-js`, which stays at 1.9.12 because
42
+ `@opentui/solid` 0.2.5 requires exactly that version; 1.6 is the line
43
+ `solid-js` 1.9.17 itself depends on. `glob` 14.0.2 fixes GHSA-3g3m-2fjr-6pw4
44
+ and, through its `minimatch` 11 range, GHSA-g3hv-75wg-m249 under
45
+ `babel-plugin-module-resolver`; that plugin only calls `glob` for its `root`
46
+ option, which `@opentui/solid` does not pass. `zod` 4.6.7 fixes
47
+ GHSA-mrhx-c7xc-m3w5 under the pinned `@opencode-ai/plugin`. `effect` 4.0.7
48
+ fixes GHSA-chp3-j5qr-2vfr under the same plugin, which pins the vulnerable
49
+ `4.0.0-beta.59` and only uses it for the `Effect.Effect<void>` type in
50
+ `tool.d.ts`; 4.0.7 is the last 4.0 stable release and has no dependencies,
51
+ which also drops the `toml` and `uuid` that only `effect` 4.0.0-beta.59
52
+ pulled in. Change an override and regenerate the lockfile in the same
36
53
  reviewed diff. Review every changed version, `resolved` URL, integrity value,
37
54
  lifecycle script, and Git or non-registry dependency.
38
55
 
@@ -80,8 +97,9 @@ For each surface, also record:
80
97
  signature audit, import, and typecheck evidence.
81
98
  - `brace-expansion` override: advisory rationale, manifest/lockfile diff, low
82
99
  audit, signature audit, import, and full package smoke evidence.
83
- - `uuid` override: compatibility rationale, manifest/lockfile diff, signature
84
- audit, import, and typecheck evidence.
100
+ - `effect`, `glob`, `seroval`, `seroval-plugins` and `zod` overrides: advisory rationale,
101
+ manifest/lockfile diff, low audit, signature audit, import, and OpenCode
102
+ compatibility smoke evidence.
85
103
 
86
104
  Run installation, core/default, and package smokes wherever a changed surface
87
105
  can affect them.
package/docs/workflows.md CHANGED
@@ -44,7 +44,9 @@ One explicit invocation runs the whole task without human gates:
44
44
  4. The cycle repeats within a one-to-six iteration budget: a focused change,
45
45
  deterministic validation, `oak-runtime-verification` when there is a runtime
46
46
  surface, `oak-update-docs`, and a fresh `reviewer` subagent applying
47
- `oak-adversarial-review`.
47
+ `oak-adversarial-review`. Each later review round closes the previous
48
+ round's findings instead of starting over, and a third round that still
49
+ blocks stops the run.
48
50
  5. After approval, `oak state attest-review`, `oak state record --status
49
51
  completed`, and `oak run close` write the attestation and the run summary.
50
52
  6. `developer` commits with `oak-commit` and runs `oak deliver pr`.
@@ -170,7 +170,8 @@ it as the working rule for behavior or testable logic changes:
170
170
  - write the test that reproduces or protects the behavior first when viable;
171
171
  - make it pass with the minimum change;
172
172
  - refactor only after green;
173
- - cover relevant edge cases for the changed logic;
173
+ - cover relevant edge cases for the changed logic, with the fewest tests that
174
+ pin it, following "Which Tests to Write" in `test-driven-development`;
174
175
  - report commands and results in the `Verification Envelope`.
175
176
 
176
177
  If TDD does not apply (docs, copy, config without a viable runner, or behavior
@@ -25,7 +25,8 @@ permission:
25
25
  "grep *": allow
26
26
  "rg *": allow
27
27
  "node scripts/collect-session-evidence.mjs --iteration *": allow
28
- "node scripts/loop-state.mjs inspect*": allow
28
+ "node *scripts/loop-state.mjs inspect*": allow
29
+ "node *scripts/mission-status.mjs*": allow
29
30
  "node scripts/preflight-audit.mjs --iteration *": allow
30
31
  "tail *": allow
31
32
  "which": allow
@@ -64,7 +64,7 @@ task, applicable repository instructions, ADR, specification, or architecture
64
64
  documentation explicitly declares them. Directory layout alone is not enough.
65
65
 
66
66
  For every `review_stage: final`, also load `oak-adversarial-review` and apply its
67
- four stages before writing findings. Its coverage line opens the output, its
67
+ five stages before writing findings. Its coverage line opens the output, its
68
68
  findings keep the canonical fields above, and its verdict maps to the canonical
69
69
  verdict as that skill defines. Do not read the developer's summary, the run
70
70
  events or an autonomy log before forming your own view; read them last.
@@ -67,7 +67,7 @@ oak state resume --root . --slug <slug> --contract .opencode/loops/<slug>.md --s
67
67
  oak run event --root . --type runtime_verification surface=<none|command|endpoint|store|screen> verdict=<verdict> evidence_count=<n>
68
68
  oak state record --root . --slug <slug> --session-id <RUN> --action-id iteration-<n> --iteration <n> --completed-step <step> --blocking-cause null
69
69
  # after each review, with the counts the reviewer returned:
70
- oak run event --root . --type review review=adversarial files_in_change=<n> files_reviewed=<n> files_skipped=<n> blocking=<n> should_fix=<n> nit=<n> verdict=<safe_to_commit|not_safe_to_commit>
70
+ oak run event --root . --type review review=adversarial round=<n> files_in_change=<n> files_reviewed=<n> files_skipped=<n> blocking=<n> should_fix=<n> nit=<n> pre_existing=<n> verdict=<safe_to_commit|not_safe_to_commit>
71
71
  # after the final reviewer approval:
72
72
  oak state attest-review --root . --slug <slug> --reviewer-session-id <reviewer child session id> --reviewer-agent reviewer --reviewer-verdict APPROVE
73
73
  oak state record --root . --slug <slug> --session-id <RUN> --action-id completed --iteration <n> --completed-step reviewer_approved --blocking-cause null --status completed
@@ -132,9 +132,11 @@ review, `developer` runs `oak-update-docs`, so the reviewer sees the docs too.
132
132
  `lead` invokes `reviewer` only as a
133
133
  subagent with `task reviewer`; never run `opencode run --agent reviewer`. The
134
134
  reviewer applies `oak-adversarial-review` and stays read-only: it returns the
135
- report and its counts, and the state-sync `developer` copies the report
136
- verbatim to `docs/ai/runs/<date>-<slug>/oak-adversarial-review.md` and records the
137
- `review` run event. The reviewer must not read the autonomy log; a correction
135
+ report and its counts, and the state-sync `developer` appends the report
136
+ verbatim to `docs/ai/runs/<date>-<slug>/oak-adversarial-review.md` under a
137
+ `## Round <n>` heading, never overwriting an earlier round, and records the
138
+ `review` run event. `lead` tells each later reviewer its round number and that
139
+ file's path. The reviewer must not read the autonomy log; a correction
138
140
  pass reads it first.
139
141
 
140
142
  Only that child session's final `pass` or `pass_with_observations` may complete
@@ -178,7 +180,9 @@ This list is closed. Stop only when:
178
180
  public interface, or rewriting pushed history; production, migrations,
179
181
  Terraform and Kubernetes land here;
180
182
  5. the harness itself blocks;
181
- 6. two attempts at the same failure both failed; attach the output;
183
+ 6. two attempts at the same failure both failed; attach the output. A third
184
+ review round that still blocks lands here too: the fixes are not
185
+ converging, so attach the review report with its three rounds;
182
186
  7. the task looks wrong or already done.
183
187
 
184
188
  "I would prefer to confirm" is not a stop reason. Provider rate limits and
@@ -9,8 +9,8 @@ Usa esta consulta para inspeccionar un loop existente sin reanudarlo ni
9
9
  modificarlo.
10
10
 
11
11
  ```bash
12
- node scripts/mission-status.mjs --root /ruta/absoluta/al/repo --slug <slug>
13
- node scripts/mission-status.mjs --root /ruta/absoluta/al/repo --slug <slug> --json
12
+ node "${OPENCODE_CONFIG_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/opencode}/scripts/mission-status.mjs" --root /ruta/absoluta/al/repo --slug <slug>
13
+ node "${OPENCODE_CONFIG_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/opencode}/scripts/mission-status.mjs" --root /ruta/absoluta/al/repo --slug <slug> --json
14
14
  ```
15
15
 
16
16
  La salida proyecta el snapshot canónico y el último evento validado:
@@ -26,8 +26,22 @@ history_path: .opencode/loops/<slug>.history.jsonl
26
26
  lock_path: .opencode/loops/<slug>.lock
27
27
  human_view_path: .opencode/loops/<slug>.md
28
28
  worktree_mode: explicit_opt_in
29
+ state_runtime: ${OPENCODE_CONFIG_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/opencode}/scripts/loop-state.mjs
30
+ state_runtime_missing: stop_and_report
29
31
  ```
30
32
 
33
+ ## State runtime
34
+
35
+ The state writer is the kit's own `loop-state.mjs`, installed in the OpenCode
36
+ config directory, not in the project. Every `loop-state.mjs` subcommand in this
37
+ command (`inspect`, `init`, `resume`, `record`, `repair`, `migrate`, `release`)
38
+ runs as `node "${OPENCODE_CONFIG_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/opencode}/scripts/loop-state.mjs" <subcommand>`
39
+ from the project root. A project-local `scripts/loop-state.mjs` is never used.
40
+
41
+ If that file does not exist, stop and report the missing path. Never create,
42
+ copy, or hand-write a state writer, and never write `.opencode/loops/` files
43
+ directly.
44
+
31
45
  The three-iteration value limits one invocation. The persisted
32
46
  `planned_iteration_budget` (`planned_iterations` in canonical state) is the total budget for the mission and may not
33
47
  exceed the hard ceiling of six; `current_iteration` may never exceed that
@@ -64,7 +78,7 @@ Before any write or handoff to `developer`:
64
78
 
65
79
  1. Read `AGENTS.md`, `PROJECT_CONTEXT.md`, or `docs/ai/project-context.md` when
66
80
  present, plus git state and the minimum relevant repository documentation.
67
- 2. For resume, run only `node scripts/loop-state.mjs inspect` and read the
81
+ 2. For resume, run only `node "${OPENCODE_CONFIG_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/opencode}/scripts/loop-state.mjs" inspect` and read the
68
82
  requested Markdown. If state is missing or corrupt, stop; do not silently
69
83
  repair or replace it. `inspect` is read-only and does not acquire the lock.
70
84
  3. Identify pre-existing local changes and mark them protected. If the loop must
@@ -93,9 +107,9 @@ writes. Approval of the original objective is not approval of the concrete
93
107
  After approval, delegate only:
94
108
 
95
109
  1. for a new loop, creation or update of `.opencode/loops/<slug>.md`, followed
96
- by `node scripts/loop-state.mjs init` with git baseline, session, and a
110
+ by `node "${OPENCODE_CONFIG_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/opencode}/scripts/loop-state.mjs" init` with git baseline, session, and a
97
111
  unique `action_id`;
98
- 2. for an approved resume, `node scripts/loop-state.mjs resume` with slug,
112
+ 2. for an approved resume, `node "${OPENCODE_CONFIG_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/opencode}/scripts/loop-state.mjs" resume` with slug,
99
113
  contract, session, and a new `action_id`.
100
114
 
101
115
  Do not edit those files as `lead`.
@@ -118,7 +132,7 @@ modify `.gitignore` unless explicitly requested.
118
132
  JSON is the source of truth for schema version, approved contract hash, git
119
133
  baseline, session, approval, lease, status, iteration, last completed step,
120
134
  blocking cause, and last action ID. Record every transition with
121
- `node scripts/loop-state.mjs record`. Repeating identical content with the same
135
+ `node "${OPENCODE_CONFIG_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/opencode}/scripts/loop-state.mjs" record`. Repeating identical content with the same
122
136
  `action_id` is idempotent; reusing it for different content is an error.
123
137
  Transitions from the same session are serialized inside the durable lock. A
124
138
  retry succeeds only when journal, snapshot, and locks prove a complete commit;
@@ -175,7 +189,7 @@ For sensitive paths use `blocked` or `paused`; never create a silent exception.
175
189
  ## Recovery and repair
176
190
 
177
191
  - An interrupted write can leave the journal ahead of the snapshot. Run
178
- `node scripts/loop-state.mjs repair` to rebuild JSON from the latest complete
192
+ `node "${OPENCODE_CONFIG_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/opencode}/scripts/loop-state.mjs" repair` to rebuild JSON from the latest complete
179
193
  event.
180
194
  - Repair validates continuity of slug, contract, baseline, approval, iteration,
181
195
  and lease before trusting `state_after`.
@@ -44,7 +44,9 @@ generate or modify frontmatter.
44
44
  run anything, writes included. Measured: `lead` implemented on its own with
45
45
  grep/glob/read/bash instead of delegating. It is now `"*": deny` with a
46
46
  read-only allowlist, plus the exact scripts its own commands tell it to run
47
- (`loop-state.mjs inspect`, `preflight-audit.mjs`). A shell plugin that
47
+ (`loop-state.mjs inspect` and `mission-status.mjs`, matched by
48
+ `node *scripts/...` because `/loop` and `/loop-status` run them from the
49
+ config directory; `preflight-audit.mjs`). A shell plugin that
48
50
  rewrites commands must have its rewritten forms allowlisted too, or they fall
49
51
  through to the deny.
50
52
  - `lead` emits its routing decision as **fields, not prose**: `route`,
@@ -159,6 +159,10 @@ Criteria:
159
159
  - `scripts/loop-state.mjs` performs atomic writes, requires idempotent
160
160
  `action_id` values, rejects a different contract, prevents simultaneous
161
161
  resumes, and serializes concurrent transitions from the same session.
162
+ - `/loop` runs the kit's `scripts/loop-state.mjs` from the OpenCode config
163
+ directory (`${OPENCODE_CONFIG_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/opencode}`),
164
+ never a project-local copy. If it is missing, `/loop` stops and reports; it
165
+ never improvises a state writer.
162
166
  - Each iteration allows one focused `developer` change; `reviewer` has exclusive
163
167
  authority to approve or escalate.
164
168
  - `developer` synchronizes the verdict into state without mixing in
@@ -180,7 +184,7 @@ Contract: `lead` read-only projection.
180
184
 
181
185
  `/loop-status --slug <slug>` inspects the canonical snapshot and append-only
182
186
  history without acquiring a write lock or changing files. Use
183
- `node scripts/mission-status.mjs --root /absolute/repository --slug <slug>`
187
+ `node "${OPENCODE_CONFIG_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/opencode}/scripts/mission-status.mjs" --root /absolute/repository --slug <slug>`
184
188
  when an explicit repository root is needed. If state is missing, stale, or
185
189
  corrupt, report the durable error and do not repair or resume automatically.
186
190