@vaubaan/harness 2.3.1 → 3.0.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/README.md +207 -83
- package/dist/cli/index.js +4165 -843
- package/dist/cli/index.js.map +1 -1
- package/dist/commands/harn-canvas.cmd.md +23 -0
- package/dist/commands/{decision.cmd.md → harn-decision.cmd.md} +6 -6
- package/dist/commands/{doc-audit.cmd.md → harn-doc-audit.cmd.md} +7 -7
- package/dist/commands/{drift.cmd.md → harn-drift.cmd.md} +6 -6
- package/dist/commands/{handbook.cmd.md → harn-handbook.cmd.md} +6 -6
- package/dist/commands/harn-improve.cmd.md +20 -0
- package/dist/commands/{intent.cmd.md → harn-intent.cmd.md} +9 -9
- package/dist/commands/{readme.cmd.md → harn-readme.cmd.md} +6 -6
- package/dist/commands/{spec.cmd.md → harn-spec.cmd.md} +6 -6
- package/dist/commands/{test-plan.cmd.md → harn-test-plan.cmd.md} +6 -6
- package/dist/commands/harn-upgrade.cmd.md +22 -0
- package/dist/commands/{workflow.cmd.md → harn-workflow.cmd.md} +6 -6
- package/dist/index.d.ts +32 -3
- package/dist/index.js +533 -96
- package/dist/index.js.map +1 -1
- package/dist/init.d.ts +1 -1
- package/dist/init.js +468 -93
- package/dist/init.js.map +1 -1
- package/dist/linters/index.d.ts +3 -34
- package/dist/linters/index.js +996 -554
- package/dist/linters/index.js.map +1 -1
- package/dist/parser/index.d.ts +96 -6
- package/dist/parser/index.js +220 -10
- package/dist/parser/index.js.map +1 -1
- package/dist/render-BhUar2gf.d.ts +81 -0
- package/dist/render.d.ts +1 -1
- package/dist/render.js +233 -22
- package/dist/render.js.map +1 -1
- package/dist/skills/harn-canvas-review.skill.md +87 -0
- package/dist/skills/{decision-record-writer.skill.md → harn-decision-record-writer.skill.md} +2 -1
- package/dist/skills/{doc-audit.skill.md → harn-doc-audit.skill.md} +75 -26
- package/dist/skills/{drift-detector.skill.md → harn-drift-detector.skill.md} +15 -14
- package/dist/skills/harn-guide.skill.md +137 -0
- package/dist/skills/{handbook-writer.skill.md → harn-handbook-writer.skill.md} +2 -1
- package/dist/skills/{intent-writer.skill.md → harn-intent-writer.skill.md} +83 -16
- package/dist/skills/{readme-writer.skill.md → harn-readme-writer.skill.md} +4 -4
- package/dist/skills/harn-self-improve.skill.md +84 -0
- package/dist/skills/{spec-writer.skill.md → harn-spec-writer.skill.md} +8 -8
- package/dist/skills/{test-plan-writer.skill.md → harn-test-plan-writer.skill.md} +6 -5
- package/dist/skills/harn-upgrade.skill.md +171 -0
- package/dist/skills/{workflow-writer.skill.md → harn-workflow-writer.skill.md} +6 -5
- package/dist/templates/decisions-index.md.tmpl +11 -0
- package/dist/templates/handbook-index.md.tmpl +8 -0
- package/dist/templates/profile.md.tmpl +30 -0
- package/dist/types-CfUByAIr.d.ts +35 -0
- package/dist/view/index.d.ts +117 -0
- package/dist/view/index.js +3987 -0
- package/dist/view/index.js.map +1 -0
- package/package.json +6 -2
- package/dist/render-CTx7VNOK.d.ts +0 -45
package/dist/init.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/cli/init.ts
|
|
2
|
-
import { existsSync as
|
|
3
|
-
import { dirname as dirname6, join as
|
|
2
|
+
import { existsSync as existsSync11, mkdirSync as mkdirSync2, rmSync, writeFileSync as writeFileSync3 } from "fs";
|
|
3
|
+
import { dirname as dirname6, join as join13, resolve as resolve6 } from "path";
|
|
4
4
|
|
|
5
5
|
// src/cli/managed-paths.ts
|
|
6
6
|
import { lstatSync, realpathSync, statSync } from "fs";
|
|
@@ -9,11 +9,37 @@ var MANAGED_FILES = /* @__PURE__ */ new Set([
|
|
|
9
9
|
"AGENTS.md",
|
|
10
10
|
"CLAUDE.md",
|
|
11
11
|
".harness-manifest.json",
|
|
12
|
-
//
|
|
12
|
+
// Indexes of the intents and profiles pillars, rendered while the pillar is active.
|
|
13
13
|
"docs/intents/README.md",
|
|
14
|
+
"docs/profiles/README.md",
|
|
14
15
|
// Its 2.2 location, kept managed so `update` can remove it (see MOVED_PATHS).
|
|
15
16
|
"docs/journeys/README.md"
|
|
16
17
|
]);
|
|
18
|
+
var RENAMED_IDS = /* @__PURE__ */ new Map([
|
|
19
|
+
["canvas-review", "harn-canvas-review"],
|
|
20
|
+
["decision-record-writer", "harn-decision-record-writer"],
|
|
21
|
+
["doc-audit", "harn-doc-audit"],
|
|
22
|
+
["drift-detector", "harn-drift-detector"],
|
|
23
|
+
["handbook-writer", "harn-handbook-writer"],
|
|
24
|
+
["harness-guide", "harn-guide"],
|
|
25
|
+
["harness-upgrade", "harn-upgrade"],
|
|
26
|
+
["intent-writer", "harn-intent-writer"],
|
|
27
|
+
["lesson-miner", "harn-self-improve"],
|
|
28
|
+
["readme-writer", "harn-readme-writer"],
|
|
29
|
+
["spec-writer", "harn-spec-writer"],
|
|
30
|
+
["test-plan-writer", "harn-test-plan-writer"],
|
|
31
|
+
["workflow-writer", "harn-workflow-writer"],
|
|
32
|
+
["canvas", "harn-canvas"],
|
|
33
|
+
["decision", "harn-decision"],
|
|
34
|
+
["drift", "harn-drift"],
|
|
35
|
+
["handbook", "harn-handbook"],
|
|
36
|
+
["intent", "harn-intent"],
|
|
37
|
+
["lessons", "harn-improve"],
|
|
38
|
+
["readme", "harn-readme"],
|
|
39
|
+
["spec", "harn-spec"],
|
|
40
|
+
["test-plan", "harn-test-plan"],
|
|
41
|
+
["workflow", "harn-workflow"]
|
|
42
|
+
]);
|
|
17
43
|
var MOVED_PATHS = /* @__PURE__ */ new Map([
|
|
18
44
|
// 2.3: the journeys pillar became the intents pillar.
|
|
19
45
|
["docs/journeys/README.md", "docs/intents/README.md"]
|
|
@@ -90,7 +116,7 @@ import { join as join2 } from "path";
|
|
|
90
116
|
import { z } from "zod";
|
|
91
117
|
|
|
92
118
|
// src/version.ts
|
|
93
|
-
var VERSION = "
|
|
119
|
+
var VERSION = "3.0.0";
|
|
94
120
|
|
|
95
121
|
// src/cli/manifest.ts
|
|
96
122
|
var MANIFEST_FILENAME = ".harness-manifest.json";
|
|
@@ -120,13 +146,13 @@ function readManifest(targetDir) {
|
|
|
120
146
|
}
|
|
121
147
|
|
|
122
148
|
// src/cli/plan-render.ts
|
|
123
|
-
import { existsSync as
|
|
124
|
-
import { dirname as dirname2, join as
|
|
149
|
+
import { existsSync as existsSync7 } from "fs";
|
|
150
|
+
import { dirname as dirname2, join as join8, resolve as resolve2 } from "path";
|
|
125
151
|
import { fileURLToPath } from "url";
|
|
126
152
|
|
|
127
153
|
// src/loader.ts
|
|
128
|
-
import { existsSync as
|
|
129
|
-
import { join as
|
|
154
|
+
import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
|
|
155
|
+
import { join as join4 } from "path";
|
|
130
156
|
import fg from "fast-glob";
|
|
131
157
|
import { z as z3 } from "zod";
|
|
132
158
|
|
|
@@ -137,6 +163,101 @@ import matter from "gray-matter";
|
|
|
137
163
|
// src/parser/schemas.ts
|
|
138
164
|
import { z as z2 } from "zod";
|
|
139
165
|
|
|
166
|
+
// src/pillars.ts
|
|
167
|
+
import { existsSync as existsSync2, readdirSync, statSync as statSync2 } from "fs";
|
|
168
|
+
import { join as join3 } from "path";
|
|
169
|
+
var PILLAR_IDS = [
|
|
170
|
+
"readme",
|
|
171
|
+
"spec",
|
|
172
|
+
"decisions",
|
|
173
|
+
"handbook",
|
|
174
|
+
"tests",
|
|
175
|
+
"workflow",
|
|
176
|
+
"quality",
|
|
177
|
+
"skills",
|
|
178
|
+
"intents",
|
|
179
|
+
"profiles"
|
|
180
|
+
];
|
|
181
|
+
var PILLARS = [
|
|
182
|
+
{ id: "readme", core: true },
|
|
183
|
+
{ id: "spec", dir: "docs/spec", core: true },
|
|
184
|
+
{
|
|
185
|
+
id: "decisions",
|
|
186
|
+
dir: "docs/decisions",
|
|
187
|
+
core: false,
|
|
188
|
+
starters: [{ template: "decisions-index.md.tmpl", path: "docs/decisions/README.md" }],
|
|
189
|
+
next: "write the first decision with the `harn-decision-record-writer` skill (`/harn-decision`)"
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
id: "handbook",
|
|
193
|
+
dir: "docs/handbook",
|
|
194
|
+
core: false,
|
|
195
|
+
starters: [{ template: "handbook-index.md.tmpl", path: "docs/handbook/README.md" }],
|
|
196
|
+
next: "write the first handbook with the `harn-handbook-writer` skill (`/harn-handbook`)"
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
id: "tests",
|
|
200
|
+
dir: "docs/tests",
|
|
201
|
+
core: false,
|
|
202
|
+
starters: [
|
|
203
|
+
{ template: "integration-tests.md.tmpl", path: "docs/tests/integration-tests.md" },
|
|
204
|
+
{ template: "e2e-tests.md.tmpl", path: "docs/tests/e2e-tests.md" }
|
|
205
|
+
],
|
|
206
|
+
next: "fill both test plans with the `harn-test-plan-writer` skill (`/harn-test-plan`); the lint fails on their placeholders until then"
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
id: "workflow",
|
|
210
|
+
dir: "docs/workflow",
|
|
211
|
+
core: false,
|
|
212
|
+
starters: [{ template: "coding-workflow.md.tmpl", path: "docs/workflow/coding-workflow.md" }],
|
|
213
|
+
next: "fill the workflow with the `harn-workflow-writer` skill (`/harn-workflow`); the lint fails on its placeholders until then"
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
id: "quality",
|
|
217
|
+
dir: "docs/quality",
|
|
218
|
+
core: false,
|
|
219
|
+
starters: [{ template: "code-quality.md.tmpl", path: "docs/quality/code-quality.md" }],
|
|
220
|
+
next: "fill docs/quality/code-quality.md by hand: the tools, the project's rules, the accepted deviations"
|
|
221
|
+
},
|
|
222
|
+
// Active as soon as it holds a `*.skill.md`: nothing to add.
|
|
223
|
+
{ id: "skills", dir: "docs/skills", core: false },
|
|
224
|
+
{
|
|
225
|
+
id: "intents",
|
|
226
|
+
dir: "docs/intents",
|
|
227
|
+
core: false,
|
|
228
|
+
starters: [],
|
|
229
|
+
next: "write the first intent with the `harn-intent-writer` skill (`/harn-intent <verb + object>`)"
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
id: "profiles",
|
|
233
|
+
dir: "docs/profiles",
|
|
234
|
+
core: false,
|
|
235
|
+
starters: [],
|
|
236
|
+
next: "describe the first profile with the `harn-intent-writer` skill, from the research you point it to"
|
|
237
|
+
}
|
|
238
|
+
];
|
|
239
|
+
var ADDABLE_PILLARS = PILLARS.filter(
|
|
240
|
+
(pillar) => pillar.starters !== void 0
|
|
241
|
+
);
|
|
242
|
+
function getPillar(id) {
|
|
243
|
+
return PILLARS.find((pillar) => pillar.id === id);
|
|
244
|
+
}
|
|
245
|
+
function isDirectory(path) {
|
|
246
|
+
return existsSync2(path) && statSync2(path).isDirectory();
|
|
247
|
+
}
|
|
248
|
+
function isPillarActive(repoRoot, id) {
|
|
249
|
+
const pillar = getPillar(id);
|
|
250
|
+
if (!pillar) return false;
|
|
251
|
+
if (pillar.core) return true;
|
|
252
|
+
return pillar.dir !== void 0 && isDirectory(join3(repoRoot, pillar.dir));
|
|
253
|
+
}
|
|
254
|
+
function activePillars(repoRoot) {
|
|
255
|
+
return new Set(PILLARS.filter((p) => isPillarActive(repoRoot, p.id)).map((p) => p.id));
|
|
256
|
+
}
|
|
257
|
+
function allPillars() {
|
|
258
|
+
return new Set(PILLAR_IDS);
|
|
259
|
+
}
|
|
260
|
+
|
|
140
261
|
// src/types.ts
|
|
141
262
|
var ENGINES = ["claude-code", "codex-cli", "opencode"];
|
|
142
263
|
var CAPABILITIES = ["multi-step", "slash-command", "inline-exec"];
|
|
@@ -156,6 +277,8 @@ var SkillFrontmatterSchema = z2.object({
|
|
|
156
277
|
description: z2.string().min(1),
|
|
157
278
|
engines: z2.array(z2.enum(ENGINES)).min(1).optional(),
|
|
158
279
|
requires: z2.array(z2.enum(CAPABILITIES)).optional(),
|
|
280
|
+
/** Rendered while one of these pillars is active; omitted = always. */
|
|
281
|
+
pillars: z2.array(z2.enum(PILLAR_IDS)).min(1).optional(),
|
|
159
282
|
tags: z2.array(z2.string()).optional()
|
|
160
283
|
}).strict();
|
|
161
284
|
var CmdArgEnumSchema = z2.object({
|
|
@@ -189,10 +312,18 @@ var IntentFrontmatterSchema = z2.object({
|
|
|
189
312
|
spec: z2.union([z2.string().min(1), z2.array(z2.string().min(1)).min(1)]),
|
|
190
313
|
last_reviewed: z2.union([z2.date(), z2.string().min(1)])
|
|
191
314
|
}).strict();
|
|
315
|
+
var PROFILE_STATUSES = ["hypothesis", "validated"];
|
|
316
|
+
var ProfileFrontmatterSchema = z2.object({
|
|
317
|
+
title: z2.string().min(1),
|
|
318
|
+
status: z2.enum(PROFILE_STATUSES),
|
|
319
|
+
evidence: z2.union([z2.string().min(1), z2.array(z2.string().min(1)).min(1)]).optional(),
|
|
320
|
+
last_reviewed: z2.union([z2.date(), z2.string().min(1)])
|
|
321
|
+
}).strict();
|
|
192
322
|
var Schemas = {
|
|
193
323
|
Skill: SkillFrontmatterSchema,
|
|
194
324
|
Cmd: CmdFrontmatterSchema,
|
|
195
|
-
Intent: IntentFrontmatterSchema
|
|
325
|
+
Intent: IntentFrontmatterSchema,
|
|
326
|
+
Profile: ProfileFrontmatterSchema
|
|
196
327
|
};
|
|
197
328
|
var ParseError = class extends Error {
|
|
198
329
|
constructor(file, issues) {
|
|
@@ -240,8 +371,8 @@ function parseYAML(source) {
|
|
|
240
371
|
// src/loader.ts
|
|
241
372
|
var DisableYamlSchema = z3.object({ disable: z3.array(z3.string()).optional() }).passthrough();
|
|
242
373
|
function loadHarness(packageDir, opts = {}) {
|
|
243
|
-
const skillsDir = opts.skillsDir ??
|
|
244
|
-
const commandsDir = opts.commandsDir ??
|
|
374
|
+
const skillsDir = opts.skillsDir ?? join4(packageDir, "skills");
|
|
375
|
+
const commandsDir = opts.commandsDir ?? join4(packageDir, "commands");
|
|
245
376
|
const skillFiles = fg.sync("*.skill.md", { cwd: skillsDir, absolute: true });
|
|
246
377
|
const cmdFiles = fg.sync("*.cmd.md", { cwd: commandsDir, absolute: true });
|
|
247
378
|
return {
|
|
@@ -250,21 +381,21 @@ function loadHarness(packageDir, opts = {}) {
|
|
|
250
381
|
};
|
|
251
382
|
}
|
|
252
383
|
function loadProjectSkills(targetDir) {
|
|
253
|
-
const skillsDir =
|
|
254
|
-
if (!
|
|
384
|
+
const skillsDir = join4(targetDir, "docs", "skills");
|
|
385
|
+
if (!existsSync3(skillsDir)) return [];
|
|
255
386
|
const skillFiles = fg.sync("*.skill.md", { cwd: skillsDir, absolute: true });
|
|
256
387
|
return skillFiles.map((f) => parseSkill(f, readFileSync3(f, "utf8")));
|
|
257
388
|
}
|
|
258
389
|
function loadOverrides(worktreeDir) {
|
|
259
|
-
const overridesDir =
|
|
260
|
-
if (!
|
|
390
|
+
const overridesDir = join4(worktreeDir, ".harness-overrides");
|
|
391
|
+
if (!existsSync3(overridesDir)) return void 0;
|
|
261
392
|
const added = loadHarness(overridesDir, {
|
|
262
|
-
skillsDir:
|
|
263
|
-
commandsDir:
|
|
393
|
+
skillsDir: join4(overridesDir, "skills"),
|
|
394
|
+
commandsDir: join4(overridesDir, "commands")
|
|
264
395
|
});
|
|
265
|
-
const disablePath =
|
|
396
|
+
const disablePath = join4(overridesDir, "disable.yaml");
|
|
266
397
|
let disable = [];
|
|
267
|
-
if (
|
|
398
|
+
if (existsSync3(disablePath)) {
|
|
268
399
|
try {
|
|
269
400
|
const parsed = DisableYamlSchema.safeParse(parseYAML(readFileSync3(disablePath, "utf8")));
|
|
270
401
|
if (parsed.success && parsed.data.disable) {
|
|
@@ -277,8 +408,8 @@ function loadOverrides(worktreeDir) {
|
|
|
277
408
|
}
|
|
278
409
|
|
|
279
410
|
// src/parser/intent.ts
|
|
280
|
-
import { existsSync as
|
|
281
|
-
import { basename as basename2, join as
|
|
411
|
+
import { existsSync as existsSync4, readFileSync as readFileSync4, readdirSync as readdirSync2, statSync as statSync3 } from "fs";
|
|
412
|
+
import { basename as basename2, join as join5 } from "path";
|
|
282
413
|
import matter2 from "gray-matter";
|
|
283
414
|
var INTENTS_DIR = "docs/intents";
|
|
284
415
|
var INTENTS_INDEX_PATH = `${INTENTS_DIR}/README.md`;
|
|
@@ -288,7 +419,9 @@ var NODE_FIELDS = [
|
|
|
288
419
|
"anchors",
|
|
289
420
|
"acceptance",
|
|
290
421
|
"requires",
|
|
291
|
-
"creates"
|
|
422
|
+
"creates",
|
|
423
|
+
"relieves",
|
|
424
|
+
"delivers"
|
|
292
425
|
];
|
|
293
426
|
var MASKED_LINE = "\0";
|
|
294
427
|
var FENCE_RE = /^ {0,3}(`{3,}|~{3,})/;
|
|
@@ -354,6 +487,8 @@ function newNode(title, level, line) {
|
|
|
354
487
|
acceptance: [],
|
|
355
488
|
requires: [],
|
|
356
489
|
creates: [],
|
|
490
|
+
relieves: [],
|
|
491
|
+
delivers: [],
|
|
357
492
|
unknownFields: []
|
|
358
493
|
};
|
|
359
494
|
}
|
|
@@ -453,14 +588,14 @@ function parseIntentFile(relPath, text) {
|
|
|
453
588
|
return { ...meta ? { meta } : {}, title, ...statement ? { statement } : {}, nodes, errors };
|
|
454
589
|
}
|
|
455
590
|
function listIntentFiles(targetDir) {
|
|
456
|
-
const dir =
|
|
457
|
-
if (!
|
|
458
|
-
return
|
|
591
|
+
const dir = join5(targetDir, INTENTS_DIR);
|
|
592
|
+
if (!existsSync4(dir) || !statSync3(dir).isDirectory()) return [];
|
|
593
|
+
return readdirSync2(dir).filter((f) => f.endsWith(".md") && f !== "README.md").filter((f) => statSync3(join5(dir, f)).isFile()).sort();
|
|
459
594
|
}
|
|
460
595
|
function readIntentFiles(targetDir) {
|
|
461
596
|
return listIntentFiles(targetDir).map((file) => {
|
|
462
597
|
const path = `${INTENTS_DIR}/${file}`;
|
|
463
|
-
const text = readFileSync4(
|
|
598
|
+
const text = readFileSync4(join5(targetDir, path), "utf8");
|
|
464
599
|
return { path, file, ...parseIntentFile(path, text) };
|
|
465
600
|
});
|
|
466
601
|
}
|
|
@@ -478,6 +613,112 @@ ${problems.join("\n")}`
|
|
|
478
613
|
return intentFiles;
|
|
479
614
|
}
|
|
480
615
|
|
|
616
|
+
// src/parser/profile.ts
|
|
617
|
+
import { existsSync as existsSync6, readFileSync as readFileSync6, readdirSync as readdirSync3, statSync as statSync5 } from "fs";
|
|
618
|
+
import { basename as basename3, join as join7 } from "path";
|
|
619
|
+
import matter4 from "gray-matter";
|
|
620
|
+
|
|
621
|
+
// src/parser/docs.ts
|
|
622
|
+
function entitySlug(term) {
|
|
623
|
+
return term.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
// src/linters/intent-util.ts
|
|
627
|
+
import { posix } from "path";
|
|
628
|
+
|
|
629
|
+
// src/linters/util.ts
|
|
630
|
+
import { execFileSync } from "child_process";
|
|
631
|
+
import { existsSync as existsSync5, readFileSync as readFileSync5, statSync as statSync4 } from "fs";
|
|
632
|
+
import { join as join6, relative } from "path";
|
|
633
|
+
import fg2 from "fast-glob";
|
|
634
|
+
import matter3 from "gray-matter";
|
|
635
|
+
|
|
636
|
+
// src/parser/profile.ts
|
|
637
|
+
var PROFILES_DIR = "docs/profiles";
|
|
638
|
+
var PROFILES_INDEX_PATH = `${PROFILES_DIR}/README.md`;
|
|
639
|
+
var PAINS_HEADING = /^(Pains|Irritants|Douleurs)\s*$/i;
|
|
640
|
+
var GAINS_HEADING = /^(Gains|B[ée]n[ée]fices)\s*$/i;
|
|
641
|
+
var BULLET = /^[-*]\s+(.*)$/;
|
|
642
|
+
var NAMED = /^\*\*([^*]+)\*\*/;
|
|
643
|
+
function parseFrontmatter2(text, errors) {
|
|
644
|
+
let data;
|
|
645
|
+
try {
|
|
646
|
+
data = matter4(text).data;
|
|
647
|
+
} catch (error) {
|
|
648
|
+
const reason = error instanceof Error ? error.message.split("\n")[0] : String(error);
|
|
649
|
+
errors.push({ line: 1, message: `invalid frontmatter YAML: ${reason}` });
|
|
650
|
+
return void 0;
|
|
651
|
+
}
|
|
652
|
+
const result = Schemas.Profile.safeParse(data);
|
|
653
|
+
if (result.success) return result.data;
|
|
654
|
+
for (const issue of result.error.issues) {
|
|
655
|
+
const where = issue.path.length ? ` \`${issue.path.join(".")}\`` : "";
|
|
656
|
+
errors.push({ line: 1, message: `frontmatter${where}: ${issue.message}` });
|
|
657
|
+
}
|
|
658
|
+
return void 0;
|
|
659
|
+
}
|
|
660
|
+
function parseProfileFile(relPath, text) {
|
|
661
|
+
const errors = [];
|
|
662
|
+
const meta = parseFrontmatter2(text, errors);
|
|
663
|
+
const lines = maskFencedCode(text.split(/\r?\n/));
|
|
664
|
+
const pains = [];
|
|
665
|
+
const gains = [];
|
|
666
|
+
let h1;
|
|
667
|
+
let current;
|
|
668
|
+
let start = 0;
|
|
669
|
+
if (lines[0]?.trim() === "---") {
|
|
670
|
+
const end = lines.findIndex((line, i) => i > 0 && /^(---|\.\.\.)\s*$/.test(line));
|
|
671
|
+
start = end < 0 ? lines.length : end + 1;
|
|
672
|
+
}
|
|
673
|
+
for (let i = start; i < lines.length; i++) {
|
|
674
|
+
const line = lines[i] ?? "";
|
|
675
|
+
const heading = parseHeading(line);
|
|
676
|
+
if (heading) {
|
|
677
|
+
if (heading.depth === 1 && h1 === void 0) h1 = heading.title;
|
|
678
|
+
if (current && heading.depth > current.depth) continue;
|
|
679
|
+
if (PAINS_HEADING.test(heading.title)) {
|
|
680
|
+
current = { kind: "pain", depth: heading.depth, items: pains };
|
|
681
|
+
} else if (GAINS_HEADING.test(heading.title)) {
|
|
682
|
+
current = { kind: "gain", depth: heading.depth, items: gains };
|
|
683
|
+
} else {
|
|
684
|
+
current = void 0;
|
|
685
|
+
}
|
|
686
|
+
continue;
|
|
687
|
+
}
|
|
688
|
+
if (!current) continue;
|
|
689
|
+
const bullet = BULLET.exec(line)?.[1];
|
|
690
|
+
if (bullet === void 0) continue;
|
|
691
|
+
const name = NAMED.exec(bullet)?.[1]?.trim();
|
|
692
|
+
const slug = name ? entitySlug(name) : "";
|
|
693
|
+
if (!name || !slug) {
|
|
694
|
+
errors.push({ line: i + 1, message: `a ${current.kind} opens with its name in bold` });
|
|
695
|
+
continue;
|
|
696
|
+
}
|
|
697
|
+
if (current.items.some((item) => item.slug === slug)) {
|
|
698
|
+
errors.push({ line: i + 1, message: `duplicate ${current.kind} \`${slug}\`` });
|
|
699
|
+
continue;
|
|
700
|
+
}
|
|
701
|
+
current.items.push({ name, slug, line: i + 1 });
|
|
702
|
+
}
|
|
703
|
+
if (pains.length === 0 && gains.length === 0) {
|
|
704
|
+
errors.push({ message: "a profile names at least one pain or one gain" });
|
|
705
|
+
}
|
|
706
|
+
const title = meta?.title ?? h1 ?? basename3(relPath, ".md");
|
|
707
|
+
return { ...meta ? { meta } : {}, title, pains, gains, errors };
|
|
708
|
+
}
|
|
709
|
+
function listProfileFiles(targetDir) {
|
|
710
|
+
const dir = join7(targetDir, PROFILES_DIR);
|
|
711
|
+
if (!existsSync6(dir) || !statSync5(dir).isDirectory()) return [];
|
|
712
|
+
return readdirSync3(dir).filter((f) => f.endsWith(".md") && f !== "README.md").filter((f) => statSync5(join7(dir, f)).isFile()).sort();
|
|
713
|
+
}
|
|
714
|
+
function readProfileFiles(targetDir) {
|
|
715
|
+
return listProfileFiles(targetDir).map((file) => {
|
|
716
|
+
const path = `${PROFILES_DIR}/${file}`;
|
|
717
|
+
const text = readFileSync6(join7(targetDir, path), "utf8");
|
|
718
|
+
return { path, file, slug: basename3(file, ".md"), ...parseProfileFile(path, text) };
|
|
719
|
+
});
|
|
720
|
+
}
|
|
721
|
+
|
|
481
722
|
// src/renderers/common.ts
|
|
482
723
|
import { stringify as yamlStringify } from "yaml";
|
|
483
724
|
function checkSkillCapabilities(skill, engine) {
|
|
@@ -547,6 +788,10 @@ function buildUmbrellaBody(extras) {
|
|
|
547
788
|
const label = triggers.length > 0 ? `\`${s.meta.id}\` (${triggers.map((t) => `\`${t}\``).join(", ")})` : `\`${s.meta.id}\``;
|
|
548
789
|
return `- ${label} \u2014 ${s.meta.description.split("\n")[0]}`;
|
|
549
790
|
});
|
|
791
|
+
const has = (pillar) => extras.activePillars.has(pillar);
|
|
792
|
+
const exposes = (id) => extras.availableSkills.some((s) => s.meta.id === id);
|
|
793
|
+
const when = (condition, ...lines) => condition ? lines : [];
|
|
794
|
+
const inactive = ADDABLE_PILLARS.filter((pillar) => !has(pillar.id)).map((p) => `\`${p.id}\``);
|
|
550
795
|
const sections = [
|
|
551
796
|
"# How we work",
|
|
552
797
|
"",
|
|
@@ -556,29 +801,65 @@ function buildUmbrellaBody(extras) {
|
|
|
556
801
|
"",
|
|
557
802
|
"- `README.md` \u2014 pitch, quick start, scripts. Entry point.",
|
|
558
803
|
"- `docs/spec/<subsystem>.md` \u2014 *what* and *why* (tech-agnostic).",
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
...
|
|
564
|
-
|
|
804
|
+
...when(
|
|
805
|
+
has("handbook"),
|
|
806
|
+
"- `docs/handbook/<feature>.md` \u2014 what the code does not say: entry points, traps, settings outside the repo, manual procedures."
|
|
807
|
+
),
|
|
808
|
+
...when(
|
|
809
|
+
has("decisions"),
|
|
810
|
+
"- `docs/decisions/<slug>.md` \u2014 ADRs: structural choices and rejected alternatives."
|
|
811
|
+
),
|
|
812
|
+
...when(
|
|
813
|
+
has("tests"),
|
|
814
|
+
"- `docs/tests/integration-tests.md` & `e2e-tests.md` \u2014 test scope, stack, conventions, known gaps."
|
|
815
|
+
),
|
|
816
|
+
...when(
|
|
817
|
+
has("workflow"),
|
|
818
|
+
"- `docs/workflow/coding-workflow.md` \u2014 CI, branches, PR, release. How this team works: follow it."
|
|
819
|
+
),
|
|
820
|
+
...when(
|
|
821
|
+
extras.hasProjectSkills === true,
|
|
822
|
+
"- `docs/skills/*.skill.md` \u2014 the project's domain skills."
|
|
823
|
+
),
|
|
824
|
+
...when(
|
|
825
|
+
has("quality"),
|
|
565
826
|
"- `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."
|
|
566
|
-
|
|
567
|
-
...
|
|
827
|
+
),
|
|
828
|
+
...when(
|
|
829
|
+
has("intents"),
|
|
568
830
|
"- `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
|
-
|
|
831
|
+
),
|
|
832
|
+
...when(
|
|
833
|
+
has("profiles"),
|
|
834
|
+
"- `docs/profiles/<profile>.md` \u2014 who the project serves, their pains and gains. `docs/profiles/README.md` is the generated index: which intent serves which pain."
|
|
835
|
+
),
|
|
836
|
+
...when(
|
|
837
|
+
inactive.length > 0,
|
|
838
|
+
"",
|
|
839
|
+
`Not in this project yet: ${inactive.join(", ")}. A pillar is added the day the project needs it, with \`npx @vaubaan/harness add <pillar>\`${exposes("harn-guide") ? "; the `harn-guide` skill says when each one is worth it" : ""}. Propose it to the human, never create the folder unasked.`
|
|
840
|
+
),
|
|
570
841
|
"",
|
|
571
842
|
"## Doc-first",
|
|
572
843
|
"",
|
|
573
844
|
"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.",
|
|
574
845
|
"",
|
|
575
|
-
...
|
|
576
|
-
"
|
|
577
|
-
|
|
846
|
+
...when(
|
|
847
|
+
has("intents"),
|
|
848
|
+
"- Visible change of behavior \u2192 a `proposed` intent first (`/harn-intent <verb + object>`), never the code first."
|
|
849
|
+
),
|
|
578
850
|
"- Missing spec for a subsystem you touch \u2192 **do not code**, report the gap.",
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
851
|
+
...when(
|
|
852
|
+
has("decisions"),
|
|
853
|
+
"- Implicit structural decision in your changes \u2192 an ADR (`/harn-decision`)."
|
|
854
|
+
),
|
|
855
|
+
...when(
|
|
856
|
+
has("handbook"),
|
|
857
|
+
"- Changed feature behavior \u2192 update the matching handbook (`/harn-handbook`)."
|
|
858
|
+
),
|
|
859
|
+
...when(
|
|
860
|
+
exposes("harn-drift-detector"),
|
|
861
|
+
"- Suspected code \u2194 doc drift \u2192 `/harn-drift` before moving on."
|
|
862
|
+
),
|
|
582
863
|
"",
|
|
583
864
|
"## Checks",
|
|
584
865
|
"",
|
|
@@ -587,7 +868,7 @@ function buildUmbrellaBody(extras) {
|
|
|
587
868
|
"The files the harness generates (`AGENTS.md`, `CLAUDE.md`, the `.claude/`, `.agents/` and `.opencode/` folders, `.harness-manifest.json`) are committed. Never edit them by hand: change their source in `docs/` or `.harness-overrides/`, run `npx @vaubaan/harness update .`, and commit the result. The linter fails when a generated file no longer matches its render."
|
|
588
869
|
];
|
|
589
870
|
if (skillLines.length > 0) {
|
|
590
|
-
sections.push("", "##
|
|
871
|
+
sections.push("", "## Skills", "", skillLines.join("\n"));
|
|
591
872
|
}
|
|
592
873
|
return `${sections.join("\n")}
|
|
593
874
|
`;
|
|
@@ -705,8 +986,10 @@ function getRenderer(engine) {
|
|
|
705
986
|
|
|
706
987
|
// src/renderers/intents-index.ts
|
|
707
988
|
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 .`.";
|
|
989
|
+
var EMPTY = "No intent yet. `/harn-intent <verb + object>` writes the first one, before the code.";
|
|
708
990
|
function buildIntentsIndex(intentFiles) {
|
|
709
991
|
const lines = ["# Intents", "", INTRO, ""];
|
|
992
|
+
if (intentFiles.length === 0) lines.push(EMPTY);
|
|
710
993
|
const sorted = [...intentFiles].sort((a, b) => a.file < b.file ? -1 : a.file > b.file ? 1 : 0);
|
|
711
994
|
for (const intentFile of sorted) {
|
|
712
995
|
const status = intentFile.meta?.status ?? "proposed";
|
|
@@ -720,6 +1003,54 @@ function buildIntentsIndex(intentFiles) {
|
|
|
720
1003
|
`;
|
|
721
1004
|
}
|
|
722
1005
|
|
|
1006
|
+
// src/renderers/profiles-index.ts
|
|
1007
|
+
var INTRO2 = "Who this project serves, and what the intents do for them. Generated by `@vaubaan/harness` from `docs/profiles/*.md` and `docs/intents/*.md`: edit those, not this file, then run `npx @vaubaan/harness update .`.";
|
|
1008
|
+
var EMPTY2 = "No profile yet. The `harn-intent-writer` skill writes the first one from the research you point it to.";
|
|
1009
|
+
function buildProfilesIndex(profiles, intentFiles = []) {
|
|
1010
|
+
const lines = ["# Profiles", "", INTRO2];
|
|
1011
|
+
if (profiles.length === 0) lines.push("", EMPTY2);
|
|
1012
|
+
const sortedIntents = [...intentFiles].sort(
|
|
1013
|
+
(a, b) => a.file < b.file ? -1 : a.file > b.file ? 1 : 0
|
|
1014
|
+
);
|
|
1015
|
+
for (const profile of [...profiles].sort((a, b) => a.file < b.file ? -1 : 1)) {
|
|
1016
|
+
const theirs = sortedIntents.filter((file) => file.meta?.actors.includes(profile.slug));
|
|
1017
|
+
lines.push(
|
|
1018
|
+
"",
|
|
1019
|
+
`## [${profile.title}](./${profile.file}) \u2014 ${profile.meta?.status ?? "hypothesis"}`,
|
|
1020
|
+
""
|
|
1021
|
+
);
|
|
1022
|
+
lines.push(
|
|
1023
|
+
theirs.length ? `Intents: ${theirs.map((f) => `[${f.title}](../intents/${f.file})`).join(", ")}.` : "Intents: none names this profile yet."
|
|
1024
|
+
);
|
|
1025
|
+
const served = (kind, item) => {
|
|
1026
|
+
const by = [];
|
|
1027
|
+
for (const file of theirs) {
|
|
1028
|
+
for (const node of file.nodes) {
|
|
1029
|
+
if (node[kind].includes(item.slug)) {
|
|
1030
|
+
by.push(`[${node.title}](../intents/${file.file})`);
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
if (by.length) return by.join(", ");
|
|
1035
|
+
return kind === "relieves" ? "*no intent relieves it yet*" : "*no intent delivers it yet*";
|
|
1036
|
+
};
|
|
1037
|
+
if (profile.pains.length) {
|
|
1038
|
+
lines.push("", "Pains, most severe first:", "");
|
|
1039
|
+
for (const pain of profile.pains) {
|
|
1040
|
+
lines.push(`- **${pain.name}** (\`${pain.slug}\`) \u2014 ${served("relieves", pain)}`);
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
if (profile.gains.length) {
|
|
1044
|
+
lines.push("", "Gains:", "");
|
|
1045
|
+
for (const gain of profile.gains) {
|
|
1046
|
+
lines.push(`- **${gain.name}** (\`${gain.slug}\`) \u2014 ${served("delivers", gain)}`);
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
return `${lines.join("\n")}
|
|
1051
|
+
`;
|
|
1052
|
+
}
|
|
1053
|
+
|
|
723
1054
|
// src/render.ts
|
|
724
1055
|
var RenderError = class extends Error {
|
|
725
1056
|
constructor(message) {
|
|
@@ -751,13 +1082,21 @@ var CLAUDE_MD_STUB = "@AGENTS.md\n";
|
|
|
751
1082
|
function opencodeLast(engines) {
|
|
752
1083
|
return [...engines].sort((a, b) => Number(a === "opencode") - Number(b === "opencode"));
|
|
753
1084
|
}
|
|
1085
|
+
function servesAnActivePillar(skill, active) {
|
|
1086
|
+
return !skill.meta.pillars || skill.meta.pillars.some((pillar) => active.has(pillar));
|
|
1087
|
+
}
|
|
754
1088
|
function render(input) {
|
|
755
1089
|
const { engines } = input;
|
|
756
1090
|
if (engines.length === 0) {
|
|
757
1091
|
throw new RenderError("at least one engine must be selected");
|
|
758
1092
|
}
|
|
759
1093
|
const base = input.projectSkills?.length ? { ...input.harness, skills: mergeById(input.harness.skills, input.projectSkills) } : input.harness;
|
|
760
|
-
const
|
|
1094
|
+
const active = input.activePillars ?? allPillars();
|
|
1095
|
+
const merged = applyOverrides(base, input.overrides);
|
|
1096
|
+
const harness = {
|
|
1097
|
+
...merged,
|
|
1098
|
+
skills: merged.skills.filter((skill) => servesAnActivePillar(skill, active))
|
|
1099
|
+
};
|
|
761
1100
|
const files = [];
|
|
762
1101
|
const warnings = [];
|
|
763
1102
|
const exposedSkills = /* @__PURE__ */ new Map();
|
|
@@ -789,21 +1128,25 @@ function render(input) {
|
|
|
789
1128
|
availableSkills: Array.from(exposedSkills.values()),
|
|
790
1129
|
availableCommands: Array.from(exposedCmds.values()),
|
|
791
1130
|
hasProjectSkills: (input.projectSkills?.length ?? 0) > 0,
|
|
792
|
-
|
|
793
|
-
hasIntents: (input.intentFiles?.length ?? 0) > 0
|
|
1131
|
+
activePillars: active
|
|
794
1132
|
});
|
|
795
1133
|
files.push({ path: "AGENTS.md", content: umbrellaContent });
|
|
796
1134
|
if (engines.includes("claude-code")) {
|
|
797
1135
|
files.push({ path: "CLAUDE.md", content: CLAUDE_MD_STUB });
|
|
798
1136
|
}
|
|
799
|
-
if (input.intentFiles
|
|
1137
|
+
if (input.intentFiles) {
|
|
800
1138
|
files.push({ path: INTENTS_INDEX_PATH, content: buildIntentsIndex(input.intentFiles) });
|
|
801
1139
|
}
|
|
1140
|
+
if (input.profileFiles) {
|
|
1141
|
+
files.push({
|
|
1142
|
+
path: PROFILES_INDEX_PATH,
|
|
1143
|
+
content: buildProfilesIndex(input.profileFiles, input.intentFiles ?? [])
|
|
1144
|
+
});
|
|
1145
|
+
}
|
|
802
1146
|
return { files, warnings };
|
|
803
1147
|
}
|
|
804
1148
|
|
|
805
1149
|
// src/cli/plan-render.ts
|
|
806
|
-
var QUALITY_DOC_PATH = "docs/quality/code-quality.md";
|
|
807
1150
|
function resolveEngineList(requested) {
|
|
808
1151
|
if (!requested || requested.length === 0) {
|
|
809
1152
|
throw new Error(
|
|
@@ -820,7 +1163,7 @@ function resolveEngineList(requested) {
|
|
|
820
1163
|
}
|
|
821
1164
|
function defaultPackageDir() {
|
|
822
1165
|
const here = dirname2(fileURLToPath(import.meta.url));
|
|
823
|
-
if (
|
|
1166
|
+
if (existsSync7(join8(here, "skills"))) return here;
|
|
824
1167
|
return resolve2(here, "..");
|
|
825
1168
|
}
|
|
826
1169
|
function planInit(args) {
|
|
@@ -829,15 +1172,22 @@ function planInit(args) {
|
|
|
829
1172
|
const harness = loadHarness(packageDir);
|
|
830
1173
|
const overrides = args.overridesDir ? loadOverrides(args.overridesDir) : void 0;
|
|
831
1174
|
const projectSkills = loadProjectSkills(args.targetDir);
|
|
832
|
-
const
|
|
833
|
-
const
|
|
834
|
-
|
|
1175
|
+
const active = activePillars(args.targetDir);
|
|
1176
|
+
const output = render({
|
|
1177
|
+
harness,
|
|
1178
|
+
engines,
|
|
1179
|
+
overrides,
|
|
1180
|
+
projectSkills,
|
|
1181
|
+
activePillars: active,
|
|
1182
|
+
...active.has("intents") ? { intentFiles: loadIntentFiles(args.targetDir) } : {},
|
|
1183
|
+
...active.has("profiles") ? { profileFiles: readProfileFiles(args.targetDir) } : {}
|
|
1184
|
+
});
|
|
835
1185
|
return { engines, output };
|
|
836
1186
|
}
|
|
837
1187
|
|
|
838
1188
|
// src/cli/uninstall.ts
|
|
839
|
-
import { existsSync as
|
|
840
|
-
import { dirname as dirname3, join as
|
|
1189
|
+
import { existsSync as existsSync8, readFileSync as readFileSync7, readdirSync as readdirSync4, rmdirSync, unlinkSync } from "fs";
|
|
1190
|
+
import { dirname as dirname3, join as join9, relative as relative2, resolve as resolve3 } from "path";
|
|
841
1191
|
function pruneEmptyDirs(root, leaves) {
|
|
842
1192
|
const candidates = /* @__PURE__ */ new Set();
|
|
843
1193
|
for (const leaf of leaves) {
|
|
@@ -850,10 +1200,10 @@ function pruneEmptyDirs(root, leaves) {
|
|
|
850
1200
|
const pruned = [];
|
|
851
1201
|
const sorted = [...candidates].sort((a, b) => b.length - a.length);
|
|
852
1202
|
for (const dir of sorted) {
|
|
853
|
-
if (!
|
|
854
|
-
if (
|
|
1203
|
+
if (!existsSync8(dir)) continue;
|
|
1204
|
+
if (readdirSync4(dir).length > 0) continue;
|
|
855
1205
|
rmdirSync(dir);
|
|
856
|
-
pruned.push(
|
|
1206
|
+
pruned.push(relative2(root, dir));
|
|
857
1207
|
}
|
|
858
1208
|
return pruned;
|
|
859
1209
|
}
|
|
@@ -867,28 +1217,28 @@ import {
|
|
|
867
1217
|
lstatSync as lstatSync2,
|
|
868
1218
|
mkdirSync,
|
|
869
1219
|
openSync,
|
|
870
|
-
readFileSync as
|
|
871
|
-
readdirSync as
|
|
1220
|
+
readFileSync as readFileSync8,
|
|
1221
|
+
readdirSync as readdirSync5,
|
|
872
1222
|
realpathSync as realpathSync2,
|
|
873
1223
|
rmdirSync as rmdirSync2,
|
|
874
1224
|
unlinkSync as unlinkSync2,
|
|
875
1225
|
writeFileSync as writeFileSync2
|
|
876
1226
|
} from "fs";
|
|
877
1227
|
import { homedir } from "os";
|
|
878
|
-
import { basename as
|
|
1228
|
+
import { basename as basename4, dirname as dirname4, isAbsolute as isAbsolute2, join as join10, relative as relative3, resolve as resolve4, sep } from "path";
|
|
879
1229
|
var MANIFEST_PATH = ".harness-manifest.json";
|
|
880
1230
|
var PRIVATE_FILES = /* @__PURE__ */ new Set([MANIFEST_PATH]);
|
|
881
1231
|
function canonicalRoot(root) {
|
|
882
1232
|
let ancestor = resolve4(root);
|
|
883
1233
|
const missing = [];
|
|
884
1234
|
while (!lstatSync2(ancestor, { throwIfNoEntry: false })) {
|
|
885
|
-
missing.unshift(
|
|
1235
|
+
missing.unshift(basename4(ancestor));
|
|
886
1236
|
ancestor = dirname4(ancestor);
|
|
887
1237
|
}
|
|
888
|
-
return
|
|
1238
|
+
return join10(realpathSync2(ancestor), ...missing);
|
|
889
1239
|
}
|
|
890
1240
|
function contains(parent, child) {
|
|
891
|
-
const path =
|
|
1241
|
+
const path = relative3(parent, child);
|
|
892
1242
|
return path === "" || !isAbsolute2(path) && path !== ".." && !path.startsWith(`..${sep}`);
|
|
893
1243
|
}
|
|
894
1244
|
function assertBackupLocation(root, backup) {
|
|
@@ -936,14 +1286,14 @@ function saveSnapshot(root, paths, backup) {
|
|
|
936
1286
|
createDirectories(dirname4(backup), [], 448);
|
|
937
1287
|
mkdirSync(backup, { mode: 448 });
|
|
938
1288
|
for (const path of paths) {
|
|
939
|
-
const full =
|
|
1289
|
+
const full = join10(root, path);
|
|
940
1290
|
const info = lstatSync2(full, { throwIfNoEntry: false });
|
|
941
1291
|
if (!info) {
|
|
942
1292
|
entries.push({ path, exists: false });
|
|
943
1293
|
continue;
|
|
944
1294
|
}
|
|
945
|
-
const content =
|
|
946
|
-
writeBackupFile(
|
|
1295
|
+
const content = readFileSync8(full);
|
|
1296
|
+
writeBackupFile(join10(backup, "files", path), content);
|
|
947
1297
|
entries.push({
|
|
948
1298
|
path,
|
|
949
1299
|
exists: true,
|
|
@@ -952,7 +1302,7 @@ function saveSnapshot(root, paths, backup) {
|
|
|
952
1302
|
});
|
|
953
1303
|
}
|
|
954
1304
|
writeBackupFile(
|
|
955
|
-
|
|
1305
|
+
join10(backup, "snapshot.json"),
|
|
956
1306
|
`${JSON.stringify({ version: 1, root, createdAt: (/* @__PURE__ */ new Date()).toISOString(), entries }, null, 2)}
|
|
957
1307
|
`
|
|
958
1308
|
);
|
|
@@ -967,14 +1317,14 @@ function rollback(root, backup, entries, touched, createdDirectories) {
|
|
|
967
1317
|
try {
|
|
968
1318
|
assertManagedPaths(root, [path]);
|
|
969
1319
|
const entry = entries.get(path);
|
|
970
|
-
const full =
|
|
1320
|
+
const full = join10(root, path);
|
|
971
1321
|
const current = lstatSync2(full, { throwIfNoEntry: false });
|
|
972
1322
|
if (!entry?.exists) {
|
|
973
1323
|
if (current) unlinkSync2(full);
|
|
974
1324
|
continue;
|
|
975
1325
|
}
|
|
976
|
-
const original =
|
|
977
|
-
if (!current || !
|
|
1326
|
+
const original = readFileSync8(join10(backup, "files", path));
|
|
1327
|
+
if (!current || !readFileSync8(full).equals(original)) {
|
|
978
1328
|
if (current) unlinkSync2(full);
|
|
979
1329
|
writeFileSync2(full, original, { mode: 384 });
|
|
980
1330
|
}
|
|
@@ -985,7 +1335,7 @@ function rollback(root, backup, entries, touched, createdDirectories) {
|
|
|
985
1335
|
}
|
|
986
1336
|
for (const directory of [...createdDirectories].reverse()) {
|
|
987
1337
|
try {
|
|
988
|
-
if (
|
|
1338
|
+
if (readdirSync5(directory).length === 0) rmdirSync2(directory);
|
|
989
1339
|
} catch (error) {
|
|
990
1340
|
errors.push(`${directory}: ${errorMessage(error)}`);
|
|
991
1341
|
}
|
|
@@ -997,7 +1347,7 @@ function applyUpdateTransaction(root, writes, removals, backupDir) {
|
|
|
997
1347
|
assertManagedPaths(root, paths);
|
|
998
1348
|
const target = canonicalRoot(root);
|
|
999
1349
|
const backup = resolve4(
|
|
1000
|
-
backupDir ??
|
|
1350
|
+
backupDir ?? join10(homedir(), ".local", "state", "vaubaan-harness", "backups", randomUUID())
|
|
1001
1351
|
);
|
|
1002
1352
|
assertBackupLocation(target, backup);
|
|
1003
1353
|
let snapshot;
|
|
@@ -1015,12 +1365,12 @@ function applyUpdateTransaction(root, writes, removals, backupDir) {
|
|
|
1015
1365
|
try {
|
|
1016
1366
|
assertManagedPaths(target, paths);
|
|
1017
1367
|
for (const path of removals) {
|
|
1018
|
-
if (!lstatSync2(
|
|
1368
|
+
if (!lstatSync2(join10(target, path), { throwIfNoEntry: false })) continue;
|
|
1019
1369
|
touched.add(path);
|
|
1020
|
-
unlinkSync2(
|
|
1370
|
+
unlinkSync2(join10(target, path));
|
|
1021
1371
|
}
|
|
1022
1372
|
for (const file of writes) {
|
|
1023
|
-
const full =
|
|
1373
|
+
const full = join10(target, file.path);
|
|
1024
1374
|
createDirectories(dirname4(full), createdDirectories);
|
|
1025
1375
|
touched.add(file.path);
|
|
1026
1376
|
const entry = entries.get(file.path);
|
|
@@ -1040,13 +1390,13 @@ function applyUpdateTransaction(root, writes, removals, backupDir) {
|
|
|
1040
1390
|
}
|
|
1041
1391
|
|
|
1042
1392
|
// src/cli/update.ts
|
|
1043
|
-
import { existsSync as
|
|
1044
|
-
import { dirname as dirname5, join as
|
|
1393
|
+
import { existsSync as existsSync10, readFileSync as readFileSync10, readdirSync as readdirSync6, statSync as statSync6 } from "fs";
|
|
1394
|
+
import { dirname as dirname5, join as join12, resolve as resolve5 } from "path";
|
|
1045
1395
|
import { isDeepStrictEqual } from "util";
|
|
1046
1396
|
|
|
1047
1397
|
// src/cli/update-manifest.ts
|
|
1048
|
-
import { existsSync as
|
|
1049
|
-
import { join as
|
|
1398
|
+
import { existsSync as existsSync9, readFileSync as readFileSync9 } from "fs";
|
|
1399
|
+
import { join as join11 } from "path";
|
|
1050
1400
|
import { z as z4 } from "zod";
|
|
1051
1401
|
var EngineSchema = z4.enum(ENGINES);
|
|
1052
1402
|
var LegacySchema = z4.object({
|
|
@@ -1061,7 +1411,7 @@ var LegacySchema = z4.object({
|
|
|
1061
1411
|
var LEGACY_HOOK_FILES = [".claude/settings.json", ".codex/hooks.json"];
|
|
1062
1412
|
var LEGACY_HOOK_MARKER = "@vaubaan/harness stop-hook";
|
|
1063
1413
|
function currentContent(root, path) {
|
|
1064
|
-
return
|
|
1414
|
+
return existsSync10(join12(root, path)) ? readFileSync10(join12(root, path), "utf8") : void 0;
|
|
1065
1415
|
}
|
|
1066
1416
|
function checkArtifactConflicts(root, previous, writes, removals) {
|
|
1067
1417
|
const desired = new Map(writes.map((file) => [file.path, file.content]));
|
|
@@ -1095,7 +1445,7 @@ function carryMovedPaths(root, previous, warnings) {
|
|
|
1095
1445
|
let files = previous.files;
|
|
1096
1446
|
let fileHashes = previous.fileHashes;
|
|
1097
1447
|
for (const [from, to] of MOVED_PATHS) {
|
|
1098
|
-
if (!files.includes(from) ||
|
|
1448
|
+
if (!files.includes(from) || existsSync10(join12(root, from))) continue;
|
|
1099
1449
|
files = [...new Set(files.map((path) => path === from ? to : path))];
|
|
1100
1450
|
const hash = fileHashes?.[from];
|
|
1101
1451
|
if (fileHashes && hash !== void 0) {
|
|
@@ -1103,8 +1453,8 @@ function carryMovedPaths(root, previous, warnings) {
|
|
|
1103
1453
|
fileHashes = { ...rest, [to]: hash };
|
|
1104
1454
|
}
|
|
1105
1455
|
}
|
|
1106
|
-
const oldDir =
|
|
1107
|
-
if (
|
|
1456
|
+
const oldDir = join12(root, "docs/journeys");
|
|
1457
|
+
if (existsSync10(oldDir) && statSync6(oldDir).isDirectory() && readdirSync6(oldDir).length > 0) {
|
|
1108
1458
|
warnings.push(
|
|
1109
1459
|
"docs/journeys/ is now docs/intents/: run `git mv docs/journeys docs/intents`, then `npx @vaubaan/harness update .` again"
|
|
1110
1460
|
);
|
|
@@ -1118,12 +1468,33 @@ function legacyHookWarnings(root) {
|
|
|
1118
1468
|
const content = currentContent(root, path);
|
|
1119
1469
|
if (content?.includes(LEGACY_HOOK_MARKER)) {
|
|
1120
1470
|
warnings.push(
|
|
1121
|
-
`remove the harness Stop hook entry from ${path}: the
|
|
1471
|
+
`remove the harness Stop hook entry from ${path}: the stop-hook command was removed in 3.0 and the entry now fails; run \`npx @vaubaan/harness lint\` in CI and pre-commit instead`
|
|
1122
1472
|
);
|
|
1123
1473
|
}
|
|
1124
1474
|
}
|
|
1125
1475
|
return warnings;
|
|
1126
1476
|
}
|
|
1477
|
+
function renamedIdWarnings(root, overridesParent) {
|
|
1478
|
+
const used = loadProjectSkills(root).map((skill) => ({
|
|
1479
|
+
id: skill.meta.id,
|
|
1480
|
+
where: "docs/skills/"
|
|
1481
|
+
}));
|
|
1482
|
+
if (overridesParent) {
|
|
1483
|
+
const overrides = loadOverrides(overridesParent);
|
|
1484
|
+
for (const item of [...overrides?.add?.skills ?? [], ...overrides?.add?.cmds ?? []]) {
|
|
1485
|
+
used.push({ id: item.meta.id, where: ".harness-overrides/" });
|
|
1486
|
+
}
|
|
1487
|
+
for (const id of overrides?.disable ?? []) {
|
|
1488
|
+
used.push({ id, where: ".harness-overrides/disable.yaml" });
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
return used.flatMap(({ id, where }) => {
|
|
1492
|
+
const renamed = RENAMED_IDS.get(id);
|
|
1493
|
+
return renamed ? [
|
|
1494
|
+
`${where} names \`${id}\`, renamed \`${renamed}\` in 3.0: it no longer replaces or disables the shipped one \u2014 rename it`
|
|
1495
|
+
] : [];
|
|
1496
|
+
});
|
|
1497
|
+
}
|
|
1127
1498
|
function planInstallation(args, settings) {
|
|
1128
1499
|
const root = resolve5(args.targetDir);
|
|
1129
1500
|
const { engines } = settings;
|
|
@@ -1137,14 +1508,14 @@ function planInstallation(args, settings) {
|
|
|
1137
1508
|
assertManagedPaths(root, [...previous.files, ...preserved]);
|
|
1138
1509
|
const requestedOverrides = args.overridesDir ?? previous.overridesDir;
|
|
1139
1510
|
const overridesDir = args.overridesDir ? resolve5(args.overridesDir) : previous.overridesDir ? resolve5(root, previous.overridesDir) : root;
|
|
1140
|
-
if (requestedOverrides && !
|
|
1511
|
+
if (requestedOverrides && !existsSync10(join12(overridesDir, ".harness-overrides"))) {
|
|
1141
1512
|
throw new Error(`recorded overrides are missing: ${overridesDir}/.harness-overrides`);
|
|
1142
1513
|
}
|
|
1143
|
-
const hasOverrides =
|
|
1144
|
-
const disablePath =
|
|
1145
|
-
if (
|
|
1514
|
+
const hasOverrides = existsSync10(join12(overridesDir, ".harness-overrides"));
|
|
1515
|
+
const disablePath = join12(overridesDir, ".harness-overrides", "disable.yaml");
|
|
1516
|
+
if (existsSync10(disablePath)) {
|
|
1146
1517
|
try {
|
|
1147
|
-
DisableYamlSchema.parse(parseYAML(
|
|
1518
|
+
DisableYamlSchema.parse(parseYAML(readFileSync10(disablePath, "utf8")));
|
|
1148
1519
|
} catch {
|
|
1149
1520
|
throw new Error(`invalid override selection: ${disablePath}`);
|
|
1150
1521
|
}
|
|
@@ -1174,13 +1545,17 @@ function planInstallation(args, settings) {
|
|
|
1174
1545
|
...preserved.length ? { preservedFiles: preserved } : {}
|
|
1175
1546
|
};
|
|
1176
1547
|
const writes = output.filter((file) => currentContent(root, file.path) !== file.content);
|
|
1177
|
-
const existingRemovals = removals.filter((path) =>
|
|
1548
|
+
const existingRemovals = removals.filter((path) => existsSync10(join12(root, path)));
|
|
1178
1549
|
if (writes.length || existingRemovals.length || !isDeepStrictEqual(settings.previous, manifest)) {
|
|
1179
1550
|
manifest.renderedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
1180
1551
|
writes.push({ path: MANIFEST_FILENAME, content: `${JSON.stringify(manifest, null, 2)}
|
|
1181
1552
|
` });
|
|
1182
1553
|
}
|
|
1183
|
-
warnings.push(
|
|
1554
|
+
warnings.push(
|
|
1555
|
+
...rendered.output.warnings,
|
|
1556
|
+
...legacyHookWarnings(root),
|
|
1557
|
+
...renamedIdWarnings(root, hasOverrides ? overridesDir : void 0)
|
|
1558
|
+
);
|
|
1184
1559
|
if (preserved.length) warnings.push(`preserved user-owned artifacts: ${preserved.join(", ")}`);
|
|
1185
1560
|
return { writes, removals: existingRemovals, owned, manifest, warnings };
|
|
1186
1561
|
}
|
|
@@ -1193,7 +1568,7 @@ function writeFilesToTarget(files, targetDir) {
|
|
|
1193
1568
|
);
|
|
1194
1569
|
const written = [];
|
|
1195
1570
|
for (const f of files) {
|
|
1196
|
-
const full =
|
|
1571
|
+
const full = join13(targetDir, f.path);
|
|
1197
1572
|
mkdirSync2(dirname6(full), { recursive: true });
|
|
1198
1573
|
writeFileSync3(full, f.content);
|
|
1199
1574
|
written.push(f.path);
|
|
@@ -1217,7 +1592,7 @@ function initCommand(args) {
|
|
|
1217
1592
|
{ previous, sourceVersion: previous.version, engines }
|
|
1218
1593
|
);
|
|
1219
1594
|
const touchedExisting = [...plan.writes.map((file) => file.path), ...plan.removals].some(
|
|
1220
|
-
(path) => path !== MANIFEST_FILENAME &&
|
|
1595
|
+
(path) => path !== MANIFEST_FILENAME && existsSync11(join13(root, path))
|
|
1221
1596
|
);
|
|
1222
1597
|
let backupDir;
|
|
1223
1598
|
if (plan.writes.length || plan.removals.length) {
|
|
@@ -1226,7 +1601,7 @@ function initCommand(args) {
|
|
|
1226
1601
|
rmSync(backupDir, { recursive: true, force: true });
|
|
1227
1602
|
backupDir = void 0;
|
|
1228
1603
|
}
|
|
1229
|
-
pruneEmptyDirs(root, new Set(plan.removals.map((path) => dirname6(
|
|
1604
|
+
pruneEmptyDirs(root, new Set(plan.removals.map((path) => dirname6(join13(root, path)))));
|
|
1230
1605
|
}
|
|
1231
1606
|
return {
|
|
1232
1607
|
filesWritten: plan.owned,
|