oc-harness-setup 0.4.4 → 0.5.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/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # Changelog
2
2
 
3
+ ## [Unreleased]
4
+
5
+ ## [0.5.0] - 2026-10-28
6
+
7
+ ### Fixed
8
+
9
+ - `plugins[]` entries are emitted in the OpenCode 2.2.0 shape: a specifier
10
+ string. A 1.x `[specifier, options]` tuple is reduced to its specifier and
11
+ reported (2.2.0 drops a tuple entry outright, so the plugin silently stopped
12
+ loading), a non-string entry is reported instead of written, and the union
13
+ dedupes on strings so a re-run is byte-identical. The retired distro-plugin
14
+ match no longer assumes an unscoped `name@version` specifier.
15
+ - Config shapes are proven against the installed host rather than assumed:
16
+ new `test/host-schema.test.js` round-trips the shipped config and a real
17
+ merged config through `opencode debug config` and fails if the host drops any
18
+ key, while the hermetic suite pins `plugins` strings, `permissions[]` rules,
19
+ `policies[]` with `tool.use`, and the absence of 1.x singular keys.
20
+ - Preflight reads the `opencode v2.2.0` banner instead of echoing it (the log
21
+ line printed the product name twice), refuses a 1.x host before writing
22
+ anything (different config dialect), warns on a 2.0/2.1 host that the
23
+ `permissions[]`/`policies[]` deny gate is unproven there, and records the
24
+ host version in the install manifest. Compatibility truth: 2.2.0 tested;
25
+ 2.x warned; 1.x refused.
26
+
27
+ ## [0.4.5] - 2026-10-23
28
+
29
+ - npm front door split into a short `README.md`; full documentation moved to `docs/GUIDE.md`; no functional change.
30
+
3
31
  ## [0.4.4] - 2026-10-22
4
32
 
5
33
  - Version bump for the monorepo release; no runtime change.
package/README.md CHANGED
@@ -1,5 +1,6 @@
1
- <h1 align="center">oc-harness-setup</h1>
2
- <p align="center"><strong>A compact OpenCode starter that runs a real loop, researches before it claims, keeps a ledger, cleans up after itself, and grows the next skill you need.</strong></p>
1
+ # oc-harness-setup
2
+
3
+ A compact OpenCode starter that runs a real loop, researches before it claims, keeps a ledger, cleans up after itself, and grows the next skill you need.
3
4
 
4
5
  ## Install
5
6
 
@@ -7,73 +8,23 @@
7
8
  npx --yes oc-harness-setup setup
8
9
  ```
9
10
 
10
- First run prints a manifest of everything it will touch and waits for you to type `y`. It then lays the agents, commands, skills, references, doctor gate, and merged base config into your OpenCode config dir, seeds your `state/` dir, and ends on the harness doctor gate.
11
-
12
- ## Why this starter
13
-
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.
16
- - Research that cites: researcher + search + canon; claims arrive sourced or `UNVERIFIED`.
17
- - Memory that survives: historian writes session state; `state/` is seeded and preserved on upgrade.
18
- - Cleanup that ships: cleaner removes this session's scratch; hygiene proves the tree clean.
19
- - Grows with you: `evolve` turns a repeated workflow, a user request, or an upstream feature into a skill, command, reference, seat, or config change — 1:1 and doctor-checked.
20
- - Reversible and fail-closed: manifest first, SHA-256 journal, uninstall restores originals, hard denies last.
21
-
22
- ## What you get
23
-
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.
26
- - 12 on-demand references behind a single index; load only the file a rule names.
27
- - 18-law doctor gate: every setup run ends on it, and failures name the check and the fix.
28
- - Consent-first install: the full manifest prints before anything moves, and `--dry-run` changes nothing.
29
- - Your settings and state survive: your model, provider, and keys are preserved while the pack owns runtime policy, and your state dir survives upgrades untouched.
30
- - No plugin, no model pins, no credentials.
31
-
32
- ## Commands
33
-
34
- ```bash
35
- npx --yes oc-harness-setup setup # full install (default when you pass no args)
36
- npx --yes oc-harness-setup setup --dry-run # print the manifest, touch nothing
37
- npx --yes oc-harness-setup setup --ci # print-only, refuse to mutate
38
- npx --yes oc-harness-setup setup --uninstall # remove exactly the manifest-listed files
39
- npx --yes oc-harness-setup --help # print usage
40
- ```
41
-
42
- Set `OPENCODE_CONFIG_DIR` to override the config dir when the OpenCode CLI cannot report a path; otherwise setup uses the path from the CLI first, then the platform default under your config home. Restart OpenCode after install so the new agents, commands, and skills load.
43
-
44
- ## Safe upgrade
45
-
46
- - Your `opencode.jsonc` settings, providers, MCP servers, plugins, and state survive.
47
- - `default_agent` stays `orchestrator`, so an existing 0.3.x config keeps resolving.
48
- - Unmodified 0.3.x agents, commands, skills, references, and scripts are retired.
49
- - Files you edited are archived under `state/archive/legacy-0.3.x/` instead of deleted, and reported.
50
- - Stale `skill` allow entries for retired skills are pruned; custom skills are left alone.
51
- - `setup --dry-run` previews it; `--uninstall` restores the pre-upgrade snapshot.
11
+ First run prints a manifest of everything it will touch and waits for you to type `y`. It then lays the agents, commands, skills, references, doctor gate, and merged base config into your OpenCode config dir, seeds your state dir, and ends on the harness doctor gate. `setup --dry-run` prints the same manifest and touches nothing.
52
12
 
53
- ## Grow it
13
+ ## What it does
54
14
 
55
- This starter grows through `evolve`: the smallest deliberate extension — one skill, command, reference, seat, or config change at a time, always 1:1 and doctor-checked. Repeat something twice, and `evolve` is how it earns a place.
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.
17
+ - Researches before it claims: a finding arrives sourced or marked unverified.
18
+ - Keeps your model, provider, keys, and state across upgrades, and reverses cleanly on uninstall.
19
+ - Grows with you: one skill, command, reference, seat, or config change at a time.
56
20
 
57
21
  ## Requirements
58
22
 
59
- - Windows 10/11 only; macOS and Linux are not supported.
60
- - Node.js 22 or newer, the only runtime requirement with zero runtime dependencies.
61
- - OpenCode CLI installed and runnable; setup refuses without it.
62
- - PowerShell 7 for the doctor gate; without it the doctor reports skipped, never passed.
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.
63
24
 
64
- ## Links
25
+ ## Full documentation
65
26
 
66
- - Source: [nathwn12/oc-collections](https://github.com/nathwn12/oc-collections/tree/main/packages/oc-harness-setup) — the npm package remains individually installable.
67
- - [Published package](https://www.npmjs.com/package/oc-harness-setup)
68
- - [Changelog](CHANGELOG.md)
69
- - [Releases](https://github.com/nathwn12/oc-collections/releases)
70
- - [Issues](https://github.com/nathwn12/oc-collections/issues)
71
- - [License](LICENSE)
27
+ - Guide: <https://github.com/nathwn12/oc-collections/blob/main/packages/oc-harness-setup/docs/GUIDE.md>
28
+ - Package: <https://www.npmjs.com/package/oc-harness-setup>
72
29
 
73
- <!-- nathwn12 house footer: identical in every repo. Do not edit. -->
74
- <p align="center">
75
- <a href="https://github.com/nathwn12"><img src="assets/signature.svg" width="96" alt="nathwn12" /></a>
76
- </p>
77
- <p align="center">
78
- <sub>Built by <a href="https://github.com/nathwn12">nathwn12</a> · <a href="https://github.com/nathwn12?tab=repositories">All projects</a></sub>
79
- </p>
30
+ The guide covers the full command list, the safe upgrade path, what the doctor gate checks, and how `evolve` grows the setup. It also links the changelog, the licence, and the issue tracker.
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() {
@@ -699,24 +773,25 @@ function mergeJsonc(configDir, backupPath, manifest, retiredSkills = new Set(),
699
773
  }
700
774
  merged.permissions = [...distroHead, ...userOnly, ...distroTail];
701
775
  } 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]])];
776
+ if (!Array.isArray(user[k])) {
777
+ merged[k] = user[k]; // adopter's non-array value wins verbatim
705
778
  } else {
706
- next = user[k];
779
+ // `plugins` is the only union key, and it is the one whose element
780
+ // shape changed in 2.2.0: normalize before the union so dedupe works
781
+ // on strings (a tuple would never compare equal across runs and
782
+ // would accumulate).
783
+ merged[k] = normalizePluginEntries([
784
+ ...(Array.isArray(merged[k]) ? merged[k] : []),
785
+ ...user[k],
786
+ ]);
707
787
  }
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)`);
788
+ if (k === 'plugins' && priorIsOlder && Array.isArray(merged[k])) {
789
+ const isDistroPlugin = (e) => DISTRO_PLUGIN_IDS.includes(pluginIdOf(e));
790
+ for (const d of merged[k].filter(isDistroPlugin)) {
791
+ log('merge', `dropped the retired distro plugin ${pluginIdOf(d)} (this version ships no plugin; your own plugin entries are kept)`);
716
792
  }
717
- next = next.filter((e) => !isDistroPlugin(e));
793
+ merged[k] = merged[k].filter((e) => !isDistroPlugin(e));
718
794
  }
719
- merged[k] = next;
720
795
  } else if (k === 'references') {
721
796
  // Object union: distro keys + user-only keys.
722
797
  merged.references = { ...(user.references ?? {}), ...(merged.references ?? {}) };
@@ -1195,7 +1270,7 @@ async function setup(opts) {
1195
1270
  console.log('[ci] refusing to mutate — print-only. Run setup interactively to install.');
1196
1271
  return 0;
1197
1272
  }
1198
- preflight();
1273
+ const host = preflight();
1199
1274
  const configDir = findConfigDir();
1200
1275
  warnConfigTargets(configDir);
1201
1276
  const files = collectIncoming(configDir);
@@ -1239,6 +1314,9 @@ async function setup(opts) {
1239
1314
  const manifest = {
1240
1315
  package: PKG_NAME,
1241
1316
  version: pkgVersion(),
1317
+ // The host whose dialect the merged config was written for: recorded so an
1318
+ // install's config shapes are auditable against the CLI that will read them.
1319
+ hostVersion: host.raw,
1242
1320
  created: new Date().toISOString(),
1243
1321
  configDir,
1244
1322
  backupPath: backupPath,
package/docs/GUIDE.md ADDED
@@ -0,0 +1,79 @@
1
+ <h1 align="center">oc-harness-setup</h1>
2
+ <p align="center"><strong>A compact OpenCode starter that runs a real loop, researches before it claims, keeps a ledger, cleans up after itself, and grows the next skill you need.</strong></p>
3
+
4
+ ## Install
5
+
6
+ ```bash
7
+ npx --yes oc-harness-setup setup
8
+ ```
9
+
10
+ First run prints a manifest of everything it will touch and waits for you to type `y`. It then lays the agents, commands, skills, references, doctor gate, and merged base config into your OpenCode config dir, seeds your `state/` dir, and ends on the harness doctor gate.
11
+
12
+ ## Why this starter
13
+
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.
16
+ - Research that cites: researcher + search + canon; claims arrive sourced or `UNVERIFIED`.
17
+ - Memory that survives: historian writes session state; `state/` is seeded and preserved on upgrade.
18
+ - Cleanup that ships: cleaner removes this session's scratch; hygiene proves the tree clean.
19
+ - Grows with you: `evolve` turns a repeated workflow, a user request, or an upstream feature into a skill, command, reference, seat, or config change — 1:1 and doctor-checked.
20
+ - Reversible and fail-closed: manifest first, SHA-256 journal, uninstall restores originals, hard denies last.
21
+
22
+ ## What you get
23
+
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.
26
+ - 12 on-demand references behind a single index; load only the file a rule names.
27
+ - 18-law doctor gate: every setup run ends on it, and failures name the check and the fix.
28
+ - Consent-first install: the full manifest prints before anything moves, and `--dry-run` changes nothing.
29
+ - Your settings and state survive: your model, provider, and keys are preserved while the pack owns runtime policy, and your state dir survives upgrades untouched.
30
+ - No plugin, no model pins, no credentials.
31
+
32
+ ## Commands
33
+
34
+ ```bash
35
+ npx --yes oc-harness-setup setup # full install (default when you pass no args)
36
+ npx --yes oc-harness-setup setup --dry-run # print the manifest, touch nothing
37
+ npx --yes oc-harness-setup setup --ci # print-only, refuse to mutate
38
+ npx --yes oc-harness-setup setup --uninstall # remove exactly the manifest-listed files
39
+ npx --yes oc-harness-setup --help # print usage
40
+ ```
41
+
42
+ Set `OPENCODE_CONFIG_DIR` to override the config dir when the OpenCode CLI cannot report a path; otherwise setup uses the path from the CLI first, then the platform default under your config home. Restart OpenCode after install so the new agents, commands, and skills load.
43
+
44
+ ## Safe upgrade
45
+
46
+ - Your `opencode.jsonc` settings, providers, MCP servers, plugins, and state survive.
47
+ - `default_agent` stays `orchestrator`, so an existing 0.3.x config keeps resolving.
48
+ - Unmodified 0.3.x agents, commands, skills, references, and scripts are retired.
49
+ - Files you edited are archived under `state/archive/legacy-0.3.x/` instead of deleted, and reported.
50
+ - Stale `skill` allow entries for retired skills are pruned; custom skills are left alone.
51
+ - `setup --dry-run` previews it; `--uninstall` restores the pre-upgrade snapshot.
52
+
53
+ ## Grow it
54
+
55
+ This starter grows through `evolve`: the smallest deliberate extension — one skill, command, reference, seat, or config change at a time, always 1:1 and doctor-checked. Repeat something twice, and `evolve` is how it earns a place.
56
+
57
+ ## Requirements
58
+
59
+ - Windows 10/11 only; macOS and Linux are not supported.
60
+ - Node.js 22 or newer, the only runtime requirement with zero runtime dependencies.
61
+ - 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
+ - PowerShell 7 for the doctor gate; without it the doctor reports skipped, never passed.
63
+
64
+ ## Links
65
+
66
+ - Source: [nathwn12/oc-collections](https://github.com/nathwn12/oc-collections/tree/main/packages/oc-harness-setup) — the npm package remains individually installable.
67
+ - [Published package](https://www.npmjs.com/package/oc-harness-setup)
68
+ - [Changelog](../CHANGELOG.md)
69
+ - [Releases](https://github.com/nathwn12/oc-collections/releases)
70
+ - [Issues](https://github.com/nathwn12/oc-collections/issues)
71
+ - [License](../LICENSE)
72
+
73
+ <!-- nathwn12 house footer: identical in every repo. Do not edit. -->
74
+ <p align="center">
75
+ <a href="https://github.com/nathwn12"><img src="../assets/signature.svg" width="96" alt="nathwn12" /></a>
76
+ </p>
77
+ <p align="center">
78
+ <sub>Built by <a href="https://github.com/nathwn12">nathwn12</a> · <a href="https://github.com/nathwn12?tab=repositories">All projects</a></sub>
79
+ </p>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oc-harness-setup",
3
- "version": "0.4.4",
3
+ "version": "0.5.0",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "oc-harness-setup": "bin/cli.js"
@@ -21,7 +21,8 @@
21
21
  "opencode.jsonc",
22
22
  "README.md",
23
23
  "LICENSE",
24
- "assets"
24
+ "assets",
25
+ "docs/GUIDE.md"
25
26
  ],
26
27
  "engines": {
27
28
  "node": ">=22"