@nurix/etna 0.16.0 → 0.17.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.
Files changed (56) hide show
  1. package/bin/etna.js +148 -67
  2. package/data/harness-index.json +1 -1
  3. package/data/harnesses/code/.prettierignore +12 -0
  4. package/data/harnesses/code/.prettierrc.json +3 -0
  5. package/data/harnesses/code/.vscode/settings.json +10 -0
  6. package/data/harnesses/code/CLAUDE.md +5 -8
  7. package/data/harnesses/code/agents/change-review.md +13 -14
  8. package/data/harnesses/code/agents/harness-manager.md +14 -26
  9. package/data/harnesses/code/agents/maintenance.md +10 -18
  10. package/data/harnesses/code/harness.json +8 -3
  11. package/data/harnesses/code/hooks/hooks.json +2 -2
  12. package/data/harnesses/code/hooks/lib/{redact.js → redact.mjs} +2 -4
  13. package/data/harnesses/{code-fable/hooks/prompt-recall.js → code/hooks/prompt-recall.mjs} +5 -7
  14. package/data/harnesses/{code-fable/hooks/session-reflect.js → code/hooks/session-reflect.mjs} +9 -7
  15. package/data/harnesses/code/rules/general.md +23 -40
  16. package/data/harnesses/code/rules/nomenclature.md +0 -4
  17. package/data/harnesses/code/rules/typescript.md +19 -0
  18. package/data/harnesses/code/skills/boundary/SKILL.md +53 -239
  19. package/data/harnesses/code/skills/brainstorm/harvest.md +2 -2
  20. package/data/harnesses/code/skills/documentation/SKILL.md +2 -4
  21. package/data/harnesses/code/skills/documentation/references/templates.md +12 -89
  22. package/data/harnesses/code-fable/.prettierignore +12 -0
  23. package/data/harnesses/code-fable/.prettierrc.json +3 -0
  24. package/data/harnesses/code-fable/.vscode/settings.json +10 -0
  25. package/data/harnesses/code-fable/CLAUDE.md +5 -8
  26. package/data/harnesses/code-fable/agents/change-review.md +13 -14
  27. package/data/harnesses/code-fable/agents/harness-manager.md +14 -26
  28. package/data/harnesses/code-fable/agents/maintenance.md +10 -18
  29. package/data/harnesses/code-fable/harness.json +8 -3
  30. package/data/harnesses/code-fable/hooks/hooks.json +2 -2
  31. package/data/harnesses/code-fable/hooks/lib/{redact.js → redact.mjs} +2 -4
  32. package/data/harnesses/{code/hooks/prompt-recall.js → code-fable/hooks/prompt-recall.mjs} +5 -7
  33. package/data/harnesses/{code/hooks/session-reflect.js → code-fable/hooks/session-reflect.mjs} +9 -7
  34. package/data/harnesses/code-fable/rules/general.md +23 -40
  35. package/data/harnesses/code-fable/rules/nomenclature.md +0 -4
  36. package/data/harnesses/code-fable/rules/typescript.md +19 -0
  37. package/data/harnesses/code-fable/skills/boundary/SKILL.md +53 -239
  38. package/data/harnesses/code-fable/skills/brainstorm/harvest.md +2 -2
  39. package/data/harnesses/code-fable/skills/documentation/SKILL.md +2 -4
  40. package/data/harnesses/code-fable/skills/documentation/references/templates.md +12 -89
  41. package/data/harnesses/discover/.prettierignore +12 -0
  42. package/data/harnesses/discover/.prettierrc.json +3 -0
  43. package/data/harnesses/discover/.vscode/settings.json +10 -0
  44. package/data/harnesses/discover/harness.json +6 -1
  45. package/data/harnesses/discover/rules/evaluation.md +13 -1
  46. package/data/harnesses/discover/rules/ingestion.md +15 -0
  47. package/data/harnesses/discover/rules/tradecraft.md +13 -0
  48. package/data/harnesses/hr/.prettierignore +12 -0
  49. package/data/harnesses/hr/.prettierrc.json +3 -0
  50. package/data/harnesses/hr/.vscode/settings.json +10 -0
  51. package/data/harnesses/hr/harness.json +6 -1
  52. package/data/harnesses/kb-agi/.prettierignore +12 -0
  53. package/data/harnesses/kb-agi/.prettierrc.json +3 -0
  54. package/data/harnesses/kb-agi/.vscode/settings.json +10 -0
  55. package/data/harnesses/kb-agi/harness.json +6 -1
  56. package/package.json +4 -1
package/bin/etna.js CHANGED
@@ -1,11 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
  // packages/cli/bin/etna.js
3
- // `npx @nurix/etna <harness-name>` — copy a Nurix harness into the current
4
- // directory. Drops the harness's CLAUDE.md at the project root and copies its
5
- // skills, agents, rules, and scripts into <project>/.claude/. No marketplace,
6
- // no plugin enablement — files live in the project, version-controlled and
7
- // editable per project. Re-run `etna` to refresh. Harnesses are addressed by
8
- // their harness/<folder> name; several harnesses may share one plugin.
3
+ // `npx @nurix/etna [harness-name]` — copy a Nurix harness into the current
4
+ // directory. Given a name it installs straight away; with no name (in a TTY) it
5
+ // prompts you to pick one. Drops the harness's CLAUDE.md + project-root config
6
+ // files (.prettierrc.json, .vscode/settings.json, …) at the project root, and
7
+ // copies its skills, agents, rules, scripts, and hooks into <project>/.claude/.
8
+ // No marketplace, no plugin enablement — files live in the project,
9
+ // version-controlled and editable per project. Re-run `etna` to refresh.
10
+ // Harnesses are addressed by their harness/<folder> name; several harnesses may
11
+ // share one plugin.
9
12
 
10
13
  import {
11
14
  existsSync,
@@ -20,6 +23,7 @@ import {
20
23
  } from 'node:fs';
21
24
  import { join, dirname, resolve } from 'node:path';
22
25
  import { fileURLToPath } from 'node:url';
26
+ import * as p from '@clack/prompts';
23
27
 
24
28
  const __dirname = dirname(fileURLToPath(import.meta.url));
25
29
  const pkgRoot = resolve(__dirname, '..');
@@ -31,29 +35,37 @@ const dataDir = join(pkgRoot, 'data');
31
35
  // the settings merge reads it from the bundle, not the project copy).
32
36
  const PLUGIN_SUBDIRS = ['skills', 'agents', 'rules', 'scripts', 'hooks'];
33
37
 
34
- function usage() {
35
- const idx = loadHarnessIndex();
36
- console.log(`\nUsage: npx @nurix/etna <harness-name>\n`);
37
- const entries = Object.entries(idx.harnesses || {});
38
- if (entries.length) {
39
- console.log(`Available harnesses:`);
40
- for (const [folder, plugin] of entries) {
41
- console.log(` ${folder}${plugin && plugin !== folder ? ` (plugin: ${plugin})` : ''}`);
42
- }
38
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
39
+
40
+ // True when both stdin and stdout are a terminal — clack prompts can't resolve
41
+ // otherwise (CI, piped stdin), so the no-arg pick must fall back to an error.
42
+ function isInteractive() {
43
+ return Boolean(process.stdin.isTTY && process.stdout.isTTY);
44
+ }
45
+
46
+ // Boxed list of installable harnesses, for --help and the non-interactive no-arg path.
47
+ function printHarnessList(harnesses) {
48
+ const entries = Object.entries(harnesses);
49
+ if (!entries.length) {
50
+ p.log.warn('No harnesses are bundled. Run `npm run build:data` from the package root.');
51
+ return;
43
52
  }
44
- console.log();
53
+ const lines = entries.map(
54
+ ([folder, plugin]) => `${folder}${plugin && plugin !== folder ? ` (plugin: ${plugin})` : ''}`,
55
+ );
56
+ p.note(lines.join('\n'), 'Available harnesses');
45
57
  }
46
58
 
47
59
  function loadHarnessIndex() {
48
60
  const path = join(dataDir, 'harness-index.json');
49
61
  if (!existsSync(path)) {
50
- die(`harness-index.json missing — run \`npm run build:data\` from the package root.`);
62
+ die('harness-index.json missing — run `npm run build:data` from the package root.');
51
63
  }
52
64
  return JSON.parse(readFileSync(path, 'utf8'));
53
65
  }
54
66
 
55
67
  function die(msg, code = 1) {
56
- console.error(`error: ${msg}`);
68
+ p.log.error(msg);
57
69
  process.exit(code);
58
70
  }
59
71
 
@@ -204,22 +216,47 @@ function mergeHooks(targetDir, bundledHooksJson) {
204
216
  return added;
205
217
  }
206
218
 
207
- async function main(args) {
208
- if (args.includes('-h') || args.includes('--help') || args.length === 0) {
209
- usage();
210
- process.exit(args.length === 0 ? 1 : 0);
219
+ // Resolve the harness to install: the positional arg, or — in a TTY — an interactive
220
+ // pick. Returns the chosen folder name, or null if the user cancels / can't be prompted.
221
+ async function resolveHarnessName(positional, harnesses) {
222
+ const names = Object.keys(harnesses);
223
+ if (positional) {
224
+ if (!harnesses[positional]) {
225
+ p.log.error(`Unknown harness '${positional}'.`);
226
+ printHarnessList(harnesses);
227
+ p.outro('Pick one of the harnesses above.');
228
+ process.exit(1);
229
+ }
230
+ return positional;
211
231
  }
212
-
213
- const harnessName = args[0];
214
- const idx = loadHarnessIndex();
215
- const harnesses = idx.harnesses || {};
216
- if (!harnesses[harnessName]) {
217
- die(
218
- `Unknown harness '${harnessName}'. Available: ${Object.keys(harnesses).join(', ') || '(none)'}`,
219
- );
232
+ if (!isInteractive()) {
233
+ p.log.error('No harness specified, and not running in an interactive terminal.');
234
+ printHarnessList(harnesses);
235
+ p.outro('Re-run as `npx @nurix/etna <harness-name>`.');
236
+ process.exit(1);
220
237
  }
221
- const harnessFolder = harnessName;
238
+ const choice = await p.select({
239
+ message: 'Which harness do you want to install here?',
240
+ options: names.map((folder) => {
241
+ const plugin = harnesses[folder];
242
+ return {
243
+ value: folder,
244
+ label: folder,
245
+ hint: plugin && plugin !== folder ? `plugin: ${plugin}` : undefined,
246
+ };
247
+ }),
248
+ });
249
+ if (p.isCancel(choice)) {
250
+ p.cancel('Cancelled — nothing installed.');
251
+ return null;
252
+ }
253
+ return choice;
254
+ }
222
255
 
256
+ // Copy one harness's bundled payload into the current directory. All file ops run
257
+ // inside a spinner; the per-item detail + any warnings are emitted after it stops.
258
+ async function installHarness(harnessName, harnesses) {
259
+ const harnessFolder = harnessName;
223
260
  const bundledHarnessDir = join(dataDir, 'harnesses', harnessFolder);
224
261
  const bundledClaudeMd = join(bundledHarnessDir, 'CLAUDE.md');
225
262
  if (!existsSync(bundledClaudeMd)) {
@@ -229,8 +266,8 @@ async function main(args) {
229
266
  const targetDir = process.cwd();
230
267
  const claudeMdDest = join(targetDir, 'CLAUDE.md');
231
268
 
232
- // Read the bundled epoch marker up front so the install banner can name the
233
- // harness version; the file itself is copied into the project further down.
269
+ // Bundled epoch marker — names the version for the banner and carries the
270
+ // `files` list (project-root config shipped outside the plugin route).
234
271
  const bundledHarnessJson = join(bundledHarnessDir, 'harness.json');
235
272
  const harnessMeta = existsSync(bundledHarnessJson) ? readJson(bundledHarnessJson) : {};
236
273
  const versionTag = harnessMeta.version ? ` v${harnessMeta.version}` : '';
@@ -238,31 +275,35 @@ async function main(args) {
238
275
  // harnesses may share it. Used only for legacy marketplace-entry cleanup.
239
276
  const pluginName = harnessMeta.name || harnesses[harnessName] || harnessName;
240
277
 
241
- console.log(`\nInstalling ${harnessName}${versionTag} into ${targetDir}`);
278
+ const spin = p.spinner();
279
+ spin.start(`Installing ${harnessName}${versionTag} into ${targetDir}`);
242
280
 
243
- const claudeBackup = backupIfExists(claudeMdDest);
244
- if (claudeBackup) console.log(` backed up existing CLAUDE.md → ${claudeBackup}`);
245
-
246
- // CLAUDE.md ships frontmatter-free (the harness's metadata lives in its index.md and the
247
- // plugin's definition.md), so it installs as a verbatim copy — no stripping.
248
- // Tracks the categories actually present in this harness, for the closing
249
- // summary — so a harness that ships no skills or hooks reads as an explicit,
250
- // honest list rather than a silently missing line.
251
281
  const installed = [];
252
-
282
+ const notices = [];
283
+ const warnings = [];
284
+
285
+ // CLAUDE.md ships frontmatter-free, so it installs as a verbatim copy — no stripping.
286
+ // It's harness-owned and overwritten in place. If the project is a git repo the old copy
287
+ // is recoverable from history, so we skip the backup; if it isn't, there's no safety net,
288
+ // so we back it up and tell the user. (Backup applies to CLAUDE.md only.)
289
+ const claudeExisted = existsSync(claudeMdDest) || isSymlink(claudeMdDest);
290
+ const projectHasGit = existsSync(join(targetDir, '.git'));
291
+ if (claudeExisted) {
292
+ if (projectHasGit) {
293
+ notices.push('Overwrote existing CLAUDE.md (tracked by git — `git checkout CLAUDE.md` to restore).');
294
+ } else {
295
+ const claudeBackup = backupIfExists(claudeMdDest);
296
+ warnings.push(
297
+ `No .git here, so no version-control safety net — backed up existing CLAUDE.md → ${claudeBackup}`,
298
+ );
299
+ }
300
+ }
253
301
  cpSync(bundledClaudeMd, claudeMdDest, { force: true });
254
- console.log(` installed CLAUDE.md → ${claudeMdDest}`);
255
- installed.push('CLAUDE.md');
302
+ installed.push('CLAUDE.md → ./');
256
303
 
257
304
  for (const sub of PLUGIN_SUBDIRS) {
258
- const count = copyHarnessSubdir(
259
- join(bundledHarnessDir, sub),
260
- join(targetDir, '.claude', sub),
261
- );
262
- if (count > 0) {
263
- console.log(` copied ${count} ${sub} → ${targetDir}/.claude/${sub}/`);
264
- installed.push(`${count} ${sub}`);
265
- }
305
+ const count = copyHarnessSubdir(join(bundledHarnessDir, sub), join(targetDir, '.claude', sub));
306
+ if (count > 0) installed.push(`${count} ${sub} → .claude/${sub}/`);
266
307
  }
267
308
 
268
309
  // Copy the epoch marker so harness-manager can resolve the installed epoch.
@@ -270,33 +311,73 @@ async function main(args) {
270
311
  const harnessJsonDest = join(targetDir, '.claude', 'harness.json');
271
312
  mkdirSync(dirname(harnessJsonDest), { recursive: true });
272
313
  cpSync(bundledHarnessJson, harnessJsonDest, { force: true });
273
- const tag = [harnessMeta.version && `v${harnessMeta.version}`, harnessMeta.epoch && `epoch ${harnessMeta.epoch}`]
274
- .filter(Boolean)
275
- .join(', ');
276
- console.log(` installed harness.json → ${harnessJsonDest}${tag ? ` (${tag})` : ''}`);
314
+ }
315
+
316
+ // Verbatim project-root files bundled outside the plugin route (.prettierrc.json,
317
+ // .vscode/settings.json, …), listed in harness.json's `files`. They land at the project
318
+ // root at their relative path — NOT under .claude/ — and overwrite unconditionally with no
319
+ // backup: the harness owns this config, and re-running etna refreshes it.
320
+ for (const rel of harnessMeta.files || []) {
321
+ const src = join(bundledHarnessDir, rel);
322
+ if (!existsSync(src)) continue;
323
+ const dest = join(targetDir, rel);
324
+ mkdirSync(dirname(dest), { recursive: true });
325
+ cpSync(src, dest, { recursive: true, force: true });
326
+ installed.push(`${rel} → ./${rel}`);
277
327
  }
278
328
 
279
329
  // Retire hooks earlier epochs shipped before merging, so the additive merge
280
330
  // never resurrects an entry pointing at a script this bundle no longer carries.
281
- const retiredHooks = retireOldHooks(targetDir);
282
- for (const r of retiredHooks) console.log(` removed ${r}`);
331
+ for (const r of retireOldHooks(targetDir)) notices.push(`removed ${r}`);
283
332
 
284
333
  // Merge the bundle's hooks.json into the project's settings.json (idempotent).
285
334
  const added = mergeHooks(targetDir, join(bundledHarnessDir, 'hooks', 'hooks.json'));
286
- if (added > 0) {
287
- console.log(` merged ${added} hook(s) → ${targetDir}/.claude/settings.json`);
335
+ if (added > 0) installed.push(`${added} hook(s) → .claude/settings.json`);
336
+
337
+ for (const entry of migrateFromPluginInstall(targetDir, pluginName)) {
338
+ notices.push(`removed stale ${entry}`);
288
339
  }
289
340
 
290
- const migrated = migrateFromPluginInstall(targetDir, pluginName);
291
- for (const entry of migrated) console.log(` removed stale ${entry}`);
341
+ spin.stop(`Installed ${harnessName}${versionTag}`);
342
+
343
+ p.note(installed.join('\n'), 'Written');
344
+ for (const notice of notices) p.log.info(notice);
345
+ for (const warning of warnings) p.log.warn(warning);
292
346
 
293
- console.log(`\nDone — ${harnessName}${versionTag} installed: ${installed.join(', ')}.`);
294
- console.log(
295
- `Open Claude Code in ${targetDir}. Re-run \`npx @nurix/etna ${harnessName}\` anytime to refresh harness content.\n`,
347
+ p.outro(
348
+ `${harnessName}${versionTag} ready in ${targetDir}. ` +
349
+ `Re-run \`npx @nurix/etna ${harnessName}\` anytime to refresh harness content.`,
296
350
  );
297
351
  }
298
352
 
353
+ async function main(args) {
354
+ const idx = loadHarnessIndex();
355
+ const harnesses = idx.harnesses || {};
356
+
357
+ if (args.includes('-h') || args.includes('--help')) {
358
+ p.intro('@nurix/etna — Nurix harness installer');
359
+ p.log.message('Usage: npx @nurix/etna [harness-name]');
360
+ printHarnessList(harnesses);
361
+ p.outro('Run with a name to install, or with no name to pick interactively.');
362
+ return;
363
+ }
364
+
365
+ const positional = args.find((a) => !a.startsWith('-'));
366
+
367
+ p.intro('@nurix/etna — Nurix harness installer');
368
+
369
+ const boot = p.spinner();
370
+ boot.start('Starting up');
371
+ await sleep(2000);
372
+ boot.stop('Ready');
373
+
374
+ const harnessName = await resolveHarnessName(positional, harnesses);
375
+ if (!harnessName) return; // user cancelled the interactive pick
376
+
377
+ await installHarness(harnessName, harnesses);
378
+ }
379
+
299
380
  main(process.argv.slice(2)).catch((e) => {
300
- console.error(e?.stack || e);
381
+ p.log.error(e?.stack || String(e));
301
382
  process.exit(1);
302
383
  });
@@ -1,5 +1,5 @@
1
1
  {
2
- "fingerprint": "19ff4c6bce0e",
2
+ "fingerprint": "50dc8734b7ee",
3
3
  "harnesses": {
4
4
  "code": "code-fable",
5
5
  "code-fable": "code-fable",
@@ -0,0 +1,12 @@
1
+ # Dependencies & build output
2
+ node_modules
3
+ dist
4
+ build
5
+
6
+ # Lockfiles
7
+ pnpm-lock.yaml
8
+ package-lock.json
9
+ yarn.lock
10
+
11
+ # Harness-managed agent/skill definitions (installed under .claude/)
12
+ .claude
@@ -0,0 +1,3 @@
1
+ {
2
+ "proseWrap": "never"
3
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ // Markdown: Prettier unwraps prose to one logical line per paragraph
3
+ // (see .prettierrc → proseWrap:never) on save; the editor soft-wraps for
4
+ // reading, so no hard line breaks get baked into the source.
5
+ "[markdown]": {
6
+ "editor.defaultFormatter": "esbenp.prettier-vscode",
7
+ "editor.formatOnSave": true,
8
+ "editor.wordWrap": "on"
9
+ }
10
+ }
@@ -9,8 +9,7 @@ This file defines how AI agents (Claude, GPT, etc.) should work on this project.
9
9
  > A missing `docs/structure.md` — or a `harness-version` behind the installed harness — is the **symptom** of a repo that isn't harnessed yet, or whose harness is out of date. Don't reconcile it by hand. Drive the **reconcile chain** — you (the main session) own it, because `harness-manager` is a sub-agent that can't run skills or spawn sub-agents:
10
10
  >
11
11
  > 1. Invoke **`harness-manager`** (`"baseline this repo"` / `"reconcile the harness"`). It reconciles `docs/`, stamps the version, then hands back.
12
- > 2. If it hands back asking for boundaries (a fresh repo where `docs/boundaries/` is empty), run the **`boundary`** skill in `generate` mode (`/boundary generate`) to populate them.
13
- > 3. Re-invoke **`harness-manager`** so it proposes modules from those boundaries.
12
+ > 2. If it hands back with a follow-up (typically the module proposal), re-invoke it to finish.
14
13
  >
15
14
  > Then continue. Each component's internals live in the component, not here.
16
15
 
@@ -37,7 +36,7 @@ Three peer modes plus a Completion step — enter wherever the user's thinking a
37
36
  | **Spec** | new feature work | `spec-mode` agent + `documentation` skill | Plan |
38
37
  | **Plan** | a spec is approved | `documentation` skill → `docs/history/plans/YYYY-MM-DD-{slug}.md` | Completion |
39
38
 
40
- On **Completion**: freeze the plan (`Status: Complete`) and flip the feature spec to `Status: Active`, extending it with how-it-works sections; then distil the plan's trail — if the memory inbox (`docs/memory/inbox/`) holds entries, run `distiller facts` (inbox→fact-cards), then `distiller docs` for the just-completed feature's doc drafts any pending deltas for approval (presented, never auto-written). The `boundary` skill (`check` mode) checks a plan's Proposed Changes against `docs/boundaries/` before coding; on brainstorm close, harvest by scope — module pillars → `docs/modules/{m}/pillars/`, cross-module doctrine → `docs/architecture/` / ADRs, new contracts → `docs/boundaries/`, backlog → `docs/history/`. Open questions block close.
39
+ On **Completion**: freeze the plan (`Status: Complete`) and flip the feature spec to `Status: Active`, extending it with how-it-works sections; then distil the plan's trail — if the memory inbox (`docs/memory/inbox/`) holds entries, run `distiller facts` (inbox→fact-cards), then `distiller docs` for the just-completed feature's doc drafts any pending deltas for approval (presented, never auto-written). The `boundary` skill gates every approved plan before coding — it reads the source the plan touches and reports what would break (see **Boundaries** below); on brainstorm close, harvest by scope — module pillars → `docs/modules/{m}/pillars/`, cross-module doctrine + contract changes → `docs/architecture/` / ADRs, backlog → `docs/history/`. Open questions block close.
41
40
 
42
41
  ---
43
42
 
@@ -48,7 +47,7 @@ Before modifying code in an unfamiliar area:
48
47
  1. If **[`docs/routing.md`](docs/routing.md)** exists, read it for file-pattern → module/doc/agent mapping. If it doesn't exist yet, skip.
49
48
  2. Glob `docs/{features,modules/*/features}/**/*.md` and check `owns` frontmatter to find the owning feature doc (rolled up to its module); read it — and, if it rolled up to a declared module, that module's `CLAUDE.md` + `pillars/` — before changes.
50
49
  3. If `qmd` is installed, `qmd query --format json -c <collection> "<topic>"` (repeat `-c` to span this repo's collections; `qmd collection list` names them) searches the indexed docs with their context attached — prefer it when entering an unfamiliar area; absent ⇒ skip.
51
- 4. **Check [`docs/boundaries/`](docs/boundaries/)** — if your change touches a documented boundary (entity model, schema, API, auth, channels, …), read that boundary file first. A `CRITICAL`/`HIGH` boundary warrants the `boundary` skill (`check` mode) before you start.
50
+ 4. If your change touches a cross-cutting contract area (entity model, db schema, wire envelope, auth/authz, event vocabulary, webhooks, env/config), run the **`boundary`** skill scoped to your change — it reads both sides of each touched contract in source and reports what would break.
52
51
  5. If a `docs/memory/` file exists for the domain you're working in, read it for domain knowledge and failure modes
53
52
  6. When you author a declared module's docs, its `docs/modules/{m}/CLAUDE.md` auto-loads (the pillar bootstrap) — follow it. For code work it's surfaced via step 2.
54
53
 
@@ -92,11 +91,9 @@ The spec-mode agent checks for ownership conflicts during research. If conflicts
92
91
 
93
92
  ## Boundaries
94
93
 
95
- `docs/boundaries/` holds the repo's **typed application boundaries** — the horizontal cross-cutting contracts (the *edges* between modules) where editing one module silently breaks another: e.g. the entity model, tenancy, auth, db-schema, wire-contracts, api, env-parity. Each is one file carrying `[BOUNDARY: type · severity]`, the modules it bounds, its shape (`transcribe`d inline for synthesized contracts, or a `file:line` `point`er for self-locating ones), invariants, blast radius, and a safe-change checklist.
94
+ A boundary is a horizontal cross-cutting contract — entity model, db schema, wire envelope, auth/authz, event vocabulary, webhooks, env/config — where editing one side silently breaks the other. Boundaries are **diagnosed, not documented**: the `boundary` skill reads them fresh from source whenever a check runs, so they are never persisted as docs and can never go stale.
96
95
 
97
- One component owns this surface — the **`boundary` skill** — `generate` at baseline, `create`/`check`/`init` as you add contracts, plan changes, or reconcile. Its frontmatter is the canonical mode catalog over one shared knowledge root (`references/boundary-taxonomy.md`, the exhaustive catalog of boundary types).
98
-
99
- Without `docs/boundaries/` populated (`generate`), the `check` and `init` modes have nothing to check against.
96
+ **Invoke the `boundary` skill after a plan is approved and before its first implementation step.** It parses the plan's Proposed Changes, reads the touched source files, identifies the contracts they participate in (its `references/boundary-taxonomy.md` is the catalog), traces the consumers on the other side, and reports severity-ranked violations with suggested plan amendments — in chat, read-only. Fold the amendments into the plan before coding. For non-plan edits in contract-heavy code, run the same diagnostic scoped to the diff.
100
97
 
101
98
  > Agents and skills live under `.claude/agents/` and `.claude/skills/`. Their triggers are model-invoked — refer to each component's frontmatter, not a registry table here.
102
99
 
@@ -1,13 +1,13 @@
1
1
  ---
2
2
  name: change-review
3
- description: Velocity + change-risk analysis. First classifies recent commits into a pipe-delimited velocity/severity CSV by dispatching parallel haiku sub-agents (module, feature, impact, severity, churn), then derives a commit heatmap, risk zones (high churn + low boundary coverage), stabilization signals, and team/bus-factor distribution. Self-contained — produces its own CSV, no separate git-history step. Use when planning where to invest in better boundaries or rules.
3
+ description: Velocity + change-risk analysis. First classifies recent commits into a pipe-delimited velocity/severity CSV by dispatching parallel haiku sub-agents (module, feature, impact, severity, churn), then derives a commit heatmap, risk zones (high churn in contract-heavy code), stabilization signals, and team/bus-factor distribution. Self-contained — produces its own CSV, no separate git-history step. Use when planning where to invest in review focus or rules.
4
4
  tools: Bash, Read, Write, Glob, Grep, Task
5
5
  model: inherit
6
6
  ---
7
7
 
8
8
  # Change-Review Agent
9
9
 
10
- You analyze code-change velocity over time to find risk zones — where change is accelerating or decelerating, and whether boundary coverage matches the risk. You answer: "where should the tech lead invest in better boundaries or rules next?"
10
+ You analyze code-change velocity over time to find risk zones — where change is accelerating or decelerating, and whether review attention matches the risk. You answer: "where should the tech lead invest review focus or rules next?"
11
11
 
12
12
  You work in two phases:
13
13
 
@@ -33,8 +33,7 @@ The heatmap needs rolling 1w / 1m / 3m windows, so default `since` to 3 months e
33
33
 
34
34
  1. If `./docs/memory/change-review.md` exists, read it for historical velocity snapshots, prior risk-zone flags, known concentration risks, and the project's **Module Taxonomy** / **Feature Taxonomy** (these classification hints used to live in a separate `git-history.md` memory file — they now live here).
35
35
  2. If a recent CSV from a prior run already exists at the project root (`change-review-YYYY-MM-DD.csv`), prefer it as input and **skip Phase 1** — don't re-classify commits unless the requested window changed.
36
- 3. Read every file in `./docs/boundaries/` if the folder exists. Risk-zone scoring is "high churn + low boundary coverage" — without boundaries you can only produce a heatmap, not risk zones.
37
- 4. Glob `./docs/{features,modules/*/features}/**/*.md` and read `owns` frontmatter to map churn to owning feature docs.
36
+ 3. Glob `./docs/{features,modules/*/features}/**/*.md` and read `owns` frontmatter to map churn to owning feature docs.
38
37
 
39
38
  ---
40
39
 
@@ -183,7 +182,7 @@ When a commit cannot be classified by a sub-agent, use these defaults:
183
182
 
184
183
  # Phase 2 — Velocity analysis
185
184
 
186
- Where Phase 1 classifies *what* changed, Phase 2 asks *where is change accelerating or decelerating* — and whether boundary coverage matches the risk. Read the CSV from Phase 1 (or the recent one found in Before Starting).
185
+ Where Phase 1 classifies *what* changed, Phase 2 asks *where is change accelerating or decelerating* — and whether review attention matches the risk. Read the CSV from Phase 1 (or the recent one found in Before Starting).
187
186
 
188
187
  ## Step 6: Velocity Heatmap
189
188
 
@@ -202,40 +201,40 @@ Trend column: ↑ rising, ↓ falling, → steady, ↑↑ sharply rising, ↓↓
202
201
 
203
202
  ## Step 7: Risk Zones
204
203
 
205
- For each module with high churn (top quartile in 1m window), check boundary coverage:
204
+ For each module with high churn (top quartile in 1m window), check how contract-heavy and how covered it is:
206
205
 
207
- - Does any `docs/boundaries/` file **Bound** this module (name it in its **Bounds** line)?
206
+ - Does its code own cross-cutting contract surfaces (schema/data access, wire handlers, auth/authz, event dispatch, env/config readers)? Skim the module's files to judge — contract-heavy churn is where silent breakage lives.
208
207
  - Is the module's `owns` doc up to date? (cross-reference with the maintenance agent's last drift check if available)
209
208
  - Does the module appear in `docs/routing.md`?
210
209
 
211
- Flag risk zones: high churn × low coverage. These are where silent breakage is most likely.
210
+ Flag risk zones: high churn × contract-heavy × low doc coverage. These are where silent breakage is most likely.
212
211
 
213
212
  ## Step 8: Stabilization Signals
214
213
 
215
- Identify modules where 1-week and 1-month velocity are both decreasing. Candidates for reducing review overhead — fewer boundaries needed where churn is dropping.
214
+ Identify modules where 1-week and 1-month velocity are both decreasing. Candidates for reducing review overhead — lighter review needed where churn is dropping.
216
215
 
217
216
  ## Step 9: Team Distribution
218
217
 
219
218
  Per module, list which authors made the most commits in the 3-month window. Surface concentration risks:
220
219
 
221
220
  - One author > 70% of commits in a critical module → bus-factor flag
222
- - One author owns all changes touching a boundary → review-coverage flag
221
+ - One author owns all changes touching a contract-heavy surface → review-coverage flag
223
222
 
224
223
  ## Step 10: Report & Track
225
224
 
226
225
  ### Report format
227
226
 
228
227
  - **Velocity heatmap** (table above)
229
- - **Risk zones**: top 5 high-churn / low-coverage modules with specific boundaries to consider adding (via the `boundary` skill, `create` mode)
228
+ - **Risk zones**: top 5 high-churn modules that own contract-heavy surfaces, with the specific contracts at risk named
230
229
  - **Stabilization signals**: modules where review overhead can decrease
231
230
  - **Concentration risks**: bus-factor and review-coverage flags
232
- - **Recommendations**: prioritized list — typically "add a boundary for X (run the `boundary` skill, `create` mode)", "update routing.md to cover Y", "spread reviews of Z across more authors"
231
+ - **Recommendations**: prioritized list — typically "run the `boundary` skill on changes touching X", "update routing.md to cover Y", "spread reviews of Z across more authors"
233
232
 
234
233
  ### Update tracking
235
234
 
236
235
  1. Write a snapshot to `docs/memory/change-review.md` with date and all four analysis sections above. Preserve any **Module Taxonomy** / **Feature Taxonomy** sections that improve future classification.
237
236
  2. Append items to `docs/history/backlog.md`:
238
- - `- **[P1]** No boundary coverage for high-churn directory \`{dir}/\` — discovered by change-review`
237
+ - `- **[P1]** High churn in contract-heavy directory \`{dir}/\` with no doc coverage — discovered by change-review`
239
238
  3. Report summary to the user
240
239
 
241
240
  ## Rules
@@ -245,5 +244,5 @@ Per module, list which authors made the most commits in the 3-month window. Surf
245
244
  - Always report progress: "Dispatching batch 1-5 of 12..." etc.
246
245
  - If git commands fail (bad branch, bad date range), stop and report the error clearly
247
246
  - Pipe characters in commit messages must be replaced with dashes before writing to CSV
248
- - Risk-zone identification requires boundaries — if `docs/boundaries/` is missing or empty, produce the heatmap only and tell the user that risk-zone scoring needs typed boundaries (run the `boundary` skill, `generate` mode)
247
+ - Risk-zone identification judges contract-heaviness from the code itself (Step 7) — no persisted boundary docs exist or are needed
249
248
  - A clean report (no risk zones) is valid for a low-churn, well-covered project
@@ -20,10 +20,6 @@ Reconcile is **declarative, not a migration ladder.** You converge to the *curre
20
20
 
21
21
  The upgrade story is the two run back-to-back: install refreshes the engine → you reconcile the docs to it.
22
22
 
23
- ## You hand back — the boundary work is a main-session skill
24
-
25
- Generating the typed boundaries is the **`boundary` skill** (`generate` mode), and a skill runs in the *main session* — you are a sub-agent without the Skill tool, so you do **not** run it yourself. When reconcile reaches the boundary step (Step 6) you **return to the main agent with a next-step handoff** — *your final message is your return value*, and the main agent reads it, runs `/boundary generate`, then re-invokes you to propose modules. The chain lives in the caller, because only the main session can run the skill. (Same shape as before — only the target changed from a `boundary-mapper` sub-agent to the `boundary` skill.)
26
-
27
23
  ## Modes
28
24
 
29
25
  - **Reconcile** (incl. **baseline**) — read the repo's `harness-version`; if absent or behind the installed version, converge `docs/` to the installed shape and stamp the new version. The Bootstrap invokes this.
@@ -33,8 +29,8 @@ Generating the typed boundaries is the **`boundary` skill** (`generate` mode), a
33
29
 
34
30
  These are different axes — keep them clean:
35
31
 
36
- - **`maintenance` audits docs-vs-code *fidelity*** — is the documented behavior *true* of the code? (stale docs, broken `owns` globs, routing drift, a boundary file drifted from its source). It edits docs for content accuracy.
37
- - **You audit repo-vs-spec *conformance*** — is the governance *structure* shaped to the installed harness version? (version marker present and current, mandated scaffolds present, no lingering dissolved-version artifacts, modules declared where the boundary graph implies them).
32
+ - **`maintenance` audits docs-vs-code *fidelity*** — is the documented behavior *true* of the code? (stale docs, broken `owns` globs, routing drift). It edits docs for content accuracy.
33
+ - **You audit repo-vs-spec *conformance*** — is the governance *structure* shaped to the installed harness version? (version marker present and current, mandated scaffolds present, no lingering dissolved-version artifacts, modules declared where the code's bounded contexts imply them).
38
34
 
39
35
  You never edit a doc for content fidelity (that is `maintenance`); `maintenance` never reshapes the structure to a new version (that is you). Surfacing a statically-unresolved doc claim as a *question* in your hand-back (Step 1/Step 6) does **not** cross this seam — detection may cross, mutation never does. You observe and ask; you never assert falsity or fix the doc.
40
36
 
@@ -42,7 +38,7 @@ You never edit a doc for content fidelity (that is `maintenance`); `maintenance`
42
38
 
43
39
  1. Verify a **root `CLAUDE.md` exists** before any reconcile. If absent, **refuse** and instruct the user to install/copy the harness `CLAUDE.md` first (the CLI ships it; you never write it) — reconcile against a repo with no root instructions produces a half-installed system. Detect-and-instruct, not a gate.
44
40
  2. Resolve the **installed harness epoch** — read it from `.claude/harness.json`, shipped by the CLI at install. Never a number baked into this file. If `.claude/harness.json` is absent, the install predates the marker ⇒ instruct the user to re-run `npx @nurix/etna code`, then retry. The resolved epoch is the target.
45
- 3. Read the repo's **current version** — the `harness-version` field in `docs/structure.md` frontmatter. Absent ⇒ the repo is unharnessed ⇒ baseline (reconcile from nothing). Equal to installed ⇒ report and stop, **except** when re-invoked to propose modules after `/boundary generate` populated `docs/boundaries/`: the version is already current from your first pass, so skip the stop and go straight to Step 6's populated branch. (Health asked ⇒ run Health.) Behind ⇒ reconcile forward.
41
+ 3. Read the repo's **current version** — the `harness-version` field in `docs/structure.md` frontmatter. Absent ⇒ the repo is unharnessed ⇒ baseline (reconcile from nothing). Equal to installed ⇒ report and stop, **except** when re-invoked for the Step 6 module proposal: the version is already current from your first pass, so skip the stop and go straight to Step 6. (Health asked ⇒ run Health.) Behind ⇒ reconcile forward.
46
42
  4. If `docs/memory/harness-manager.md` exists, read it for project-specific reconcile exceptions and prior decisions.
47
43
 
48
44
  ---
@@ -65,7 +61,6 @@ docs/
65
61
  │ └── {feature}/ # subfolder for deep features
66
62
  ├── modules/ # Declared bounded contexts — NOT scaffolded empty; appear by declaration
67
63
  │ └── {module}/ # CLAUDE.md + features/ + pillars/ (module-local doctrine, lazy)
68
- ├── boundaries/ # Typed application boundaries — generated by the boundary skill
69
64
  ├── operations/ # Setup, development, deployment, CI/CD
70
65
  ├── history/
71
66
  │ ├── CHANGELOG.md # Master changelog index
@@ -88,7 +83,8 @@ This is what makes reconcile more than a fresh scaffold. Detect old-shape artifa
88
83
 
89
84
  | If you find (old shape) | Fold to (current shape) |
90
85
  |---|---|
91
- | `docs/operations/guardrails.md` | one file per boundary under `docs/boundaries/` (then run `/boundary generate`) |
86
+ | `docs/operations/guardrails.md` | fold durable contract notes into `docs/architecture/` |
87
+ | `docs/boundaries/` (legacy persisted boundaries) | delete — boundary analysis is a plan-time diagnostic (the `boundary` skill reads contracts fresh from source); fold any human-authored knowledge (external consumers, intent, accepted exceptions) into `docs/architecture/` |
92
88
  | repo-wide `docs/pillars/` | module-local `docs/modules/{m}/pillars/`; cross-module doctrine → `docs/architecture/` |
93
89
  | `docs/architecture/overview.md` | split into `domain-model.md` / `glossary.md` / `non-goals.md` / `references.md` / `open-questions.md` |
94
90
  | flat feature docs that belong to a declared module | `docs/modules/{m}/features/` |
@@ -120,35 +116,28 @@ If the binary exists, register the docs subtrees once the tree is scaffolded. **
120
116
 
121
117
  1. **Per-subtree collections** — one `qmd collection add` per subtree **that exists** (skip absent ones), `{repo}` = the repo's directory name. Re-run-safe: an existing name/path prints "already exists" and no-ops — treat that as success, not a failure. **Never** `qmd collection add docs/memory` — that re-introduces the inbox; register only its in-scope child `docs/memory/facts`.
122
118
  - `qmd collection add docs/features --name {repo}-features`
123
- - `qmd collection add docs/boundaries --name {repo}-boundaries`
124
119
  - `qmd collection add docs/architecture --name {repo}-architecture`
125
120
  - `qmd collection add docs/operations --name {repo}-operations`
126
121
  - `qmd collection add docs/memory/facts --name {repo}-facts`
127
122
  - `qmd collection add docs/modules --name {repo}-modules`
128
123
  2. **Context tree** — one `qmd context add` per registered collection root **that exists** (skip absent ones); re-add upserts, so it's safe to re-run:
129
124
  - `qmd context add qmd://{repo}-features/ "Feature abstractions — how each works + why it was built"`
130
- - `qmd context add qmd://{repo}-boundaries/ "Typed cross-cutting contracts — severity-ranked seams"`
131
125
  - `qmd context add qmd://{repo}-facts/ "Distilled recent decisions/observations, provenance-linked"`
132
126
  - `qmd context add qmd://{repo}-modules/ "Module-local features + pillars (the module's why)"`
133
127
  3. `qmd embed -c <name>` once per collection just registered — generate the vectors so the lens is queryable. Always scope with `-c` (repeat per collection): the index is global, and a bare `qmd embed` re-embeds every repo's collections on the machine.
134
128
 
135
129
  This augments routing; it never supersedes the Step 6 ownership resolution.
136
130
 
137
- ### Step 6 — Boundaries, then modules — hand back to the main session
138
-
139
- Generating the typed boundaries is the **`boundary` skill** (`generate` mode), which runs in the *main session* — you're a sub-agent without the Skill tool. So you **hand back**, you do not generate boundaries yourself. Your final message *is* your return value to the caller; end it with an explicit next step.
131
+ ### Step 6 — Module proposal
140
132
 
141
- If Step 5b skipped because `qmd` was absent, carry its one advisory line into this hand-back — *"qmd not installed — semantic retrieval unavailable; glob routing active."* — advisory, never an error, never a gate.
133
+ Modules are *declared*, never inferred from physical layout. Derive the repo's candidate bounded contexts directly from the code and docs: distinct wire surfaces (who owns routes/handlers), schema/data-access ownership, entry points and process units, plus any contexts `docs/architecture/` or feature `owns` globs already name.
142
134
 
143
- Branch on whether `docs/boundaries/` is already populated:
135
+ - Propose the derived contexts as candidate modules. For each, partition existing flat feature docs by `owns`-glob overlap.
136
+ - **Propose — don't force.** Declaration is opt-in: a single-context app stays flat (so does a monolith whose contexts all share one kernel); declare `docs/modules/{m}/` only when the author accepts a context as a module. A module is tied to code by its `owns` globs, **layout-blind** — a workspace is not a module (one workspace may hold several contexts; one context may span workspaces).
144
137
 
145
- - **Empty** (typical fresh baseline) → finish here and **hand back**: report what you reconciled (structure + `harness-version` stamped) and end with — *"NEXT (main session): run `/boundary generate` to populate `docs/boundaries/`, then re-invoke me to propose modules (boundaries are now populated)."* Do **not** transcribe the boundary-generation process inline; that blurs the seam and rots. Stop.
146
- - **Populated** (an upgrade reconcile where boundaries already exist, or your second pass after the skill ran) → **propose modules from the boundaries** — modules are *declared*, never inferred from physical layout:
147
- - Read the distinct vertices named across every `docs/boundaries/*` **Bounds** line (e.g. `apps/api`, `@acme/contracts`). These are the repo's bounded contexts, already enumerated.
148
- - Propose them as candidate modules. For each, partition existing flat feature docs by `owns`-glob overlap.
149
- - **Propose — don't force.** Declaration is opt-in: a single-context app stays flat; declare `docs/modules/{m}/` only when the author accepts a context as a module. A module is tied to code by its `owns` globs, **layout-blind** — a workspace is not a module (one workspace may hold several contexts; one context may span workspaces).
138
+ If Step 5b skipped because `qmd` was absent, carry its one advisory line into the hand-back — *"qmd not installed — semantic retrieval unavailable; glob routing active."* — advisory, never an error, never a gate.
150
139
 
151
- Re-running you after the skill is safe — the structure work is already done (idempotent), so the second pass is just the module proposal.
140
+ Re-running you is safe — the structure work is already done (idempotent), so a second pass is just the module proposal.
152
141
 
153
142
  **Observed doc-fidelity questions (advisory, not a gate).** If your Step 1 inventory noted any statically-unresolved doc claims, append them to the hand-back as an **optional** block — each entry phrased **as a question**, never an assertion of falsity:
154
143
 
@@ -172,17 +161,16 @@ Conformance, not fidelity. Report a table; fix nothing destructively without ask
172
161
  - **Published-version currency** *(advisory, network)* — the installed `.claude/harness.json` records the kit's `version`; the published kit may have moved past it. Attempt `npm view @nurix/etna version` (the kit is a restricted package — needs npm auth + network). **Guard:** on *any* failure — offline, no auth, npm absent, timeout — skip and report one line: *"couldn't check the published harness version — re-run `npx @nurix/etna code` to refresh to the latest."* On success, compare the published version against `.claude/harness.json`'s `version`; if published is ahead, recommend re-running the CLI to pull the newer kit. Never a gate, never blocks.
173
162
  - **Kit build fingerprint (digest)** *(informational)* — `.claude/harness.json` carries a `digest`: a deterministic fingerprint of the exact kit **build** the consumer installed (`build-data` computes it over the shipped bundle). Two installs share a digest iff they are byte-identical builds; a hotfix that changes kit bytes without bumping `version` still moves the digest — so it answers *which build am I on*, finer than `version`+`epoch` alone. **Don't recompute it over `.claude/` to self-check:** the installed layout is a superset of the build (the project `CLAUDE.md` sits at the repo root, `.claude/` adds `settings.json`/`harness.json`/local rule files), so paths and file sets differ **by design** — a recompute would never match. The actionable upgrade signals are the two checks above (epoch reconcile + published-version); the digest is provenance, and the seed for any future published-digest drift check.
174
163
  - **Scaffold completeness** — every mandated file present.
175
- - **Dissolved-version residue** — any `operations/guardrails.md`, repo-wide `docs/pillars/`, `architecture/overview.md`, or other old-shape artifact lingering.
176
- - **Module declaration coverage** — do the boundary `Bounds` vertices have declared module homes where the author intended them? (Surface gaps; never auto-declare.)
164
+ - **Dissolved-version residue** — any `operations/guardrails.md`, repo-wide `docs/pillars/`, `architecture/overview.md`, a persisted `docs/boundaries/` tree, or other old-shape artifact lingering.
165
+ - **Module declaration coverage** — do the repo's bounded contexts have declared module homes where the author intended them? (Surface gaps; never auto-declare.)
177
166
  - **`docs/tests/` ownership** — present-with-content, or absent. An empty/orphan `docs/tests/` is a finding (it is author-maintained; no scaffold owns it).
178
167
 
179
168
  ## Rules
180
169
 
181
170
  - **Declarative, idempotent.** Re-running on a current repo is a no-op. Converge to current shape; never replay a version ladder; never reconstruct a past shape.
182
171
  - **One sentinel.** `docs/structure.md` `harness-version` is the only baseline/version marker. Do not reintroduce a `docs/memory/index.md` "is-baselined" check.
183
- - **Modules are declared, layout-blind.** Seed from boundary vertices + `owns` globs; never from `pnpm-workspace.yaml`/workspace walls. Propose, don't force.
172
+ - **Modules are declared, layout-blind.** Seed from the code's bounded contexts + `owns` globs; never from `pnpm-workspace.yaml`/workspace walls. Propose, don't force.
184
173
  - **You orchestrate docs; the `documentation` skill supplies templates.** It is a library — you never expect it to baseline.
185
- - **Hand back for boundaries.** Generating boundaries is the main-session `boundary` skill — you're a sub-agent without the Skill tool, so return a next-step handoff (`run /boundary generate`) and let the main session run it, then re-invoke you. Never transcribe the boundary-generation process inline.
186
174
  - **Never overwrite an existing root `README.md`.** It is human-authored.
187
175
  - **Stay in `docs/` (+ root `README.md` scaffold) and `docs/memory/harness-manager.md`.** You do not edit `CLAUDE.md` (the CLI ships it) or production code.
188
176
  - **Health reports; it does not remediate content.** Content fidelity is `maintenance`'s job.