@vaubaan/harness 2.1.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/init.js CHANGED
@@ -1,11 +1,23 @@
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 intents pillar, rendered while an intent file exists.
13
+ "docs/intents/README.md",
14
+ // Its 2.2 location, kept managed so `update` can remove it (see MOVED_PATHS).
15
+ "docs/journeys/README.md"
16
+ ]);
17
+ var MOVED_PATHS = /* @__PURE__ */ new Map([
18
+ // 2.3: the journeys pillar became the intents pillar.
19
+ ["docs/journeys/README.md", "docs/intents/README.md"]
20
+ ]);
9
21
  var RELEASED_PATHS = [
10
22
  ".mcp.json",
11
23
  ".codex/config.toml",
@@ -78,7 +90,7 @@ import { join as join2 } from "path";
78
90
  import { z } from "zod";
79
91
 
80
92
  // src/version.ts
81
- var VERSION = "2.1.0";
93
+ var VERSION = "2.3.0";
82
94
 
83
95
  // src/cli/manifest.ts
84
96
  var MANIFEST_FILENAME = ".harness-manifest.json";
@@ -108,8 +120,8 @@ function readManifest(targetDir) {
108
120
  }
109
121
 
110
122
  // 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";
123
+ import { existsSync as existsSync4 } from "fs";
124
+ import { dirname as dirname2, join as join5, resolve as resolve2 } from "path";
113
125
  import { fileURLToPath } from "url";
114
126
 
115
127
  // src/loader.ts
@@ -150,12 +162,16 @@ var CmdArgEnumSchema = z2.object({
150
162
  name: z2.string().min(1),
151
163
  type: z2.literal("enum"),
152
164
  values: z2.array(z2.string()).min(1),
153
- default: z2.string().optional()
165
+ default: z2.string().optional(),
166
+ /** False when the command runs without the argument. Defaults to true. */
167
+ required: z2.boolean().optional()
154
168
  }).strict();
155
169
  var CmdArgStringSchema = z2.object({
156
170
  name: z2.string().min(1),
157
171
  type: z2.literal("string"),
158
- default: z2.string().optional()
172
+ default: z2.string().optional(),
173
+ /** False when the command runs without the argument. Defaults to true. */
174
+ required: z2.boolean().optional()
159
175
  }).strict();
160
176
  var CmdArgSchema = z2.discriminatedUnion("type", [CmdArgEnumSchema, CmdArgStringSchema]);
161
177
  var CmdFrontmatterSchema = z2.object({
@@ -165,9 +181,18 @@ var CmdFrontmatterSchema = z2.object({
165
181
  args: z2.array(CmdArgSchema).optional(),
166
182
  description: z2.string().min(1)
167
183
  }).strict();
184
+ var INTENT_STATUSES = ["proposed", "implemented", "deprecated"];
185
+ var IntentFrontmatterSchema = z2.object({
186
+ title: z2.string().min(1),
187
+ status: z2.enum(INTENT_STATUSES),
188
+ actors: z2.array(z2.string().min(1)).min(1),
189
+ spec: z2.union([z2.string().min(1), z2.array(z2.string().min(1)).min(1)]),
190
+ last_reviewed: z2.union([z2.date(), z2.string().min(1)])
191
+ }).strict();
168
192
  var Schemas = {
169
193
  Skill: SkillFrontmatterSchema,
170
- Cmd: CmdFrontmatterSchema
194
+ Cmd: CmdFrontmatterSchema,
195
+ Intent: IntentFrontmatterSchema
171
196
  };
172
197
  var ParseError = class extends Error {
173
198
  constructor(file, issues) {
@@ -251,6 +276,208 @@ function loadOverrides(worktreeDir) {
251
276
  return { add: added, disable };
252
277
  }
253
278
 
279
+ // src/parser/intent.ts
280
+ import { existsSync as existsSync3, readFileSync as readFileSync4, readdirSync, statSync as statSync2 } from "fs";
281
+ import { basename as basename2, join as join4 } from "path";
282
+ import matter2 from "gray-matter";
283
+ var INTENTS_DIR = "docs/intents";
284
+ var INTENTS_INDEX_PATH = `${INTENTS_DIR}/README.md`;
285
+ var NODE_FIELDS = [
286
+ "status",
287
+ "spec",
288
+ "anchors",
289
+ "acceptance",
290
+ "requires",
291
+ "creates"
292
+ ];
293
+ var MASKED_LINE = "\0";
294
+ var FENCE_RE = /^ {0,3}(`{3,}|~{3,})/;
295
+ var HEADING_RE = /^(#{1,6})[ \t]+(.+?)(?:[ \t]+#+)?[ \t]*$/;
296
+ var FIELD_RE = /^([a-z][a-z-]*):\s*(.*)$/;
297
+ var LIST_ITEM_RE = /^\s*-\s+(.*)$/;
298
+ function maskFencedCode(lines) {
299
+ let fence;
300
+ return lines.map((line) => {
301
+ const m = FENCE_RE.exec(line);
302
+ if (fence !== void 0) {
303
+ if (m?.[1] && m[1][0] === fence[0] && m[1].length >= fence.length) fence = void 0;
304
+ return MASKED_LINE;
305
+ }
306
+ if (m?.[1]) {
307
+ fence = m[1];
308
+ return MASKED_LINE;
309
+ }
310
+ return line;
311
+ });
312
+ }
313
+ function parseHeading(line) {
314
+ const m = HEADING_RE.exec(line);
315
+ if (!m?.[1] || !m[2]) return void 0;
316
+ return { depth: m[1].length, title: m[2] };
317
+ }
318
+ function splitList(value) {
319
+ return value.split(",").map((v) => v.trim()).filter(Boolean);
320
+ }
321
+ function bodyStart(lines) {
322
+ if (lines[0]?.trim() !== "---") return 0;
323
+ for (let i = 1; i < lines.length; i++) {
324
+ const l = lines[i]?.trim();
325
+ if (l === "---" || l === "...") return i + 1;
326
+ }
327
+ return lines.length;
328
+ }
329
+ function parseFrontmatter(text, errors) {
330
+ let data;
331
+ try {
332
+ data = matter2(text).data;
333
+ } catch (error) {
334
+ const reason = error instanceof Error ? error.message.split("\n")[0] : String(error);
335
+ errors.push({ line: 1, message: `invalid frontmatter YAML: ${reason}` });
336
+ return void 0;
337
+ }
338
+ const result = Schemas.Intent.safeParse(data);
339
+ if (result.success) return result.data;
340
+ for (const issue of result.error.issues) {
341
+ const where = issue.path.length ? ` \`${issue.path.join(".")}\`` : "";
342
+ errors.push({ line: 1, message: `frontmatter${where}: ${issue.message}` });
343
+ }
344
+ return void 0;
345
+ }
346
+ function newNode(title, level, line) {
347
+ return {
348
+ title,
349
+ level,
350
+ line,
351
+ isTerminal: true,
352
+ fieldLines: {},
353
+ anchors: [],
354
+ acceptance: [],
355
+ requires: [],
356
+ creates: [],
357
+ unknownFields: []
358
+ };
359
+ }
360
+ function parseFields(node, lines, from, to, errors) {
361
+ let lastKey;
362
+ for (let i = from; i < to; i++) {
363
+ const line = lines[i] ?? "";
364
+ if (line.trim() === "") continue;
365
+ const lineNo = i + 1;
366
+ const field = FIELD_RE.exec(line.trimEnd());
367
+ if (field?.[1] !== void 0) {
368
+ const key = field[1];
369
+ const value = (field[2] ?? "").trim();
370
+ lastKey = key;
371
+ if (!NODE_FIELDS.includes(key)) {
372
+ node.unknownFields.push({ key, line: lineNo });
373
+ continue;
374
+ }
375
+ const known = key;
376
+ node.fieldLines[known] = lineNo;
377
+ if (known === "status") {
378
+ if (INTENT_STATUSES.includes(value)) {
379
+ node.status = value;
380
+ } else {
381
+ errors.push({
382
+ line: lineNo,
383
+ message: `invalid status \`${value}\` (expected ${INTENT_STATUSES.join(" | ")})`
384
+ });
385
+ }
386
+ } else if (known === "spec") {
387
+ node.spec = value;
388
+ } else if (known === "acceptance") {
389
+ if (value) node.acceptance.push(value);
390
+ } else {
391
+ node[known] = splitList(value);
392
+ }
393
+ continue;
394
+ }
395
+ const item = LIST_ITEM_RE.exec(line);
396
+ if (lastKey === "acceptance" && item) {
397
+ const text = (item[1] ?? "").trim();
398
+ if (text) node.acceptance.push(text);
399
+ continue;
400
+ }
401
+ return;
402
+ }
403
+ }
404
+ function parseIntentFile(relPath, text) {
405
+ const errors = [];
406
+ const meta = parseFrontmatter(text, errors);
407
+ const lines = maskFencedCode(text.split(/\r?\n/));
408
+ const start = bodyStart(lines);
409
+ const headings = [];
410
+ for (let i = start; i < lines.length; i++) {
411
+ const h = parseHeading(lines[i] ?? "");
412
+ if (h) headings.push({ index: i, ...h });
413
+ }
414
+ const h1 = headings.find((h) => h.depth === 1);
415
+ let statement;
416
+ if (h1) {
417
+ const paragraph = [];
418
+ for (let i = h1.index + 1; i < lines.length; i++) {
419
+ const line = lines[i] ?? "";
420
+ if (line.trim() === "") {
421
+ if (paragraph.length) break;
422
+ continue;
423
+ }
424
+ if (line === MASKED_LINE || parseHeading(line)) break;
425
+ paragraph.push(line.trim());
426
+ }
427
+ if (paragraph.length) statement = paragraph.join(" ");
428
+ }
429
+ const nodes = [];
430
+ const stack = [];
431
+ for (const [k, h] of headings.entries()) {
432
+ if (h.depth < 2) continue;
433
+ const node = newNode(h.title, h.depth - 1, h.index + 1);
434
+ while (stack.length) {
435
+ const top = nodes[stack[stack.length - 1]];
436
+ if (top && top.level < node.level) break;
437
+ stack.pop();
438
+ }
439
+ const parentIndex = stack[stack.length - 1];
440
+ if (parentIndex !== void 0) {
441
+ node.parent = parentIndex;
442
+ const parent = nodes[parentIndex];
443
+ if (parent) parent.isTerminal = false;
444
+ }
445
+ const next = headings[k + 1];
446
+ parseFields(node, lines, h.index + 1, next ? next.index : lines.length, errors);
447
+ const inherited = parentIndex !== void 0 ? nodes[parentIndex]?.effectiveStatus : meta?.status;
448
+ node.effectiveStatus = node.status ?? inherited;
449
+ stack.push(nodes.length);
450
+ nodes.push(node);
451
+ }
452
+ const title = meta?.title ?? h1?.title ?? basename2(relPath, ".md");
453
+ return { ...meta ? { meta } : {}, title, ...statement ? { statement } : {}, nodes, errors };
454
+ }
455
+ function listIntentFiles(targetDir) {
456
+ const dir = join4(targetDir, INTENTS_DIR);
457
+ if (!existsSync3(dir) || !statSync2(dir).isDirectory()) return [];
458
+ return readdirSync(dir).filter((f) => f.endsWith(".md") && f !== "README.md").filter((f) => statSync2(join4(dir, f)).isFile()).sort();
459
+ }
460
+ function readIntentFiles(targetDir) {
461
+ return listIntentFiles(targetDir).map((file) => {
462
+ const path = `${INTENTS_DIR}/${file}`;
463
+ const text = readFileSync4(join4(targetDir, path), "utf8");
464
+ return { path, file, ...parseIntentFile(path, text) };
465
+ });
466
+ }
467
+ function loadIntentFiles(targetDir) {
468
+ const intentFiles = readIntentFiles(targetDir);
469
+ const problems = intentFiles.flatMap(
470
+ (j) => j.errors.map((e) => ` - ${j.path}${e.line !== void 0 ? `:${e.line}` : ""}: ${e.message}`)
471
+ );
472
+ if (problems.length) {
473
+ throw new Error(
474
+ `invalid intents (run \`npx @vaubaan/harness lint --pillar intents\`):
475
+ ${problems.join("\n")}`
476
+ );
477
+ }
478
+ return intentFiles;
479
+ }
480
+
254
481
  // src/renderers/common.ts
255
482
  import { stringify as yamlStringify } from "yaml";
256
483
  function checkSkillCapabilities(skill, engine) {
@@ -298,22 +525,26 @@ function frontmatterDataForCmd(cmd) {
298
525
  description: cmd.meta.description
299
526
  };
300
527
  if (cmd.meta.args && cmd.meta.args.length > 0) {
301
- data.args = cmd.meta.args.map((a) => {
302
- if (a.type === "enum") {
303
- return a.default !== void 0 ? { name: a.name, type: a.type, values: a.values, default: a.default } : { name: a.name, type: a.type, values: a.values };
304
- }
305
- return a.default !== void 0 ? { name: a.name, type: a.type, default: a.default } : { name: a.name, type: a.type };
306
- });
528
+ data.args = cmd.meta.args.map((a) => ({
529
+ name: a.name,
530
+ type: a.type,
531
+ ...a.type === "enum" ? { values: a.values } : {},
532
+ ...a.default !== void 0 ? { default: a.default } : {},
533
+ ...a.required === false ? { required: false } : {}
534
+ }));
307
535
  }
308
536
  return data;
309
537
  }
310
538
  function buildUmbrellaBody(extras) {
311
- const triggerBySkill = new Map(
312
- extras.availableCommands.map((c) => [c.meta.invokes_skill, c.meta.trigger])
313
- );
539
+ const triggersBySkill = /* @__PURE__ */ new Map();
540
+ for (const c of extras.availableCommands) {
541
+ const triggers = triggersBySkill.get(c.meta.invokes_skill) ?? [];
542
+ triggers.push(c.meta.trigger);
543
+ triggersBySkill.set(c.meta.invokes_skill, triggers);
544
+ }
314
545
  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}\``;
546
+ const triggers = triggersBySkill.get(s.meta.id) ?? [];
547
+ const label = triggers.length > 0 ? `\`${s.meta.id}\` (${triggers.map((t) => `\`${t}\``).join(", ")})` : `\`${s.meta.id}\``;
317
548
  return `- ${label} \u2014 ${s.meta.description.split("\n")[0]}`;
318
549
  });
319
550
  const sections = [
@@ -333,11 +564,17 @@ function buildUmbrellaBody(extras) {
333
564
  ...extras.hasQualityDoc ? [
334
565
  "- `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
566
  ] : [],
567
+ ...extras.hasIntents ? [
568
+ "- `docs/intents/<intent>.md` \u2014 user intents, one tree per level-1 intent, anchored to the code. `docs/intents/README.md` is the generated index."
569
+ ] : [],
336
570
  "",
337
571
  "## Doc-first",
338
572
  "",
339
573
  "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
574
  "",
575
+ ...extras.hasIntents ? [
576
+ "- Visible change of behavior \u2192 a `proposed` intent first (`/intent <verb + object>`), never the code first."
577
+ ] : [],
341
578
  "- Missing spec for a subsystem you touch \u2192 **do not code**, report the gap.",
342
579
  "- Implicit structural decision in your changes \u2192 an ADR (`/decision`).",
343
580
  "- Changed feature behavior \u2192 update the matching handbook (`/handbook`).",
@@ -466,6 +703,23 @@ function getRenderer(engine) {
466
703
  return RENDERERS[engine];
467
704
  }
468
705
 
706
+ // src/renderers/intents-index.ts
707
+ var INTRO = "User intents of this project, anchored to the code. Generated by `@vaubaan/harness` from `docs/intents/*.md`: edit the intents, not this file, then run `npx @vaubaan/harness update .`.";
708
+ function buildIntentsIndex(intentFiles) {
709
+ const lines = ["# Intents", "", INTRO, ""];
710
+ const sorted = [...intentFiles].sort((a, b) => a.file < b.file ? -1 : a.file > b.file ? 1 : 0);
711
+ for (const intentFile of sorted) {
712
+ const status = intentFile.meta?.status ?? "proposed";
713
+ const actors = intentFile.meta?.actors.join(", ") ?? "";
714
+ lines.push(`- [${intentFile.title}](./${intentFile.file}) \u2014 ${status} \xB7 ${actors}`);
715
+ for (const node of intentFile.nodes) {
716
+ lines.push(`${" ".repeat(node.level)}- ${node.title} \u2014 ${node.effectiveStatus ?? status}`);
717
+ }
718
+ }
719
+ return `${lines.join("\n")}
720
+ `;
721
+ }
722
+
469
723
  // src/render.ts
470
724
  var RenderError = class extends Error {
471
725
  constructor(message) {
@@ -535,12 +789,16 @@ function render(input) {
535
789
  availableSkills: Array.from(exposedSkills.values()),
536
790
  availableCommands: Array.from(exposedCmds.values()),
537
791
  hasProjectSkills: (input.projectSkills?.length ?? 0) > 0,
538
- hasQualityDoc: input.hasQualityDoc === true
792
+ hasQualityDoc: input.hasQualityDoc === true,
793
+ hasIntents: (input.intentFiles?.length ?? 0) > 0
539
794
  });
540
795
  files.push({ path: "AGENTS.md", content: umbrellaContent });
541
796
  if (engines.includes("claude-code")) {
542
797
  files.push({ path: "CLAUDE.md", content: CLAUDE_MD_STUB });
543
798
  }
799
+ if (input.intentFiles && input.intentFiles.length > 0) {
800
+ files.push({ path: INTENTS_INDEX_PATH, content: buildIntentsIndex(input.intentFiles) });
801
+ }
544
802
  return { files, warnings };
545
803
  }
546
804
 
@@ -562,7 +820,7 @@ function resolveEngineList(requested) {
562
820
  }
563
821
  function defaultPackageDir() {
564
822
  const here = dirname2(fileURLToPath(import.meta.url));
565
- if (existsSync3(join4(here, "skills"))) return here;
823
+ if (existsSync4(join5(here, "skills"))) return here;
566
824
  return resolve2(here, "..");
567
825
  }
568
826
  function planInit(args) {
@@ -571,14 +829,15 @@ function planInit(args) {
571
829
  const harness = loadHarness(packageDir);
572
830
  const overrides = args.overridesDir ? loadOverrides(args.overridesDir) : void 0;
573
831
  const projectSkills = loadProjectSkills(args.targetDir);
574
- const hasQualityDoc = existsSync3(join4(args.targetDir, QUALITY_DOC_PATH));
575
- const output = render({ harness, engines, overrides, projectSkills, hasQualityDoc });
832
+ const hasQualityDoc = existsSync4(join5(args.targetDir, QUALITY_DOC_PATH));
833
+ const intentFiles = loadIntentFiles(args.targetDir);
834
+ const output = render({ harness, engines, overrides, projectSkills, hasQualityDoc, intentFiles });
576
835
  return { engines, output };
577
836
  }
578
837
 
579
838
  // 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";
839
+ import { existsSync as existsSync5, readFileSync as readFileSync5, readdirSync as readdirSync2, rmdirSync, unlinkSync } from "fs";
840
+ import { dirname as dirname3, join as join6, relative, resolve as resolve3 } from "path";
582
841
  function pruneEmptyDirs(root, leaves) {
583
842
  const candidates = /* @__PURE__ */ new Set();
584
843
  for (const leaf of leaves) {
@@ -591,8 +850,8 @@ function pruneEmptyDirs(root, leaves) {
591
850
  const pruned = [];
592
851
  const sorted = [...candidates].sort((a, b) => b.length - a.length);
593
852
  for (const dir of sorted) {
594
- if (!existsSync4(dir)) continue;
595
- if (readdirSync(dir).length > 0) continue;
853
+ if (!existsSync5(dir)) continue;
854
+ if (readdirSync2(dir).length > 0) continue;
596
855
  rmdirSync(dir);
597
856
  pruned.push(relative(root, dir));
598
857
  }
@@ -608,25 +867,25 @@ import {
608
867
  lstatSync as lstatSync2,
609
868
  mkdirSync,
610
869
  openSync,
611
- readFileSync as readFileSync5,
612
- readdirSync as readdirSync2,
870
+ readFileSync as readFileSync6,
871
+ readdirSync as readdirSync3,
613
872
  realpathSync as realpathSync2,
614
873
  rmdirSync as rmdirSync2,
615
874
  unlinkSync as unlinkSync2,
616
875
  writeFileSync as writeFileSync2
617
876
  } from "fs";
618
877
  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";
878
+ import { basename as basename3, dirname as dirname4, isAbsolute as isAbsolute2, join as join7, relative as relative2, resolve as resolve4, sep } from "path";
620
879
  var MANIFEST_PATH = ".harness-manifest.json";
621
880
  var PRIVATE_FILES = /* @__PURE__ */ new Set([MANIFEST_PATH]);
622
881
  function canonicalRoot(root) {
623
882
  let ancestor = resolve4(root);
624
883
  const missing = [];
625
884
  while (!lstatSync2(ancestor, { throwIfNoEntry: false })) {
626
- missing.unshift(basename2(ancestor));
885
+ missing.unshift(basename3(ancestor));
627
886
  ancestor = dirname4(ancestor);
628
887
  }
629
- return join6(realpathSync2(ancestor), ...missing);
888
+ return join7(realpathSync2(ancestor), ...missing);
630
889
  }
631
890
  function contains(parent, child) {
632
891
  const path = relative2(parent, child);
@@ -677,14 +936,14 @@ function saveSnapshot(root, paths, backup) {
677
936
  createDirectories(dirname4(backup), [], 448);
678
937
  mkdirSync(backup, { mode: 448 });
679
938
  for (const path of paths) {
680
- const full = join6(root, path);
939
+ const full = join7(root, path);
681
940
  const info = lstatSync2(full, { throwIfNoEntry: false });
682
941
  if (!info) {
683
942
  entries.push({ path, exists: false });
684
943
  continue;
685
944
  }
686
- const content = readFileSync5(full);
687
- writeBackupFile(join6(backup, "files", path), content);
945
+ const content = readFileSync6(full);
946
+ writeBackupFile(join7(backup, "files", path), content);
688
947
  entries.push({
689
948
  path,
690
949
  exists: true,
@@ -693,7 +952,7 @@ function saveSnapshot(root, paths, backup) {
693
952
  });
694
953
  }
695
954
  writeBackupFile(
696
- join6(backup, "snapshot.json"),
955
+ join7(backup, "snapshot.json"),
697
956
  `${JSON.stringify({ version: 1, root, createdAt: (/* @__PURE__ */ new Date()).toISOString(), entries }, null, 2)}
698
957
  `
699
958
  );
@@ -708,14 +967,14 @@ function rollback(root, backup, entries, touched, createdDirectories) {
708
967
  try {
709
968
  assertManagedPaths(root, [path]);
710
969
  const entry = entries.get(path);
711
- const full = join6(root, path);
970
+ const full = join7(root, path);
712
971
  const current = lstatSync2(full, { throwIfNoEntry: false });
713
972
  if (!entry?.exists) {
714
973
  if (current) unlinkSync2(full);
715
974
  continue;
716
975
  }
717
- const original = readFileSync5(join6(backup, "files", path));
718
- if (!current || !readFileSync5(full).equals(original)) {
976
+ const original = readFileSync6(join7(backup, "files", path));
977
+ if (!current || !readFileSync6(full).equals(original)) {
719
978
  if (current) unlinkSync2(full);
720
979
  writeFileSync2(full, original, { mode: 384 });
721
980
  }
@@ -726,7 +985,7 @@ function rollback(root, backup, entries, touched, createdDirectories) {
726
985
  }
727
986
  for (const directory of [...createdDirectories].reverse()) {
728
987
  try {
729
- if (readdirSync2(directory).length === 0) rmdirSync2(directory);
988
+ if (readdirSync3(directory).length === 0) rmdirSync2(directory);
730
989
  } catch (error) {
731
990
  errors.push(`${directory}: ${errorMessage(error)}`);
732
991
  }
@@ -738,7 +997,7 @@ function applyUpdateTransaction(root, writes, removals, backupDir) {
738
997
  assertManagedPaths(root, paths);
739
998
  const target = canonicalRoot(root);
740
999
  const backup = resolve4(
741
- backupDir ?? join6(homedir(), ".local", "state", "vaubaan-harness", "backups", randomUUID())
1000
+ backupDir ?? join7(homedir(), ".local", "state", "vaubaan-harness", "backups", randomUUID())
742
1001
  );
743
1002
  assertBackupLocation(target, backup);
744
1003
  let snapshot;
@@ -756,12 +1015,12 @@ function applyUpdateTransaction(root, writes, removals, backupDir) {
756
1015
  try {
757
1016
  assertManagedPaths(target, paths);
758
1017
  for (const path of removals) {
759
- if (!lstatSync2(join6(target, path), { throwIfNoEntry: false })) continue;
1018
+ if (!lstatSync2(join7(target, path), { throwIfNoEntry: false })) continue;
760
1019
  touched.add(path);
761
- unlinkSync2(join6(target, path));
1020
+ unlinkSync2(join7(target, path));
762
1021
  }
763
1022
  for (const file of writes) {
764
- const full = join6(target, file.path);
1023
+ const full = join7(target, file.path);
765
1024
  createDirectories(dirname4(full), createdDirectories);
766
1025
  touched.add(file.path);
767
1026
  const entry = entries.get(file.path);
@@ -781,13 +1040,13 @@ function applyUpdateTransaction(root, writes, removals, backupDir) {
781
1040
  }
782
1041
 
783
1042
  // 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";
1043
+ import { existsSync as existsSync7, readFileSync as readFileSync8, readdirSync as readdirSync4, statSync as statSync3 } from "fs";
1044
+ import { dirname as dirname5, join as join9, resolve as resolve5 } from "path";
786
1045
  import { isDeepStrictEqual } from "util";
787
1046
 
788
1047
  // src/cli/update-manifest.ts
789
- import { existsSync as existsSync5, readFileSync as readFileSync6 } from "fs";
790
- import { join as join7 } from "path";
1048
+ import { existsSync as existsSync6, readFileSync as readFileSync7 } from "fs";
1049
+ import { join as join8 } from "path";
791
1050
  import { z as z4 } from "zod";
792
1051
  var EngineSchema = z4.enum(ENGINES);
793
1052
  var LegacySchema = z4.object({
@@ -802,7 +1061,7 @@ var LegacySchema = z4.object({
802
1061
  var LEGACY_HOOK_FILES = [".claude/settings.json", ".codex/hooks.json"];
803
1062
  var LEGACY_HOOK_MARKER = "@vaubaan/harness stop-hook";
804
1063
  function currentContent(root, path) {
805
- return existsSync6(join8(root, path)) ? readFileSync7(join8(root, path), "utf8") : void 0;
1064
+ return existsSync7(join9(root, path)) ? readFileSync8(join9(root, path), "utf8") : void 0;
806
1065
  }
807
1066
  function checkArtifactConflicts(root, previous, writes, removals) {
808
1067
  const desired = new Map(writes.map((file) => [file.path, file.content]));
@@ -832,6 +1091,27 @@ function releaseLegacyPaths(previous, warnings) {
832
1091
  if (released.length === 0) return previous;
833
1092
  return { ...previous, files: previous.files.filter((path) => !released.includes(path)) };
834
1093
  }
1094
+ function carryMovedPaths(root, previous, warnings) {
1095
+ let files = previous.files;
1096
+ let fileHashes = previous.fileHashes;
1097
+ for (const [from, to] of MOVED_PATHS) {
1098
+ if (!files.includes(from) || existsSync7(join9(root, from))) continue;
1099
+ files = [...new Set(files.map((path) => path === from ? to : path))];
1100
+ const hash = fileHashes?.[from];
1101
+ if (fileHashes && hash !== void 0) {
1102
+ const { [from]: _moved, ...rest } = fileHashes;
1103
+ fileHashes = { ...rest, [to]: hash };
1104
+ }
1105
+ }
1106
+ const oldDir = join9(root, "docs/journeys");
1107
+ if (existsSync7(oldDir) && statSync3(oldDir).isDirectory() && readdirSync4(oldDir).length > 0) {
1108
+ warnings.push(
1109
+ "docs/journeys/ is now docs/intents/: run `git mv docs/journeys docs/intents`, then `npx @vaubaan/harness update .` again"
1110
+ );
1111
+ }
1112
+ if (files === previous.files) return previous;
1113
+ return { ...previous, files, ...fileHashes ? { fileHashes } : {} };
1114
+ }
835
1115
  function legacyHookWarnings(root) {
836
1116
  const warnings = [];
837
1117
  for (const path of LEGACY_HOOK_FILES) {
@@ -848,7 +1128,7 @@ function planInstallation(args, settings) {
848
1128
  const root = resolve5(args.targetDir);
849
1129
  const { engines } = settings;
850
1130
  const warnings = [];
851
- const previous = releaseLegacyPaths(settings.previous, warnings);
1131
+ const previous = carryMovedPaths(root, releaseLegacyPaths(settings.previous, warnings), warnings);
852
1132
  const preserved = [
853
1133
  .../* @__PURE__ */ new Set([...previous.preservedFiles ?? [], ...args.preserveFiles ?? []])
854
1134
  ].sort();
@@ -857,14 +1137,14 @@ function planInstallation(args, settings) {
857
1137
  assertManagedPaths(root, [...previous.files, ...preserved]);
858
1138
  const requestedOverrides = args.overridesDir ?? previous.overridesDir;
859
1139
  const overridesDir = args.overridesDir ? resolve5(args.overridesDir) : previous.overridesDir ? resolve5(root, previous.overridesDir) : root;
860
- if (requestedOverrides && !existsSync6(join8(overridesDir, ".harness-overrides"))) {
1140
+ if (requestedOverrides && !existsSync7(join9(overridesDir, ".harness-overrides"))) {
861
1141
  throw new Error(`recorded overrides are missing: ${overridesDir}/.harness-overrides`);
862
1142
  }
863
- const hasOverrides = existsSync6(join8(overridesDir, ".harness-overrides"));
864
- const disablePath = join8(overridesDir, ".harness-overrides", "disable.yaml");
865
- if (existsSync6(disablePath)) {
1143
+ const hasOverrides = existsSync7(join9(overridesDir, ".harness-overrides"));
1144
+ const disablePath = join9(overridesDir, ".harness-overrides", "disable.yaml");
1145
+ if (existsSync7(disablePath)) {
866
1146
  try {
867
- DisableYamlSchema.parse(parseYAML(readFileSync7(disablePath, "utf8")));
1147
+ DisableYamlSchema.parse(parseYAML(readFileSync8(disablePath, "utf8")));
868
1148
  } catch {
869
1149
  throw new Error(`invalid override selection: ${disablePath}`);
870
1150
  }
@@ -894,7 +1174,7 @@ function planInstallation(args, settings) {
894
1174
  ...preserved.length ? { preservedFiles: preserved } : {}
895
1175
  };
896
1176
  const writes = output.filter((file) => currentContent(root, file.path) !== file.content);
897
- const existingRemovals = removals.filter((path) => existsSync6(join8(root, path)));
1177
+ const existingRemovals = removals.filter((path) => existsSync7(join9(root, path)));
898
1178
  if (writes.length || existingRemovals.length || !isDeepStrictEqual(settings.previous, manifest)) {
899
1179
  manifest.renderedAt = (/* @__PURE__ */ new Date()).toISOString();
900
1180
  writes.push({ path: MANIFEST_FILENAME, content: `${JSON.stringify(manifest, null, 2)}
@@ -913,7 +1193,7 @@ function writeFilesToTarget(files, targetDir) {
913
1193
  );
914
1194
  const written = [];
915
1195
  for (const f of files) {
916
- const full = join9(targetDir, f.path);
1196
+ const full = join10(targetDir, f.path);
917
1197
  mkdirSync2(dirname6(full), { recursive: true });
918
1198
  writeFileSync3(full, f.content);
919
1199
  written.push(f.path);
@@ -937,7 +1217,7 @@ function initCommand(args) {
937
1217
  { previous, sourceVersion: previous.version, engines }
938
1218
  );
939
1219
  const touchedExisting = [...plan.writes.map((file) => file.path), ...plan.removals].some(
940
- (path) => path !== MANIFEST_FILENAME && existsSync7(join9(root, path))
1220
+ (path) => path !== MANIFEST_FILENAME && existsSync8(join10(root, path))
941
1221
  );
942
1222
  let backupDir;
943
1223
  if (plan.writes.length || plan.removals.length) {
@@ -946,7 +1226,7 @@ function initCommand(args) {
946
1226
  rmSync(backupDir, { recursive: true, force: true });
947
1227
  backupDir = void 0;
948
1228
  }
949
- pruneEmptyDirs(root, new Set(plan.removals.map((path) => dirname6(join9(root, path)))));
1229
+ pruneEmptyDirs(root, new Set(plan.removals.map((path) => dirname6(join10(root, path)))));
950
1230
  }
951
1231
  return {
952
1232
  filesWritten: plan.owned,