@vaubaan/harness 2.0.0 → 2.2.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.
Files changed (37) hide show
  1. package/README.md +25 -21
  2. package/dist/cli/index.js +543 -76
  3. package/dist/cli/index.js.map +1 -1
  4. package/dist/commands/doc-audit.cmd.md +1 -1
  5. package/dist/commands/handbook.cmd.md +4 -3
  6. package/dist/commands/journey.cmd.md +22 -0
  7. package/dist/commands/story.cmd.md +24 -0
  8. package/dist/commands/test-plan.cmd.md +4 -4
  9. package/dist/index.d.ts +2 -2
  10. package/dist/index.js +304 -56
  11. package/dist/index.js.map +1 -1
  12. package/dist/init.d.ts +2 -3
  13. package/dist/init.js +301 -53
  14. package/dist/init.js.map +1 -1
  15. package/dist/linters/index.js +523 -56
  16. package/dist/linters/index.js.map +1 -1
  17. package/dist/parser/index.d.ts +110 -1
  18. package/dist/parser/index.js +229 -2
  19. package/dist/parser/index.js.map +1 -1
  20. package/dist/{render-C-FWmUfX.d.ts → render-BzrBb_l4.d.ts} +3 -1
  21. package/dist/render.d.ts +1 -1
  22. package/dist/render.js +89 -10
  23. package/dist/render.js.map +1 -1
  24. package/dist/skills/decision-record-writer.skill.md +93 -130
  25. package/dist/skills/doc-audit.skill.md +37 -7
  26. package/dist/skills/drift-detector.skill.md +41 -11
  27. package/dist/skills/handbook-writer.skill.md +71 -159
  28. package/dist/skills/journey-writer.skill.md +159 -0
  29. package/dist/skills/spec-writer.skill.md +25 -3
  30. package/dist/skills/test-plan-writer.skill.md +46 -53
  31. package/dist/skills/workflow-writer.skill.md +20 -3
  32. package/dist/templates/decision.md.tmpl +20 -47
  33. package/dist/templates/e2e-tests.md.tmpl +16 -45
  34. package/dist/templates/handbook.md.tmpl +20 -38
  35. package/dist/templates/integration-tests.md.tmpl +16 -34
  36. package/dist/templates/journey.md.tmpl +45 -0
  37. package/package.json +1 -1
package/dist/init.js CHANGED
@@ -1,11 +1,17 @@
1
1
  // src/cli/init.ts
2
- import { existsSync as existsSync7, mkdirSync as mkdirSync2, rmSync, writeFileSync as writeFileSync3 } from "fs";
3
- import { dirname as dirname6, join as join9, resolve as resolve6 } from "path";
2
+ import { existsSync as existsSync8, mkdirSync as mkdirSync2, rmSync, writeFileSync as writeFileSync3 } from "fs";
3
+ import { dirname as dirname6, join as join10, resolve as resolve6 } from "path";
4
4
 
5
5
  // src/cli/managed-paths.ts
6
6
  import { lstatSync, realpathSync, statSync } from "fs";
7
7
  import { basename, dirname, isAbsolute, join, resolve, win32 } from "path";
8
- var MANAGED_FILES = /* @__PURE__ */ new Set(["AGENTS.md", "CLAUDE.md", ".harness-manifest.json"]);
8
+ var MANAGED_FILES = /* @__PURE__ */ new Set([
9
+ "AGENTS.md",
10
+ "CLAUDE.md",
11
+ ".harness-manifest.json",
12
+ // Index of the optional journeys pillar, rendered while a journey exists.
13
+ "docs/journeys/README.md"
14
+ ]);
9
15
  var RELEASED_PATHS = [
10
16
  ".mcp.json",
11
17
  ".codex/config.toml",
@@ -78,7 +84,7 @@ import { join as join2 } from "path";
78
84
  import { z } from "zod";
79
85
 
80
86
  // src/version.ts
81
- var VERSION = "2.0.0";
87
+ var VERSION = "2.2.0";
82
88
 
83
89
  // src/cli/manifest.ts
84
90
  var MANIFEST_FILENAME = ".harness-manifest.json";
@@ -108,8 +114,8 @@ function readManifest(targetDir) {
108
114
  }
109
115
 
110
116
  // src/cli/plan-render.ts
111
- import { existsSync as existsSync3 } from "fs";
112
- import { dirname as dirname2, join as join4, resolve as resolve2 } from "path";
117
+ import { existsSync as existsSync4 } from "fs";
118
+ import { dirname as dirname2, join as join5, resolve as resolve2 } from "path";
113
119
  import { fileURLToPath } from "url";
114
120
 
115
121
  // src/loader.ts
@@ -165,9 +171,18 @@ var CmdFrontmatterSchema = z2.object({
165
171
  args: z2.array(CmdArgSchema).optional(),
166
172
  description: z2.string().min(1)
167
173
  }).strict();
174
+ var JOURNEY_STATUSES = ["proposed", "implemented", "deprecated"];
175
+ var JourneyFrontmatterSchema = z2.object({
176
+ title: z2.string().min(1),
177
+ status: z2.enum(JOURNEY_STATUSES),
178
+ actors: z2.array(z2.string().min(1)).min(1),
179
+ spec: z2.union([z2.string().min(1), z2.array(z2.string().min(1)).min(1)]),
180
+ last_reviewed: z2.union([z2.date(), z2.string().min(1)])
181
+ }).strict();
168
182
  var Schemas = {
169
183
  Skill: SkillFrontmatterSchema,
170
- Cmd: CmdFrontmatterSchema
184
+ Cmd: CmdFrontmatterSchema,
185
+ Journey: JourneyFrontmatterSchema
171
186
  };
172
187
  var ParseError = class extends Error {
173
188
  constructor(file, issues) {
@@ -251,6 +266,208 @@ function loadOverrides(worktreeDir) {
251
266
  return { add: added, disable };
252
267
  }
253
268
 
269
+ // src/parser/journey.ts
270
+ import { existsSync as existsSync3, readFileSync as readFileSync4, readdirSync, statSync as statSync2 } from "fs";
271
+ import { basename as basename2, join as join4 } from "path";
272
+ import matter2 from "gray-matter";
273
+ var JOURNEYS_DIR = "docs/journeys";
274
+ var JOURNEYS_INDEX_PATH = `${JOURNEYS_DIR}/README.md`;
275
+ var NODE_FIELDS = [
276
+ "status",
277
+ "spec",
278
+ "anchors",
279
+ "acceptance",
280
+ "requires",
281
+ "creates"
282
+ ];
283
+ var MASKED_LINE = "\0";
284
+ var FENCE_RE = /^ {0,3}(`{3,}|~{3,})/;
285
+ var HEADING_RE = /^(#{1,6})[ \t]+(.+?)(?:[ \t]+#+)?[ \t]*$/;
286
+ var FIELD_RE = /^([a-z][a-z-]*):\s*(.*)$/;
287
+ var LIST_ITEM_RE = /^\s*-\s+(.*)$/;
288
+ function maskFencedCode(lines) {
289
+ let fence;
290
+ return lines.map((line) => {
291
+ const m = FENCE_RE.exec(line);
292
+ if (fence !== void 0) {
293
+ if (m?.[1] && m[1][0] === fence[0] && m[1].length >= fence.length) fence = void 0;
294
+ return MASKED_LINE;
295
+ }
296
+ if (m?.[1]) {
297
+ fence = m[1];
298
+ return MASKED_LINE;
299
+ }
300
+ return line;
301
+ });
302
+ }
303
+ function parseHeading(line) {
304
+ const m = HEADING_RE.exec(line);
305
+ if (!m?.[1] || !m[2]) return void 0;
306
+ return { depth: m[1].length, title: m[2] };
307
+ }
308
+ function splitList(value) {
309
+ return value.split(",").map((v) => v.trim()).filter(Boolean);
310
+ }
311
+ function bodyStart(lines) {
312
+ if (lines[0]?.trim() !== "---") return 0;
313
+ for (let i = 1; i < lines.length; i++) {
314
+ const l = lines[i]?.trim();
315
+ if (l === "---" || l === "...") return i + 1;
316
+ }
317
+ return lines.length;
318
+ }
319
+ function parseFrontmatter(text, errors) {
320
+ let data;
321
+ try {
322
+ data = matter2(text).data;
323
+ } catch (error) {
324
+ const reason = error instanceof Error ? error.message.split("\n")[0] : String(error);
325
+ errors.push({ line: 1, message: `invalid frontmatter YAML: ${reason}` });
326
+ return void 0;
327
+ }
328
+ const result = Schemas.Journey.safeParse(data);
329
+ if (result.success) return result.data;
330
+ for (const issue of result.error.issues) {
331
+ const where = issue.path.length ? ` \`${issue.path.join(".")}\`` : "";
332
+ errors.push({ line: 1, message: `frontmatter${where}: ${issue.message}` });
333
+ }
334
+ return void 0;
335
+ }
336
+ function newNode(title, level, line) {
337
+ return {
338
+ title,
339
+ level,
340
+ line,
341
+ isLeaf: true,
342
+ fieldLines: {},
343
+ anchors: [],
344
+ acceptance: [],
345
+ requires: [],
346
+ creates: [],
347
+ unknownFields: []
348
+ };
349
+ }
350
+ function parseFields(node, lines, from, to, errors) {
351
+ let lastKey;
352
+ for (let i = from; i < to; i++) {
353
+ const line = lines[i] ?? "";
354
+ if (line.trim() === "") continue;
355
+ const lineNo = i + 1;
356
+ const field = FIELD_RE.exec(line.trimEnd());
357
+ if (field?.[1] !== void 0) {
358
+ const key = field[1];
359
+ const value = (field[2] ?? "").trim();
360
+ lastKey = key;
361
+ if (!NODE_FIELDS.includes(key)) {
362
+ node.unknownFields.push({ key, line: lineNo });
363
+ continue;
364
+ }
365
+ const known = key;
366
+ node.fieldLines[known] = lineNo;
367
+ if (known === "status") {
368
+ if (JOURNEY_STATUSES.includes(value)) {
369
+ node.status = value;
370
+ } else {
371
+ errors.push({
372
+ line: lineNo,
373
+ message: `invalid status \`${value}\` (expected ${JOURNEY_STATUSES.join(" | ")})`
374
+ });
375
+ }
376
+ } else if (known === "spec") {
377
+ node.spec = value;
378
+ } else if (known === "acceptance") {
379
+ if (value) node.acceptance.push(value);
380
+ } else {
381
+ node[known] = splitList(value);
382
+ }
383
+ continue;
384
+ }
385
+ const item = LIST_ITEM_RE.exec(line);
386
+ if (lastKey === "acceptance" && item) {
387
+ const text = (item[1] ?? "").trim();
388
+ if (text) node.acceptance.push(text);
389
+ continue;
390
+ }
391
+ return;
392
+ }
393
+ }
394
+ function parseJourney(relPath, text) {
395
+ const errors = [];
396
+ const meta = parseFrontmatter(text, errors);
397
+ const lines = maskFencedCode(text.split(/\r?\n/));
398
+ const start = bodyStart(lines);
399
+ const headings = [];
400
+ for (let i = start; i < lines.length; i++) {
401
+ const h = parseHeading(lines[i] ?? "");
402
+ if (h) headings.push({ index: i, ...h });
403
+ }
404
+ const h1 = headings.find((h) => h.depth === 1);
405
+ let story;
406
+ if (h1) {
407
+ const paragraph = [];
408
+ for (let i = h1.index + 1; i < lines.length; i++) {
409
+ const line = lines[i] ?? "";
410
+ if (line.trim() === "") {
411
+ if (paragraph.length) break;
412
+ continue;
413
+ }
414
+ if (line === MASKED_LINE || parseHeading(line)) break;
415
+ paragraph.push(line.trim());
416
+ }
417
+ if (paragraph.length) story = paragraph.join(" ");
418
+ }
419
+ const nodes = [];
420
+ const stack = [];
421
+ for (const [k, h] of headings.entries()) {
422
+ if (h.depth < 2) continue;
423
+ const node = newNode(h.title, h.depth - 1, h.index + 1);
424
+ while (stack.length) {
425
+ const top = nodes[stack[stack.length - 1]];
426
+ if (top && top.level < node.level) break;
427
+ stack.pop();
428
+ }
429
+ const parentIndex = stack[stack.length - 1];
430
+ if (parentIndex !== void 0) {
431
+ node.parent = parentIndex;
432
+ const parent = nodes[parentIndex];
433
+ if (parent) parent.isLeaf = false;
434
+ }
435
+ const next = headings[k + 1];
436
+ parseFields(node, lines, h.index + 1, next ? next.index : lines.length, errors);
437
+ const inherited = parentIndex !== void 0 ? nodes[parentIndex]?.effectiveStatus : meta?.status;
438
+ node.effectiveStatus = node.status ?? inherited;
439
+ stack.push(nodes.length);
440
+ nodes.push(node);
441
+ }
442
+ const title = meta?.title ?? h1?.title ?? basename2(relPath, ".md");
443
+ return { ...meta ? { meta } : {}, title, ...story ? { story } : {}, nodes, errors };
444
+ }
445
+ function listJourneyFiles(targetDir) {
446
+ const dir = join4(targetDir, JOURNEYS_DIR);
447
+ if (!existsSync3(dir) || !statSync2(dir).isDirectory()) return [];
448
+ return readdirSync(dir).filter((f) => f.endsWith(".md") && f !== "README.md").filter((f) => statSync2(join4(dir, f)).isFile()).sort();
449
+ }
450
+ function readJourneys(targetDir) {
451
+ return listJourneyFiles(targetDir).map((file) => {
452
+ const path = `${JOURNEYS_DIR}/${file}`;
453
+ const text = readFileSync4(join4(targetDir, path), "utf8");
454
+ return { path, file, ...parseJourney(path, text) };
455
+ });
456
+ }
457
+ function loadJourneys(targetDir) {
458
+ const journeys = readJourneys(targetDir);
459
+ const problems = journeys.flatMap(
460
+ (j) => j.errors.map((e) => ` - ${j.path}${e.line !== void 0 ? `:${e.line}` : ""}: ${e.message}`)
461
+ );
462
+ if (problems.length) {
463
+ throw new Error(
464
+ `invalid journeys (run \`npx @vaubaan/harness lint --pillar journeys\`):
465
+ ${problems.join("\n")}`
466
+ );
467
+ }
468
+ return journeys;
469
+ }
470
+
254
471
  // src/renderers/common.ts
255
472
  import { stringify as yamlStringify } from "yaml";
256
473
  function checkSkillCapabilities(skill, engine) {
@@ -308,12 +525,15 @@ function frontmatterDataForCmd(cmd) {
308
525
  return data;
309
526
  }
310
527
  function buildUmbrellaBody(extras) {
311
- const triggerBySkill = new Map(
312
- extras.availableCommands.map((c) => [c.meta.invokes_skill, c.meta.trigger])
313
- );
528
+ const triggersBySkill = /* @__PURE__ */ new Map();
529
+ for (const c of extras.availableCommands) {
530
+ const triggers = triggersBySkill.get(c.meta.invokes_skill) ?? [];
531
+ triggers.push(c.meta.trigger);
532
+ triggersBySkill.set(c.meta.invokes_skill, triggers);
533
+ }
314
534
  const skillLines = extras.availableSkills.map((s) => {
315
- const trigger = triggerBySkill.get(s.meta.id);
316
- const label = trigger ? `\`${s.meta.id}\` (\`${trigger}\`)` : `\`${s.meta.id}\``;
535
+ const triggers = triggersBySkill.get(s.meta.id) ?? [];
536
+ const label = triggers.length > 0 ? `\`${s.meta.id}\` (${triggers.map((t) => `\`${t}\``).join(", ")})` : `\`${s.meta.id}\``;
317
537
  return `- ${label} \u2014 ${s.meta.description.split("\n")[0]}`;
318
538
  });
319
539
  const sections = [
@@ -325,19 +545,25 @@ function buildUmbrellaBody(extras) {
325
545
  "",
326
546
  "- `README.md` \u2014 pitch, quick start, scripts. Entry point.",
327
547
  "- `docs/spec/<subsystem>.md` \u2014 *what* and *why* (tech-agnostic).",
328
- "- `docs/handbook/<feature>.md` \u2014 *how it actually works* today.",
548
+ "- `docs/handbook/<feature>.md` \u2014 what the code does not say: entry points, traps, settings outside the repo, manual procedures.",
329
549
  "- `docs/decisions/<slug>.md` \u2014 ADRs: structural choices and rejected alternatives.",
330
- "- `docs/tests/integration-tests.md` & `e2e-tests.md` \u2014 core scenarios.",
550
+ "- `docs/tests/integration-tests.md` & `e2e-tests.md` \u2014 test scope, stack, conventions, known gaps.",
331
551
  "- `docs/workflow/coding-workflow.md` \u2014 CI, branches, PR, release. How this team works: follow it.",
332
552
  ...extras.hasProjectSkills ? ["- `docs/skills/*.skill.md` \u2014 the project's domain skills."] : [],
333
553
  ...extras.hasQualityDoc ? [
334
554
  "- `docs/quality/code-quality.md` \u2014 the project's code-quality rules: mechanical checks, judgment rules, accepted deviations. Read it before writing or auditing code."
335
555
  ] : [],
556
+ ...extras.hasJourneys ? [
557
+ "- `docs/journeys/<journey>.md` \u2014 user intentions and journeys, anchored to the code. `docs/journeys/README.md` is the generated index."
558
+ ] : [],
336
559
  "",
337
560
  "## Doc-first",
338
561
  "",
339
562
  "The order is: **understand the docs \u2192 fill the gaps \u2192 code \u2192 update the docs \u2192 commit**. If the docs are silent or stale on something you change, fill the gap upfront with the doc-skill writers \u2014 not downstream, not after the fact.",
340
563
  "",
564
+ ...extras.hasJourneys ? [
565
+ "- Visible change of behavior \u2192 a `proposed` leaf first (`/story <intent>`), never the code first."
566
+ ] : [],
341
567
  "- Missing spec for a subsystem you touch \u2192 **do not code**, report the gap.",
342
568
  "- Implicit structural decision in your changes \u2192 an ADR (`/decision`).",
343
569
  "- Changed feature behavior \u2192 update the matching handbook (`/handbook`).",
@@ -466,6 +692,23 @@ function getRenderer(engine) {
466
692
  return RENDERERS[engine];
467
693
  }
468
694
 
695
+ // src/renderers/journeys-index.ts
696
+ var INTRO = "User intentions and journeys of this project, anchored to the code. Generated by `@vaubaan/harness` from `docs/journeys/*.md`: edit the journeys, not this file, then run `npx @vaubaan/harness update .`.";
697
+ function buildJourneysIndex(journeys) {
698
+ const lines = ["# Journeys", "", INTRO, ""];
699
+ const sorted = [...journeys].sort((a, b) => a.file < b.file ? -1 : a.file > b.file ? 1 : 0);
700
+ for (const journey of sorted) {
701
+ const status = journey.meta?.status ?? "proposed";
702
+ const actors = journey.meta?.actors.join(", ") ?? "";
703
+ lines.push(`- [${journey.title}](./${journey.file}) \u2014 ${status} \xB7 ${actors}`);
704
+ for (const node of journey.nodes) {
705
+ lines.push(`${" ".repeat(node.level)}- ${node.title} \u2014 ${node.effectiveStatus ?? status}`);
706
+ }
707
+ }
708
+ return `${lines.join("\n")}
709
+ `;
710
+ }
711
+
469
712
  // src/render.ts
470
713
  var RenderError = class extends Error {
471
714
  constructor(message) {
@@ -535,12 +778,16 @@ function render(input) {
535
778
  availableSkills: Array.from(exposedSkills.values()),
536
779
  availableCommands: Array.from(exposedCmds.values()),
537
780
  hasProjectSkills: (input.projectSkills?.length ?? 0) > 0,
538
- hasQualityDoc: input.hasQualityDoc === true
781
+ hasQualityDoc: input.hasQualityDoc === true,
782
+ hasJourneys: (input.journeys?.length ?? 0) > 0
539
783
  });
540
784
  files.push({ path: "AGENTS.md", content: umbrellaContent });
541
785
  if (engines.includes("claude-code")) {
542
786
  files.push({ path: "CLAUDE.md", content: CLAUDE_MD_STUB });
543
787
  }
788
+ if (input.journeys && input.journeys.length > 0) {
789
+ files.push({ path: JOURNEYS_INDEX_PATH, content: buildJourneysIndex(input.journeys) });
790
+ }
544
791
  return { files, warnings };
545
792
  }
546
793
 
@@ -562,7 +809,7 @@ function resolveEngineList(requested) {
562
809
  }
563
810
  function defaultPackageDir() {
564
811
  const here = dirname2(fileURLToPath(import.meta.url));
565
- if (existsSync3(join4(here, "skills"))) return here;
812
+ if (existsSync4(join5(here, "skills"))) return here;
566
813
  return resolve2(here, "..");
567
814
  }
568
815
  function planInit(args) {
@@ -571,14 +818,15 @@ function planInit(args) {
571
818
  const harness = loadHarness(packageDir);
572
819
  const overrides = args.overridesDir ? loadOverrides(args.overridesDir) : void 0;
573
820
  const projectSkills = loadProjectSkills(args.targetDir);
574
- const hasQualityDoc = existsSync3(join4(args.targetDir, QUALITY_DOC_PATH));
575
- const output = render({ harness, engines, overrides, projectSkills, hasQualityDoc });
821
+ const hasQualityDoc = existsSync4(join5(args.targetDir, QUALITY_DOC_PATH));
822
+ const journeys = loadJourneys(args.targetDir);
823
+ const output = render({ harness, engines, overrides, projectSkills, hasQualityDoc, journeys });
576
824
  return { engines, output };
577
825
  }
578
826
 
579
827
  // src/cli/uninstall.ts
580
- import { existsSync as existsSync4, readFileSync as readFileSync4, readdirSync, rmdirSync, unlinkSync } from "fs";
581
- import { dirname as dirname3, join as join5, relative, resolve as resolve3 } from "path";
828
+ import { existsSync as existsSync5, readFileSync as readFileSync5, readdirSync as readdirSync2, rmdirSync, unlinkSync } from "fs";
829
+ import { dirname as dirname3, join as join6, relative, resolve as resolve3 } from "path";
582
830
  function pruneEmptyDirs(root, leaves) {
583
831
  const candidates = /* @__PURE__ */ new Set();
584
832
  for (const leaf of leaves) {
@@ -591,8 +839,8 @@ function pruneEmptyDirs(root, leaves) {
591
839
  const pruned = [];
592
840
  const sorted = [...candidates].sort((a, b) => b.length - a.length);
593
841
  for (const dir of sorted) {
594
- if (!existsSync4(dir)) continue;
595
- if (readdirSync(dir).length > 0) continue;
842
+ if (!existsSync5(dir)) continue;
843
+ if (readdirSync2(dir).length > 0) continue;
596
844
  rmdirSync(dir);
597
845
  pruned.push(relative(root, dir));
598
846
  }
@@ -608,25 +856,25 @@ import {
608
856
  lstatSync as lstatSync2,
609
857
  mkdirSync,
610
858
  openSync,
611
- readFileSync as readFileSync5,
612
- readdirSync as readdirSync2,
859
+ readFileSync as readFileSync6,
860
+ readdirSync as readdirSync3,
613
861
  realpathSync as realpathSync2,
614
862
  rmdirSync as rmdirSync2,
615
863
  unlinkSync as unlinkSync2,
616
864
  writeFileSync as writeFileSync2
617
865
  } from "fs";
618
866
  import { homedir } from "os";
619
- import { basename as basename2, dirname as dirname4, isAbsolute as isAbsolute2, join as join6, relative as relative2, resolve as resolve4, sep } from "path";
867
+ import { basename as basename3, dirname as dirname4, isAbsolute as isAbsolute2, join as join7, relative as relative2, resolve as resolve4, sep } from "path";
620
868
  var MANIFEST_PATH = ".harness-manifest.json";
621
869
  var PRIVATE_FILES = /* @__PURE__ */ new Set([MANIFEST_PATH]);
622
870
  function canonicalRoot(root) {
623
871
  let ancestor = resolve4(root);
624
872
  const missing = [];
625
873
  while (!lstatSync2(ancestor, { throwIfNoEntry: false })) {
626
- missing.unshift(basename2(ancestor));
874
+ missing.unshift(basename3(ancestor));
627
875
  ancestor = dirname4(ancestor);
628
876
  }
629
- return join6(realpathSync2(ancestor), ...missing);
877
+ return join7(realpathSync2(ancestor), ...missing);
630
878
  }
631
879
  function contains(parent, child) {
632
880
  const path = relative2(parent, child);
@@ -677,14 +925,14 @@ function saveSnapshot(root, paths, backup) {
677
925
  createDirectories(dirname4(backup), [], 448);
678
926
  mkdirSync(backup, { mode: 448 });
679
927
  for (const path of paths) {
680
- const full = join6(root, path);
928
+ const full = join7(root, path);
681
929
  const info = lstatSync2(full, { throwIfNoEntry: false });
682
930
  if (!info) {
683
931
  entries.push({ path, exists: false });
684
932
  continue;
685
933
  }
686
- const content = readFileSync5(full);
687
- writeBackupFile(join6(backup, "files", path), content);
934
+ const content = readFileSync6(full);
935
+ writeBackupFile(join7(backup, "files", path), content);
688
936
  entries.push({
689
937
  path,
690
938
  exists: true,
@@ -693,7 +941,7 @@ function saveSnapshot(root, paths, backup) {
693
941
  });
694
942
  }
695
943
  writeBackupFile(
696
- join6(backup, "snapshot.json"),
944
+ join7(backup, "snapshot.json"),
697
945
  `${JSON.stringify({ version: 1, root, createdAt: (/* @__PURE__ */ new Date()).toISOString(), entries }, null, 2)}
698
946
  `
699
947
  );
@@ -708,14 +956,14 @@ function rollback(root, backup, entries, touched, createdDirectories) {
708
956
  try {
709
957
  assertManagedPaths(root, [path]);
710
958
  const entry = entries.get(path);
711
- const full = join6(root, path);
959
+ const full = join7(root, path);
712
960
  const current = lstatSync2(full, { throwIfNoEntry: false });
713
961
  if (!entry?.exists) {
714
962
  if (current) unlinkSync2(full);
715
963
  continue;
716
964
  }
717
- const original = readFileSync5(join6(backup, "files", path));
718
- if (!current || !readFileSync5(full).equals(original)) {
965
+ const original = readFileSync6(join7(backup, "files", path));
966
+ if (!current || !readFileSync6(full).equals(original)) {
719
967
  if (current) unlinkSync2(full);
720
968
  writeFileSync2(full, original, { mode: 384 });
721
969
  }
@@ -726,7 +974,7 @@ function rollback(root, backup, entries, touched, createdDirectories) {
726
974
  }
727
975
  for (const directory of [...createdDirectories].reverse()) {
728
976
  try {
729
- if (readdirSync2(directory).length === 0) rmdirSync2(directory);
977
+ if (readdirSync3(directory).length === 0) rmdirSync2(directory);
730
978
  } catch (error) {
731
979
  errors.push(`${directory}: ${errorMessage(error)}`);
732
980
  }
@@ -738,7 +986,7 @@ function applyUpdateTransaction(root, writes, removals, backupDir) {
738
986
  assertManagedPaths(root, paths);
739
987
  const target = canonicalRoot(root);
740
988
  const backup = resolve4(
741
- backupDir ?? join6(homedir(), ".local", "state", "vaubaan-harness", "backups", randomUUID())
989
+ backupDir ?? join7(homedir(), ".local", "state", "vaubaan-harness", "backups", randomUUID())
742
990
  );
743
991
  assertBackupLocation(target, backup);
744
992
  let snapshot;
@@ -756,12 +1004,12 @@ function applyUpdateTransaction(root, writes, removals, backupDir) {
756
1004
  try {
757
1005
  assertManagedPaths(target, paths);
758
1006
  for (const path of removals) {
759
- if (!lstatSync2(join6(target, path), { throwIfNoEntry: false })) continue;
1007
+ if (!lstatSync2(join7(target, path), { throwIfNoEntry: false })) continue;
760
1008
  touched.add(path);
761
- unlinkSync2(join6(target, path));
1009
+ unlinkSync2(join7(target, path));
762
1010
  }
763
1011
  for (const file of writes) {
764
- const full = join6(target, file.path);
1012
+ const full = join7(target, file.path);
765
1013
  createDirectories(dirname4(full), createdDirectories);
766
1014
  touched.add(file.path);
767
1015
  const entry = entries.get(file.path);
@@ -781,13 +1029,13 @@ function applyUpdateTransaction(root, writes, removals, backupDir) {
781
1029
  }
782
1030
 
783
1031
  // src/cli/update.ts
784
- import { existsSync as existsSync6, readFileSync as readFileSync7 } from "fs";
785
- import { dirname as dirname5, join as join8, resolve as resolve5 } from "path";
1032
+ import { existsSync as existsSync7, readFileSync as readFileSync8 } from "fs";
1033
+ import { dirname as dirname5, join as join9, resolve as resolve5 } from "path";
786
1034
  import { isDeepStrictEqual } from "util";
787
1035
 
788
1036
  // src/cli/update-manifest.ts
789
- import { existsSync as existsSync5, readFileSync as readFileSync6 } from "fs";
790
- import { join as join7 } from "path";
1037
+ import { existsSync as existsSync6, readFileSync as readFileSync7 } from "fs";
1038
+ import { join as join8 } from "path";
791
1039
  import { z as z4 } from "zod";
792
1040
  var EngineSchema = z4.enum(ENGINES);
793
1041
  var LegacySchema = z4.object({
@@ -802,7 +1050,7 @@ var LegacySchema = z4.object({
802
1050
  var LEGACY_HOOK_FILES = [".claude/settings.json", ".codex/hooks.json"];
803
1051
  var LEGACY_HOOK_MARKER = "@vaubaan/harness stop-hook";
804
1052
  function currentContent(root, path) {
805
- return existsSync6(join8(root, path)) ? readFileSync7(join8(root, path), "utf8") : void 0;
1053
+ return existsSync7(join9(root, path)) ? readFileSync8(join9(root, path), "utf8") : void 0;
806
1054
  }
807
1055
  function checkArtifactConflicts(root, previous, writes, removals) {
808
1056
  const desired = new Map(writes.map((file) => [file.path, file.content]));
@@ -857,14 +1105,14 @@ function planInstallation(args, settings) {
857
1105
  assertManagedPaths(root, [...previous.files, ...preserved]);
858
1106
  const requestedOverrides = args.overridesDir ?? previous.overridesDir;
859
1107
  const overridesDir = args.overridesDir ? resolve5(args.overridesDir) : previous.overridesDir ? resolve5(root, previous.overridesDir) : root;
860
- if (requestedOverrides && !existsSync6(join8(overridesDir, ".harness-overrides"))) {
1108
+ if (requestedOverrides && !existsSync7(join9(overridesDir, ".harness-overrides"))) {
861
1109
  throw new Error(`recorded overrides are missing: ${overridesDir}/.harness-overrides`);
862
1110
  }
863
- const hasOverrides = existsSync6(join8(overridesDir, ".harness-overrides"));
864
- const disablePath = join8(overridesDir, ".harness-overrides", "disable.yaml");
865
- if (existsSync6(disablePath)) {
1111
+ const hasOverrides = existsSync7(join9(overridesDir, ".harness-overrides"));
1112
+ const disablePath = join9(overridesDir, ".harness-overrides", "disable.yaml");
1113
+ if (existsSync7(disablePath)) {
866
1114
  try {
867
- DisableYamlSchema.parse(parseYAML(readFileSync7(disablePath, "utf8")));
1115
+ DisableYamlSchema.parse(parseYAML(readFileSync8(disablePath, "utf8")));
868
1116
  } catch {
869
1117
  throw new Error(`invalid override selection: ${disablePath}`);
870
1118
  }
@@ -894,7 +1142,7 @@ function planInstallation(args, settings) {
894
1142
  ...preserved.length ? { preservedFiles: preserved } : {}
895
1143
  };
896
1144
  const writes = output.filter((file) => currentContent(root, file.path) !== file.content);
897
- const existingRemovals = removals.filter((path) => existsSync6(join8(root, path)));
1145
+ const existingRemovals = removals.filter((path) => existsSync7(join9(root, path)));
898
1146
  if (writes.length || existingRemovals.length || !isDeepStrictEqual(settings.previous, manifest)) {
899
1147
  manifest.renderedAt = (/* @__PURE__ */ new Date()).toISOString();
900
1148
  writes.push({ path: MANIFEST_FILENAME, content: `${JSON.stringify(manifest, null, 2)}
@@ -913,7 +1161,7 @@ function writeFilesToTarget(files, targetDir) {
913
1161
  );
914
1162
  const written = [];
915
1163
  for (const f of files) {
916
- const full = join9(targetDir, f.path);
1164
+ const full = join10(targetDir, f.path);
917
1165
  mkdirSync2(dirname6(full), { recursive: true });
918
1166
  writeFileSync3(full, f.content);
919
1167
  written.push(f.path);
@@ -937,7 +1185,7 @@ function initCommand(args) {
937
1185
  { previous, sourceVersion: previous.version, engines }
938
1186
  );
939
1187
  const touchedExisting = [...plan.writes.map((file) => file.path), ...plan.removals].some(
940
- (path) => path !== MANIFEST_FILENAME && existsSync7(join9(root, path))
1188
+ (path) => path !== MANIFEST_FILENAME && existsSync8(join10(root, path))
941
1189
  );
942
1190
  let backupDir;
943
1191
  if (plan.writes.length || plan.removals.length) {
@@ -946,7 +1194,7 @@ function initCommand(args) {
946
1194
  rmSync(backupDir, { recursive: true, force: true });
947
1195
  backupDir = void 0;
948
1196
  }
949
- pruneEmptyDirs(root, new Set(plan.removals.map((path) => dirname6(join9(root, path)))));
1197
+ pruneEmptyDirs(root, new Set(plan.removals.map((path) => dirname6(join10(root, path)))));
950
1198
  }
951
1199
  return {
952
1200
  filesWritten: plan.owned,