@vaubaan/harness 2.4.0 → 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 +5 -1
- package/dist/render-CTx7VNOK.d.ts +0 -45
package/dist/parser/index.d.ts
CHANGED
|
@@ -11,18 +11,22 @@ declare const SkillFrontmatterSchema: z.ZodObject<{
|
|
|
11
11
|
description: z.ZodString;
|
|
12
12
|
engines: z.ZodOptional<z.ZodArray<z.ZodEnum<["claude-code", "codex-cli", "opencode"]>, "many">>;
|
|
13
13
|
requires: z.ZodOptional<z.ZodArray<z.ZodEnum<["multi-step", "slash-command", "inline-exec"]>, "many">>;
|
|
14
|
+
/** Rendered while one of these pillars is active; omitted = always. */
|
|
15
|
+
pillars: z.ZodOptional<z.ZodArray<z.ZodEnum<["readme", "spec", "decisions", "handbook", "tests", "workflow", "quality", "skills", "intents", "profiles"]>, "many">>;
|
|
14
16
|
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
15
17
|
}, "strict", z.ZodTypeAny, {
|
|
16
18
|
id: string;
|
|
17
19
|
description: string;
|
|
18
20
|
engines?: ("claude-code" | "codex-cli" | "opencode")[] | undefined;
|
|
19
21
|
requires?: ("multi-step" | "slash-command" | "inline-exec")[] | undefined;
|
|
22
|
+
pillars?: ("readme" | "spec" | "decisions" | "handbook" | "tests" | "workflow" | "quality" | "skills" | "intents" | "profiles")[] | undefined;
|
|
20
23
|
tags?: string[] | undefined;
|
|
21
24
|
}, {
|
|
22
25
|
id: string;
|
|
23
26
|
description: string;
|
|
24
27
|
engines?: ("claude-code" | "codex-cli" | "opencode")[] | undefined;
|
|
25
28
|
requires?: ("multi-step" | "slash-command" | "inline-exec")[] | undefined;
|
|
29
|
+
pillars?: ("readme" | "spec" | "decisions" | "handbook" | "tests" | "workflow" | "quality" | "skills" | "intents" | "profiles")[] | undefined;
|
|
26
30
|
tags?: string[] | undefined;
|
|
27
31
|
}>;
|
|
28
32
|
type SkillFrontmatter = z.infer<typeof SkillFrontmatterSchema>;
|
|
@@ -149,37 +153,60 @@ declare const IntentFrontmatterSchema: z.ZodObject<{
|
|
|
149
153
|
spec: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
|
|
150
154
|
last_reviewed: z.ZodUnion<[z.ZodDate, z.ZodString]>;
|
|
151
155
|
}, "strict", z.ZodTypeAny, {
|
|
156
|
+
spec: string | string[];
|
|
152
157
|
status: "proposed" | "implemented" | "deprecated";
|
|
153
158
|
title: string;
|
|
154
159
|
actors: string[];
|
|
155
|
-
spec: string | string[];
|
|
156
160
|
last_reviewed: string | Date;
|
|
157
161
|
}, {
|
|
162
|
+
spec: string | string[];
|
|
158
163
|
status: "proposed" | "implemented" | "deprecated";
|
|
159
164
|
title: string;
|
|
160
165
|
actors: string[];
|
|
161
|
-
spec: string | string[];
|
|
162
166
|
last_reviewed: string | Date;
|
|
163
167
|
}>;
|
|
164
168
|
type IntentFrontmatter = z.infer<typeof IntentFrontmatterSchema>;
|
|
169
|
+
declare const PROFILE_STATUSES: readonly ["hypothesis", "validated"];
|
|
170
|
+
type ProfileStatus = (typeof PROFILE_STATUSES)[number];
|
|
171
|
+
declare const ProfileFrontmatterSchema: z.ZodObject<{
|
|
172
|
+
title: z.ZodString;
|
|
173
|
+
status: z.ZodEnum<["hypothesis", "validated"]>;
|
|
174
|
+
evidence: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
175
|
+
last_reviewed: z.ZodUnion<[z.ZodDate, z.ZodString]>;
|
|
176
|
+
}, "strict", z.ZodTypeAny, {
|
|
177
|
+
status: "hypothesis" | "validated";
|
|
178
|
+
title: string;
|
|
179
|
+
last_reviewed: string | Date;
|
|
180
|
+
evidence?: string | string[] | undefined;
|
|
181
|
+
}, {
|
|
182
|
+
status: "hypothesis" | "validated";
|
|
183
|
+
title: string;
|
|
184
|
+
last_reviewed: string | Date;
|
|
185
|
+
evidence?: string | string[] | undefined;
|
|
186
|
+
}>;
|
|
187
|
+
type ProfileFrontmatter = z.infer<typeof ProfileFrontmatterSchema>;
|
|
165
188
|
declare const Schemas: {
|
|
166
189
|
readonly Skill: z.ZodObject<{
|
|
167
190
|
id: z.ZodString;
|
|
168
191
|
description: z.ZodString;
|
|
169
192
|
engines: z.ZodOptional<z.ZodArray<z.ZodEnum<["claude-code", "codex-cli", "opencode"]>, "many">>;
|
|
170
193
|
requires: z.ZodOptional<z.ZodArray<z.ZodEnum<["multi-step", "slash-command", "inline-exec"]>, "many">>;
|
|
194
|
+
/** Rendered while one of these pillars is active; omitted = always. */
|
|
195
|
+
pillars: z.ZodOptional<z.ZodArray<z.ZodEnum<["readme", "spec", "decisions", "handbook", "tests", "workflow", "quality", "skills", "intents", "profiles"]>, "many">>;
|
|
171
196
|
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
172
197
|
}, "strict", z.ZodTypeAny, {
|
|
173
198
|
id: string;
|
|
174
199
|
description: string;
|
|
175
200
|
engines?: ("claude-code" | "codex-cli" | "opencode")[] | undefined;
|
|
176
201
|
requires?: ("multi-step" | "slash-command" | "inline-exec")[] | undefined;
|
|
202
|
+
pillars?: ("readme" | "spec" | "decisions" | "handbook" | "tests" | "workflow" | "quality" | "skills" | "intents" | "profiles")[] | undefined;
|
|
177
203
|
tags?: string[] | undefined;
|
|
178
204
|
}, {
|
|
179
205
|
id: string;
|
|
180
206
|
description: string;
|
|
181
207
|
engines?: ("claude-code" | "codex-cli" | "opencode")[] | undefined;
|
|
182
208
|
requires?: ("multi-step" | "slash-command" | "inline-exec")[] | undefined;
|
|
209
|
+
pillars?: ("readme" | "spec" | "decisions" | "handbook" | "tests" | "workflow" | "quality" | "skills" | "intents" | "profiles")[] | undefined;
|
|
183
210
|
tags?: string[] | undefined;
|
|
184
211
|
}>;
|
|
185
212
|
readonly Cmd: z.ZodObject<{
|
|
@@ -265,18 +292,34 @@ declare const Schemas: {
|
|
|
265
292
|
spec: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
|
|
266
293
|
last_reviewed: z.ZodUnion<[z.ZodDate, z.ZodString]>;
|
|
267
294
|
}, "strict", z.ZodTypeAny, {
|
|
295
|
+
spec: string | string[];
|
|
268
296
|
status: "proposed" | "implemented" | "deprecated";
|
|
269
297
|
title: string;
|
|
270
298
|
actors: string[];
|
|
271
|
-
spec: string | string[];
|
|
272
299
|
last_reviewed: string | Date;
|
|
273
300
|
}, {
|
|
301
|
+
spec: string | string[];
|
|
274
302
|
status: "proposed" | "implemented" | "deprecated";
|
|
275
303
|
title: string;
|
|
276
304
|
actors: string[];
|
|
277
|
-
spec: string | string[];
|
|
278
305
|
last_reviewed: string | Date;
|
|
279
306
|
}>;
|
|
307
|
+
readonly Profile: z.ZodObject<{
|
|
308
|
+
title: z.ZodString;
|
|
309
|
+
status: z.ZodEnum<["hypothesis", "validated"]>;
|
|
310
|
+
evidence: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
311
|
+
last_reviewed: z.ZodUnion<[z.ZodDate, z.ZodString]>;
|
|
312
|
+
}, "strict", z.ZodTypeAny, {
|
|
313
|
+
status: "hypothesis" | "validated";
|
|
314
|
+
title: string;
|
|
315
|
+
last_reviewed: string | Date;
|
|
316
|
+
evidence?: string | string[] | undefined;
|
|
317
|
+
}, {
|
|
318
|
+
status: "hypothesis" | "validated";
|
|
319
|
+
title: string;
|
|
320
|
+
last_reviewed: string | Date;
|
|
321
|
+
evidence?: string | string[] | undefined;
|
|
322
|
+
}>;
|
|
280
323
|
};
|
|
281
324
|
declare class ParseError extends Error {
|
|
282
325
|
readonly file: string;
|
|
@@ -292,7 +335,7 @@ declare function parseCmdFile(filePath: string): Cmd;
|
|
|
292
335
|
declare const INTENTS_DIR = "docs/intents";
|
|
293
336
|
/** The generated index of the pillar; never an intent file. */
|
|
294
337
|
declare const INTENTS_INDEX_PATH = "docs/intents/README.md";
|
|
295
|
-
declare const NODE_FIELDS: readonly ["status", "spec", "anchors", "acceptance", "requires", "creates"];
|
|
338
|
+
declare const NODE_FIELDS: readonly ["status", "spec", "anchors", "acceptance", "requires", "creates", "relieves", "delivers"];
|
|
296
339
|
type NodeField = (typeof NODE_FIELDS)[number];
|
|
297
340
|
/** Fields only a terminal intent (a node with no sub-intent) may carry. */
|
|
298
341
|
declare const TERMINAL_FIELDS: ReadonlyArray<NodeField>;
|
|
@@ -318,6 +361,9 @@ interface IntentNode {
|
|
|
318
361
|
acceptance: string[];
|
|
319
362
|
requires: string[];
|
|
320
363
|
creates: string[];
|
|
364
|
+
/** Pains relieved and gains delivered: slugs of the actors' profiles (§9.1.4). */
|
|
365
|
+
relieves: string[];
|
|
366
|
+
delivers: string[];
|
|
321
367
|
unknownFields: Array<{
|
|
322
368
|
key: string;
|
|
323
369
|
line: number;
|
|
@@ -357,8 +403,52 @@ declare function readIntentFiles(targetDir: string): ParsedIntentFile[];
|
|
|
357
403
|
*/
|
|
358
404
|
declare function loadIntentFiles(targetDir: string): ParsedIntentFile[];
|
|
359
405
|
|
|
406
|
+
/** The profiles pillar (docs/spec/coding-agent-harness.md §9.1.4). */
|
|
407
|
+
declare const PROFILES_DIR = "docs/profiles";
|
|
408
|
+
/** The generated index of the pillar; never a profile file. */
|
|
409
|
+
declare const PROFILES_INDEX_PATH = "docs/profiles/README.md";
|
|
410
|
+
interface ProfileError {
|
|
411
|
+
line?: number;
|
|
412
|
+
message: string;
|
|
413
|
+
}
|
|
414
|
+
/** A pain or a gain: a bullet that opens with its name in bold. */
|
|
415
|
+
interface ProfileItem {
|
|
416
|
+
name: string;
|
|
417
|
+
/** `**Context rot**` gives `context-rot`, like an entity of the spec. */
|
|
418
|
+
slug: string;
|
|
419
|
+
/** 1-based line of the bullet. */
|
|
420
|
+
line: number;
|
|
421
|
+
}
|
|
422
|
+
interface ProfileFile {
|
|
423
|
+
meta?: ProfileFrontmatter;
|
|
424
|
+
title: string;
|
|
425
|
+
/** In rank order: the first is the most severe. */
|
|
426
|
+
pains: ProfileItem[];
|
|
427
|
+
gains: ProfileItem[];
|
|
428
|
+
errors: ProfileError[];
|
|
429
|
+
}
|
|
430
|
+
interface ParsedProfileFile extends ProfileFile {
|
|
431
|
+
/** Path from the repo root, e.g. `docs/profiles/lead-developer.md`. */
|
|
432
|
+
path: string;
|
|
433
|
+
/** File name, e.g. `lead-developer.md`. */
|
|
434
|
+
file: string;
|
|
435
|
+
/** The profile's name wherever it is referred to: the file name without `.md`. */
|
|
436
|
+
slug: string;
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Parses one profile file. Never throws: problems are collected in `errors`
|
|
440
|
+
* so a linter reports everything at once and the index still renders.
|
|
441
|
+
*/
|
|
442
|
+
declare function parseProfileFile(relPath: string, text: string): ProfileFile;
|
|
443
|
+
/** Profile files: `docs/profiles/*.md` minus the generated index, sorted by file name. */
|
|
444
|
+
declare function listProfileFiles(targetDir: string): string[];
|
|
445
|
+
/** Parses every profile file without throwing; linters read their `errors`. */
|
|
446
|
+
declare function readProfileFiles(targetDir: string): ParsedProfileFile[];
|
|
447
|
+
/** The frontmatter `evidence:` as a list. */
|
|
448
|
+
declare function profileEvidence(meta: ProfileFrontmatter | undefined): string[];
|
|
449
|
+
|
|
360
450
|
type Skill = ParsedFile<SkillFrontmatter>;
|
|
361
451
|
declare function parseSkill(filePath: string, source: string): Skill;
|
|
362
452
|
declare function parseSkillFile(filePath: string): Skill;
|
|
363
453
|
|
|
364
|
-
export { type Cmd, type CmdArg, type CmdFrontmatter, INTENTS_DIR, INTENTS_INDEX_PATH, INTENT_STATUSES, type IntentError, type IntentFile, type IntentFrontmatter, type IntentNode, type IntentStatus, NODE_FIELDS, type NodeField, ParseError, type ParsedFile, type ParsedIntentFile, Schemas, type Skill, type SkillFrontmatter, TERMINAL_FIELDS, listIntentFiles, loadIntentFiles, maskFencedCode, parseCmd, parseCmdFile, parseIntentFile, parseSkill, parseSkillFile, readIntentFiles };
|
|
454
|
+
export { type Cmd, type CmdArg, type CmdFrontmatter, INTENTS_DIR, INTENTS_INDEX_PATH, INTENT_STATUSES, type IntentError, type IntentFile, type IntentFrontmatter, type IntentNode, type IntentStatus, NODE_FIELDS, type NodeField, PROFILES_DIR, PROFILES_INDEX_PATH, PROFILE_STATUSES, ParseError, type ParsedFile, type ParsedIntentFile, type ParsedProfileFile, type ProfileError, type ProfileFile, type ProfileFrontmatter, type ProfileItem, type ProfileStatus, Schemas, type Skill, type SkillFrontmatter, TERMINAL_FIELDS, listIntentFiles, listProfileFiles, loadIntentFiles, maskFencedCode, parseCmd, parseCmdFile, parseIntentFile, parseProfileFile, parseSkill, parseSkillFile, profileEvidence, readIntentFiles, readProfileFiles };
|
package/dist/parser/index.js
CHANGED
|
@@ -5,6 +5,83 @@ import matter from "gray-matter";
|
|
|
5
5
|
// src/parser/schemas.ts
|
|
6
6
|
import { z } from "zod";
|
|
7
7
|
|
|
8
|
+
// src/pillars.ts
|
|
9
|
+
import { existsSync, readdirSync, statSync } from "fs";
|
|
10
|
+
import { join } from "path";
|
|
11
|
+
var PILLAR_IDS = [
|
|
12
|
+
"readme",
|
|
13
|
+
"spec",
|
|
14
|
+
"decisions",
|
|
15
|
+
"handbook",
|
|
16
|
+
"tests",
|
|
17
|
+
"workflow",
|
|
18
|
+
"quality",
|
|
19
|
+
"skills",
|
|
20
|
+
"intents",
|
|
21
|
+
"profiles"
|
|
22
|
+
];
|
|
23
|
+
var PILLARS = [
|
|
24
|
+
{ id: "readme", core: true },
|
|
25
|
+
{ id: "spec", dir: "docs/spec", core: true },
|
|
26
|
+
{
|
|
27
|
+
id: "decisions",
|
|
28
|
+
dir: "docs/decisions",
|
|
29
|
+
core: false,
|
|
30
|
+
starters: [{ template: "decisions-index.md.tmpl", path: "docs/decisions/README.md" }],
|
|
31
|
+
next: "write the first decision with the `harn-decision-record-writer` skill (`/harn-decision`)"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
id: "handbook",
|
|
35
|
+
dir: "docs/handbook",
|
|
36
|
+
core: false,
|
|
37
|
+
starters: [{ template: "handbook-index.md.tmpl", path: "docs/handbook/README.md" }],
|
|
38
|
+
next: "write the first handbook with the `harn-handbook-writer` skill (`/harn-handbook`)"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: "tests",
|
|
42
|
+
dir: "docs/tests",
|
|
43
|
+
core: false,
|
|
44
|
+
starters: [
|
|
45
|
+
{ template: "integration-tests.md.tmpl", path: "docs/tests/integration-tests.md" },
|
|
46
|
+
{ template: "e2e-tests.md.tmpl", path: "docs/tests/e2e-tests.md" }
|
|
47
|
+
],
|
|
48
|
+
next: "fill both test plans with the `harn-test-plan-writer` skill (`/harn-test-plan`); the lint fails on their placeholders until then"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: "workflow",
|
|
52
|
+
dir: "docs/workflow",
|
|
53
|
+
core: false,
|
|
54
|
+
starters: [{ template: "coding-workflow.md.tmpl", path: "docs/workflow/coding-workflow.md" }],
|
|
55
|
+
next: "fill the workflow with the `harn-workflow-writer` skill (`/harn-workflow`); the lint fails on its placeholders until then"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
id: "quality",
|
|
59
|
+
dir: "docs/quality",
|
|
60
|
+
core: false,
|
|
61
|
+
starters: [{ template: "code-quality.md.tmpl", path: "docs/quality/code-quality.md" }],
|
|
62
|
+
next: "fill docs/quality/code-quality.md by hand: the tools, the project's rules, the accepted deviations"
|
|
63
|
+
},
|
|
64
|
+
// Active as soon as it holds a `*.skill.md`: nothing to add.
|
|
65
|
+
{ id: "skills", dir: "docs/skills", core: false },
|
|
66
|
+
{
|
|
67
|
+
id: "intents",
|
|
68
|
+
dir: "docs/intents",
|
|
69
|
+
core: false,
|
|
70
|
+
starters: [],
|
|
71
|
+
next: "write the first intent with the `harn-intent-writer` skill (`/harn-intent <verb + object>`)"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
id: "profiles",
|
|
75
|
+
dir: "docs/profiles",
|
|
76
|
+
core: false,
|
|
77
|
+
starters: [],
|
|
78
|
+
next: "describe the first profile with the `harn-intent-writer` skill, from the research you point it to"
|
|
79
|
+
}
|
|
80
|
+
];
|
|
81
|
+
var ADDABLE_PILLARS = PILLARS.filter(
|
|
82
|
+
(pillar) => pillar.starters !== void 0
|
|
83
|
+
);
|
|
84
|
+
|
|
8
85
|
// src/types.ts
|
|
9
86
|
var ENGINES = ["claude-code", "codex-cli", "opencode"];
|
|
10
87
|
var CAPABILITIES = ["multi-step", "slash-command", "inline-exec"];
|
|
@@ -16,6 +93,8 @@ var SkillFrontmatterSchema = z.object({
|
|
|
16
93
|
description: z.string().min(1),
|
|
17
94
|
engines: z.array(z.enum(ENGINES)).min(1).optional(),
|
|
18
95
|
requires: z.array(z.enum(CAPABILITIES)).optional(),
|
|
96
|
+
/** Rendered while one of these pillars is active; omitted = always. */
|
|
97
|
+
pillars: z.array(z.enum(PILLAR_IDS)).min(1).optional(),
|
|
19
98
|
tags: z.array(z.string()).optional()
|
|
20
99
|
}).strict();
|
|
21
100
|
var CmdArgEnumSchema = z.object({
|
|
@@ -49,10 +128,18 @@ var IntentFrontmatterSchema = z.object({
|
|
|
49
128
|
spec: z.union([z.string().min(1), z.array(z.string().min(1)).min(1)]),
|
|
50
129
|
last_reviewed: z.union([z.date(), z.string().min(1)])
|
|
51
130
|
}).strict();
|
|
131
|
+
var PROFILE_STATUSES = ["hypothesis", "validated"];
|
|
132
|
+
var ProfileFrontmatterSchema = z.object({
|
|
133
|
+
title: z.string().min(1),
|
|
134
|
+
status: z.enum(PROFILE_STATUSES),
|
|
135
|
+
evidence: z.union([z.string().min(1), z.array(z.string().min(1)).min(1)]).optional(),
|
|
136
|
+
last_reviewed: z.union([z.date(), z.string().min(1)])
|
|
137
|
+
}).strict();
|
|
52
138
|
var Schemas = {
|
|
53
139
|
Skill: SkillFrontmatterSchema,
|
|
54
140
|
Cmd: CmdFrontmatterSchema,
|
|
55
|
-
Intent: IntentFrontmatterSchema
|
|
141
|
+
Intent: IntentFrontmatterSchema,
|
|
142
|
+
Profile: ProfileFrontmatterSchema
|
|
56
143
|
};
|
|
57
144
|
var ParseError = class extends Error {
|
|
58
145
|
constructor(file, issues) {
|
|
@@ -102,8 +189,8 @@ function parseSkillFile(filePath) {
|
|
|
102
189
|
}
|
|
103
190
|
|
|
104
191
|
// src/parser/intent.ts
|
|
105
|
-
import { existsSync, readFileSync as readFileSync2, readdirSync, statSync } from "fs";
|
|
106
|
-
import { basename, join } from "path";
|
|
192
|
+
import { existsSync as existsSync2, readFileSync as readFileSync2, readdirSync as readdirSync2, statSync as statSync2 } from "fs";
|
|
193
|
+
import { basename, join as join2 } from "path";
|
|
107
194
|
import matter2 from "gray-matter";
|
|
108
195
|
var INTENTS_DIR = "docs/intents";
|
|
109
196
|
var INTENTS_INDEX_PATH = `${INTENTS_DIR}/README.md`;
|
|
@@ -113,13 +200,17 @@ var NODE_FIELDS = [
|
|
|
113
200
|
"anchors",
|
|
114
201
|
"acceptance",
|
|
115
202
|
"requires",
|
|
116
|
-
"creates"
|
|
203
|
+
"creates",
|
|
204
|
+
"relieves",
|
|
205
|
+
"delivers"
|
|
117
206
|
];
|
|
118
207
|
var TERMINAL_FIELDS = [
|
|
119
208
|
"anchors",
|
|
120
209
|
"acceptance",
|
|
121
210
|
"requires",
|
|
122
|
-
"creates"
|
|
211
|
+
"creates",
|
|
212
|
+
"relieves",
|
|
213
|
+
"delivers"
|
|
123
214
|
];
|
|
124
215
|
var MASKED_LINE = "\0";
|
|
125
216
|
var FENCE_RE = /^ {0,3}(`{3,}|~{3,})/;
|
|
@@ -185,6 +276,8 @@ function newNode(title, level, line) {
|
|
|
185
276
|
acceptance: [],
|
|
186
277
|
requires: [],
|
|
187
278
|
creates: [],
|
|
279
|
+
relieves: [],
|
|
280
|
+
delivers: [],
|
|
188
281
|
unknownFields: []
|
|
189
282
|
};
|
|
190
283
|
}
|
|
@@ -284,14 +377,14 @@ function parseIntentFile(relPath, text) {
|
|
|
284
377
|
return { ...meta ? { meta } : {}, title, ...statement ? { statement } : {}, nodes, errors };
|
|
285
378
|
}
|
|
286
379
|
function listIntentFiles(targetDir) {
|
|
287
|
-
const dir =
|
|
288
|
-
if (!
|
|
289
|
-
return
|
|
380
|
+
const dir = join2(targetDir, INTENTS_DIR);
|
|
381
|
+
if (!existsSync2(dir) || !statSync2(dir).isDirectory()) return [];
|
|
382
|
+
return readdirSync2(dir).filter((f) => f.endsWith(".md") && f !== "README.md").filter((f) => statSync2(join2(dir, f)).isFile()).sort();
|
|
290
383
|
}
|
|
291
384
|
function readIntentFiles(targetDir) {
|
|
292
385
|
return listIntentFiles(targetDir).map((file) => {
|
|
293
386
|
const path = `${INTENTS_DIR}/${file}`;
|
|
294
|
-
const text = readFileSync2(
|
|
387
|
+
const text = readFileSync2(join2(targetDir, path), "utf8");
|
|
295
388
|
return { path, file, ...parseIntentFile(path, text) };
|
|
296
389
|
});
|
|
297
390
|
}
|
|
@@ -308,22 +401,139 @@ ${problems.join("\n")}`
|
|
|
308
401
|
}
|
|
309
402
|
return intentFiles;
|
|
310
403
|
}
|
|
404
|
+
|
|
405
|
+
// src/parser/profile.ts
|
|
406
|
+
import { existsSync as existsSync4, readFileSync as readFileSync4, readdirSync as readdirSync3, statSync as statSync4 } from "fs";
|
|
407
|
+
import { basename as basename2, join as join4 } from "path";
|
|
408
|
+
import matter4 from "gray-matter";
|
|
409
|
+
|
|
410
|
+
// src/parser/docs.ts
|
|
411
|
+
function entitySlug(term) {
|
|
412
|
+
return term.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
// src/linters/intent-util.ts
|
|
416
|
+
import { posix } from "path";
|
|
417
|
+
|
|
418
|
+
// src/linters/util.ts
|
|
419
|
+
import { execFileSync } from "child_process";
|
|
420
|
+
import { existsSync as existsSync3, readFileSync as readFileSync3, statSync as statSync3 } from "fs";
|
|
421
|
+
import { join as join3, relative } from "path";
|
|
422
|
+
import fg from "fast-glob";
|
|
423
|
+
import matter3 from "gray-matter";
|
|
424
|
+
|
|
425
|
+
// src/parser/profile.ts
|
|
426
|
+
var PROFILES_DIR = "docs/profiles";
|
|
427
|
+
var PROFILES_INDEX_PATH = `${PROFILES_DIR}/README.md`;
|
|
428
|
+
var PAINS_HEADING = /^(Pains|Irritants|Douleurs)\s*$/i;
|
|
429
|
+
var GAINS_HEADING = /^(Gains|B[ée]n[ée]fices)\s*$/i;
|
|
430
|
+
var BULLET = /^[-*]\s+(.*)$/;
|
|
431
|
+
var NAMED = /^\*\*([^*]+)\*\*/;
|
|
432
|
+
function parseFrontmatter2(text, errors) {
|
|
433
|
+
let data;
|
|
434
|
+
try {
|
|
435
|
+
data = matter4(text).data;
|
|
436
|
+
} catch (error) {
|
|
437
|
+
const reason = error instanceof Error ? error.message.split("\n")[0] : String(error);
|
|
438
|
+
errors.push({ line: 1, message: `invalid frontmatter YAML: ${reason}` });
|
|
439
|
+
return void 0;
|
|
440
|
+
}
|
|
441
|
+
const result = Schemas.Profile.safeParse(data);
|
|
442
|
+
if (result.success) return result.data;
|
|
443
|
+
for (const issue of result.error.issues) {
|
|
444
|
+
const where = issue.path.length ? ` \`${issue.path.join(".")}\`` : "";
|
|
445
|
+
errors.push({ line: 1, message: `frontmatter${where}: ${issue.message}` });
|
|
446
|
+
}
|
|
447
|
+
return void 0;
|
|
448
|
+
}
|
|
449
|
+
function parseProfileFile(relPath, text) {
|
|
450
|
+
const errors = [];
|
|
451
|
+
const meta = parseFrontmatter2(text, errors);
|
|
452
|
+
const lines = maskFencedCode(text.split(/\r?\n/));
|
|
453
|
+
const pains = [];
|
|
454
|
+
const gains = [];
|
|
455
|
+
let h1;
|
|
456
|
+
let current;
|
|
457
|
+
let start = 0;
|
|
458
|
+
if (lines[0]?.trim() === "---") {
|
|
459
|
+
const end = lines.findIndex((line, i) => i > 0 && /^(---|\.\.\.)\s*$/.test(line));
|
|
460
|
+
start = end < 0 ? lines.length : end + 1;
|
|
461
|
+
}
|
|
462
|
+
for (let i = start; i < lines.length; i++) {
|
|
463
|
+
const line = lines[i] ?? "";
|
|
464
|
+
const heading = parseHeading(line);
|
|
465
|
+
if (heading) {
|
|
466
|
+
if (heading.depth === 1 && h1 === void 0) h1 = heading.title;
|
|
467
|
+
if (current && heading.depth > current.depth) continue;
|
|
468
|
+
if (PAINS_HEADING.test(heading.title)) {
|
|
469
|
+
current = { kind: "pain", depth: heading.depth, items: pains };
|
|
470
|
+
} else if (GAINS_HEADING.test(heading.title)) {
|
|
471
|
+
current = { kind: "gain", depth: heading.depth, items: gains };
|
|
472
|
+
} else {
|
|
473
|
+
current = void 0;
|
|
474
|
+
}
|
|
475
|
+
continue;
|
|
476
|
+
}
|
|
477
|
+
if (!current) continue;
|
|
478
|
+
const bullet = BULLET.exec(line)?.[1];
|
|
479
|
+
if (bullet === void 0) continue;
|
|
480
|
+
const name = NAMED.exec(bullet)?.[1]?.trim();
|
|
481
|
+
const slug = name ? entitySlug(name) : "";
|
|
482
|
+
if (!name || !slug) {
|
|
483
|
+
errors.push({ line: i + 1, message: `a ${current.kind} opens with its name in bold` });
|
|
484
|
+
continue;
|
|
485
|
+
}
|
|
486
|
+
if (current.items.some((item) => item.slug === slug)) {
|
|
487
|
+
errors.push({ line: i + 1, message: `duplicate ${current.kind} \`${slug}\`` });
|
|
488
|
+
continue;
|
|
489
|
+
}
|
|
490
|
+
current.items.push({ name, slug, line: i + 1 });
|
|
491
|
+
}
|
|
492
|
+
if (pains.length === 0 && gains.length === 0) {
|
|
493
|
+
errors.push({ message: "a profile names at least one pain or one gain" });
|
|
494
|
+
}
|
|
495
|
+
const title = meta?.title ?? h1 ?? basename2(relPath, ".md");
|
|
496
|
+
return { ...meta ? { meta } : {}, title, pains, gains, errors };
|
|
497
|
+
}
|
|
498
|
+
function listProfileFiles(targetDir) {
|
|
499
|
+
const dir = join4(targetDir, PROFILES_DIR);
|
|
500
|
+
if (!existsSync4(dir) || !statSync4(dir).isDirectory()) return [];
|
|
501
|
+
return readdirSync3(dir).filter((f) => f.endsWith(".md") && f !== "README.md").filter((f) => statSync4(join4(dir, f)).isFile()).sort();
|
|
502
|
+
}
|
|
503
|
+
function readProfileFiles(targetDir) {
|
|
504
|
+
return listProfileFiles(targetDir).map((file) => {
|
|
505
|
+
const path = `${PROFILES_DIR}/${file}`;
|
|
506
|
+
const text = readFileSync4(join4(targetDir, path), "utf8");
|
|
507
|
+
return { path, file, slug: basename2(file, ".md"), ...parseProfileFile(path, text) };
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
function profileEvidence(meta) {
|
|
511
|
+
if (!meta?.evidence) return [];
|
|
512
|
+
return typeof meta.evidence === "string" ? [meta.evidence] : [...meta.evidence];
|
|
513
|
+
}
|
|
311
514
|
export {
|
|
312
515
|
INTENTS_DIR,
|
|
313
516
|
INTENTS_INDEX_PATH,
|
|
314
517
|
INTENT_STATUSES,
|
|
315
518
|
NODE_FIELDS,
|
|
519
|
+
PROFILES_DIR,
|
|
520
|
+
PROFILES_INDEX_PATH,
|
|
521
|
+
PROFILE_STATUSES,
|
|
316
522
|
ParseError,
|
|
317
523
|
Schemas,
|
|
318
524
|
TERMINAL_FIELDS,
|
|
319
525
|
listIntentFiles,
|
|
526
|
+
listProfileFiles,
|
|
320
527
|
loadIntentFiles,
|
|
321
528
|
maskFencedCode,
|
|
322
529
|
parseCmd,
|
|
323
530
|
parseCmdFile,
|
|
324
531
|
parseIntentFile,
|
|
532
|
+
parseProfileFile,
|
|
325
533
|
parseSkill,
|
|
326
534
|
parseSkillFile,
|
|
327
|
-
|
|
535
|
+
profileEvidence,
|
|
536
|
+
readIntentFiles,
|
|
537
|
+
readProfileFiles
|
|
328
538
|
};
|
|
329
539
|
//# sourceMappingURL=index.js.map
|