oc-harness-setup 0.4.5 → 0.6.0

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
@@ -102,6 +102,6 @@ Working on this pack is `CONTRIBUTING.md`; this file is the shipped starter cont
102
102
  - `close`: load at the end of a session — "all green, all cleaned, done or parked".
103
103
  - `evolve`: load when adding a skill, adopting upstream, or improving the harness.
104
104
  - `fast`: load when shortcutting safely — "what is the shortest safe route".
105
- - `goal`: load when looping to done — "take this ticket to green with TDD".
105
+ - `loop`: load when looping to done — "take this ticket to green with TDD".
106
106
  - `search`: load when researching — "research this from primary sources with citations".
107
107
  - `swarm`: load when splitting work — "split this across workers with seams".
package/CHANGELOG.md CHANGED
@@ -1,5 +1,94 @@
1
1
  # Changelog
2
2
 
3
+ ## [Unreleased]
4
+
5
+ ## [0.6.0] - 2026-10-29
6
+
7
+ ### Added
8
+
9
+ - The custom end-to-end looper ships as `/loop` (`commands/loop.md` +
10
+ `skills/loop/SKILL.md`) instead of `/goal`. OpenCode 2.2.1 ships a
11
+ first-party `/goal` session-continuation command
12
+ (`Usage: /goal <objective> | pause | resume | clear`), so a custom
13
+ `commands/goal.md` collided with it. A fresh install writes no `/goal` —
14
+ the pack ships neither file — and its `skill` allow names `loop`. The
15
+ command and skill bodies name the native built-in so the distinction is
16
+ explicit.
17
+
18
+ ### Changed
19
+
20
+ Upgrades decide per prior-manifest entry, not per file name (`bin/cli.js`
21
+ `retireStale`; the allow prune lives in `mergeJsonc`):
22
+
23
+ | Prior-manifest entry | Path kind | Hash vs disk | Action | Adds a skill ID |
24
+ | --- | --- | --- | --- | --- |
25
+ | absent — fresh install, no `/goal` on disk | any | — | nothing selected; nothing removed | no |
26
+ | absent — installed tree with no prior manifest | any | — | nothing selected; any `/goal` file on disk is untouched | no |
27
+ | present; this version still ships the same path | any | — | not stale; the sweep ignores it | no |
28
+ | present with `action: merged` | `opencode.jsonc` | — | ignored | no |
29
+ | present, already `retired`/`archived` by an earlier run | `skills/<id>/...` | — | not re-examined; the earlier outcome stands | yes — `<id>` |
30
+ | present, already `retired`/`archived` by an earlier run | other | — | not re-examined | no |
31
+ | present, path absent from disk | `skills/<id>/...` | — | nothing to retire | yes — `<id>` |
32
+ | present, path absent from disk | other | — | nothing to retire | no |
33
+ | present, path is not a regular file | any | — | kept (refused) | no |
34
+ | present, path unreadable | any | — | kept (refused) | no |
35
+ | present, path escapes the config dir | any | — | skipped (refused) | no |
36
+ | present, regular file | `skills/<id>/...` | matches | deleted, journaled `retired` | yes — `<id>` |
37
+ | present, regular file | `skills/<id>/...` | differs | moved under `state/archive/legacy-0.3.x/`, journaled `archived` | yes — `<id>` |
38
+ | present, regular file | `skills/<id>/...` | not recorded | kept; the adopter owns the bytes | no |
39
+ | present, regular file | `commands/goal.md` or other | matches | deleted, journaled `retired` | no |
40
+ | present, regular file | `commands/goal.md` or other | differs | moved under `state/archive/legacy-0.3.x/`, journaled `archived` | no |
41
+ | present, regular file | `commands/goal.md` or other | not recorded | kept; the adopter owns the bytes | no |
42
+
43
+ Only a `skills/<id>/...` path (three or more segments, first segment
44
+ `skills`) can contribute `<id>`, and only where its row above says yes —
45
+ a kept file with no recorded hash does not; `commands/goal.md` and a bare
46
+ `skills/goal` never do. A row that adds no skill ID therefore never prunes
47
+ an allow, while an earlier run's retired or archived entry keeps
48
+ contributing its skill on every later run.
49
+
50
+ The merge applies the run's final set (`retiredSkills`) to the adopter's
51
+ own rules:
52
+
53
+ | `retiredSkills` | Adopter rule naming `goal` | Prune result |
54
+ | --- | --- | --- |
55
+ | contains `goal` | `{"action": "skill", "resource": "goal", "effect": "allow"}` | dropped from the merged config and logged |
56
+ | contains `goal` | a `goal` rule with any other effect, or a `skill *` rule | not eligible for the prune |
57
+ | does not contain `goal` | any | kept |
58
+
59
+ So a concrete `goal` allow is pruned if and only if a `skills/goal/...`
60
+ entry put `goal` in the run's final retired-skill set; retiring or
61
+ archiving only `commands/goal.md` leaves the allow alone, and a `goal`
62
+ allow with no supporting manifest entry survives as adopter-owned.
63
+ Unknown files are preserved throughout: anything the manifest does not
64
+ list, any entry with no recorded hash, and any refused entry stay on disk.
65
+ An emptied `skills/goal/` directory is pruned once its last file leaves,
66
+ while a `/goal` file the manifest never listed is not removed by this
67
+ upgrade. Rules identical to a shipped harness rule are deduped by the
68
+ permissions union on any run; that is separate from the prune.
69
+
70
+ ## [0.5.0] - 2026-10-28
71
+
72
+ ### Fixed
73
+
74
+ - `plugins[]` entries are emitted in the OpenCode 2.2.0 shape: a specifier
75
+ string. A 1.x `[specifier, options]` tuple is reduced to its specifier and
76
+ reported (2.2.0 drops a tuple entry outright, so the plugin silently stopped
77
+ loading), a non-string entry is reported instead of written, and the union
78
+ dedupes on strings so a re-run is byte-identical. The retired distro-plugin
79
+ match no longer assumes an unscoped `name@version` specifier.
80
+ - Config shapes are proven against the installed host rather than assumed:
81
+ new `test/host-schema.test.js` round-trips the shipped config and a real
82
+ merged config through `opencode debug config` and fails if the host drops any
83
+ key, while the hermetic suite pins `plugins` strings, `permissions[]` rules,
84
+ `policies[]` with `tool.use`, and the absence of 1.x singular keys.
85
+ - Preflight reads the `opencode v2.2.0` banner instead of echoing it (the log
86
+ line printed the product name twice), refuses a 1.x host before writing
87
+ anything (different config dialect), warns on a 2.0/2.1 host that the
88
+ `permissions[]`/`policies[]` deny gate is unproven there, and records the
89
+ host version in the install manifest. Compatibility truth: 2.2.0 tested;
90
+ 2.x warned; 1.x refused.
91
+
3
92
  ## [0.4.5] - 2026-10-23
4
93
 
5
94
  - npm front door split into a short `README.md`; full documentation moved to `docs/GUIDE.md`; no functional change.
package/README.md CHANGED
@@ -13,14 +13,14 @@ First run prints a manifest of everything it will touch and waits for you to typ
13
13
  ## What it does
14
14
 
15
15
  - Lays down a working OpenCode setup: 9 agents, 6 skills, and 12 on-demand references.
16
- - Closes the loop: goal, worker, verifier, historian, cleaner, close, with no self-verdicts.
16
+ - Closes the loop: loop -> worker -> verifier -> historian -> cleaner -> close, with no self-verdicts.
17
17
  - Researches before it claims: a finding arrives sourced or marked unverified.
18
18
  - Keeps your model, provider, keys, and state across upgrades, and reverses cleanly on uninstall.
19
19
  - Grows with you: one skill, command, reference, seat, or config change at a time.
20
20
 
21
21
  ## Requirements
22
22
 
23
- Windows 10/11 only, with Node.js 22 or newer plus the OpenCode CLI installed and runnable.
23
+ Windows 10/11 only, with Node.js 22 or newer and OpenCode 2.2.0 or newer (the tested floor). A 2.0/2.1 host warns before installing — its `permissions[]`/`policies[]` deny gate is not proven there — and a 1.x host is refused before anything is written.
24
24
 
25
25
  ## Full documentation
26
26
 
package/bin/cli.js CHANGED
@@ -63,6 +63,54 @@ const DIR_ALIASES = { 'state-seed': 'state' };
63
63
  const INSTALL_OWNED = ['$schema', 'default_agent', 'formatter', 'compaction', 'tool_output', 'media', 'watcher', 'policies'];
64
64
  const UNION_KEYS = ['plugins'];
65
65
  const DISTRO_PLUGIN_IDS = ['oc-flight-deck'];
66
+
67
+ // `plugins` element truth for OpenCode 2.2.0, measured against the installed
68
+ // host (`opencode v2.2.0`, `opencode debug config`): an entry must be a
69
+ // specifier STRING — an npm name, `name@version`, `github:owner/repo#ref
70
+ // ::path:pkg`, or a local `.ts` path. The 1.x `[specifier, options]` tuple is
71
+ // DROPPED by the 2.2.0 schema (so the plugin silently stops loading), and a
72
+ // non-string is dropped too. A tuple is therefore reduced to its specifier —
73
+ // 2.2.0 has nowhere to express the options — and every entry that cannot be
74
+ // expressed is reported, never written into a config the host would ignore.
75
+ function pluginSpecifier(entry) {
76
+ if (typeof entry === 'string') {
77
+ const s = entry.trim();
78
+ return s ? s : null;
79
+ }
80
+ if (Array.isArray(entry) && typeof entry[0] === 'string' && entry[0].trim()) {
81
+ return entry[0].trim();
82
+ }
83
+ return null;
84
+ }
85
+
86
+ // Bare id of a specifier without mangling a scoped name: strip only a version
87
+ // suffix after the first character (`pkg@1.2.3` → `pkg`, `@scope/pkg@1.2.3`
88
+ // → `@scope/pkg`), and leave a `github:`/path specifier untouched.
89
+ function pluginIdOf(spec) {
90
+ const s = String(spec ?? '');
91
+ const at = s.indexOf('@', 1);
92
+ return at > 0 ? s.slice(0, at) : s;
93
+ }
94
+
95
+ // Reduce, dedupe (order preserved), and report 1.x plugin entries so a re-run
96
+ // produces byte-identical output and nothing the host would drop survives.
97
+ function normalizePluginEntries(entries) {
98
+ const out = [];
99
+ for (const entry of entries) {
100
+ const spec = pluginSpecifier(entry);
101
+ if (spec === null) {
102
+ log('merge', `dropped an unrepresentable plugins entry ${JSON.stringify(entry)} — OpenCode 2.2.0 accepts specifier strings only`);
103
+ continue;
104
+ }
105
+ if (Array.isArray(entry)) {
106
+ log('merge', `normalized the 1.x plugin tuple ${JSON.stringify(entry)} → "${spec}" (OpenCode 2.2.0 drops tuple entries; per-plugin options cannot be carried)`);
107
+ }
108
+ if (out.includes(spec)) continue;
109
+ out.push(spec);
110
+ }
111
+ return out;
112
+ }
113
+
66
114
  // Adopter-owned files: a shipped skeleton that the adopter genuinely edited
67
115
  // MUST survive an upgrade — overwriting it destroys their data. Genuineness
68
116
  // is proven against the prior manifest (see stageFiles): a destination that
@@ -234,8 +282,34 @@ function preflight() {
234
282
  '). Install/upgrade OpenCode first, then re-run setup.'
235
283
  );
236
284
  }
237
- const first = (res.stdout || '').trim().split(/\r?\n/)[0] || 'unknown version';
238
- log('preflight', `opencode ${first} — OK`);
285
+ // The 2.2.0 host prints exactly `opencode v2.2.0`; parse the version out of
286
+ // the banner instead of echoing the whole line (which logged the product name
287
+ // twice) and instead of accepting ANY version: the merged config uses the
288
+ // 2.2.0 dialect, so a 1.x host would silently drop `plugins[]` tuples,
289
+ // `permissions[]` and `policies[]` rather than honour them.
290
+ const banner = (res.stdout || '').trim().split(/\r?\n/)[0] || '';
291
+ const m = banner.match(/(\d+)\.(\d+)\.(\d+)/);
292
+ if (!m) {
293
+ bail(`could not read an OpenCode version from '${banner || 'no output'}' — expected 'opencode v2.2.0' or newer. Check 'opencode --version' by hand.`);
294
+ }
295
+ const host = { raw: `${m[1]}.${m[2]}.${m[3]}`, major: Number(m[1]), minor: Number(m[2]) };
296
+ if (host.major < 2) {
297
+ bail(
298
+ `OpenCode ${host.raw} speaks the 1.x config dialect (@opencode-ai/* plugins, an object \`permission\` block), not the 2.2.0 shape this package writes ` +
299
+ '(plugins[] of specifier strings, permissions[] of {action,resource,effect}, policies[] with tool.use). Nothing was written. ' +
300
+ 'Upgrade first (opencode upgrade), then re-run setup.'
301
+ );
302
+ }
303
+ if (host.minor < 2) {
304
+ console.warn(
305
+ `[warn] preflight: OpenCode ${host.raw} is below the 2.2.0 this package is tested on. The merge writes the 2.2-shaped config ` +
306
+ '(plugins[] as specifier strings, permissions[] of {action,resource,effect}, policies[] with tool.use); ' +
307
+ 'on 2.0/2.1 those blocks may be partly ignored, so the deny gate is not proven on this host. ' +
308
+ 'The install proceeds — upgrade to 2.2.0 or newer when you can.'
309
+ );
310
+ }
311
+ log('preflight', `opencode ${host.raw} — OK`);
312
+ return host;
239
313
  }
240
314
 
241
315
  function findConfigDir() {
@@ -528,7 +602,10 @@ function retireStale(configDir, prior, files, manifest) {
528
602
  log('retire', `keep ${rel} (unreadable — refusing)`);
529
603
  continue;
530
604
  }
531
- if (entry.hash && sha256File(resolved) === entry.hash) {
605
+ let hashMatched = false;
606
+ try { hashMatched = entry.hash ? sha256File(resolved) === entry.hash : false; }
607
+ catch { log('retire', `keep ${rel} (content read failed — refusing)`); continue; }
608
+ if (entry.hash && hashMatched) {
532
609
  rmSync(resolved, { force: true });
533
610
  manifest.files.push({ path: rel, hash: entry.hash, action: 'retired' });
534
611
  if (skillId) retiredSkills.add(skillId);
@@ -699,24 +776,25 @@ function mergeJsonc(configDir, backupPath, manifest, retiredSkills = new Set(),
699
776
  }
700
777
  merged.permissions = [...distroHead, ...userOnly, ...distroTail];
701
778
  } else if (UNION_KEYS.includes(k)) {
702
- let next;
703
- if (Array.isArray(user[k])) {
704
- next = [...new Set([...(Array.isArray(merged[k]) ? merged[k] : []), ...user[k]])];
779
+ if (!Array.isArray(user[k])) {
780
+ merged[k] = user[k]; // adopter's non-array value wins verbatim
705
781
  } else {
706
- next = user[k];
782
+ // `plugins` is the only union key, and it is the one whose element
783
+ // shape changed in 2.2.0: normalize before the union so dedupe works
784
+ // on strings (a tuple would never compare equal across runs and
785
+ // would accumulate).
786
+ merged[k] = normalizePluginEntries([
787
+ ...(Array.isArray(merged[k]) ? merged[k] : []),
788
+ ...user[k],
789
+ ]);
707
790
  }
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)`);
791
+ if (k === 'plugins' && priorIsOlder && Array.isArray(merged[k])) {
792
+ const isDistroPlugin = (e) => DISTRO_PLUGIN_IDS.includes(pluginIdOf(e));
793
+ for (const d of merged[k].filter(isDistroPlugin)) {
794
+ log('merge', `dropped the retired distro plugin ${pluginIdOf(d)} (this version ships no plugin; your own plugin entries are kept)`);
716
795
  }
717
- next = next.filter((e) => !isDistroPlugin(e));
796
+ merged[k] = merged[k].filter((e) => !isDistroPlugin(e));
718
797
  }
719
- merged[k] = next;
720
798
  } else if (k === 'references') {
721
799
  // Object union: distro keys + user-only keys.
722
800
  merged.references = { ...(user.references ?? {}), ...(merged.references ?? {}) };
@@ -1195,7 +1273,7 @@ async function setup(opts) {
1195
1273
  console.log('[ci] refusing to mutate — print-only. Run setup interactively to install.');
1196
1274
  return 0;
1197
1275
  }
1198
- preflight();
1276
+ const host = preflight();
1199
1277
  const configDir = findConfigDir();
1200
1278
  warnConfigTargets(configDir);
1201
1279
  const files = collectIncoming(configDir);
@@ -1239,6 +1317,9 @@ async function setup(opts) {
1239
1317
  const manifest = {
1240
1318
  package: PKG_NAME,
1241
1319
  version: pkgVersion(),
1320
+ // The host whose dialect the merged config was written for: recorded so an
1321
+ // install's config shapes are auditable against the CLI that will read them.
1322
+ hostVersion: host.raw,
1242
1323
  created: new Date().toISOString(),
1243
1324
  configDir,
1244
1325
  backupPath: backupPath,
@@ -4,8 +4,10 @@ agent: orchestrator
4
4
  subagent: false
5
5
  ---
6
6
 
7
- # /goal
7
+ # /loop
8
8
 
9
- Load the `goal` skill; `skills/goal/SKILL.md` owns the procedure. Apply it to `$ARGUMENTS`.
9
+ Load the `loop` skill; `skills/loop/SKILL.md` owns the procedure. Apply it to `$ARGUMENTS`.
10
+
11
+ Distinct from the native `/goal` built-in session-continuation command (OpenCode v2.2.1).
10
12
 
11
13
  `$ARGUMENTS` is one of: a frozen SPEC, a ticket, or an issue. Empty: ask for it, then proceed.
package/docs/GUIDE.md CHANGED
@@ -12,7 +12,7 @@ First run prints a manifest of everything it will touch and waits for you to typ
12
12
  ## Why this starter
13
13
 
14
14
  - Small on purpose: 9 agents, 6 skills, 12 on-demand references; the primary loads one, the rest wait for a trigger.
15
- - A loop that closes: goal -> worker -> verifier -> historian -> cleaner -> close; no self-verdicts.
15
+ - A loop that closes: loop -> worker -> verifier -> historian -> cleaner -> close; no self-verdicts.
16
16
  - Research that cites: researcher + search + canon; claims arrive sourced or `UNVERIFIED`.
17
17
  - Memory that survives: historian writes session state; `state/` is seeded and preserved on upgrade.
18
18
  - Cleanup that ships: cleaner removes this session's scratch; hygiene proves the tree clean.
@@ -22,7 +22,7 @@ First run prints a manifest of everything it will touch and waits for you to typ
22
22
  ## What you get
23
23
 
24
24
  - 9 agents with bounded reach: one coordinator, one verdict, and seven specialists that each own exactly one surface.
25
- - 6 skills behind 6 commands: close, evolve, fast, goal, search, and swarm.
25
+ - 6 skills behind 6 commands: close, evolve, fast, loop, search, and swarm.
26
26
  - 12 on-demand references behind a single index; load only the file a rule names.
27
27
  - 18-law doctor gate: every setup run ends on it, and failures name the check and the fix.
28
28
  - Consent-first install: the full manifest prints before anything moves, and `--dry-run` changes nothing.
@@ -48,6 +48,9 @@ Set `OPENCODE_CONFIG_DIR` to override the config dir when the OpenCode CLI canno
48
48
  - Unmodified 0.3.x agents, commands, skills, references, and scripts are retired.
49
49
  - Files you edited are archived under `state/archive/legacy-0.3.x/` instead of deleted, and reported.
50
50
  - Stale `skill` allow entries for retired skills are pruned; custom skills are left alone.
51
+ - The custom `/goal` looper ships as `/loop` (`commands/loop.md` + `skills/loop/SKILL.md`); a fresh install writes neither `commands/goal.md` nor `skills/goal`, and both `/loop` bodies name the host's native `/goal` session-continuation command (OpenCode 2.2.1) so the distinction is explicit.
52
+ - An upgrade settles a tracked `/goal` path only when a prior manifest entry lists it with a recorded hash, per file: matching bytes are retired, differing bytes are archived under `state/archive/legacy-0.3.x/`.
53
+ - A `/goal` path the prior manifest never listed, an entry with no recorded hash, or an install with no prior manifest is left in place — so it can still collide with the native `/goal` name; remove it yourself if it does.
51
54
  - `setup --dry-run` previews it; `--uninstall` restores the pre-upgrade snapshot.
52
55
 
53
56
  ## Grow it
@@ -58,7 +61,7 @@ This starter grows through `evolve`: the smallest deliberate extension — one s
58
61
 
59
62
  - Windows 10/11 only; macOS and Linux are not supported.
60
63
  - Node.js 22 or newer, the only runtime requirement with zero runtime dependencies.
61
- - OpenCode CLI installed and runnable; setup refuses without it.
64
+ - OpenCode 2.2.0 or newer (the tested floor). A 2.0/2.1 host warns — the merged `permissions[]`/`policies[]` deny gate is unproven there — and a 1.x host is refused before anything is written (different config dialect).
62
65
  - PowerShell 7 for the doctor gate; without it the doctor reports skipped, never passed.
63
66
 
64
67
  ## Links
package/opencode.jsonc CHANGED
@@ -351,7 +351,7 @@
351
351
  },
352
352
  {
353
353
  "action": "skill",
354
- "resource": "goal",
354
+ "resource": "loop",
355
355
  "effect": "allow"
356
356
  },
357
357
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oc-harness-setup",
3
- "version": "0.4.5",
3
+ "version": "0.6.0",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "oc-harness-setup": "bin/cli.js"
@@ -1,9 +1,11 @@
1
1
  ---
2
- name: goal
2
+ name: loop
3
3
  description: Use when a frozen SPEC must become working code without rescoping — cut tracer-bullet tickets, loop one ticket at a time with TDD to a cited runnable check, then run the repo's full gate green.
4
4
  ---
5
5
 
6
- # goal
6
+ # loop
7
+
8
+ Distinct from the native `/goal` built-in session-continuation command (OpenCode v2.2.1); this skill is the custom end-to-end looper, invoked as `/loop`.
7
9
 
8
10
  End-to-end looper: `to-spec` → `to-tickets` → `implement` → `tdd` → repo gate → fresh verdict.
9
11