@vaubaan/harness 2.2.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.
@@ -31,28 +31,36 @@ declare const CmdArgSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
31
31
  type: z.ZodLiteral<"enum">;
32
32
  values: z.ZodArray<z.ZodString, "many">;
33
33
  default: z.ZodOptional<z.ZodString>;
34
+ /** False when the command runs without the argument. Defaults to true. */
35
+ required: z.ZodOptional<z.ZodBoolean>;
34
36
  }, "strict", z.ZodTypeAny, {
35
37
  values: string[];
36
38
  type: "enum";
37
39
  name: string;
38
40
  default?: string | undefined;
41
+ required?: boolean | undefined;
39
42
  }, {
40
43
  values: string[];
41
44
  type: "enum";
42
45
  name: string;
43
46
  default?: string | undefined;
47
+ required?: boolean | undefined;
44
48
  }>, z.ZodObject<{
45
49
  name: z.ZodString;
46
50
  type: z.ZodLiteral<"string">;
47
51
  default: z.ZodOptional<z.ZodString>;
52
+ /** False when the command runs without the argument. Defaults to true. */
53
+ required: z.ZodOptional<z.ZodBoolean>;
48
54
  }, "strict", z.ZodTypeAny, {
49
55
  type: "string";
50
56
  name: string;
51
57
  default?: string | undefined;
58
+ required?: boolean | undefined;
52
59
  }, {
53
60
  type: "string";
54
61
  name: string;
55
62
  default?: string | undefined;
63
+ required?: boolean | undefined;
56
64
  }>]>;
57
65
  type CmdArg = z.infer<typeof CmdArgSchema>;
58
66
  declare const CmdFrontmatterSchema: z.ZodObject<{
@@ -64,28 +72,36 @@ declare const CmdFrontmatterSchema: z.ZodObject<{
64
72
  type: z.ZodLiteral<"enum">;
65
73
  values: z.ZodArray<z.ZodString, "many">;
66
74
  default: z.ZodOptional<z.ZodString>;
75
+ /** False when the command runs without the argument. Defaults to true. */
76
+ required: z.ZodOptional<z.ZodBoolean>;
67
77
  }, "strict", z.ZodTypeAny, {
68
78
  values: string[];
69
79
  type: "enum";
70
80
  name: string;
71
81
  default?: string | undefined;
82
+ required?: boolean | undefined;
72
83
  }, {
73
84
  values: string[];
74
85
  type: "enum";
75
86
  name: string;
76
87
  default?: string | undefined;
88
+ required?: boolean | undefined;
77
89
  }>, z.ZodObject<{
78
90
  name: z.ZodString;
79
91
  type: z.ZodLiteral<"string">;
80
92
  default: z.ZodOptional<z.ZodString>;
93
+ /** False when the command runs without the argument. Defaults to true. */
94
+ required: z.ZodOptional<z.ZodBoolean>;
81
95
  }, "strict", z.ZodTypeAny, {
82
96
  type: "string";
83
97
  name: string;
84
98
  default?: string | undefined;
99
+ required?: boolean | undefined;
85
100
  }, {
86
101
  type: "string";
87
102
  name: string;
88
103
  default?: string | undefined;
104
+ required?: boolean | undefined;
89
105
  }>]>, "many">>;
90
106
  description: z.ZodString;
91
107
  }, "strict", z.ZodTypeAny, {
@@ -98,10 +114,12 @@ declare const CmdFrontmatterSchema: z.ZodObject<{
98
114
  type: "enum";
99
115
  name: string;
100
116
  default?: string | undefined;
117
+ required?: boolean | undefined;
101
118
  } | {
102
119
  type: "string";
103
120
  name: string;
104
121
  default?: string | undefined;
122
+ required?: boolean | undefined;
105
123
  })[] | undefined;
106
124
  }, {
107
125
  id: string;
@@ -113,16 +131,18 @@ declare const CmdFrontmatterSchema: z.ZodObject<{
113
131
  type: "enum";
114
132
  name: string;
115
133
  default?: string | undefined;
134
+ required?: boolean | undefined;
116
135
  } | {
117
136
  type: "string";
118
137
  name: string;
119
138
  default?: string | undefined;
139
+ required?: boolean | undefined;
120
140
  })[] | undefined;
121
141
  }>;
122
142
  type CmdFrontmatter = z.infer<typeof CmdFrontmatterSchema>;
123
- declare const JOURNEY_STATUSES: readonly ["proposed", "implemented", "deprecated"];
124
- type JourneyStatus = (typeof JOURNEY_STATUSES)[number];
125
- declare const JourneyFrontmatterSchema: z.ZodObject<{
143
+ declare const INTENT_STATUSES: readonly ["proposed", "implemented", "deprecated"];
144
+ type IntentStatus = (typeof INTENT_STATUSES)[number];
145
+ declare const IntentFrontmatterSchema: z.ZodObject<{
126
146
  title: z.ZodString;
127
147
  status: z.ZodEnum<["proposed", "implemented", "deprecated"]>;
128
148
  actors: z.ZodArray<z.ZodString, "many">;
@@ -141,7 +161,7 @@ declare const JourneyFrontmatterSchema: z.ZodObject<{
141
161
  spec: string | string[];
142
162
  last_reviewed: string | Date;
143
163
  }>;
144
- type JourneyFrontmatter = z.infer<typeof JourneyFrontmatterSchema>;
164
+ type IntentFrontmatter = z.infer<typeof IntentFrontmatterSchema>;
145
165
  declare const Schemas: {
146
166
  readonly Skill: z.ZodObject<{
147
167
  id: z.ZodString;
@@ -171,28 +191,36 @@ declare const Schemas: {
171
191
  type: z.ZodLiteral<"enum">;
172
192
  values: z.ZodArray<z.ZodString, "many">;
173
193
  default: z.ZodOptional<z.ZodString>;
194
+ /** False when the command runs without the argument. Defaults to true. */
195
+ required: z.ZodOptional<z.ZodBoolean>;
174
196
  }, "strict", z.ZodTypeAny, {
175
197
  values: string[];
176
198
  type: "enum";
177
199
  name: string;
178
200
  default?: string | undefined;
201
+ required?: boolean | undefined;
179
202
  }, {
180
203
  values: string[];
181
204
  type: "enum";
182
205
  name: string;
183
206
  default?: string | undefined;
207
+ required?: boolean | undefined;
184
208
  }>, z.ZodObject<{
185
209
  name: z.ZodString;
186
210
  type: z.ZodLiteral<"string">;
187
211
  default: z.ZodOptional<z.ZodString>;
212
+ /** False when the command runs without the argument. Defaults to true. */
213
+ required: z.ZodOptional<z.ZodBoolean>;
188
214
  }, "strict", z.ZodTypeAny, {
189
215
  type: "string";
190
216
  name: string;
191
217
  default?: string | undefined;
218
+ required?: boolean | undefined;
192
219
  }, {
193
220
  type: "string";
194
221
  name: string;
195
222
  default?: string | undefined;
223
+ required?: boolean | undefined;
196
224
  }>]>, "many">>;
197
225
  description: z.ZodString;
198
226
  }, "strict", z.ZodTypeAny, {
@@ -205,10 +233,12 @@ declare const Schemas: {
205
233
  type: "enum";
206
234
  name: string;
207
235
  default?: string | undefined;
236
+ required?: boolean | undefined;
208
237
  } | {
209
238
  type: "string";
210
239
  name: string;
211
240
  default?: string | undefined;
241
+ required?: boolean | undefined;
212
242
  })[] | undefined;
213
243
  }, {
214
244
  id: string;
@@ -220,13 +250,15 @@ declare const Schemas: {
220
250
  type: "enum";
221
251
  name: string;
222
252
  default?: string | undefined;
253
+ required?: boolean | undefined;
223
254
  } | {
224
255
  type: "string";
225
256
  name: string;
226
257
  default?: string | undefined;
258
+ required?: boolean | undefined;
227
259
  })[] | undefined;
228
260
  }>;
229
- readonly Journey: z.ZodObject<{
261
+ readonly Intent: z.ZodObject<{
230
262
  title: z.ZodString;
231
263
  status: z.ZodEnum<["proposed", "implemented", "deprecated"]>;
232
264
  actors: z.ZodArray<z.ZodString, "many">;
@@ -256,19 +288,19 @@ type Cmd = ParsedFile<CmdFrontmatter>;
256
288
  declare function parseCmd(filePath: string, source: string): Cmd;
257
289
  declare function parseCmdFile(filePath: string): Cmd;
258
290
 
259
- /** The optional journeys pillar (docs/spec/coding-agent-harness.md §9.1.3). */
260
- declare const JOURNEYS_DIR = "docs/journeys";
261
- /** The generated index of the pillar; never a journey. */
262
- declare const JOURNEYS_INDEX_PATH = "docs/journeys/README.md";
291
+ /** The optional intents pillar (docs/spec/coding-agent-harness.md §9.1.3). */
292
+ declare const INTENTS_DIR = "docs/intents";
293
+ /** The generated index of the pillar; never an intent file. */
294
+ declare const INTENTS_INDEX_PATH = "docs/intents/README.md";
263
295
  declare const NODE_FIELDS: readonly ["status", "spec", "anchors", "acceptance", "requires", "creates"];
264
296
  type NodeField = (typeof NODE_FIELDS)[number];
265
- /** Fields only a leaf may carry. */
266
- declare const LEAF_FIELDS: ReadonlyArray<NodeField>;
267
- interface JourneyError {
297
+ /** Fields only a terminal intent (a node with no sub-intent) may carry. */
298
+ declare const TERMINAL_FIELDS: ReadonlyArray<NodeField>;
299
+ interface IntentError {
268
300
  line?: number;
269
301
  message: string;
270
302
  }
271
- interface JourneyNode {
303
+ interface IntentNode {
272
304
  title: string;
273
305
  /** Heading depth minus one: `##` is level 1. */
274
306
  level: number;
@@ -276,10 +308,11 @@ interface JourneyNode {
276
308
  line: number;
277
309
  /** Index of the parent node in `nodes`, absent for a level-1 node. */
278
310
  parent?: number;
279
- isLeaf: boolean;
311
+ /** True when the node has no sub-intent: a terminal intent. */
312
+ isTerminal: boolean;
280
313
  /** Line of each known field the node declares. */
281
314
  fieldLines: Partial<Record<NodeField, number>>;
282
- status?: JourneyStatus;
315
+ status?: IntentStatus;
283
316
  spec?: string;
284
317
  anchors: string[];
285
318
  acceptance: string[];
@@ -290,17 +323,17 @@ interface JourneyNode {
290
323
  line: number;
291
324
  }>;
292
325
  /** Nearest `status:` up the tree, else the file status. */
293
- effectiveStatus?: JourneyStatus;
326
+ effectiveStatus?: IntentStatus;
294
327
  }
295
- interface JourneyParse {
296
- meta?: JourneyFrontmatter;
328
+ interface IntentFile {
329
+ meta?: IntentFrontmatter;
297
330
  title: string;
298
- story?: string;
299
- nodes: JourneyNode[];
300
- errors: JourneyError[];
331
+ statement?: string;
332
+ nodes: IntentNode[];
333
+ errors: IntentError[];
301
334
  }
302
- interface ParsedJourney extends JourneyParse {
303
- /** Path from the repo root, e.g. `docs/journeys/harness-a-project.md`. */
335
+ interface ParsedIntentFile extends IntentFile {
336
+ /** Path from the repo root, e.g. `docs/intents/harness-a-project.md`. */
304
337
  path: string;
305
338
  /** File name, e.g. `harness-a-project.md`. */
306
339
  file: string;
@@ -308,24 +341,24 @@ interface ParsedJourney extends JourneyParse {
308
341
  /** Replaces every line of fenced code (fences included), keeping line numbers. */
309
342
  declare function maskFencedCode(lines: ReadonlyArray<string>): string[];
310
343
  /**
311
- * Parses one journey (docs/spec/coding-agent-harness.md §9.1.3). Never
344
+ * Parses one intent file (docs/spec/coding-agent-harness.md §9.1.3). Never
312
345
  * throws: frontmatter and node problems are collected in `errors` and the
313
346
  * nodes are parsed regardless, so a linter reports everything at once.
314
347
  */
315
- declare function parseJourney(relPath: string, text: string): JourneyParse;
316
- /** Journey files: `docs/journeys/*.md` minus the generated index, sorted by file name. */
317
- declare function listJourneyFiles(targetDir: string): string[];
318
- /** Parses every journey without throwing; linters read their `errors`. */
319
- declare function readJourneys(targetDir: string): ParsedJourney[];
348
+ declare function parseIntentFile(relPath: string, text: string): IntentFile;
349
+ /** Intent files: `docs/intents/*.md` minus the generated index, sorted by file name. */
350
+ declare function listIntentFiles(targetDir: string): string[];
351
+ /** Parses every intent file without throwing; linters read their `errors`. */
352
+ declare function readIntentFiles(targetDir: string): ParsedIntentFile[];
320
353
  /**
321
- * The journeys the render needs. A journey that does not parse fails the
354
+ * The intent files the render needs. One that does not parse fails the
322
355
  * render, like an invalid project skill: `init`, `update` and
323
356
  * `lint:generated-fresh` report it.
324
357
  */
325
- declare function loadJourneys(targetDir: string): ParsedJourney[];
358
+ declare function loadIntentFiles(targetDir: string): ParsedIntentFile[];
326
359
 
327
360
  type Skill = ParsedFile<SkillFrontmatter>;
328
361
  declare function parseSkill(filePath: string, source: string): Skill;
329
362
  declare function parseSkillFile(filePath: string): Skill;
330
363
 
331
- export { type Cmd, type CmdArg, type CmdFrontmatter, JOURNEYS_DIR, JOURNEYS_INDEX_PATH, JOURNEY_STATUSES, type JourneyError, type JourneyFrontmatter, type JourneyNode, type JourneyParse, type JourneyStatus, LEAF_FIELDS, NODE_FIELDS, type NodeField, ParseError, type ParsedFile, type ParsedJourney, Schemas, type Skill, type SkillFrontmatter, listJourneyFiles, loadJourneys, maskFencedCode, parseCmd, parseCmdFile, parseJourney, parseSkill, parseSkillFile, readJourneys };
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 };
@@ -22,12 +22,16 @@ var CmdArgEnumSchema = z.object({
22
22
  name: z.string().min(1),
23
23
  type: z.literal("enum"),
24
24
  values: z.array(z.string()).min(1),
25
- default: z.string().optional()
25
+ default: z.string().optional(),
26
+ /** False when the command runs without the argument. Defaults to true. */
27
+ required: z.boolean().optional()
26
28
  }).strict();
27
29
  var CmdArgStringSchema = z.object({
28
30
  name: z.string().min(1),
29
31
  type: z.literal("string"),
30
- default: z.string().optional()
32
+ default: z.string().optional(),
33
+ /** False when the command runs without the argument. Defaults to true. */
34
+ required: z.boolean().optional()
31
35
  }).strict();
32
36
  var CmdArgSchema = z.discriminatedUnion("type", [CmdArgEnumSchema, CmdArgStringSchema]);
33
37
  var CmdFrontmatterSchema = z.object({
@@ -37,10 +41,10 @@ var CmdFrontmatterSchema = z.object({
37
41
  args: z.array(CmdArgSchema).optional(),
38
42
  description: z.string().min(1)
39
43
  }).strict();
40
- var JOURNEY_STATUSES = ["proposed", "implemented", "deprecated"];
41
- var JourneyFrontmatterSchema = z.object({
44
+ var INTENT_STATUSES = ["proposed", "implemented", "deprecated"];
45
+ var IntentFrontmatterSchema = z.object({
42
46
  title: z.string().min(1),
43
- status: z.enum(JOURNEY_STATUSES),
47
+ status: z.enum(INTENT_STATUSES),
44
48
  actors: z.array(z.string().min(1)).min(1),
45
49
  spec: z.union([z.string().min(1), z.array(z.string().min(1)).min(1)]),
46
50
  last_reviewed: z.union([z.date(), z.string().min(1)])
@@ -48,7 +52,7 @@ var JourneyFrontmatterSchema = z.object({
48
52
  var Schemas = {
49
53
  Skill: SkillFrontmatterSchema,
50
54
  Cmd: CmdFrontmatterSchema,
51
- Journey: JourneyFrontmatterSchema
55
+ Intent: IntentFrontmatterSchema
52
56
  };
53
57
  var ParseError = class extends Error {
54
58
  constructor(file, issues) {
@@ -97,12 +101,12 @@ function parseSkillFile(filePath) {
97
101
  return parseFileWithSchema(filePath, Schemas.Skill);
98
102
  }
99
103
 
100
- // src/parser/journey.ts
104
+ // src/parser/intent.ts
101
105
  import { existsSync, readFileSync as readFileSync2, readdirSync, statSync } from "fs";
102
106
  import { basename, join } from "path";
103
107
  import matter2 from "gray-matter";
104
- var JOURNEYS_DIR = "docs/journeys";
105
- var JOURNEYS_INDEX_PATH = `${JOURNEYS_DIR}/README.md`;
108
+ var INTENTS_DIR = "docs/intents";
109
+ var INTENTS_INDEX_PATH = `${INTENTS_DIR}/README.md`;
106
110
  var NODE_FIELDS = [
107
111
  "status",
108
112
  "spec",
@@ -111,7 +115,7 @@ var NODE_FIELDS = [
111
115
  "requires",
112
116
  "creates"
113
117
  ];
114
- var LEAF_FIELDS = [
118
+ var TERMINAL_FIELDS = [
115
119
  "anchors",
116
120
  "acceptance",
117
121
  "requires",
@@ -162,7 +166,7 @@ function parseFrontmatter(text, errors) {
162
166
  errors.push({ line: 1, message: `invalid frontmatter YAML: ${reason}` });
163
167
  return void 0;
164
168
  }
165
- const result = Schemas.Journey.safeParse(data);
169
+ const result = Schemas.Intent.safeParse(data);
166
170
  if (result.success) return result.data;
167
171
  for (const issue of result.error.issues) {
168
172
  const where = issue.path.length ? ` \`${issue.path.join(".")}\`` : "";
@@ -175,7 +179,7 @@ function newNode(title, level, line) {
175
179
  title,
176
180
  level,
177
181
  line,
178
- isLeaf: true,
182
+ isTerminal: true,
179
183
  fieldLines: {},
180
184
  anchors: [],
181
185
  acceptance: [],
@@ -202,12 +206,12 @@ function parseFields(node, lines, from, to, errors) {
202
206
  const known = key;
203
207
  node.fieldLines[known] = lineNo;
204
208
  if (known === "status") {
205
- if (JOURNEY_STATUSES.includes(value)) {
209
+ if (INTENT_STATUSES.includes(value)) {
206
210
  node.status = value;
207
211
  } else {
208
212
  errors.push({
209
213
  line: lineNo,
210
- message: `invalid status \`${value}\` (expected ${JOURNEY_STATUSES.join(" | ")})`
214
+ message: `invalid status \`${value}\` (expected ${INTENT_STATUSES.join(" | ")})`
211
215
  });
212
216
  }
213
217
  } else if (known === "spec") {
@@ -228,7 +232,7 @@ function parseFields(node, lines, from, to, errors) {
228
232
  return;
229
233
  }
230
234
  }
231
- function parseJourney(relPath, text) {
235
+ function parseIntentFile(relPath, text) {
232
236
  const errors = [];
233
237
  const meta = parseFrontmatter(text, errors);
234
238
  const lines = maskFencedCode(text.split(/\r?\n/));
@@ -239,7 +243,7 @@ function parseJourney(relPath, text) {
239
243
  if (h) headings.push({ index: i, ...h });
240
244
  }
241
245
  const h1 = headings.find((h) => h.depth === 1);
242
- let story;
246
+ let statement;
243
247
  if (h1) {
244
248
  const paragraph = [];
245
249
  for (let i = h1.index + 1; i < lines.length; i++) {
@@ -251,7 +255,7 @@ function parseJourney(relPath, text) {
251
255
  if (line === MASKED_LINE || parseHeading(line)) break;
252
256
  paragraph.push(line.trim());
253
257
  }
254
- if (paragraph.length) story = paragraph.join(" ");
258
+ if (paragraph.length) statement = paragraph.join(" ");
255
259
  }
256
260
  const nodes = [];
257
261
  const stack = [];
@@ -267,7 +271,7 @@ function parseJourney(relPath, text) {
267
271
  if (parentIndex !== void 0) {
268
272
  node.parent = parentIndex;
269
273
  const parent = nodes[parentIndex];
270
- if (parent) parent.isLeaf = false;
274
+ if (parent) parent.isTerminal = false;
271
275
  }
272
276
  const next = headings[k + 1];
273
277
  parseFields(node, lines, h.index + 1, next ? next.index : lines.length, errors);
@@ -277,49 +281,49 @@ function parseJourney(relPath, text) {
277
281
  nodes.push(node);
278
282
  }
279
283
  const title = meta?.title ?? h1?.title ?? basename(relPath, ".md");
280
- return { ...meta ? { meta } : {}, title, ...story ? { story } : {}, nodes, errors };
284
+ return { ...meta ? { meta } : {}, title, ...statement ? { statement } : {}, nodes, errors };
281
285
  }
282
- function listJourneyFiles(targetDir) {
283
- const dir = join(targetDir, JOURNEYS_DIR);
286
+ function listIntentFiles(targetDir) {
287
+ const dir = join(targetDir, INTENTS_DIR);
284
288
  if (!existsSync(dir) || !statSync(dir).isDirectory()) return [];
285
289
  return readdirSync(dir).filter((f) => f.endsWith(".md") && f !== "README.md").filter((f) => statSync(join(dir, f)).isFile()).sort();
286
290
  }
287
- function readJourneys(targetDir) {
288
- return listJourneyFiles(targetDir).map((file) => {
289
- const path = `${JOURNEYS_DIR}/${file}`;
291
+ function readIntentFiles(targetDir) {
292
+ return listIntentFiles(targetDir).map((file) => {
293
+ const path = `${INTENTS_DIR}/${file}`;
290
294
  const text = readFileSync2(join(targetDir, path), "utf8");
291
- return { path, file, ...parseJourney(path, text) };
295
+ return { path, file, ...parseIntentFile(path, text) };
292
296
  });
293
297
  }
294
- function loadJourneys(targetDir) {
295
- const journeys = readJourneys(targetDir);
296
- const problems = journeys.flatMap(
298
+ function loadIntentFiles(targetDir) {
299
+ const intentFiles = readIntentFiles(targetDir);
300
+ const problems = intentFiles.flatMap(
297
301
  (j) => j.errors.map((e) => ` - ${j.path}${e.line !== void 0 ? `:${e.line}` : ""}: ${e.message}`)
298
302
  );
299
303
  if (problems.length) {
300
304
  throw new Error(
301
- `invalid journeys (run \`npx @vaubaan/harness lint --pillar journeys\`):
305
+ `invalid intents (run \`npx @vaubaan/harness lint --pillar intents\`):
302
306
  ${problems.join("\n")}`
303
307
  );
304
308
  }
305
- return journeys;
309
+ return intentFiles;
306
310
  }
307
311
  export {
308
- JOURNEYS_DIR,
309
- JOURNEYS_INDEX_PATH,
310
- JOURNEY_STATUSES,
311
- LEAF_FIELDS,
312
+ INTENTS_DIR,
313
+ INTENTS_INDEX_PATH,
314
+ INTENT_STATUSES,
312
315
  NODE_FIELDS,
313
316
  ParseError,
314
317
  Schemas,
315
- listJourneyFiles,
316
- loadJourneys,
318
+ TERMINAL_FIELDS,
319
+ listIntentFiles,
320
+ loadIntentFiles,
317
321
  maskFencedCode,
318
322
  parseCmd,
319
323
  parseCmdFile,
320
- parseJourney,
324
+ parseIntentFile,
321
325
  parseSkill,
322
326
  parseSkillFile,
323
- readJourneys
327
+ readIntentFiles
324
328
  };
325
329
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/parser/common.ts","../../src/parser/schemas.ts","../../src/types.ts","../../src/parser/cmd.ts","../../src/parser/skill.ts","../../src/parser/journey.ts"],"sourcesContent":["import { readFileSync } from \"node:fs\";\nimport matter from \"gray-matter\";\nimport type { z } from \"zod\";\nimport { ParseError } from \"./schemas.js\";\n\nexport interface ParsedFile<T> {\n meta: T;\n body: string;\n sourcePath: string;\n}\n\nexport function parseWithSchema<T extends z.ZodTypeAny>(\n filePath: string,\n source: string,\n schema: T,\n): ParsedFile<z.infer<T>> {\n const parsed = matter(source);\n const result = schema.safeParse(parsed.data);\n if (!result.success) {\n throw new ParseError(filePath, result.error.issues);\n }\n return {\n meta: result.data,\n body: parsed.content.trim(),\n sourcePath: filePath,\n };\n}\n\nexport function parseFileWithSchema<T extends z.ZodTypeAny>(\n filePath: string,\n schema: T,\n): ParsedFile<z.infer<T>> {\n const source = readFileSync(filePath, \"utf8\");\n return parseWithSchema(filePath, source, schema);\n}\n","import { z } from \"zod\";\nimport { CAPABILITIES, ENGINES } from \"../types.js\";\n\nconst IdSchema = z\n .string()\n .min(1)\n .regex(/^[a-z][a-z0-9-]*$/, \"id must be kebab-case (lowercase + digits + hyphens)\");\n\nconst SkillFrontmatterSchema = z\n .object({\n id: IdSchema,\n description: z.string().min(1),\n engines: z.array(z.enum(ENGINES)).min(1).optional(),\n requires: z.array(z.enum(CAPABILITIES)).optional(),\n tags: z.array(z.string()).optional(),\n })\n .strict();\n\nexport type SkillFrontmatter = z.infer<typeof SkillFrontmatterSchema>;\n\nconst CmdArgEnumSchema = z\n .object({\n name: z.string().min(1),\n type: z.literal(\"enum\"),\n values: z.array(z.string()).min(1),\n default: z.string().optional(),\n })\n .strict();\n\nconst CmdArgStringSchema = z\n .object({\n name: z.string().min(1),\n type: z.literal(\"string\"),\n default: z.string().optional(),\n })\n .strict();\n\nconst CmdArgSchema = z.discriminatedUnion(\"type\", [CmdArgEnumSchema, CmdArgStringSchema]);\n\nexport type CmdArg = z.infer<typeof CmdArgSchema>;\n\nconst CmdFrontmatterSchema = z\n .object({\n id: IdSchema,\n trigger: z.string().regex(/^\\/[a-z][a-z0-9-]*$/, \"trigger must be /kebab-case\"),\n invokes_skill: IdSchema,\n args: z.array(CmdArgSchema).optional(),\n description: z.string().min(1),\n })\n .strict();\n\nexport type CmdFrontmatter = z.infer<typeof CmdFrontmatterSchema>;\n\nexport const JOURNEY_STATUSES = [\"proposed\", \"implemented\", \"deprecated\"] as const;\nexport type JourneyStatus = (typeof JOURNEY_STATUSES)[number];\n\n// gray-matter parses a bare YAML date (`2026-11-09`) into a Date object.\nconst JourneyFrontmatterSchema = z\n .object({\n title: z.string().min(1),\n status: z.enum(JOURNEY_STATUSES),\n actors: z.array(z.string().min(1)).min(1),\n spec: z.union([z.string().min(1), z.array(z.string().min(1)).min(1)]),\n last_reviewed: z.union([z.date(), z.string().min(1)]),\n })\n .strict();\n\nexport type JourneyFrontmatter = z.infer<typeof JourneyFrontmatterSchema>;\n\nexport const Schemas = {\n Skill: SkillFrontmatterSchema,\n Cmd: CmdFrontmatterSchema,\n Journey: JourneyFrontmatterSchema,\n} as const;\n\nexport class ParseError extends Error {\n constructor(\n public readonly file: string,\n public readonly issues: z.ZodIssue[],\n ) {\n const messages = issues\n .map((i) => ` - ${i.path.join(\".\") || \"<root>\"}: ${i.message}`)\n .join(\"\\n\");\n super(`Frontmatter validation failed for ${file}:\\n${messages}`);\n this.name = \"ParseError\";\n }\n}\n","export const ENGINES = [\"claude-code\", \"codex-cli\", \"opencode\"] as const;\nexport type Engine = (typeof ENGINES)[number];\n\nexport const ENGINE_ROOT_DIR: Record<Engine, string> = {\n \"claude-code\": \".claude\",\n \"codex-cli\": \".codex\",\n opencode: \".opencode\",\n};\n\nexport const CAPABILITIES = [\"multi-step\", \"slash-command\", \"inline-exec\"] as const;\nexport type Capability = (typeof CAPABILITIES)[number];\n\nexport interface RenderedFile {\n path: string;\n content: string;\n}\n\nexport interface CapabilitiesMatrix {\n [engine: string]: ReadonlyArray<Capability>;\n}\n\nexport const CAPABILITIES_MATRIX: Record<Engine, ReadonlyArray<Capability>> = {\n \"claude-code\": [\"multi-step\", \"slash-command\", \"inline-exec\"],\n \"codex-cli\": [\"multi-step\", \"slash-command\", \"inline-exec\"],\n opencode: [\"multi-step\", \"slash-command\", \"inline-exec\"],\n};\n\nexport const DEGRADED_CAPABILITIES: Partial<Record<Engine, ReadonlyArray<Capability>>> = {\n \"codex-cli\": [\"multi-step\"],\n};\n\nexport function engineSupports(engine: Engine, capability: Capability): boolean {\n return CAPABILITIES_MATRIX[engine].includes(capability);\n}\n","import { parseFileWithSchema, parseWithSchema } from \"./common.js\";\nimport type { ParsedFile } from \"./common.js\";\nimport { type CmdFrontmatter, Schemas } from \"./schemas.js\";\n\nexport type Cmd = ParsedFile<CmdFrontmatter>;\n\nexport function parseCmd(filePath: string, source: string): Cmd {\n return parseWithSchema(filePath, source, Schemas.Cmd);\n}\n\nexport function parseCmdFile(filePath: string): Cmd {\n return parseFileWithSchema(filePath, Schemas.Cmd);\n}\n","import { parseFileWithSchema, parseWithSchema } from \"./common.js\";\nimport type { ParsedFile } from \"./common.js\";\nimport { Schemas, type SkillFrontmatter } from \"./schemas.js\";\n\nexport type Skill = ParsedFile<SkillFrontmatter>;\n\nexport function parseSkill(filePath: string, source: string): Skill {\n return parseWithSchema(filePath, source, Schemas.Skill);\n}\n\nexport function parseSkillFile(filePath: string): Skill {\n return parseFileWithSchema(filePath, Schemas.Skill);\n}\n","import { existsSync, readFileSync, readdirSync, statSync } from \"node:fs\";\nimport { basename, join } from \"node:path\";\nimport matter from \"gray-matter\";\nimport {\n JOURNEY_STATUSES,\n type JourneyFrontmatter,\n type JourneyStatus,\n Schemas,\n} from \"./schemas.js\";\n\n/** The optional journeys pillar (docs/spec/coding-agent-harness.md §9.1.3). */\nexport const JOURNEYS_DIR = \"docs/journeys\";\n/** The generated index of the pillar; never a journey. */\nexport const JOURNEYS_INDEX_PATH = `${JOURNEYS_DIR}/README.md`;\n\nexport const NODE_FIELDS = [\n \"status\",\n \"spec\",\n \"anchors\",\n \"acceptance\",\n \"requires\",\n \"creates\",\n] as const;\nexport type NodeField = (typeof NODE_FIELDS)[number];\n/** Fields only a leaf may carry. */\nexport const LEAF_FIELDS: ReadonlyArray<NodeField> = [\n \"anchors\",\n \"acceptance\",\n \"requires\",\n \"creates\",\n];\n\nexport interface JourneyError {\n line?: number;\n message: string;\n}\n\nexport interface JourneyNode {\n title: string;\n /** Heading depth minus one: `##` is level 1. */\n level: number;\n /** 1-based line of the heading in the file. */\n line: number;\n /** Index of the parent node in `nodes`, absent for a level-1 node. */\n parent?: number;\n isLeaf: boolean;\n /** Line of each known field the node declares. */\n fieldLines: Partial<Record<NodeField, number>>;\n status?: JourneyStatus;\n spec?: string;\n anchors: string[];\n acceptance: string[];\n requires: string[];\n creates: string[];\n unknownFields: Array<{ key: string; line: number }>;\n /** Nearest `status:` up the tree, else the file status. */\n effectiveStatus?: JourneyStatus;\n}\n\nexport interface JourneyParse {\n meta?: JourneyFrontmatter;\n title: string;\n story?: string;\n nodes: JourneyNode[];\n errors: JourneyError[];\n}\n\nexport interface ParsedJourney extends JourneyParse {\n /** Path from the repo root, e.g. `docs/journeys/harness-a-project.md`. */\n path: string;\n /** File name, e.g. `harness-a-project.md`. */\n file: string;\n}\n\n/** Stands for a line of fenced code: not blank, not a field, not a heading. */\nconst MASKED_LINE = \"\\u0000\";\nconst FENCE_RE = /^ {0,3}(`{3,}|~{3,})/;\nconst HEADING_RE = /^(#{1,6})[ \\t]+(.+?)(?:[ \\t]+#+)?[ \\t]*$/;\nconst FIELD_RE = /^([a-z][a-z-]*):\\s*(.*)$/;\nconst LIST_ITEM_RE = /^\\s*-\\s+(.*)$/;\n\n/** Replaces every line of fenced code (fences included), keeping line numbers. */\nexport function maskFencedCode(lines: ReadonlyArray<string>): string[] {\n let fence: string | undefined;\n return lines.map((line) => {\n const m = FENCE_RE.exec(line);\n if (fence !== undefined) {\n if (m?.[1] && m[1][0] === fence[0] && m[1].length >= fence.length) fence = undefined;\n return MASKED_LINE;\n }\n if (m?.[1]) {\n fence = m[1];\n return MASKED_LINE;\n }\n return line;\n });\n}\n\nexport function parseHeading(line: string): { depth: number; title: string } | undefined {\n const m = HEADING_RE.exec(line);\n if (!m?.[1] || !m[2]) return undefined;\n return { depth: m[1].length, title: m[2] };\n}\n\nfunction splitList(value: string): string[] {\n return value\n .split(\",\")\n .map((v) => v.trim())\n .filter(Boolean);\n}\n\n/** Index of the first body line, after the frontmatter block when there is one. */\nfunction bodyStart(lines: ReadonlyArray<string>): number {\n if (lines[0]?.trim() !== \"---\") return 0;\n for (let i = 1; i < lines.length; i++) {\n const l = lines[i]?.trim();\n if (l === \"---\" || l === \"...\") return i + 1;\n }\n return lines.length;\n}\n\nfunction parseFrontmatter(text: string, errors: JourneyError[]): JourneyFrontmatter | undefined {\n let data: Record<string, unknown>;\n try {\n data = matter(text).data;\n } catch (error) {\n const reason = error instanceof Error ? error.message.split(\"\\n\")[0] : String(error);\n errors.push({ line: 1, message: `invalid frontmatter YAML: ${reason}` });\n return undefined;\n }\n const result = Schemas.Journey.safeParse(data);\n if (result.success) return result.data;\n for (const issue of result.error.issues) {\n const where = issue.path.length ? ` \\`${issue.path.join(\".\")}\\`` : \"\";\n errors.push({ line: 1, message: `frontmatter${where}: ${issue.message}` });\n }\n return undefined;\n}\n\nfunction newNode(title: string, level: number, line: number): JourneyNode {\n return {\n title,\n level,\n line,\n isLeaf: true,\n fieldLines: {},\n anchors: [],\n acceptance: [],\n requires: [],\n creates: [],\n unknownFields: [],\n };\n}\n\n/** Reads the field block directly under a heading, up to its first non-field line. */\nfunction parseFields(\n node: JourneyNode,\n lines: ReadonlyArray<string>,\n from: number,\n to: number,\n errors: JourneyError[],\n): void {\n let lastKey: string | undefined;\n for (let i = from; i < to; i++) {\n const line = lines[i] ?? \"\";\n if (line.trim() === \"\") continue;\n const lineNo = i + 1;\n const field = FIELD_RE.exec(line.trimEnd());\n if (field?.[1] !== undefined) {\n const key = field[1];\n const value = (field[2] ?? \"\").trim();\n lastKey = key;\n if (!(NODE_FIELDS as ReadonlyArray<string>).includes(key)) {\n node.unknownFields.push({ key, line: lineNo });\n continue;\n }\n const known = key as NodeField;\n node.fieldLines[known] = lineNo;\n if (known === \"status\") {\n if ((JOURNEY_STATUSES as ReadonlyArray<string>).includes(value)) {\n node.status = value as JourneyStatus;\n } else {\n errors.push({\n line: lineNo,\n message: `invalid status \\`${value}\\` (expected ${JOURNEY_STATUSES.join(\" | \")})`,\n });\n }\n } else if (known === \"spec\") {\n node.spec = value;\n } else if (known === \"acceptance\") {\n if (value) node.acceptance.push(value);\n } else {\n node[known] = splitList(value);\n }\n continue;\n }\n const item = LIST_ITEM_RE.exec(line);\n if (lastKey === \"acceptance\" && item) {\n const text = (item[1] ?? \"\").trim();\n if (text) node.acceptance.push(text);\n continue;\n }\n return;\n }\n}\n\n/**\n * Parses one journey (docs/spec/coding-agent-harness.md §9.1.3). Never\n * throws: frontmatter and node problems are collected in `errors` and the\n * nodes are parsed regardless, so a linter reports everything at once.\n */\nexport function parseJourney(relPath: string, text: string): JourneyParse {\n const errors: JourneyError[] = [];\n const meta = parseFrontmatter(text, errors);\n const lines = maskFencedCode(text.split(/\\r?\\n/));\n const start = bodyStart(lines);\n\n const headings: Array<{ index: number; depth: number; title: string }> = [];\n for (let i = start; i < lines.length; i++) {\n const h = parseHeading(lines[i] ?? \"\");\n if (h) headings.push({ index: i, ...h });\n }\n\n const h1 = headings.find((h) => h.depth === 1);\n let story: string | undefined;\n if (h1) {\n const paragraph: string[] = [];\n for (let i = h1.index + 1; i < lines.length; i++) {\n const line = lines[i] ?? \"\";\n if (line.trim() === \"\") {\n if (paragraph.length) break;\n continue;\n }\n if (line === MASKED_LINE || parseHeading(line)) break;\n paragraph.push(line.trim());\n }\n if (paragraph.length) story = paragraph.join(\" \");\n }\n\n const nodes: JourneyNode[] = [];\n const stack: number[] = [];\n for (const [k, h] of headings.entries()) {\n if (h.depth < 2) continue;\n const node = newNode(h.title, h.depth - 1, h.index + 1);\n while (stack.length) {\n const top = nodes[stack[stack.length - 1] as number];\n if (top && top.level < node.level) break;\n stack.pop();\n }\n const parentIndex = stack[stack.length - 1];\n if (parentIndex !== undefined) {\n node.parent = parentIndex;\n const parent = nodes[parentIndex];\n if (parent) parent.isLeaf = false;\n }\n const next = headings[k + 1];\n parseFields(node, lines, h.index + 1, next ? next.index : lines.length, errors);\n const inherited =\n parentIndex !== undefined ? nodes[parentIndex]?.effectiveStatus : meta?.status;\n node.effectiveStatus = node.status ?? inherited;\n stack.push(nodes.length);\n nodes.push(node);\n }\n\n const title = meta?.title ?? h1?.title ?? basename(relPath, \".md\");\n return { ...(meta ? { meta } : {}), title, ...(story ? { story } : {}), nodes, errors };\n}\n\n/** Journey files: `docs/journeys/*.md` minus the generated index, sorted by file name. */\nexport function listJourneyFiles(targetDir: string): string[] {\n const dir = join(targetDir, JOURNEYS_DIR);\n if (!existsSync(dir) || !statSync(dir).isDirectory()) return [];\n return readdirSync(dir)\n .filter((f) => f.endsWith(\".md\") && f !== \"README.md\")\n .filter((f) => statSync(join(dir, f)).isFile())\n .sort();\n}\n\n/** Parses every journey without throwing; linters read their `errors`. */\nexport function readJourneys(targetDir: string): ParsedJourney[] {\n return listJourneyFiles(targetDir).map((file) => {\n const path = `${JOURNEYS_DIR}/${file}`;\n const text = readFileSync(join(targetDir, path), \"utf8\");\n return { path, file, ...parseJourney(path, text) };\n });\n}\n\n/**\n * The journeys the render needs. A journey that does not parse fails the\n * render, like an invalid project skill: `init`, `update` and\n * `lint:generated-fresh` report it.\n */\nexport function loadJourneys(targetDir: string): ParsedJourney[] {\n const journeys = readJourneys(targetDir);\n const problems = journeys.flatMap((j) =>\n j.errors.map((e) => ` - ${j.path}${e.line !== undefined ? `:${e.line}` : \"\"}: ${e.message}`),\n );\n if (problems.length) {\n throw new Error(\n `invalid journeys (run \\`npx @vaubaan/harness lint --pillar journeys\\`):\\n${problems.join(\"\\n\")}`,\n );\n }\n return journeys;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AY,IAAI,IAAI;AACpC,UAAM,OAAOC,cAAa,KAAK,WAAW,IAAI,GAAG,MAAM;AACvD,WAAO,EAAE,MAAM,MAAM,GAAG,aAAa,MAAM,IAAI,EAAE;AAAA,EACnD,CAAC;AACH;AAOO,SAAS,aAAa,WAAoC;AAC/D,QAAM,WAAW,aAAa,SAAS;AACvC,QAAM,WAAW,SAAS;AAAA,IAAQ,CAAC,MACjC,EAAE,OAAO,IAAI,CAAC,MAAM,OAAO,EAAE,IAAI,GAAG,EAAE,SAAS,SAAY,IAAI,EAAE,IAAI,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE;AAAA,EAC9F;AACA,MAAI,SAAS,QAAQ;AACnB,UAAM,IAAI;AAAA,MACR;AAAA,EAA4E,SAAS,KAAK,IAAI,CAAC;AAAA,IACjG;AAAA,EACF;AACA,SAAO;AACT;","names":["readFileSync","matter","matter","readFileSync"]}
1
+ {"version":3,"sources":["../../src/parser/common.ts","../../src/parser/schemas.ts","../../src/types.ts","../../src/parser/cmd.ts","../../src/parser/skill.ts","../../src/parser/intent.ts"],"sourcesContent":["import { readFileSync } from \"node:fs\";\nimport matter from \"gray-matter\";\nimport type { z } from \"zod\";\nimport { ParseError } from \"./schemas.js\";\n\nexport interface ParsedFile<T> {\n meta: T;\n body: string;\n sourcePath: string;\n}\n\nexport function parseWithSchema<T extends z.ZodTypeAny>(\n filePath: string,\n source: string,\n schema: T,\n): ParsedFile<z.infer<T>> {\n const parsed = matter(source);\n const result = schema.safeParse(parsed.data);\n if (!result.success) {\n throw new ParseError(filePath, result.error.issues);\n }\n return {\n meta: result.data,\n body: parsed.content.trim(),\n sourcePath: filePath,\n };\n}\n\nexport function parseFileWithSchema<T extends z.ZodTypeAny>(\n filePath: string,\n schema: T,\n): ParsedFile<z.infer<T>> {\n const source = readFileSync(filePath, \"utf8\");\n return parseWithSchema(filePath, source, schema);\n}\n","import { z } from \"zod\";\nimport { CAPABILITIES, ENGINES } from \"../types.js\";\n\nconst IdSchema = z\n .string()\n .min(1)\n .regex(/^[a-z][a-z0-9-]*$/, \"id must be kebab-case (lowercase + digits + hyphens)\");\n\nconst SkillFrontmatterSchema = z\n .object({\n id: IdSchema,\n description: z.string().min(1),\n engines: z.array(z.enum(ENGINES)).min(1).optional(),\n requires: z.array(z.enum(CAPABILITIES)).optional(),\n tags: z.array(z.string()).optional(),\n })\n .strict();\n\nexport type SkillFrontmatter = z.infer<typeof SkillFrontmatterSchema>;\n\nconst CmdArgEnumSchema = z\n .object({\n name: z.string().min(1),\n type: z.literal(\"enum\"),\n values: z.array(z.string()).min(1),\n default: z.string().optional(),\n /** False when the command runs without the argument. Defaults to true. */\n required: z.boolean().optional(),\n })\n .strict();\n\nconst CmdArgStringSchema = z\n .object({\n name: z.string().min(1),\n type: z.literal(\"string\"),\n default: z.string().optional(),\n /** False when the command runs without the argument. Defaults to true. */\n required: z.boolean().optional(),\n })\n .strict();\n\nconst CmdArgSchema = z.discriminatedUnion(\"type\", [CmdArgEnumSchema, CmdArgStringSchema]);\n\nexport type CmdArg = z.infer<typeof CmdArgSchema>;\n\nconst CmdFrontmatterSchema = z\n .object({\n id: IdSchema,\n trigger: z.string().regex(/^\\/[a-z][a-z0-9-]*$/, \"trigger must be /kebab-case\"),\n invokes_skill: IdSchema,\n args: z.array(CmdArgSchema).optional(),\n description: z.string().min(1),\n })\n .strict();\n\nexport type CmdFrontmatter = z.infer<typeof CmdFrontmatterSchema>;\n\nexport const INTENT_STATUSES = [\"proposed\", \"implemented\", \"deprecated\"] as const;\nexport type IntentStatus = (typeof INTENT_STATUSES)[number];\n\n// gray-matter parses a bare YAML date (`2026-11-09`) into a Date object.\nconst IntentFrontmatterSchema = z\n .object({\n title: z.string().min(1),\n status: z.enum(INTENT_STATUSES),\n actors: z.array(z.string().min(1)).min(1),\n spec: z.union([z.string().min(1), z.array(z.string().min(1)).min(1)]),\n last_reviewed: z.union([z.date(), z.string().min(1)]),\n })\n .strict();\n\nexport type IntentFrontmatter = z.infer<typeof IntentFrontmatterSchema>;\n\nexport const Schemas = {\n Skill: SkillFrontmatterSchema,\n Cmd: CmdFrontmatterSchema,\n Intent: IntentFrontmatterSchema,\n} as const;\n\nexport class ParseError extends Error {\n constructor(\n public readonly file: string,\n public readonly issues: z.ZodIssue[],\n ) {\n const messages = issues\n .map((i) => ` - ${i.path.join(\".\") || \"<root>\"}: ${i.message}`)\n .join(\"\\n\");\n super(`Frontmatter validation failed for ${file}:\\n${messages}`);\n this.name = \"ParseError\";\n }\n}\n","export const ENGINES = [\"claude-code\", \"codex-cli\", \"opencode\"] as const;\nexport type Engine = (typeof ENGINES)[number];\n\nexport const ENGINE_ROOT_DIR: Record<Engine, string> = {\n \"claude-code\": \".claude\",\n \"codex-cli\": \".codex\",\n opencode: \".opencode\",\n};\n\nexport const CAPABILITIES = [\"multi-step\", \"slash-command\", \"inline-exec\"] as const;\nexport type Capability = (typeof CAPABILITIES)[number];\n\nexport interface RenderedFile {\n path: string;\n content: string;\n}\n\nexport interface CapabilitiesMatrix {\n [engine: string]: ReadonlyArray<Capability>;\n}\n\nexport const CAPABILITIES_MATRIX: Record<Engine, ReadonlyArray<Capability>> = {\n \"claude-code\": [\"multi-step\", \"slash-command\", \"inline-exec\"],\n \"codex-cli\": [\"multi-step\", \"slash-command\", \"inline-exec\"],\n opencode: [\"multi-step\", \"slash-command\", \"inline-exec\"],\n};\n\nexport const DEGRADED_CAPABILITIES: Partial<Record<Engine, ReadonlyArray<Capability>>> = {\n \"codex-cli\": [\"multi-step\"],\n};\n\nexport function engineSupports(engine: Engine, capability: Capability): boolean {\n return CAPABILITIES_MATRIX[engine].includes(capability);\n}\n","import { parseFileWithSchema, parseWithSchema } from \"./common.js\";\nimport type { ParsedFile } from \"./common.js\";\nimport { type CmdFrontmatter, Schemas } from \"./schemas.js\";\n\nexport type Cmd = ParsedFile<CmdFrontmatter>;\n\nexport function parseCmd(filePath: string, source: string): Cmd {\n return parseWithSchema(filePath, source, Schemas.Cmd);\n}\n\nexport function parseCmdFile(filePath: string): Cmd {\n return parseFileWithSchema(filePath, Schemas.Cmd);\n}\n","import { parseFileWithSchema, parseWithSchema } from \"./common.js\";\nimport type { ParsedFile } from \"./common.js\";\nimport { Schemas, type SkillFrontmatter } from \"./schemas.js\";\n\nexport type Skill = ParsedFile<SkillFrontmatter>;\n\nexport function parseSkill(filePath: string, source: string): Skill {\n return parseWithSchema(filePath, source, Schemas.Skill);\n}\n\nexport function parseSkillFile(filePath: string): Skill {\n return parseFileWithSchema(filePath, Schemas.Skill);\n}\n","import { existsSync, readFileSync, readdirSync, statSync } from \"node:fs\";\nimport { basename, join } from \"node:path\";\nimport matter from \"gray-matter\";\nimport { INTENT_STATUSES, type IntentFrontmatter, type IntentStatus, Schemas } from \"./schemas.js\";\n\n/** The optional intents pillar (docs/spec/coding-agent-harness.md §9.1.3). */\nexport const INTENTS_DIR = \"docs/intents\";\n/** The generated index of the pillar; never an intent file. */\nexport const INTENTS_INDEX_PATH = `${INTENTS_DIR}/README.md`;\n\nexport const NODE_FIELDS = [\n \"status\",\n \"spec\",\n \"anchors\",\n \"acceptance\",\n \"requires\",\n \"creates\",\n] as const;\nexport type NodeField = (typeof NODE_FIELDS)[number];\n/** Fields only a terminal intent (a node with no sub-intent) may carry. */\nexport const TERMINAL_FIELDS: ReadonlyArray<NodeField> = [\n \"anchors\",\n \"acceptance\",\n \"requires\",\n \"creates\",\n];\n\nexport interface IntentError {\n line?: number;\n message: string;\n}\n\nexport interface IntentNode {\n title: string;\n /** Heading depth minus one: `##` is level 1. */\n level: number;\n /** 1-based line of the heading in the file. */\n line: number;\n /** Index of the parent node in `nodes`, absent for a level-1 node. */\n parent?: number;\n /** True when the node has no sub-intent: a terminal intent. */\n isTerminal: boolean;\n /** Line of each known field the node declares. */\n fieldLines: Partial<Record<NodeField, number>>;\n status?: IntentStatus;\n spec?: string;\n anchors: string[];\n acceptance: string[];\n requires: string[];\n creates: string[];\n unknownFields: Array<{ key: string; line: number }>;\n /** Nearest `status:` up the tree, else the file status. */\n effectiveStatus?: IntentStatus;\n}\n\nexport interface IntentFile {\n meta?: IntentFrontmatter;\n title: string;\n statement?: string;\n nodes: IntentNode[];\n errors: IntentError[];\n}\n\nexport interface ParsedIntentFile extends IntentFile {\n /** Path from the repo root, e.g. `docs/intents/harness-a-project.md`. */\n path: string;\n /** File name, e.g. `harness-a-project.md`. */\n file: string;\n}\n\n/** Stands for a line of fenced code: not blank, not a field, not a heading. */\nconst MASKED_LINE = \"\\u0000\";\nconst FENCE_RE = /^ {0,3}(`{3,}|~{3,})/;\nconst HEADING_RE = /^(#{1,6})[ \\t]+(.+?)(?:[ \\t]+#+)?[ \\t]*$/;\nconst FIELD_RE = /^([a-z][a-z-]*):\\s*(.*)$/;\nconst LIST_ITEM_RE = /^\\s*-\\s+(.*)$/;\n\n/** Replaces every line of fenced code (fences included), keeping line numbers. */\nexport function maskFencedCode(lines: ReadonlyArray<string>): string[] {\n let fence: string | undefined;\n return lines.map((line) => {\n const m = FENCE_RE.exec(line);\n if (fence !== undefined) {\n if (m?.[1] && m[1][0] === fence[0] && m[1].length >= fence.length) fence = undefined;\n return MASKED_LINE;\n }\n if (m?.[1]) {\n fence = m[1];\n return MASKED_LINE;\n }\n return line;\n });\n}\n\nexport function parseHeading(line: string): { depth: number; title: string } | undefined {\n const m = HEADING_RE.exec(line);\n if (!m?.[1] || !m[2]) return undefined;\n return { depth: m[1].length, title: m[2] };\n}\n\nfunction splitList(value: string): string[] {\n return value\n .split(\",\")\n .map((v) => v.trim())\n .filter(Boolean);\n}\n\n/** Index of the first body line, after the frontmatter block when there is one. */\nfunction bodyStart(lines: ReadonlyArray<string>): number {\n if (lines[0]?.trim() !== \"---\") return 0;\n for (let i = 1; i < lines.length; i++) {\n const l = lines[i]?.trim();\n if (l === \"---\" || l === \"...\") return i + 1;\n }\n return lines.length;\n}\n\nfunction parseFrontmatter(text: string, errors: IntentError[]): IntentFrontmatter | undefined {\n let data: Record<string, unknown>;\n try {\n data = matter(text).data;\n } catch (error) {\n const reason = error instanceof Error ? error.message.split(\"\\n\")[0] : String(error);\n errors.push({ line: 1, message: `invalid frontmatter YAML: ${reason}` });\n return undefined;\n }\n const result = Schemas.Intent.safeParse(data);\n if (result.success) return result.data;\n for (const issue of result.error.issues) {\n const where = issue.path.length ? ` \\`${issue.path.join(\".\")}\\`` : \"\";\n errors.push({ line: 1, message: `frontmatter${where}: ${issue.message}` });\n }\n return undefined;\n}\n\nfunction newNode(title: string, level: number, line: number): IntentNode {\n return {\n title,\n level,\n line,\n isTerminal: true,\n fieldLines: {},\n anchors: [],\n acceptance: [],\n requires: [],\n creates: [],\n unknownFields: [],\n };\n}\n\n/** Reads the field block directly under a heading, up to its first non-field line. */\nfunction parseFields(\n node: IntentNode,\n lines: ReadonlyArray<string>,\n from: number,\n to: number,\n errors: IntentError[],\n): void {\n let lastKey: string | undefined;\n for (let i = from; i < to; i++) {\n const line = lines[i] ?? \"\";\n if (line.trim() === \"\") continue;\n const lineNo = i + 1;\n const field = FIELD_RE.exec(line.trimEnd());\n if (field?.[1] !== undefined) {\n const key = field[1];\n const value = (field[2] ?? \"\").trim();\n lastKey = key;\n if (!(NODE_FIELDS as ReadonlyArray<string>).includes(key)) {\n node.unknownFields.push({ key, line: lineNo });\n continue;\n }\n const known = key as NodeField;\n node.fieldLines[known] = lineNo;\n if (known === \"status\") {\n if ((INTENT_STATUSES as ReadonlyArray<string>).includes(value)) {\n node.status = value as IntentStatus;\n } else {\n errors.push({\n line: lineNo,\n message: `invalid status \\`${value}\\` (expected ${INTENT_STATUSES.join(\" | \")})`,\n });\n }\n } else if (known === \"spec\") {\n node.spec = value;\n } else if (known === \"acceptance\") {\n if (value) node.acceptance.push(value);\n } else {\n node[known] = splitList(value);\n }\n continue;\n }\n const item = LIST_ITEM_RE.exec(line);\n if (lastKey === \"acceptance\" && item) {\n const text = (item[1] ?? \"\").trim();\n if (text) node.acceptance.push(text);\n continue;\n }\n return;\n }\n}\n\n/**\n * Parses one intent file (docs/spec/coding-agent-harness.md §9.1.3). Never\n * throws: frontmatter and node problems are collected in `errors` and the\n * nodes are parsed regardless, so a linter reports everything at once.\n */\nexport function parseIntentFile(relPath: string, text: string): IntentFile {\n const errors: IntentError[] = [];\n const meta = parseFrontmatter(text, errors);\n const lines = maskFencedCode(text.split(/\\r?\\n/));\n const start = bodyStart(lines);\n\n const headings: Array<{ index: number; depth: number; title: string }> = [];\n for (let i = start; i < lines.length; i++) {\n const h = parseHeading(lines[i] ?? \"\");\n if (h) headings.push({ index: i, ...h });\n }\n\n const h1 = headings.find((h) => h.depth === 1);\n let statement: string | undefined;\n if (h1) {\n const paragraph: string[] = [];\n for (let i = h1.index + 1; i < lines.length; i++) {\n const line = lines[i] ?? \"\";\n if (line.trim() === \"\") {\n if (paragraph.length) break;\n continue;\n }\n if (line === MASKED_LINE || parseHeading(line)) break;\n paragraph.push(line.trim());\n }\n if (paragraph.length) statement = paragraph.join(\" \");\n }\n\n const nodes: IntentNode[] = [];\n const stack: number[] = [];\n for (const [k, h] of headings.entries()) {\n if (h.depth < 2) continue;\n const node = newNode(h.title, h.depth - 1, h.index + 1);\n while (stack.length) {\n const top = nodes[stack[stack.length - 1] as number];\n if (top && top.level < node.level) break;\n stack.pop();\n }\n const parentIndex = stack[stack.length - 1];\n if (parentIndex !== undefined) {\n node.parent = parentIndex;\n const parent = nodes[parentIndex];\n if (parent) parent.isTerminal = false;\n }\n const next = headings[k + 1];\n parseFields(node, lines, h.index + 1, next ? next.index : lines.length, errors);\n const inherited =\n parentIndex !== undefined ? nodes[parentIndex]?.effectiveStatus : meta?.status;\n node.effectiveStatus = node.status ?? inherited;\n stack.push(nodes.length);\n nodes.push(node);\n }\n\n const title = meta?.title ?? h1?.title ?? basename(relPath, \".md\");\n return { ...(meta ? { meta } : {}), title, ...(statement ? { statement } : {}), nodes, errors };\n}\n\n/** Intent files: `docs/intents/*.md` minus the generated index, sorted by file name. */\nexport function listIntentFiles(targetDir: string): string[] {\n const dir = join(targetDir, INTENTS_DIR);\n if (!existsSync(dir) || !statSync(dir).isDirectory()) return [];\n return readdirSync(dir)\n .filter((f) => f.endsWith(\".md\") && f !== \"README.md\")\n .filter((f) => statSync(join(dir, f)).isFile())\n .sort();\n}\n\n/** Parses every intent file without throwing; linters read their `errors`. */\nexport function readIntentFiles(targetDir: string): ParsedIntentFile[] {\n return listIntentFiles(targetDir).map((file) => {\n const path = `${INTENTS_DIR}/${file}`;\n const text = readFileSync(join(targetDir, path), \"utf8\");\n return { path, file, ...parseIntentFile(path, text) };\n });\n}\n\n/**\n * The intent files the render needs. One that does not parse fails the\n * render, like an invalid project skill: `init`, `update` and\n * `lint:generated-fresh` report it.\n */\nexport function loadIntentFiles(targetDir: string): ParsedIntentFile[] {\n const intentFiles = readIntentFiles(targetDir);\n const problems = intentFiles.flatMap((j) =>\n j.errors.map((e) => ` - ${j.path}${e.line !== undefined ? `:${e.line}` : \"\"}: ${e.message}`),\n );\n if (problems.length) {\n throw new Error(\n `invalid intents (run \\`npx @vaubaan/harness lint --pillar intents\\`):\\n${problems.join(\"\\n\")}`,\n );\n }\n return intentFiles;\n}\n"],"mappings":";AAAA,SAAS,oBAAoB;AAC7B,OAAO,YAAY;;;ACDnB,SAAS,SAAS;;;ACAX,IAAM,UAAU,CAAC,eAAe,aAAa,UAAU;AASvD,IAAM,eAAe,CAAC,cAAc,iBAAiB,aAAa;;;ADNzE,IAAM,WAAW,EACd,OAAO,EACP,IAAI,CAAC,EACL,MAAM,qBAAqB,sDAAsD;AAEpF,IAAM,yBAAyB,EAC5B,OAAO;AAAA,EACN,IAAI;AAAA,EACJ,aAAa,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EAC7B,SAAS,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,EAAE,IAAI,CAAC,EAAE,SAAS;AAAA,EAClD,UAAU,EAAE,MAAM,EAAE,KAAK,YAAY,CAAC,EAAE,SAAS;AAAA,EACjD,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS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AA,MACR;AAAA,EAA0E,SAAS,KAAK,IAAI,CAAC;AAAA,IAC/F;AAAA,EACF;AACA,SAAO;AACT;","names":["readFileSync","matter","matter","readFileSync"]}
@@ -1,4 +1,4 @@
1
- import { Skill, Cmd, ParsedJourney } from './parser/index.js';
1
+ import { Skill, Cmd, ParsedIntentFile } from './parser/index.js';
2
2
 
3
3
  declare const ENGINES: readonly ["claude-code", "codex-cli", "opencode"];
4
4
  type Engine = (typeof ENGINES)[number];
@@ -22,8 +22,8 @@ interface RenderInput {
22
22
  projectSkills?: ReadonlyArray<Skill>;
23
23
  /** True when the target project ships `docs/quality/code-quality.md` (optional pillar). */
24
24
  hasQualityDoc?: boolean;
25
- /** The project's parsed `docs/journeys/*.md` (optional pillar); renders their index. */
26
- journeys?: ReadonlyArray<ParsedJourney>;
25
+ /** The project's parsed `docs/intents/*.md` (optional pillar); renders their index. */
26
+ intentFiles?: ReadonlyArray<ParsedIntentFile>;
27
27
  }
28
28
  interface RenderOutput {
29
29
  files: RenderedFile[];
package/dist/render.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import './parser/index.js';
2
- export { H as Harness, a as HarnessOverrides, R as RenderError, b as RenderInput, c as RenderOutput, e as applyOverrides, r as render } from './render-BzrBb_l4.js';
2
+ export { H as Harness, a as HarnessOverrides, R as RenderError, b as RenderInput, c as RenderOutput, e as applyOverrides, r as render } from './render-CTx7VNOK.js';
3
3
  import 'zod';