oc-harness-setup 0.4.1 → 0.4.3

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/AGENTS.md CHANGED
@@ -41,7 +41,7 @@ Working on this pack is `CONTRIBUTING.md`; this file is the shipped starter cont
41
41
  - Split only for context isolation or genuine breadth.
42
42
  - `reference/context.md`: read for parallel-write, brief, return, and cost detail plus examples.
43
43
  - Before fanning out, run the zero test: zero overlap, zero risk, zero friction. Read-only fan-out is always safe; never parallelise a restart, a shared config, or one file.
44
- - Harness content has one writer: route changes to `maintainer`; scratch goes to `cleaner`; outward acts follow the owner gate in § Enforcement.
44
+ - Harness content has one writer: route changes to `maintainer`; scratch lives under `%TEMP%\opencode\<session>` and `cleaner` sweeps it at close; outward acts follow the owner gate in § Enforcement.
45
45
  - Cost matters only on the expensive tier: fan out freely on the cheap tier and reserve the expensive seat for verdicts. A price gap is a reason to avoid collisions, not fan-out.
46
46
 
47
47
  ## Enforcement
package/CHANGELOG.md CHANGED
@@ -11,6 +11,39 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
11
11
 
12
12
  - README uses the house centered header, public “agents” wording, and Releases/Issues links; no shipped behavior change.
13
13
 
14
+ ## [0.4.3] - 2026-10-20
15
+
16
+ ### Fixed
17
+
18
+ - Fresh installs from the registry no longer fail the doctor: npm renames a
19
+ shipped root `.gitignore` to `.npmignore` on install, so the pack now ships
20
+ `gitignore.template` and the installer writes it to `.gitignore`. A test now
21
+ packs the tarball, installs it, and runs setup from the installed copy.
22
+
23
+ ## [0.4.2] - 2026-10-20
24
+
25
+ ### Fixed
26
+
27
+ - Doctor no longer crashes when `opencode.jsonc` has no `permissions` key; the
28
+ dependent laws grade and name the missing block instead of throwing.
29
+ - Secret-name law fails only on a literal value: `{env:...}` / `{file:...}`
30
+ pointers are accepted, so a normal provider `apiKey` no longer fails setup.
31
+ - Model-routing law accepts the catalog shape the reference documents and names
32
+ both accepted shapes when it cannot derive one.
33
+ - Upgrading from an older version drops the retired `oc-flight-deck` plugin entry while keeping every adopter-owned plugin (a same-version re-run keeps one you deliberately re-added); the reference registry is pointed at the
34
+ config dir setup actually resolved.
35
+ - Two agent files said "Read `*.env` ..." under Never; they now say "Never read".
36
+ - `state/template.md` is pack-owned again (adopter edits archived, not kept), so
37
+ a stale template can never fail the key-order law.
38
+ - An edited `state/template.md` is archived before it is replaced, and the install manifest now says so.
39
+
40
+ ### Changed
41
+
42
+ - Packaging test asserts the tarball ships every path the doctor requires,
43
+ replacing a `npm run check` that could not fail.
44
+ - Docs: models catalog shape, close roles, scratch routing, the `.docs/` install
45
+ claim, and eight missing glossary terms.
46
+
14
47
  ## [0.4.1] - 2026-10-20
15
48
 
16
49
  ### Fixed
package/GLOSSARY.md CHANGED
@@ -8,16 +8,22 @@
8
8
  Not a role, personality, or craft specialty.
9
9
  **doctor** — The install-time gate (`scripts/harness-doctor.ps1`) checking the pack's shape laws.
10
10
  Not a prose enforcer; it gates what was installed, never how a sentence reads.
11
+ **drift** — A rule or fact that aged out of agreement with the tree, accepted openly.
12
+ Not a regression; only a doctor FAIL is a regression.
11
13
  **enforced vs instructed** — The split between a rule backed by a denying mechanism and a rule stated as prose that may drift.
12
14
  Not a severity scale; only the enforced side can deny.
13
15
  **evolve** — The smallest deliberate extension of the harness: a skill, command, reference, seat, or config change, never a niche one-off.
14
16
  Not a niche one-off or a user-local tweak.
15
17
  **finding** — An audit result citing a canon source or a contradiction between two starter files.
16
18
  Not an opinion or suggestion.
19
+ **gate** — A runnable check that must exit 0 before work is called done.
20
+ Not a review comment or a check that cannot fail.
17
21
  **instructed** — A rule stated as prose with no denying mechanism behind it, so drift is accepted openly.
18
22
  Not ignored or optional; it still binds, it just cannot deny.
19
23
  **integration point** — The place where disjoint parallel work is reconciled before a verdict.
20
24
  Not a branch or merge commit.
25
+ **lane** — One dispatched unit of parallel work with its own artifact and check.
26
+ Not a queue or a lock.
21
27
  **lessons** — The scar file of operational rules extracted from failures, each recorded once.
22
28
  Not a changelog, diary, or summary of what happened.
23
29
  **non-rule** — Something the starter deliberately does not do, recorded to stop it being re-added.
@@ -30,6 +36,8 @@
30
36
  Not a token budget for the whole run.
31
37
  **seam** — An independent unit of work with its own artifact and its own proving check.
32
38
  Not a file, step, or task, and not a brief; the brief is the contract around it.
39
+ **seat** — An agent holding one reach class.
40
+ Not a job title or craft specialty.
33
41
  **state** — The per-session markdown record under `state/` that lets a fresh session resume.
34
42
  Not the vendor's session store, and not YAML.
35
43
  **state-seed** — The starter files setup lays down so a fresh install has somewhere to record.
@@ -38,9 +46,17 @@
38
46
  Not a quality ranking.
39
47
  **ticket** — One frozen slice of a spec stating what it delivers plus its blocking edges.
40
48
  Not a seam without a proving check.
49
+ **tier** — The cost band a seat inherits: cheap bulk vs costly verdict.
50
+ Not a model name or a price list.
51
+ **UNVERIFIED** — Said aloud when a claim could not be resolved from a primary source.
52
+ Not a citation; never present a gap as a sourced fact.
53
+ **vendor skill** — An upstream skill that is supply invoked on demand, never a rule.
54
+ Not surface; never outranks a shipped skill.
41
55
  **verdict** — A pass/fail on the work from an agent that did not author it, with cited evidence.
42
56
  Not a review comment or summary.
43
57
  **write lane** — The single worker permitted to write a given artifact at a given time.
44
58
  Not a queue or a lock.
45
59
  **zero backend** — Nothing runs behind the agent: no scripts, daemons, services, or generated state machinery.
46
60
  Not nothing is enforced; mechanisms and judgment still bind.
61
+ **zero test** — The pre-fan-out check of zero overlap, zero risk, zero friction.
62
+ Not a gate that runs after the work; it decides whether to fan out at all.
package/agents/cleaner.md CHANGED
@@ -72,7 +72,7 @@ Sole purpose: remove what is disposable — scratch, logs, temp, test output, ca
72
72
  - Never edit source, fix code, stage, commit, push, or re-scope the cleanup.
73
73
  - Never delete an untracked file it cannot attribute to this session; name it in the report instead.
74
74
  - Never delegate; never write through shell redirection or heredocs.
75
- - Read `*.env`, `*.env.*`, or `*secrets*`.
75
+ - Never read `*.env`, `*.env.*`, or `*secrets*`.
76
76
  **Brief it receives**
77
77
  - Objective: the repos touched, the session id, the scratch paths expected, and what must be left alone.
78
78
  - Output format: `CLEAN` or `DIRTY` plus deletions, byte total, status output, and refusal list.
@@ -77,7 +77,7 @@ Sole purpose: build and fix the harness — every harness change and improvement
77
77
  - Builds and fixes every tracked file under `%USERPROFILE%\.config\opencode`: `AGENTS.md`, `agents\`, `skills\`, `commands\`, `reference\`, `README.md`, `GLOSSARY.md`.
78
78
  - Owns harness versioning and the sync into the `oc-harness-setup` repo.
79
79
  - Keeps commands and skills 1:1; creates no command without a skill and no skill without a command.
80
- - Enforces the root ceiling: 200 lines hard, 120 target; every reference 50 lines or fewer.
80
+ - Enforces the root ceiling: 200 lines hard, 120 target; every reference 50 lines target, 80 hard.
81
81
  - Writes the publish set only: `AGENTS.md`, `README.md`, `GLOSSARY.md`, `agents\`, `skills\`, `commands\`, `reference\`.
82
82
  - Publishes never: `state\`, `OWNER.md`, `tools\`, `opencode.jsonc`, `.git\`, or anything matching a secret pattern.
83
83
  - Versions by tag in the setup repo: `harness-vMAJOR.MINOR.PATCH`, with one line in its `CHANGELOG.md` naming what changed and why.
@@ -92,7 +92,7 @@ Sole purpose: build and fix the harness — every harness change and improvement
92
92
  - Never force, reset, clean, or rewrite history.
93
93
  - Never delegate.
94
94
  - Never edit `state\`; that is `historian`.
95
- - Read `*.env`, `*.env.*`, or `*secrets*`.
95
+ - Never read `*.env`, `*.env.*`, or `*secrets*`.
96
96
  **Brief it receives**
97
97
  - Objective: the harness change asked for, the files in scope, whether the setup repo is in scope, and what must not change.
98
98
  - Output format: files changed with `file:line`, root line count, tag or commit, publish-set diff, and refusal list.
package/bin/cli.js CHANGED
@@ -37,7 +37,11 @@ const PKG_NAME = 'oc-harness-setup';
37
37
  const PKG_ROOT = path.resolve(import.meta.dirname, '..');
38
38
  const MANIFEST_FILE = 'oc-harness-setup.manifest.json';
39
39
  const COPY_DIRS = ['agents', 'commands', 'skills', 'reference', 'scripts', '.docs', 'state-seed'];
40
- const COPY_FILES = ['AGENTS.md', 'GLOSSARY.md', '.gitignore'];
40
+ const COPY_FILES = ['AGENTS.md', 'GLOSSARY.md', 'gitignore.template'];
41
+ // npm renames a shipped root dotfile (`.gitignore` → `.npmignore`) on pack/
42
+ // install, so the pack ships `gitignore.template` and the installer aliases it
43
+ // back to `.gitignore` at the destination.
44
+ const FILE_ALIASES = { 'gitignore.template': '.gitignore' };
41
45
  // Source→destination aliases: the pack ships `state-seed/` (tracked) but the
42
46
  // live tree owns `state/` (git-ignored runtime), so every incoming
43
47
  // `state-seed/...` file lands at `state/...`. `rel` is ALWAYS the
@@ -58,13 +62,17 @@ const DIR_ALIASES = { 'state-seed': 'state' };
58
62
  // value stays when the adopter does not define the key.
59
63
  const INSTALL_OWNED = ['$schema', 'default_agent', 'formatter', 'compaction', 'tool_output', 'media', 'watcher', 'policies'];
60
64
  const UNION_KEYS = ['plugins'];
65
+ const DISTRO_PLUGIN_IDS = ['oc-flight-deck'];
61
66
  // Adopter-owned files: a shipped skeleton that the adopter genuinely edited
62
67
  // MUST survive an upgrade — overwriting it destroys their data. Genuineness
63
68
  // is proven against the prior manifest (see stageFiles): a destination that
64
69
  // still matches the prior installed hash is unmodified pack content and IS
65
70
  // updated, so a stock 0.3.3 AGENTS.md is replaced by the V9 contract while a
66
- // genuinely adopter-edited one is kept.
67
- const PRESERVE_IF_EXISTS = new Set(['reference/models.md', 'AGENTS.md', '.gitignore', 'state/lessons.md', 'state/template.md']);
71
+ // genuinely adopter-edited one is kept. The template is a controlled copy
72
+ // graded by the doctor, so adopter edits are archived then overwritten.
73
+ const PRESERVE_IF_EXISTS = new Set(['reference/models.md', 'AGENTS.md', '.gitignore', 'state/lessons.md']);
74
+ // Keyed on forward slashes; matched through norm() because rel is platform-native
75
+ // (path.join yields backslashes on Windows).
68
76
  // Leak markers — generic shapes, never a concrete machine. They catch the
69
77
  // maintainer's workstation leaking into the shipped tree (an absolute
70
78
  // user-profile path, a session id). They are linted against the package
@@ -163,6 +171,25 @@ function tsStamp() {
163
171
  return `${d.getFullYear()}${p(d.getMonth() + 1)}${p(d.getDate())}-${p(d.getHours())}${p(d.getMinutes())}${p(d.getSeconds())}`;
164
172
  }
165
173
 
174
+ function versionLess(a, b) {
175
+ const pa = String(a).split('.');
176
+ const pb = String(b).split('.');
177
+ const n = Math.max(pa.length, pb.length);
178
+ for (let i = 0; i < n; i++) {
179
+ const sa = i < pa.length ? pa[i] : '0';
180
+ const sb = i < pb.length ? pb[i] : '0';
181
+ const aNum = /^\d+$/.test(sa);
182
+ const bNum = /^\d+$/.test(sb);
183
+ if (aNum && bNum) {
184
+ const diff = Number(sa) - Number(sb);
185
+ if (diff !== 0) return diff < 0;
186
+ } else {
187
+ if (sa !== sb) return sa < sb;
188
+ }
189
+ }
190
+ return false;
191
+ }
192
+
166
193
  function pkgVersion() {
167
194
  try {
168
195
  return JSON.parse(readFileSync(path.join(PKG_ROOT, 'package.json'), 'utf8')).version || '0.0.0';
@@ -293,7 +320,8 @@ function collectIncoming(configDir) {
293
320
  log('staging', `note: ${f} not present in this package — nothing to copy`);
294
321
  continue;
295
322
  }
296
- files.push({ rel: f, src, dest: path.join(configDir, f) });
323
+ const rel = FILE_ALIASES[f] ?? f;
324
+ files.push({ rel, src, dest: path.join(configDir, rel) });
297
325
  }
298
326
  return files;
299
327
  }
@@ -344,7 +372,7 @@ function stageFiles(files, manifest, prior, configDir) {
344
372
  if (destHash === srcHash) {
345
373
  action = 'skip';
346
374
  log('staging', `skip ${f.rel} (already identical — rerun-safe)`);
347
- } else if (PRESERVE_IF_EXISTS.has(f.rel)) {
375
+ } else if (PRESERVE_IF_EXISTS.has(norm(f.rel))) {
348
376
  // Upgrade rule: preserve only a GENUINELY adopter-edited file, i.e.
349
377
  // one that differs from the prior manifest hash. A destination that
350
378
  // still matches the prior installed hash is unmodified pack content —
@@ -370,7 +398,11 @@ function stageFiles(files, manifest, prior, configDir) {
370
398
  // PRESERVE_IF_EXISTS never reach this branch (kept above, never
371
399
  // archived). Same archive root and nextFreePath as retireStale.
372
400
  const p = priorByPath.get(norm(f.rel));
373
- if (p && p.hash && destHash !== p.hash) {
401
+ // state/template.md is pack-owned but graded: an existing copy that
402
+ // differs from the shipped bytes is ALWAYS archived before the
403
+ // overwrite, with or without a prior manifest entry.
404
+ const isTemplate = norm(f.rel) === 'state/template.md';
405
+ if ((p && p.hash && destHash !== p.hash) || (isTemplate && destHash !== srcHash)) {
374
406
  const dest2 = nextFreePath(path.join(configDir, 'state', 'archive', 'legacy-0.3.x', f.rel));
375
407
  mkdirSync(path.dirname(dest2), { recursive: true });
376
408
  renameSync(f.dest, dest2);
@@ -591,7 +623,7 @@ function parseJsonc(text, what) {
591
623
  }
592
624
  }
593
625
 
594
- function mergeJsonc(configDir, backupPath, manifest, retiredSkills = new Set()) {
626
+ function mergeJsonc(configDir, backupPath, manifest, retiredSkills = new Set(), prior = null) {
595
627
  const distroPath = path.join(PKG_ROOT, 'opencode.jsonc');
596
628
  if (!existsSync(distroPath)) {
597
629
  log('merge', 'note: this package ships no opencode.jsonc — no merge to do');
@@ -613,6 +645,8 @@ function mergeJsonc(configDir, backupPath, manifest, retiredSkills = new Set())
613
645
  const merged = structuredClone(
614
646
  parseJsonc(readFileSync(distroPath, 'utf8'), 'the shipped opencode.jsonc (this package build looks broken)')
615
647
  );
648
+ const priorIsOlder = !!(prior && prior.version && versionLess(String(prior.version), pkgVersion()));
649
+ const distroRefKeys = new Set(Object.keys(merged.references ?? {}));
616
650
  const preserved = [];
617
651
  if (sourcePath) {
618
652
  const user = parseJsonc(
@@ -665,9 +699,24 @@ function mergeJsonc(configDir, backupPath, manifest, retiredSkills = new Set())
665
699
  }
666
700
  merged.permissions = [...distroHead, ...userOnly, ...distroTail];
667
701
  } else if (UNION_KEYS.includes(k)) {
668
- merged[k] = Array.isArray(user[k])
669
- ? [...new Set([...(Array.isArray(merged[k]) ? merged[k] : []), ...user[k]])]
670
- : user[k];
702
+ let next;
703
+ if (Array.isArray(user[k])) {
704
+ next = [...new Set([...(Array.isArray(merged[k]) ? merged[k] : []), ...user[k]])];
705
+ } else {
706
+ next = user[k];
707
+ }
708
+ if (k === 'plugins' && priorIsOlder && Array.isArray(next)) {
709
+ const isDistroPlugin = (e) => {
710
+ const raw = Array.isArray(e) ? e[0] : e;
711
+ return DISTRO_PLUGIN_IDS.includes(String(raw ?? '').split('@')[0]);
712
+ };
713
+ for (const d of next.filter(isDistroPlugin)) {
714
+ const raw = Array.isArray(d) ? d[0] : d;
715
+ log('merge', `dropped the retired distro plugin ${String(raw ?? '').split('@')[0]} (this version ships no plugin; your own plugin entries are kept)`);
716
+ }
717
+ next = next.filter((e) => !isDistroPlugin(e));
718
+ }
719
+ merged[k] = next;
671
720
  } else if (k === 'references') {
672
721
  // Object union: distro keys + user-only keys.
673
722
  merged.references = { ...(user.references ?? {}), ...(merged.references ?? {}) };
@@ -679,6 +728,26 @@ function mergeJsonc(configDir, backupPath, manifest, retiredSkills = new Set())
679
728
  } else {
680
729
  log('merge', 'no existing opencode.jsonc/opencode.json — writing the harness base');
681
730
  }
731
+ // Reference registry: point ONLY the distro's keys at the resolved config
732
+ // dir (portable `~` form under home, absolute otherwise; forward slashes).
733
+ // User-only reference keys are never touched.
734
+ if (merged.references && typeof merged.references === 'object' && distroRefKeys.size) {
735
+ const resolved = path.resolve(configDir);
736
+ const home = homedir();
737
+ let portable;
738
+ if (home && (resolved === home || resolved.startsWith(home + path.sep))) {
739
+ const rel = path.relative(home, resolved).split(path.sep).join('/');
740
+ portable = rel ? `~/${rel}` : '~';
741
+ } else {
742
+ portable = resolved.split(path.sep).join('/');
743
+ }
744
+ for (const key of distroRefKeys) {
745
+ const entry = merged.references[key];
746
+ if (entry && typeof entry === 'object' && typeof entry.path === 'string') {
747
+ entry.path = portable;
748
+ }
749
+ }
750
+ }
682
751
  // JSON.stringify strips comments, including the marker the doctor's Law 11
683
752
  // cites as evidence — reinsert it so the merged file still documents the
684
753
  // deny gate (the law grades the rules; the marker keeps its cited evidence).
@@ -740,7 +809,6 @@ function runDoctor(configDir, probe) {
740
809
  console.warn('[doctor] WARNING: pwsh (PowerShell 7) was not found — harness-doctor did NOT run, so the 18 laws are UNVERIFIED.');
741
810
  console.warn('[doctor] Your config still landed, and the skip is recorded in the manifest. To verify later:');
742
811
  console.log(' winget install --id Microsoft.PowerShell --source winget (Windows)');
743
- console.log(' brew install --cask powershell (macOS)');
744
812
  console.log(' then re-run: npx oc-harness-setup setup');
745
813
  return { code: 0, skipped: true };
746
814
  }
@@ -774,10 +842,9 @@ function printManifest(configDir, files, backupPath, doctor) {
774
842
  console.log(' opencode.jsonc merge : distro base (permissions/deny block, policies block, skill allowlist,');
775
843
  console.log(' default_agent: "orchestrator", references registry)');
776
844
  console.log(' + your keys kept · permissions: harness allows, yours, harness denies last');
777
- console.log(' state-seed/ -> state/ : shipped seed maps to live state/ (existing state/lessons.md,');
778
- console.log(' state/template.md preserved when genuinely edited)');
779
- console.log(' doctor plan : harness-doctor, 18 laws');
780
- console.log(` doctor plan : ${doctor}`);
845
+ console.log(' state-seed/ -> state/ : shipped seed maps to live state/ (state/lessons.md is preserved;');
846
+ console.log(' state/template.md is pack-owned, and an edited copy is archived under state/archive/ then replaced)');
847
+ console.log(` doctor plan : harness-doctor, 18 laws — ${doctor}`);
781
848
  console.log('----------------------------------------------------------------------------');
782
849
  }
783
850
 
@@ -986,10 +1053,12 @@ function writeManifest(configDir, manifest) {
986
1053
  // preserved stays preserved.
987
1054
  function carryForwardJournal(manifest, prior) {
988
1055
  if (!prior || !Array.isArray(prior.files)) return;
989
- const before = new Map(prior.files.map((f) => [String(f.path), f]));
1056
+ // Prior manifests may spell paths with either separator.
1057
+ const norm = (p) => String(p).replace(/\\/g, '/');
1058
+ const before = new Map(prior.files.map((f) => [norm(f.path), f]));
990
1059
  for (const e of manifest.files) {
991
1060
  if (e.action === 'retired' || e.action === 'archived') continue; // a retirement/archive is this run's truth, never downgraded
992
- const p = before.get(String(e.path));
1061
+ const p = before.get(norm(e.path));
993
1062
  if (!p) continue;
994
1063
  if (p.action === 'retired' || p.action === 'archived') continue; // a path the prior run settled that this run re-ships is fresh staging, not a settlement
995
1064
  if (p.action === 'overwritten') {
@@ -1003,11 +1072,11 @@ function carryForwardJournal(manifest, prior) {
1003
1072
  // already deleted or archived and absent from this run's staging, but
1004
1073
  // --uninstall still needs them to restore the pre-install originals from
1005
1074
  // the backup chain.
1006
- const now = new Set(manifest.files.map((f) => String(f.path)));
1075
+ const now = new Set(manifest.files.map((f) => norm(f.path)));
1007
1076
  for (const p of prior.files) {
1008
- if ((p.action === 'retired' || p.action === 'archived') && !now.has(String(p.path))) {
1077
+ if ((p.action === 'retired' || p.action === 'archived') && !now.has(norm(p.path))) {
1009
1078
  manifest.files.push(p);
1010
- now.add(String(p.path));
1079
+ now.add(norm(p.path));
1011
1080
  }
1012
1081
  }
1013
1082
  }
@@ -1183,7 +1252,7 @@ async function setup(opts) {
1183
1252
  carryForwardJournal(manifest, prior);
1184
1253
  // An adopter's own plugins[] entries survive the merge via UNION_KEYS; the
1185
1254
  // distro ships no plugins of its own, so there is nothing to register here.
1186
- mergeJsonc(configDir, backup, manifest, retiredSkills);
1255
+ mergeJsonc(configDir, backup, manifest, retiredSkills, prior);
1187
1256
 
1188
1257
  // R6: record the skip in the journal so "all 18 laws unrun" is never silent.
1189
1258
  manifest.doctorSkipped = !doctorProbe.usable || !existsSync(path.join(configDir, 'scripts', 'harness-doctor.ps1'));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oc-harness-setup",
3
- "version": "0.4.1",
3
+ "version": "0.4.3",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "oc-harness-setup": "bin/cli.js"
@@ -17,7 +17,7 @@
17
17
  "AGENTS.md",
18
18
  "GLOSSARY.md",
19
19
  "CHANGELOG.md",
20
- ".gitignore",
20
+ "gitignore.template",
21
21
  "opencode.jsonc",
22
22
  "README.md",
23
23
  "LICENSE"
package/reference/flow.md CHANGED
@@ -4,7 +4,7 @@
4
4
  - Build: `worker` writes; `worker` or `verifier` runs the named commands.
5
5
  - Review: `critic` reads the diff; `verifier` returns pass/fail.
6
6
  - Commit: `ops` runs git mechanics in product repos; `maintainer` commits the harness; neither pushes.
7
- - Close: `historian`, `cleaner`, `maintainer`.
7
+ - Close: `historian` writes state, `cleaner` sweeps scratch, then the `close` ceremony.
8
8
  - Research: `researcher`; Host: `ops`.
9
9
  - Extend: `maintainer` + `evolve`.
10
10
  - A trigger with no seat is a gap: report it, never improvise a seat mid-pass.
@@ -15,11 +15,14 @@ No model pins ship. Every seat inherits the session model until the user binds o
15
15
 
16
16
  ## Catalog
17
17
 
18
- - List each provider model the user uses as `provider/model-id`, one per line, with its tier beside it.
19
- - Example shape (ids are illustrative, replace with real ones):
20
- - `provider/cheap-workhorse` — bulk tier
21
- - `provider/costly-judge` — verdict tier
22
- - The doctor's routing law resolves every bound id against this catalog; unwired seats skip resolution and inherit the session model.
18
+ - The doctor parses one bullet per model, exactly ``- `<provider>/<model-id>` — <tier>``.
19
+ - Alternatively, a `Model (<provider>/<id>)` line plus `| n | `<id>` |` rows resolves the same way.
20
+ - Example (fenced block is illustrative only; angle-bracket placeholders are not parsed as catalog entries):
21
+
22
+ ```
23
+ - `<provider>/<cheap-model>` — bulk tier
24
+ - `<provider>/<verdict-model>` — verdict tier
25
+ ```
23
26
 
24
27
  ## Rule
25
28
 
@@ -22,7 +22,7 @@
22
22
  documents it (the record is DISCOVERED by content, never named here)
23
23
  - local skill dirs match the fail-closed skill allowlist BOTH directions
24
24
  (orphan dir or dangling allow = FAIL), under a skill:* deny
25
- - no secret-like property NAMES in opencode.jsonc (paths only, never values)
25
+ - no literal secret VALUES under a secret-like property name; a `{env:…}`/`{file:…}` pointer is not a leak
26
26
  - the deny set survives --auto (declared gates below, verified derived)
27
27
  - hard denies come after same-action allows (denies-last ordering; the
28
28
  skill fail-closed allowlist allows-after-deny by design, so the skill
@@ -229,6 +229,20 @@ function Get-McpServerNames {
229
229
  return $names
230
230
  }
231
231
 
232
+ function Get-PermissionRules {
233
+ # StrictMode-safe read of the permissions array. A config that omits the
234
+ # key (or carries a non-array) grades as an empty set, so dependent laws
235
+ # FAIL with their named reason instead of throwing a property error.
236
+ param($Config)
237
+ if ($null -eq $Config) { return @() }
238
+ $prop = $Config.PSObject.Properties['permissions']
239
+ if ($null -eq $prop -or $null -eq $prop.Value) { return @() }
240
+ $value = $prop.Value
241
+ if ($value -is [string]) { return @() }
242
+ if ($value -isnot [System.Collections.IEnumerable]) { return @() }
243
+ return @($value)
244
+ }
245
+
232
246
  function Get-RegistryMcpNames {
233
247
  # First token per line of `opencode mcp list`, minus status markers.
234
248
  param([string[]]$Lines)
@@ -242,15 +256,26 @@ function Get-RegistryMcpNames {
242
256
  return [System.Collections.Generic.List[string]]::new([string[]](@($names | Sort-Object -Unique)))
243
257
  }
244
258
 
259
+ function Test-SecretPointer {
260
+ # A value that POINTS at a secret is not the secret itself.
261
+ param($Value)
262
+ if ($null -eq $Value) { return $true }
263
+ if ($Value -isnot [string]) { return $false }
264
+ $text = $Value.Trim()
265
+ if ($text -eq '') { return $true }
266
+ return [bool]($text -match '^(\{[A-Za-z][A-Za-z0-9_-]*:[^}]*\}|\$\{[^}]*\}|\$[A-Za-z_][A-Za-z0-9_]*)$')
267
+ }
268
+
245
269
  function Find-SecretLikeProps {
246
- # Property PATHS whose names look secret-like. Values are never returned.
270
+ # Property PATHS whose names look secret-like, each with a Pointer flag.
271
+ # Values are never returned.
247
272
  param($Node, [string]$Path)
248
- $hits = [System.Collections.Generic.List[string]]::new()
273
+ $hits = [System.Collections.Generic.List[object]]::new()
249
274
  if ($null -eq $Node) { return $hits }
250
275
  if ($Node -is [System.Management.Automation.PSCustomObject]) {
251
276
  foreach ($p in $Node.PSObject.Properties) {
252
277
  $np = if ($Path) { "$Path.$($p.Name)" } else { [string]$p.Name }
253
- if ($p.Name -match $secretNamePattern) { $hits.Add($np) }
278
+ if ($p.Name -match $secretNamePattern) { $hits.Add([pscustomobject]@{ Path = $np; Pointer = (Test-SecretPointer -Value $p.Value) }) }
254
279
  foreach ($h in (Find-SecretLikeProps -Node $p.Value -Path $np)) { $hits.Add($h) }
255
280
  }
256
281
  } elseif ($Node -is [System.Collections.IEnumerable] -and $Node -isnot [string]) {
@@ -336,10 +361,13 @@ function Get-LiveModelBinding {
336
361
 
337
362
  function Get-ModelCatalog {
338
363
  # Model ids AND the provider prefix, both read from reference/models.md.
364
+ # Accepts two shapes: `- `provider/model-id`` bullets, or a
365
+ # `Model (provider/<id>)` line plus `| n | `id` |` rows.
339
366
  param([string]$Path)
340
367
  $ids = [System.Collections.Generic.List[string]]::new()
368
+ $bindings = [System.Collections.Generic.List[string]]::new()
341
369
  $provider = ''
342
- if (-not (Test-Path -LiteralPath $Path -PathType Leaf)) { return [pscustomobject]@{ Ids = $ids; Provider = $provider; Found = $false } }
370
+ if (-not (Test-Path -LiteralPath $Path -PathType Leaf)) { return [pscustomobject]@{ Ids = $ids; Bindings = $bindings; Provider = $provider; Found = $false } }
343
371
  $text = Get-SafeText -Path $Path
344
372
  $providerMatch = [regex]::Match($text, 'Model \((?<provider>[A-Za-z0-9._-]+)/<id>\)')
345
373
  $provider = if ($providerMatch.Success) { $providerMatch.Groups['provider'].Value } else { '' }
@@ -347,8 +375,10 @@ function Get-ModelCatalog {
347
375
  if ($providerMatch.Success) {
348
376
  foreach ($m in [regex]::Matches($text, [regex]::Escape($provider) + '/([A-Za-z0-9._-]+)')) { $ids.Add($m.Groups[1].Value.Trim()) }
349
377
  }
378
+ foreach ($m in [regex]::Matches($text, '(?m)^\s*[-*]\s+`([A-Za-z0-9._-]+/[A-Za-z0-9._-]+)`')) { $bindings.Add($m.Groups[1].Value.Trim()) }
350
379
  $ids = [System.Collections.Generic.List[string]]::new([string[]](@($ids | Sort-Object -Unique)))
351
- return [pscustomobject]@{ Ids = $ids; Provider = $provider; Found = $true }
380
+ $bindings = [System.Collections.Generic.List[string]]::new([string[]](@($bindings | Sort-Object -Unique)))
381
+ return [pscustomobject]@{ Ids = $ids; Bindings = $bindings; Provider = $provider; Found = $true }
352
382
  }
353
383
 
354
384
  function Test-ModelBinding {
@@ -358,14 +388,20 @@ function Test-ModelBinding {
358
388
  if ($text.Contains('#')) { $text = $text.Substring(0, $text.IndexOf('#')) }
359
389
  $text = $text.Trim()
360
390
  if ($text -notmatch '^(?<provider>[A-Za-z0-9._-]+)/(?<id>[^/]+)$') { return "model '$Value' is not a provider/id binding" }
361
- if ([string]::IsNullOrWhiteSpace($Catalog.Provider)) {
362
- return 'the model catalog no longer declares its provider prefix — the instrument cannot derive the expectation'
391
+ if (-not [string]::IsNullOrWhiteSpace($Catalog.Provider)) {
392
+ if ($Matches['provider'] -ne $Catalog.Provider) {
393
+ return "model '$Value' uses provider '$($Matches['provider'])' but the catalog declares '$($Catalog.Provider)'"
394
+ }
395
+ if (@($Catalog.Ids) -notcontains $Matches['id']) { return "model '$Value' does not resolve in reference/models.md" }
396
+ return $null
363
397
  }
364
- if ($Matches['provider'] -ne $Catalog.Provider) {
365
- return "model '$Value' uses provider '$($Matches['provider'])' but the catalog declares '$($Catalog.Provider)'"
398
+ $catalogBindings = @()
399
+ if ($null -ne $Catalog.Bindings) { $catalogBindings = @($Catalog.Bindings) }
400
+ if ($catalogBindings.Count -gt 0) {
401
+ if ($catalogBindings -contains $text) { return $null }
402
+ return "model '$Value' does not resolve in reference/models.md"
366
403
  }
367
- if (@($Catalog.Ids) -notcontains $Matches['id']) { return "model '$Value' does not resolve in reference/models.md" }
368
- return $null
404
+ return 'the model catalog declares neither shape: add `- `provider/model-id`` bullets, or a `Model (provider/<id>)` line plus `| n | `id` |` rows'
369
405
  }
370
406
 
371
407
  function Get-UnwiredRoutingDoc {
@@ -608,7 +644,7 @@ if ($agentFiles.Count -eq 0) {
608
644
  $binding = Get-LiveModelBinding -FrontmatterText (Get-FrontmatterText -Path $file.FullName)
609
645
  if ($null -eq $binding) { continue }
610
646
  $liveBindings.Add($file.BaseName)
611
- if (-not $catalog.Found -or $catalog.Ids.Count -eq 0) {
647
+ if (-not $catalog.Found -or ($catalog.Ids.Count -eq 0 -and $catalog.Bindings.Count -eq 0)) {
612
648
  $bindingProblems.Add("$($file.Name): live model '$binding' cannot be resolved because reference/models.md is missing or lists no models")
613
649
  continue
614
650
  }
@@ -672,7 +708,7 @@ if (-not $configOk) {
672
708
  Add-Law 'local skills match the fail-closed allowlist both directions' 'FAIL' $skillDetail `
673
709
  "repair the skill directories or their frontmatter under skills\: $skillDetail"
674
710
  } else {
675
- $permissions = @($config.permissions)
711
+ $permissions = @(Get-PermissionRules -Config $config)
676
712
  $skillRules = @($permissions | Where-Object { $_.action -eq 'skill' })
677
713
  $wildcardDeny = @($skillRules | Where-Object { $_.resource -eq '*' -and $_.effect -eq 'deny' })
678
714
  $allowedSkillIds = @($skillRules | Where-Object { $_.effect -eq 'allow' -and $_.resource -ne '*' } | Select-Object -ExpandProperty resource)
@@ -690,16 +726,20 @@ if (-not $configOk) {
690
726
  }
691
727
  }
692
728
 
693
- # Law 10: no secret-like property NAMES in opencode.jsonc (paths only).
729
+ # Law 10: no literal secret VALUES under a secret-like property name; a `{env:…}`/`{file:…}` pointer is not a leak (paths only).
694
730
  if (-not $configOk) {
695
731
  Add-ConfigDrift 'no secret-like property names in opencode.jsonc'
696
732
  } else {
697
- $secretPaths = @(Find-SecretLikeProps -Node $config -Path '')
698
- if ($secretPaths.Count -eq 0) {
699
- Add-Law 'no secret-like property names in opencode.jsonc' 'PASS' 'no apiKey/secret/password/credential property names found (values are never printed)'
733
+ $secretHits = @(Find-SecretLikeProps -Node $config -Path '')
734
+ $literalHits = @($secretHits | Where-Object { -not $_.Pointer } | ForEach-Object { $_.Path })
735
+ $pointerHits = @($secretHits | Where-Object { $_.Pointer } | ForEach-Object { $_.Path })
736
+ if ($literalHits.Count -gt 0) {
737
+ Add-Law 'no secret-like property names in opencode.jsonc' 'FAIL' "literal secret values at: $($literalHits -join ', ')" `
738
+ "replace each with a pointer (``{env:...}`` or ``{file:...}``) or move it to the secret store: $($literalHits -join ', ')"
700
739
  } else {
701
- Add-Law 'no secret-like property names in opencode.jsonc' 'FAIL' "secret-like fields at: $($secretPaths -join ', ')" `
702
- "move them to environment or the secret store (by pointer, never by value): $($secretPaths -join ', ')"
740
+ $passDetail = 'no literal secret values under a secret-like property name'
741
+ if ($pointerHits.Count -gt 0) { $passDetail += " (pointer(s) accepted: $($pointerHits -join ', '))" }
742
+ Add-Law 'no secret-like property names in opencode.jsonc' 'PASS' $passDetail
703
743
  }
704
744
  }
705
745
 
@@ -707,7 +747,7 @@ if (-not $configOk) {
707
747
  if (-not $configOk) {
708
748
  Add-ConfigDrift 'deny set survives --auto'
709
749
  } else {
710
- $permissions = @($config.permissions)
750
+ $permissions = @(Get-PermissionRules -Config $config)
711
751
  if ($null -eq $permissions -or $permissions.Count -eq 0) {
712
752
  Add-Law 'deny set survives --auto' 'FAIL' 'permissions block missing; dependent boundary checks cannot be trusted' 'restore the permissions block in opencode.jsonc'
713
753
  } else {
@@ -739,7 +779,7 @@ if (-not $configOk) {
739
779
  if (-not $configOk) {
740
780
  Add-ConfigDrift 'hard denies come after same-action allows'
741
781
  } else {
742
- $permissions = @($config.permissions)
782
+ $permissions = @(Get-PermissionRules -Config $config)
743
783
  if ($null -eq $permissions -or $permissions.Count -eq 0) {
744
784
  Add-Law 'hard denies come after same-action allows' 'FAIL' 'permissions block missing; ordering cannot be evaluated' 'restore the permissions block in opencode.jsonc'
745
785
  } else {
@@ -780,7 +820,7 @@ if (-not $configOk) {
780
820
  if (-not $configOk) {
781
821
  Add-ConfigDrift 'no broad shell allows'
782
822
  } else {
783
- $permissions = @($config.permissions)
823
+ $permissions = @(Get-PermissionRules -Config $config)
784
824
  if ($null -eq $permissions -or $permissions.Count -eq 0) {
785
825
  Add-Law 'no broad shell allows' 'FAIL' 'permissions block missing; broad allows cannot be evaluated' 'restore the permissions block in opencode.jsonc'
786
826
  } else {
@@ -809,7 +849,7 @@ if (-not $configOk) {
809
849
  if (-not $configOk) {
810
850
  Add-ConfigDrift 'skill allow entries match local skill IDs both directions'
811
851
  } else {
812
- $permissions = @($config.permissions)
852
+ $permissions = @(Get-PermissionRules -Config $config)
813
853
  $allowIds = @($permissions | Where-Object { $_.action -eq 'skill' -and $_.effect -eq 'allow' -and $_.resource -ne '*' } | Select-Object -ExpandProperty resource | Sort-Object -Unique)
814
854
  $localIds = @($localSkillIds | Sort-Object -Unique)
815
855
  if ($localIds.Count -eq 0 -and $allowIds.Count -eq 0) {
@@ -52,7 +52,7 @@ End-to-end looper: `to-spec` → `to-tickets` → `implement` → `tdd` → repo
52
52
  - `to-tickets` (vendor): SPEC sliced into blocked tracer-bullet tickets.
53
53
  - `implement` (vendor): ticket built with typechecks plus test runs.
54
54
  - `tdd` (vendor): red-green loop rules, seams, and anti-patterns.
55
- - Vendor skills above are optional and load only when present locally.
55
+ - Vendor skills above are optional supply: this harness denies non-local skills (`skill *`), so the procedure above stands alone — the named vendor skill is a shortcut, never a dependency.
56
56
 
57
57
  ## Never
58
58
 
@@ -45,7 +45,7 @@ All-purpose researcher returning a cited verdict from primary sources.
45
45
 
46
46
  ## Delegates to
47
47
 
48
- - `research` (vendor): investigation against primary sources plus the Markdown note.
48
+ - `research` (vendor): investigation against primary sources plus the Markdown note. It is optional supply: this harness denies non-local skills (`skill *`), so the procedure above stands alone — the named vendor skill is a shortcut, never a dependency.
49
49
 
50
50
  ## Canon
51
51
 
File without changes