oc-harness-setup 1.0.2 → 1.1.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/bin/evolve.mjs ADDED
@@ -0,0 +1,320 @@
1
+ /**
2
+ * Standalone evolve engine. The CLI supplies every I/O seam; this module never
3
+ * imports bin/cli.js and never parses JSONC. One factory, one returned runner.
4
+ */
5
+ import { readFileSync, rmSync } from 'node:fs';
6
+ import path from 'node:path';
7
+
8
+ const KINDS = ['skill', 'command', 'agent', 'playbook'];
9
+ const ID_RE = /^[a-z][a-z0-9-]*$/;
10
+ const TOKEN_RE = /\{\{[^{}]*\}\}/;
11
+ const TODO_BODY = 'TODO: add the procedure.';
12
+
13
+ const fail = (log, message, code = 1) => {
14
+ log(`evolve: ${message}`);
15
+ return code;
16
+ };
17
+
18
+ const render = (template, vars) => {
19
+ let out = template;
20
+ for (const [key, value] of Object.entries(vars)) {
21
+ out = out.split(`{{${key}}}`).join(String(value));
22
+ }
23
+ return out;
24
+ };
25
+
26
+ const bodyText = (body, readText) => {
27
+ if (body === undefined || body === null) return TODO_BODY;
28
+ if (body === '-') {
29
+ try {
30
+ return readFileSync(0, 'utf8');
31
+ } catch (error) {
32
+ throw new Error(`cannot read stdin: ${error.message}`);
33
+ }
34
+ }
35
+ if (typeof body !== 'string') throw new Error('body must be a path, "-", or omitted');
36
+ try {
37
+ return readText(body);
38
+ } catch (error) {
39
+ throw new Error(`cannot read body file ${body}: ${error.message}`);
40
+ }
41
+ };
42
+
43
+ /* A missing frontmatter block is valid (playbooks carry none). An opened but
44
+ * unterminated one, an unquoted ': ' value, or a name/id mismatch is not. */
45
+ function frontmatterError(text, kind, id) {
46
+ const lines = text.split(/\r?\n/);
47
+ if (lines[0]?.trim() !== '---') return null;
48
+ const end = lines.indexOf('---', 1);
49
+ if (end === -1) return 'unterminated frontmatter';
50
+ for (const line of lines.slice(1, end)) {
51
+ const colon = line.indexOf(':');
52
+ if (colon === -1) continue;
53
+ const key = line.slice(0, colon).trim();
54
+ const value = line.slice(colon + 1).trim();
55
+ const quoted = /^".*"$/.test(value) || /^'.*'$/.test(value);
56
+ if (!quoted && value.includes(': ')) return `unquoted ': ' scalar in ${key}`;
57
+ if (kind === 'skill' && key === 'name' && value !== id) {
58
+ return `skill name ${value} does not match id ${id}`;
59
+ }
60
+ }
61
+ return null;
62
+ }
63
+
64
+ /* Every plain object, string-aware, at any nesting depth. A stack of opening
65
+ * braces keeps the walk generic: a permission entry under `permissions` is
66
+ * found the same way as any other nested object, with no path special case. */
67
+ function scanObjects(text) {
68
+ const objects = [];
69
+ const starts = [];
70
+ let inString = false;
71
+ let escaped = false;
72
+ for (let i = 0; i < text.length; i++) {
73
+ const c = text[i];
74
+ if (inString) {
75
+ if (escaped) escaped = false;
76
+ else if (c === '\\') escaped = true;
77
+ else if (c === '"') inString = false;
78
+ continue;
79
+ }
80
+ if (c === '"') { inString = true; continue; }
81
+ if (c === '{') starts.push(i);
82
+ else if (c === '}' && starts.length) {
83
+ const start = starts.pop();
84
+ objects.push({ start, end: i + 1, text: text.slice(start, i + 1) });
85
+ }
86
+ }
87
+ return objects;
88
+ }
89
+
90
+ const field = (object, name) => new RegExp(`"${name}"\\s*:\\s*"([^"]*)"`).exec(object.text)?.[1];
91
+
92
+ const isSkillAllow = (object) =>
93
+ field(object, 'action') === 'skill' && field(object, 'effect') === 'allow';
94
+
95
+ /* Insert after the last shipped skill allow, matching its exact shape. No
96
+ * duplicate when the id is already allowed. */
97
+ function amendConfig(text, id) {
98
+ const allows = scanObjects(text).filter(isSkillAllow);
99
+ if (allows.some((object) => field(object, 'resource') === id)) return text;
100
+
101
+ if (allows.length) {
102
+ const last = allows[allows.length - 1];
103
+ const lineStart = text.lastIndexOf('\n', last.start - 1) + 1;
104
+ const indent = /^[ \t]*/.exec(text.slice(lineStart, last.start))?.[0] || ' ';
105
+ const trailing = /^\s*,/.exec(text.slice(last.end))?.[0];
106
+ const insertAt = trailing ? last.end + trailing.length : last.end;
107
+ const block = [
108
+ trailing ? '' : ',',
109
+ '\n',
110
+ `${indent}{`,
111
+ `${indent} "action": "skill",`,
112
+ `${indent} "resource": "${id}",`,
113
+ `${indent} "effect": "allow"`,
114
+ `${indent}}${trailing ? ',' : ''}`,
115
+ ].join('');
116
+ return text.slice(0, insertAt) + block + text.slice(insertAt);
117
+ }
118
+
119
+ const match = /"permissions"\s*:\s*\[/.exec(text);
120
+ if (!match) throw new Error('opencode.jsonc has no permissions array');
121
+ let inString = false;
122
+ let escaped = false;
123
+ let depth = 0;
124
+ let close = -1;
125
+ for (let i = match.index + match[0].length - 1; i < text.length; i++) {
126
+ const c = text[i];
127
+ if (inString) {
128
+ if (escaped) escaped = false;
129
+ else if (c === '\\') escaped = true;
130
+ else if (c === '"') inString = false;
131
+ continue;
132
+ }
133
+ if (c === '"') { inString = true; continue; }
134
+ if (c === '[') depth++;
135
+ else if (c === ']') {
136
+ depth--;
137
+ if (depth === 0) { close = i; break; }
138
+ }
139
+ }
140
+ if (close === -1) throw new Error('unterminated permissions array');
141
+ const open = match.index + match[0].length - 1;
142
+ const lineStart = text.lastIndexOf('\n', close - 1) + 1;
143
+ const before = text.slice(0, lineStart).replace(/[ \t\r\n]+$/, '');
144
+ const content = text.slice(open + 1, lineStart).trim();
145
+ const needsComma = content.length > 0 && !content.endsWith(',');
146
+ const indent = ' ';
147
+ const block = [
148
+ needsComma ? ',' : '',
149
+ `\n${indent}{`,
150
+ `${indent} "action": "skill",`,
151
+ `${indent} "resource": "${id}",`,
152
+ `${indent} "effect": "allow"`,
153
+ `${indent}}`,
154
+ ].join('');
155
+ return before + block + '\n' + text.slice(lineStart);
156
+ }
157
+
158
+ /* Plain path cell, appended at the end of the existing match table. */
159
+ function amendRouter(text, id, phrase) {
160
+ const nl = text.includes('\r\n') ? '\r\n' : '\n';
161
+ const lines = text.split(/\r?\n/);
162
+ if (lines.some((line) => line.includes(`playbooks/${id}.md`))) return text;
163
+ let last = -1;
164
+ for (let i = 0; i < lines.length; i++) {
165
+ if (/^\s*\|/.test(lines[i])) last = i;
166
+ }
167
+ if (last === -1) throw new Error('playbook router has no match table');
168
+ lines.splice(last + 1, 0, `| ${phrase} | playbooks/${id}.md |`);
169
+ return lines.join(nl);
170
+ }
171
+
172
+ /**
173
+ * @param {object} deps
174
+ * @param {string} deps.pkgRoot package root holding templates/<kind>.md
175
+ * @param {string} deps.configDir config root to write into and doctor
176
+ * @param {(dir: string) => Promise<number>} deps.runDoctor
177
+ * @param {(p: string) => string} deps.readText throws when missing
178
+ * @param {(p: string, text: string) => void} deps.writeText atomic write
179
+ * @param {(line: string) => void} deps.log
180
+ * @returns {(options: object) => Promise<number>}
181
+ */
182
+ export function createEvolve({ pkgRoot, configDir, runDoctor, readText, writeText, log }) {
183
+ const emit = typeof log === 'function' ? log : () => {};
184
+ const abs = (...parts) => path.join(configDir, ...parts);
185
+ const tryRead = (p) => {
186
+ try { return readText(p); } catch { return null; }
187
+ };
188
+
189
+ return async function evolve(options = {}) {
190
+ const {
191
+ kind, id, title, description, body, dryRun = false, force = false,
192
+ } = options;
193
+
194
+ if (!KINDS.includes(kind)) {
195
+ return fail(emit, `invalid kind '${kind}'; valid kinds: ${KINDS.join(', ')}`, 2);
196
+ }
197
+ if (typeof id !== 'string' || !ID_RE.test(id)) {
198
+ return fail(emit, `invalid id '${id}'; expected ${ID_RE}`, 2);
199
+ }
200
+ if (typeof title !== 'string' || !title.trim()) return fail(emit, 'title is required');
201
+ if (typeof description !== 'string' || !description.trim()) {
202
+ return fail(emit, 'description is required');
203
+ }
204
+
205
+ const targets = [];
206
+ if (kind === 'skill') {
207
+ targets.push({ path: abs('skills', id, 'SKILL.md'), template: 'skill.md' });
208
+ targets.push({ path: abs('commands', `${id}.md`), template: 'command.md' });
209
+ } else if (kind === 'command') {
210
+ targets.push({ path: abs('commands', `${id}.md`), template: 'command.md' });
211
+ } else if (kind === 'agent') {
212
+ targets.push({ path: abs('agents', `${id}.md`), template: 'agent.md' });
213
+ } else {
214
+ targets.push({ path: abs('playbooks', `${id}.md`), template: 'playbook.md' });
215
+ }
216
+
217
+ const amendments = [];
218
+ if (kind === 'skill') {
219
+ amendments.push({
220
+ path: abs('opencode.jsonc'),
221
+ amend: (text) => amendConfig(text, id),
222
+ });
223
+ }
224
+ if (kind === 'playbook') {
225
+ const phrase = String(title).replace(/[\r\n|]/g, '-').trim() || id;
226
+ amendments.push({
227
+ path: abs('skills', 'playbook', 'SKILL.md'),
228
+ amend: (text) => amendRouter(text, id, phrase),
229
+ });
230
+ }
231
+
232
+ let vars;
233
+ try {
234
+ vars = {
235
+ id,
236
+ title,
237
+ description,
238
+ body: bodyText(body, readText),
239
+ };
240
+ } catch (error) {
241
+ return fail(emit, error.message);
242
+ }
243
+
244
+ for (const target of targets) {
245
+ let text;
246
+ try {
247
+ text = readText(path.join(pkgRoot, 'templates', target.template));
248
+ } catch (error) {
249
+ return fail(emit, `cannot read template ${target.template}: ${error.message}`);
250
+ }
251
+ const rendered = render(text, vars);
252
+ if (TOKEN_RE.test(rendered)) {
253
+ return fail(emit, `unresolved template token in ${target.template}`);
254
+ }
255
+ const problem = frontmatterError(rendered, kind, id);
256
+ if (problem) return fail(emit, problem);
257
+ target.text = rendered;
258
+ }
259
+
260
+ const originals = new Map();
261
+ for (const target of targets) originals.set(target.path, tryRead(target.path));
262
+ for (const amendment of amendments) {
263
+ const current = tryRead(amendment.path);
264
+ if (current === null) {
265
+ return fail(emit, `cannot read file to amend: ${amendment.path}`);
266
+ }
267
+ originals.set(amendment.path, current);
268
+ try {
269
+ amendment.text = amendment.amend(current);
270
+ } catch (error) {
271
+ return fail(emit, `cannot amend ${amendment.path}: ${error.message}`);
272
+ }
273
+ }
274
+
275
+ for (const target of targets) {
276
+ if (originals.get(target.path) !== null && !force) {
277
+ return fail(emit, `artifact already exists: ${target.path}`);
278
+ }
279
+ }
280
+
281
+ if (dryRun) {
282
+ for (const target of targets) emit(`would write ${target.path}`);
283
+ for (const amendment of amendments) emit(`would amend ${amendment.path}`);
284
+ return 0;
285
+ }
286
+
287
+ const plan = [
288
+ ...targets.map((t) => ({ path: t.path, text: t.text, amend: false })),
289
+ ...amendments.map((a) => ({ path: a.path, text: a.text, amend: true })),
290
+ ];
291
+ const written = [];
292
+ try {
293
+ for (const step of plan) {
294
+ writeText(step.path, step.text);
295
+ written.push(step);
296
+ }
297
+ } catch (error) {
298
+ for (const step of written.reverse()) {
299
+ try {
300
+ const original = originals.get(step.path);
301
+ if (original === null) rmSync(step.path, { force: true });
302
+ else writeText(step.path, original);
303
+ } catch (rollbackError) {
304
+ emit(`evolve: rollback failed for ${step.path}: ${rollbackError.message}`);
305
+ }
306
+ }
307
+ return fail(emit, `write failed: ${error.message}`);
308
+ }
309
+
310
+ try {
311
+ const code = await runDoctor(configDir);
312
+ if (typeof code !== 'number' || !Number.isFinite(code)) {
313
+ return fail(emit, 'doctor returned no numeric exit code');
314
+ }
315
+ return Math.trunc(code);
316
+ } catch (error) {
317
+ return fail(emit, `doctor failed: ${error.message}`);
318
+ }
319
+ };
320
+ }
@@ -6,6 +6,6 @@ subagent: false
6
6
 
7
7
  # /evolve
8
8
 
9
- Load the `evolve` skill; `skills/evolve/SKILL.md` owns the procedure. Apply it to `$ARGUMENTS`.
9
+ Load the `evolve` skill; `skills/evolve/SKILL.md` owns the CLI contract. Apply it to `$ARGUMENTS`.
10
10
 
11
- When `$ARGUMENTS` is empty, ask what capability is missing, then proceed.
11
+ When `$ARGUMENTS` is empty, ask which artifact to create, then run `oc-harness-setup evolve <kind> <id>` with the answers.
@@ -0,0 +1,9 @@
1
+ ---
2
+ description: "Route one task to one playbook, copy its steps into the todo, then do the work."
3
+ agent: orchestrator
4
+ subagent: false
5
+ ---
6
+
7
+ # /playbook
8
+
9
+ Load the `playbook` skill; `skills/playbook/SKILL.md` owns the match table. Apply it to `$ARGUMENTS`.
package/docs/GUIDE.md CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  ## How it works
4
4
 
5
- `setup` is a one-shot installer, not a runtime. It reads a file manifest, prints it, waits for your `y`, then writes into your OpenCode config directory. It ships no plugin and starts no process: everything it lays down is markdown, JSON, and one doctor script that Node runs.
5
+ `setup` is a one-shot installer, not a runtime. It runs six ordered stages declared in `stages.yaml`. At the plan stage it reads a file manifest, prints it and waits for your `y`; then it writes into your OpenCode config directory. It ships no plugin and starts no process: everything it lays down is markdown, JSON, and one doctor script that Node runs.
6
6
 
7
- **What lands where.** The config dir receives `opencode.jsonc` (merged, never replaced), `AGENTS.md`, `agents/` (10 seats), `commands/` (6 commands), `skills/` (6 skills), `reference/` (12 on-demand files behind one index), `scripts/harness-doctor.mjs`, `gitignore.template`, and `.docs/`. Your state dir is seeded once with `state/lessons.md` and `state/template.md` and is never overwritten afterwards.
7
+ **What lands where.** The config dir receives `opencode.jsonc` (merged, never replaced), `AGENTS.md`, `agents/` (10 seats), `commands/` (7 commands), `skills/` (7 skills), `playbooks/` (five procedures), `reference/` (12 on-demand files behind one index), `scripts/harness-doctor.mjs`, `gitignore.template`, and `.docs/`. Templates stay inside the package; `evolve` reads them there. Setup records stage progress in `state/setup-state.yaml` in the config dir. Your state dir is seeded once with `state/lessons.md` and `state/template.md` and is never overwritten afterwards.
8
8
 
9
9
  **The loop it installs.** Brief → seat → skill → evidence → verify → memory. One routing table in `reference/flow.md` gives each seat its trigger, owned paths, and check. The verifier never authored the work it grades, and no seat certifies its own output.
10
10
 
@@ -14,7 +14,24 @@
14
14
 
15
15
  **Journal and uninstall.** Every written path is recorded in `oc-harness-setup.manifest.json` inside the config dir, with a SHA-256 per file. `setup --uninstall` reads that manifest and removes exactly what it lists, restoring the pre-install originals from its backup path.
16
16
 
17
- **Doctor gate.** Every setup run ends by running `scripts/harness-doctor.mjs` against the config dir. It grades 18 laws and names the failing law with the fix. A failing doctor exits non-zero, and re-running setup is idempotent, so the recipe is: read the named fix, apply it, run again.
17
+ **Doctor gate.** Every setup run reaches a doctor gate: the verify stage runs `scripts/harness-doctor.mjs` against the config dir. It grades 19 laws and names the failing law with the fix. A failing doctor exits non-zero, and re-running setup is idempotent, so read the named fix, apply it and run again.
18
+
19
+ ## Stages
20
+
21
+ `setup` runs these stages in the order declared in `stages.yaml`:
22
+
23
+ | Stage | What it does |
24
+ | --- | --- |
25
+ | preflight | Checks the host. |
26
+ | resolve | Finds the config dir. |
27
+ | plan | Collects files, prints the plan and confirms. |
28
+ | write | Backs up, installs and merges config. |
29
+ | verify | Runs the doctor. |
30
+ | report | Prints the summary. |
31
+
32
+ `--list-stages` prints the list and exits without writing. `--stage <id>` runs up to and including that stage, then stops. `--from <id>` starts at that stage and runs to the end. `--ask` adds two questions: whether to keep your existing config values when an install-owned key collides, and the question "Install the playbooks?". Both default to yes.
33
+
34
+ Progress is recorded in `state/setup-state.yaml` in the config dir. Plain `setup` still runs every stage and remains the upgrade path; recorded progress never makes it skip work.
18
35
 
19
36
  ## Configuration
20
37
 
@@ -29,7 +46,7 @@ Two environment variables, and the config keys the pack owns.
29
46
  | --- | --- | --- |
30
47
  | `default_agent` | `orchestrator` | The routing seat is the entry point; an existing 0.3.x config keeps resolving. |
31
48
  | `permissions[]` / `policies[]` | The deny block, last | Hard denies land after your rules so the gate cannot be widened by ordering. |
32
- | `skill` allow entries | The six shipped skills | Retired skills are pruned; custom skills are left alone. |
49
+ | `skill` allow entries | The seven shipped skills | Retired skills are pruned; custom skills are left alone. |
33
50
 
34
51
  Everything else in that file is yours. There are no model pins and no credentials anywhere in the pack.
35
52
 
@@ -37,10 +54,15 @@ Everything else in that file is yours. There are no model pins and no credential
37
54
 
38
55
  | Command | Arguments | What it returns | Exit |
39
56
  | --- | --- | --- | --- |
40
- | `oc-harness-setup setup` | none (the default when you pass no command) | Prints the manifest, waits for `y`, installs, ends on the doctor gate | `0` on a clean install, `1` when the doctor fails or an argument is unknown |
41
- | `oc-harness-setup setup --dry-run` | — | The same manifest, and nothing is written | `0` |
57
+ | `oc-harness-setup setup` | none (the default when you pass no command) | Runs all six stages: prints the plan, waits for `y`, installs, runs the doctor and reports | `0` on a clean install, `1` when the doctor fails or an argument is unknown |
58
+ | `oc-harness-setup setup --dry-run` | — | The same plan, and nothing is written | `0` |
59
+ | `oc-harness-setup setup --list-stages` | — | The ordered stage list, then exits without writing | `0` |
60
+ | `oc-harness-setup setup --stage <id>` | a stage id | Runs up to and including that stage, then stops | `0` |
61
+ | `oc-harness-setup setup --from <id>` | a stage id | Starts at that stage and runs to the end | `0` |
62
+ | `oc-harness-setup setup --ask` | — | Asks about keeping existing config values on a collision, then asks "Install the playbooks?"; both default to yes | `0` |
42
63
  | `oc-harness-setup setup --ci` | — | The manifest only, refusing to mutate | `0` |
43
64
  | `oc-harness-setup setup --uninstall` | `--dry-run` / `--ci` also accepted | Removes exactly the manifest-listed files and restores originals; a preview writes nothing | `0`, or `1` on a doctor failure during setup |
65
+ | `oc-harness-setup evolve <kind> <id>` | a kind (`skill`, `command`, `agent`, `playbook`) and an id | Writes the artifact and its required companions, runs the doctor and reports the verdict | `0` when the doctor is clean, `1` when it fails or the input is bad, `2` for a usage error |
44
66
  | `oc-harness-setup --version` | — | The package version | `0` |
45
67
  | `oc-harness-setup --help` | — | The usage block | `0` |
46
68
 
@@ -64,9 +86,21 @@ It prints the destination config dir, the incoming file count split into new and
64
86
  - 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.
65
87
  - `setup --dry-run` previews all of it; `--uninstall` restores the pre-upgrade snapshot.
66
88
 
67
- ## Grow it
89
+ ## Playbooks
90
+
91
+ The pack ships `playbooks/` with five procedures: investigate, bug-fix, feature, refactor and ship. Invoke the router skill as `/playbook`. It matches one playbook to your task and copies its numbered steps into the todo before any work starts. Each playbook carries entry criteria, numbered steps, a reply line and an exit receipt.
92
+
93
+ ## Evolve
94
+
95
+ `evolve` turns a repeated workflow into a lasting artifact. It is a command, not a recipe.
96
+
97
+ ```bash
98
+ oc-harness-setup evolve <kind> <id>
99
+ ```
100
+
101
+ `<kind>` is `skill`, `command`, `agent` or `playbook`, and `<id>` names the artifact. `--title` and `--description` describe it. `--body <file|->` takes the body from a file, or from standard input when you pass `-`. `--dry-run` shows what would be written without writing. `--force` overwrites an existing artifact.
68
102
 
69
- 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.
103
+ The command writes the artifact from the matching template and adds the companions the doctor requires. A skill also gets its paired command and its skill allowlist entry; a playbook also gets its router row. It then runs the doctor and reports the verdict. Exit `0` when the doctor is clean, `1` when it fails or the input is bad, and `2` for a usage error.
70
104
 
71
105
  ## Troubleshooting
72
106
 
@@ -78,7 +112,7 @@ This starter grows through `evolve`: the smallest deliberate extension — one s
78
112
 
79
113
  **The doctor fails.** It names the law and the fix. Apply the fix and re-run `setup`; it is idempotent. Removing `state/template.md`, for example, fails the doctor by name.
80
114
 
81
- **The doctor did not run at all.** If `scripts/harness-doctor.mjs` is missing from the config dir, setup warns that the 18 laws are unverified and exits `0`. That is a warning, not a pass.
115
+ **The doctor did not run at all.** If `scripts/harness-doctor.mjs` is missing from the config dir, setup warns that the 19 laws are unverified and exits `0`. That is a warning, not a pass.
82
116
 
83
117
  **A file I edited got a `.new` beside it.** By design: your bytes were kept and the new version landed next to them. Merge by hand, then delete the `.new`.
84
118
 
@@ -109,7 +143,7 @@ This starter grows through `evolve`: the smallest deliberate extension — one s
109
143
 
110
144
  <!-- nathwn12 house footer: identical in every repo. Do not edit. -->
111
145
  <p align="center">
112
- <a href="https://github.com/nathwn12"><img src="../assets/signature.svg" width="96" alt="nathwn12" /></a>
146
+ <a href="https://github.com/nathwn12"><img src="../assets/signature-glyph.svg" width="96" alt="nathwn12" /></a>
113
147
  </p>
114
148
  <p align="center">
115
149
  <sub>Built by <a href="https://github.com/nathwn12">nathwn12</a> · <a href="https://github.com/nathwn12?tab=repositories">All projects</a></sub>
package/opencode.jsonc CHANGED
@@ -4,7 +4,7 @@
4
4
  // and the doctor grades 18 derived laws. Stable runtime policy lives here;
5
5
  // behavior lives beside it in agents/, commands/, skills/, and reference/
6
6
  // for smaller, hot-reloadable artifacts. Skill loading is fail-closed to
7
- // the 6 local IDs.
7
+ // the 7 local IDs.
8
8
  //
9
9
  // This is the oc-harness-setup base config; the installer preserves your
10
10
  // model/providers/mcp/plugins.
@@ -354,6 +354,11 @@
354
354
  "resource": "loop",
355
355
  "effect": "allow"
356
356
  },
357
+ {
358
+ "action": "skill",
359
+ "resource": "playbook",
360
+ "effect": "allow"
361
+ },
357
362
  {
358
363
  "action": "skill",
359
364
  "resource": "search",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oc-harness-setup",
3
- "version": "1.0.2",
3
+ "version": "1.1.1",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "oc-harness-setup": "bin/cli.js"
@@ -14,11 +14,14 @@
14
14
  "scripts",
15
15
  ".docs",
16
16
  "state-seed",
17
+ "playbooks",
18
+ "templates",
17
19
  "AGENTS.md",
18
20
  "GLOSSARY.md",
19
21
  "CHANGELOG.md",
20
22
  "gitignore.template",
21
23
  "opencode.jsonc",
24
+ "stages.yaml",
22
25
  "README.md",
23
26
  "LICENSE",
24
27
  "assets",
@@ -30,7 +33,7 @@
30
33
  "scripts": {
31
34
  "check": "npm pack --dry-run",
32
35
  "test": "node --check bin/cli.js && node --test \"test/**/*.test.js\"",
33
- "prepublishOnly": "npm run check"
36
+ "prepublishOnly": "node ../../scripts/check-version-cell.mjs . && bun run check"
34
37
  },
35
38
  "publishConfig": {
36
39
  "access": "public"
@@ -42,18 +45,19 @@
42
45
  "url": "git+https://github.com/nathwn12/oc-collections.git",
43
46
  "directory": "packages/oc-harness-setup"
44
47
  },
45
- "description": "A general OpenCode starter for Windows: 10 seats on a dispatch loop, 6 skills, fresh-verdict research, lesson memory, leave-no-trail hygiene, and self-extension tooling - installed by one explicit command.",
48
+ "description": "A consent-first OpenCode starter for Windows with skills and a doctor gate in one command.",
46
49
  "keywords": [
47
50
  "opencode",
51
+ "plugin",
52
+ "starter",
48
53
  "agents",
49
54
  "skills",
50
- "loop",
51
- "research",
52
- "memory",
53
- "cleanup",
54
- "self-extension",
55
- "starter",
56
- "oc-harness-setup"
55
+ "playbooks",
56
+ "doctor",
57
+ "setup",
58
+ "typescript",
59
+ "tooling",
60
+ "windows"
57
61
  ],
58
62
  "bugs": "https://github.com/nathwn12/oc-collections/issues",
59
63
  "homepage": "https://github.com/nathwn12/oc-collections/tree/main/packages/oc-harness-setup"
@@ -0,0 +1,22 @@
1
+ Entry criteria: Enter on a failure you have reproduced on the surface where it happens.
2
+
3
+ ### Bug fix
4
+
5
+ **You own the fix. Reproduce it, find the cause, verify the repair.**
6
+
7
+ 1. Run the failing case yourself on the matching surface.
8
+ 2. Save the exact command, exit code, and output as the before proof.
9
+ 3. List every possible cause you can name.
10
+ 4. Rule out each cause with a check you can run.
11
+ 5. Confirm the surviving cause with runtime evidence.
12
+ 6. Write the smallest change that removes that cause.
13
+ 7. Re-run the before case and save the after proof.
14
+ 8. Run the full gate for the changed area and quote its exit.
15
+ 9. Stage the before proof and the fix as two ordered commits.
16
+ 10. Report each commit SHA in the receipt.
17
+
18
+ **Reply:** what broke, the cause you confirmed, the change you made, and the before and after output pasted in full.
19
+
20
+ ## Exit - SHA receipt
21
+
22
+ Land small ordered commits, one green per commit. Report the command, exit, and key line for each check. Push and publish stay gated.
@@ -0,0 +1,22 @@
1
+ Entry criteria: Enter on new behavior with an agreed design and a named proving check.
2
+
3
+ ### Feature
4
+
5
+ **You own the design and the proof. Build the smallest change that satisfies both.**
6
+
7
+ 1. Trace the files the new behavior will touch.
8
+ 2. Name the data shape the feature needs before you write logic.
9
+ 3. Write the proving check first, in words a beginner can follow.
10
+ 4. Split the work into ordered steps you can verify one by one.
11
+ 5. Build the first step and run its check.
12
+ 6. Build each next step and run its check before moving on.
13
+ 7. Run the full gate for the changed area and quote its exit.
14
+ 8. Show the new behavior on the surface the user will use.
15
+ 9. Rebase the work into small ordered commits.
16
+ 10. Report each commit SHA in the receipt.
17
+
18
+ **Reply:** what you built, the choices you made and why, the check that proves it, and any open decision.
19
+
20
+ ## Exit - SHA receipt
21
+
22
+ Land small ordered commits, one green per commit. Report the command, exit, and key line for each check. Push and publish stay gated.
@@ -0,0 +1,22 @@
1
+ Entry criteria: Enter when you need an answer or a recommendation, and no code change is wanted.
2
+
3
+ ### Investigate
4
+
5
+ **You own the answer. Read the code, gather evidence, and report. Change nothing.**
6
+
7
+ 1. Write the question in one sentence.
8
+ 2. Name what a useful answer will contain.
9
+ 3. Find the files the question is about.
10
+ 4. Read those files from the start to the end.
11
+ 5. Trace how data enters, moves through, and leaves them.
12
+ 6. Run a check for each claim you want to make.
13
+ 7. Record the command, its exit code, and the key output line beside each finding.
14
+ 8. Label each finding proven or unverified.
15
+ 9. Write the answer as an overview, key ideas, how it works, where it lives, and gotchas.
16
+ 10. Stop and hand the task to the bug-fix or feature playbook when a code change is needed.
17
+
18
+ **Reply:** the answer, with each finding labelled proven or unverified. Say "I do not know" where evidence is missing.
19
+
20
+ ## Exit - SHA receipt
21
+
22
+ This run changes no code, so no commit is needed. If you write a report file, name its path and SHA.
@@ -0,0 +1,22 @@
1
+ Entry criteria: Enter when the structure must change while the behavior stays the same.
2
+
3
+ ### Refactor
4
+
5
+ **You own the contract. Change the structure. Hold the behavior steady.**
6
+
7
+ 1. Write down the behavior you promise to keep.
8
+ 2. Capture that behavior in a test, a snapshot, or a recorded output.
9
+ 3. Run the capture before any structural edit and save it as the pin.
10
+ 4. Name the missing shape in one sentence.
11
+ 5. Delete dead code and one-caller wrappers before adding anything.
12
+ 6. Move the structure in one small step at a time.
13
+ 7. Re-run the pin after every step and stop on the first failure.
14
+ 8. Compare the old and new outputs on a real run.
15
+ 9. Revert any step that does not make the code easier to read.
16
+ 10. Rebase the work into small ordered commits and report each SHA.
17
+
18
+ **Reply:** the structure that changed, the pin you held, the equivalence proof, what got reverted, and confirmation that no behavior was added.
19
+
20
+ ## Exit - SHA receipt
21
+
22
+ Land small ordered commits, one green per commit. Report the command, exit, and key line for each check. Push and publish stay gated.
@@ -0,0 +1,21 @@
1
+ Entry criteria: Enter when the work is verified and you are ready to land it.
2
+
3
+ ### Ship
4
+
5
+ **You own what lands. Run the gate, then land the work, then read it back.**
6
+
7
+ 1. Read the target version, the live branch, and the artifact destination.
8
+ 2. Run the repository's full gate on the final tree.
9
+ 3. Quote the gate's command, exit code, and key line.
10
+ 4. Treat an inconclusive verdict as a failure, never as a pass.
11
+ 5. Commit the slice with a conventional subject under 50 characters.
12
+ 6. Fetch and rebase onto the trunk before you push.
13
+ 7. Push with a fast-forward only.
14
+ 8. Read the landing back and report the SHA you observed.
15
+ 9. Keep publishing, tagging, and release work behind the owner's word.
16
+
17
+ **Reply:** what landed, the SHA you read back, the gate that proves it, and what still waits for approval.
18
+
19
+ ## Exit - SHA receipt
20
+
21
+ Land small ordered commits, one green per commit. Report the command, exit, and key line for each check. Push and publish stay gated.