@vaubaan/harness 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -6
- package/dist/cli/index.js +541 -74
- package/dist/cli/index.js.map +1 -1
- package/dist/commands/doc-audit.cmd.md +1 -1
- package/dist/commands/journey.cmd.md +22 -0
- package/dist/commands/story.cmd.md +24 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +302 -54
- package/dist/index.js.map +1 -1
- package/dist/init.d.ts +1 -1
- package/dist/init.js +299 -51
- package/dist/init.js.map +1 -1
- package/dist/linters/index.js +521 -54
- package/dist/linters/index.js.map +1 -1
- package/dist/parser/index.d.ts +110 -1
- package/dist/parser/index.js +229 -2
- package/dist/parser/index.js.map +1 -1
- package/dist/{render-C-FWmUfX.d.ts → render-BzrBb_l4.d.ts} +3 -1
- package/dist/render.d.ts +1 -1
- package/dist/render.js +87 -8
- package/dist/render.js.map +1 -1
- package/dist/skills/doc-audit.skill.md +34 -4
- package/dist/skills/drift-detector.skill.md +36 -5
- package/dist/skills/handbook-writer.skill.md +3 -0
- package/dist/skills/journey-writer.skill.md +159 -0
- package/dist/templates/journey.md.tmpl +45 -0
- package/package.json +1 -1
package/dist/parser/index.d.ts
CHANGED
|
@@ -120,6 +120,28 @@ declare const CmdFrontmatterSchema: z.ZodObject<{
|
|
|
120
120
|
})[] | undefined;
|
|
121
121
|
}>;
|
|
122
122
|
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<{
|
|
126
|
+
title: z.ZodString;
|
|
127
|
+
status: z.ZodEnum<["proposed", "implemented", "deprecated"]>;
|
|
128
|
+
actors: z.ZodArray<z.ZodString, "many">;
|
|
129
|
+
spec: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
|
|
130
|
+
last_reviewed: z.ZodUnion<[z.ZodDate, z.ZodString]>;
|
|
131
|
+
}, "strict", z.ZodTypeAny, {
|
|
132
|
+
status: "proposed" | "implemented" | "deprecated";
|
|
133
|
+
title: string;
|
|
134
|
+
actors: string[];
|
|
135
|
+
spec: string | string[];
|
|
136
|
+
last_reviewed: string | Date;
|
|
137
|
+
}, {
|
|
138
|
+
status: "proposed" | "implemented" | "deprecated";
|
|
139
|
+
title: string;
|
|
140
|
+
actors: string[];
|
|
141
|
+
spec: string | string[];
|
|
142
|
+
last_reviewed: string | Date;
|
|
143
|
+
}>;
|
|
144
|
+
type JourneyFrontmatter = z.infer<typeof JourneyFrontmatterSchema>;
|
|
123
145
|
declare const Schemas: {
|
|
124
146
|
readonly Skill: z.ZodObject<{
|
|
125
147
|
id: z.ZodString;
|
|
@@ -204,6 +226,25 @@ declare const Schemas: {
|
|
|
204
226
|
default?: string | undefined;
|
|
205
227
|
})[] | undefined;
|
|
206
228
|
}>;
|
|
229
|
+
readonly Journey: z.ZodObject<{
|
|
230
|
+
title: z.ZodString;
|
|
231
|
+
status: z.ZodEnum<["proposed", "implemented", "deprecated"]>;
|
|
232
|
+
actors: z.ZodArray<z.ZodString, "many">;
|
|
233
|
+
spec: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
|
|
234
|
+
last_reviewed: z.ZodUnion<[z.ZodDate, z.ZodString]>;
|
|
235
|
+
}, "strict", z.ZodTypeAny, {
|
|
236
|
+
status: "proposed" | "implemented" | "deprecated";
|
|
237
|
+
title: string;
|
|
238
|
+
actors: string[];
|
|
239
|
+
spec: string | string[];
|
|
240
|
+
last_reviewed: string | Date;
|
|
241
|
+
}, {
|
|
242
|
+
status: "proposed" | "implemented" | "deprecated";
|
|
243
|
+
title: string;
|
|
244
|
+
actors: string[];
|
|
245
|
+
spec: string | string[];
|
|
246
|
+
last_reviewed: string | Date;
|
|
247
|
+
}>;
|
|
207
248
|
};
|
|
208
249
|
declare class ParseError extends Error {
|
|
209
250
|
readonly file: string;
|
|
@@ -215,8 +256,76 @@ type Cmd = ParsedFile<CmdFrontmatter>;
|
|
|
215
256
|
declare function parseCmd(filePath: string, source: string): Cmd;
|
|
216
257
|
declare function parseCmdFile(filePath: string): Cmd;
|
|
217
258
|
|
|
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";
|
|
263
|
+
declare const NODE_FIELDS: readonly ["status", "spec", "anchors", "acceptance", "requires", "creates"];
|
|
264
|
+
type NodeField = (typeof NODE_FIELDS)[number];
|
|
265
|
+
/** Fields only a leaf may carry. */
|
|
266
|
+
declare const LEAF_FIELDS: ReadonlyArray<NodeField>;
|
|
267
|
+
interface JourneyError {
|
|
268
|
+
line?: number;
|
|
269
|
+
message: string;
|
|
270
|
+
}
|
|
271
|
+
interface JourneyNode {
|
|
272
|
+
title: string;
|
|
273
|
+
/** Heading depth minus one: `##` is level 1. */
|
|
274
|
+
level: number;
|
|
275
|
+
/** 1-based line of the heading in the file. */
|
|
276
|
+
line: number;
|
|
277
|
+
/** Index of the parent node in `nodes`, absent for a level-1 node. */
|
|
278
|
+
parent?: number;
|
|
279
|
+
isLeaf: boolean;
|
|
280
|
+
/** Line of each known field the node declares. */
|
|
281
|
+
fieldLines: Partial<Record<NodeField, number>>;
|
|
282
|
+
status?: JourneyStatus;
|
|
283
|
+
spec?: string;
|
|
284
|
+
anchors: string[];
|
|
285
|
+
acceptance: string[];
|
|
286
|
+
requires: string[];
|
|
287
|
+
creates: string[];
|
|
288
|
+
unknownFields: Array<{
|
|
289
|
+
key: string;
|
|
290
|
+
line: number;
|
|
291
|
+
}>;
|
|
292
|
+
/** Nearest `status:` up the tree, else the file status. */
|
|
293
|
+
effectiveStatus?: JourneyStatus;
|
|
294
|
+
}
|
|
295
|
+
interface JourneyParse {
|
|
296
|
+
meta?: JourneyFrontmatter;
|
|
297
|
+
title: string;
|
|
298
|
+
story?: string;
|
|
299
|
+
nodes: JourneyNode[];
|
|
300
|
+
errors: JourneyError[];
|
|
301
|
+
}
|
|
302
|
+
interface ParsedJourney extends JourneyParse {
|
|
303
|
+
/** Path from the repo root, e.g. `docs/journeys/harness-a-project.md`. */
|
|
304
|
+
path: string;
|
|
305
|
+
/** File name, e.g. `harness-a-project.md`. */
|
|
306
|
+
file: string;
|
|
307
|
+
}
|
|
308
|
+
/** Replaces every line of fenced code (fences included), keeping line numbers. */
|
|
309
|
+
declare function maskFencedCode(lines: ReadonlyArray<string>): string[];
|
|
310
|
+
/**
|
|
311
|
+
* Parses one journey (docs/spec/coding-agent-harness.md §9.1.3). Never
|
|
312
|
+
* throws: frontmatter and node problems are collected in `errors` and the
|
|
313
|
+
* nodes are parsed regardless, so a linter reports everything at once.
|
|
314
|
+
*/
|
|
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[];
|
|
320
|
+
/**
|
|
321
|
+
* The journeys the render needs. A journey that does not parse fails the
|
|
322
|
+
* render, like an invalid project skill: `init`, `update` and
|
|
323
|
+
* `lint:generated-fresh` report it.
|
|
324
|
+
*/
|
|
325
|
+
declare function loadJourneys(targetDir: string): ParsedJourney[];
|
|
326
|
+
|
|
218
327
|
type Skill = ParsedFile<SkillFrontmatter>;
|
|
219
328
|
declare function parseSkill(filePath: string, source: string): Skill;
|
|
220
329
|
declare function parseSkillFile(filePath: string): Skill;
|
|
221
330
|
|
|
222
|
-
export { type Cmd, type CmdArg, type CmdFrontmatter, ParseError, type ParsedFile, Schemas, type Skill, type SkillFrontmatter, parseCmd, parseCmdFile, parseSkill, parseSkillFile };
|
|
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 };
|
package/dist/parser/index.js
CHANGED
|
@@ -37,9 +37,18 @@ var CmdFrontmatterSchema = z.object({
|
|
|
37
37
|
args: z.array(CmdArgSchema).optional(),
|
|
38
38
|
description: z.string().min(1)
|
|
39
39
|
}).strict();
|
|
40
|
+
var JOURNEY_STATUSES = ["proposed", "implemented", "deprecated"];
|
|
41
|
+
var JourneyFrontmatterSchema = z.object({
|
|
42
|
+
title: z.string().min(1),
|
|
43
|
+
status: z.enum(JOURNEY_STATUSES),
|
|
44
|
+
actors: z.array(z.string().min(1)).min(1),
|
|
45
|
+
spec: z.union([z.string().min(1), z.array(z.string().min(1)).min(1)]),
|
|
46
|
+
last_reviewed: z.union([z.date(), z.string().min(1)])
|
|
47
|
+
}).strict();
|
|
40
48
|
var Schemas = {
|
|
41
49
|
Skill: SkillFrontmatterSchema,
|
|
42
|
-
Cmd: CmdFrontmatterSchema
|
|
50
|
+
Cmd: CmdFrontmatterSchema,
|
|
51
|
+
Journey: JourneyFrontmatterSchema
|
|
43
52
|
};
|
|
44
53
|
var ParseError = class extends Error {
|
|
45
54
|
constructor(file, issues) {
|
|
@@ -87,12 +96,230 @@ function parseSkill(filePath, source) {
|
|
|
87
96
|
function parseSkillFile(filePath) {
|
|
88
97
|
return parseFileWithSchema(filePath, Schemas.Skill);
|
|
89
98
|
}
|
|
99
|
+
|
|
100
|
+
// src/parser/journey.ts
|
|
101
|
+
import { existsSync, readFileSync as readFileSync2, readdirSync, statSync } from "fs";
|
|
102
|
+
import { basename, join } from "path";
|
|
103
|
+
import matter2 from "gray-matter";
|
|
104
|
+
var JOURNEYS_DIR = "docs/journeys";
|
|
105
|
+
var JOURNEYS_INDEX_PATH = `${JOURNEYS_DIR}/README.md`;
|
|
106
|
+
var NODE_FIELDS = [
|
|
107
|
+
"status",
|
|
108
|
+
"spec",
|
|
109
|
+
"anchors",
|
|
110
|
+
"acceptance",
|
|
111
|
+
"requires",
|
|
112
|
+
"creates"
|
|
113
|
+
];
|
|
114
|
+
var LEAF_FIELDS = [
|
|
115
|
+
"anchors",
|
|
116
|
+
"acceptance",
|
|
117
|
+
"requires",
|
|
118
|
+
"creates"
|
|
119
|
+
];
|
|
120
|
+
var MASKED_LINE = "\0";
|
|
121
|
+
var FENCE_RE = /^ {0,3}(`{3,}|~{3,})/;
|
|
122
|
+
var HEADING_RE = /^(#{1,6})[ \t]+(.+?)(?:[ \t]+#+)?[ \t]*$/;
|
|
123
|
+
var FIELD_RE = /^([a-z][a-z-]*):\s*(.*)$/;
|
|
124
|
+
var LIST_ITEM_RE = /^\s*-\s+(.*)$/;
|
|
125
|
+
function maskFencedCode(lines) {
|
|
126
|
+
let fence;
|
|
127
|
+
return lines.map((line) => {
|
|
128
|
+
const m = FENCE_RE.exec(line);
|
|
129
|
+
if (fence !== void 0) {
|
|
130
|
+
if (m?.[1] && m[1][0] === fence[0] && m[1].length >= fence.length) fence = void 0;
|
|
131
|
+
return MASKED_LINE;
|
|
132
|
+
}
|
|
133
|
+
if (m?.[1]) {
|
|
134
|
+
fence = m[1];
|
|
135
|
+
return MASKED_LINE;
|
|
136
|
+
}
|
|
137
|
+
return line;
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
function parseHeading(line) {
|
|
141
|
+
const m = HEADING_RE.exec(line);
|
|
142
|
+
if (!m?.[1] || !m[2]) return void 0;
|
|
143
|
+
return { depth: m[1].length, title: m[2] };
|
|
144
|
+
}
|
|
145
|
+
function splitList(value) {
|
|
146
|
+
return value.split(",").map((v) => v.trim()).filter(Boolean);
|
|
147
|
+
}
|
|
148
|
+
function bodyStart(lines) {
|
|
149
|
+
if (lines[0]?.trim() !== "---") return 0;
|
|
150
|
+
for (let i = 1; i < lines.length; i++) {
|
|
151
|
+
const l = lines[i]?.trim();
|
|
152
|
+
if (l === "---" || l === "...") return i + 1;
|
|
153
|
+
}
|
|
154
|
+
return lines.length;
|
|
155
|
+
}
|
|
156
|
+
function parseFrontmatter(text, errors) {
|
|
157
|
+
let data;
|
|
158
|
+
try {
|
|
159
|
+
data = matter2(text).data;
|
|
160
|
+
} catch (error) {
|
|
161
|
+
const reason = error instanceof Error ? error.message.split("\n")[0] : String(error);
|
|
162
|
+
errors.push({ line: 1, message: `invalid frontmatter YAML: ${reason}` });
|
|
163
|
+
return void 0;
|
|
164
|
+
}
|
|
165
|
+
const result = Schemas.Journey.safeParse(data);
|
|
166
|
+
if (result.success) return result.data;
|
|
167
|
+
for (const issue of result.error.issues) {
|
|
168
|
+
const where = issue.path.length ? ` \`${issue.path.join(".")}\`` : "";
|
|
169
|
+
errors.push({ line: 1, message: `frontmatter${where}: ${issue.message}` });
|
|
170
|
+
}
|
|
171
|
+
return void 0;
|
|
172
|
+
}
|
|
173
|
+
function newNode(title, level, line) {
|
|
174
|
+
return {
|
|
175
|
+
title,
|
|
176
|
+
level,
|
|
177
|
+
line,
|
|
178
|
+
isLeaf: true,
|
|
179
|
+
fieldLines: {},
|
|
180
|
+
anchors: [],
|
|
181
|
+
acceptance: [],
|
|
182
|
+
requires: [],
|
|
183
|
+
creates: [],
|
|
184
|
+
unknownFields: []
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
function parseFields(node, lines, from, to, errors) {
|
|
188
|
+
let lastKey;
|
|
189
|
+
for (let i = from; i < to; i++) {
|
|
190
|
+
const line = lines[i] ?? "";
|
|
191
|
+
if (line.trim() === "") continue;
|
|
192
|
+
const lineNo = i + 1;
|
|
193
|
+
const field = FIELD_RE.exec(line.trimEnd());
|
|
194
|
+
if (field?.[1] !== void 0) {
|
|
195
|
+
const key = field[1];
|
|
196
|
+
const value = (field[2] ?? "").trim();
|
|
197
|
+
lastKey = key;
|
|
198
|
+
if (!NODE_FIELDS.includes(key)) {
|
|
199
|
+
node.unknownFields.push({ key, line: lineNo });
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
const known = key;
|
|
203
|
+
node.fieldLines[known] = lineNo;
|
|
204
|
+
if (known === "status") {
|
|
205
|
+
if (JOURNEY_STATUSES.includes(value)) {
|
|
206
|
+
node.status = value;
|
|
207
|
+
} else {
|
|
208
|
+
errors.push({
|
|
209
|
+
line: lineNo,
|
|
210
|
+
message: `invalid status \`${value}\` (expected ${JOURNEY_STATUSES.join(" | ")})`
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
} else if (known === "spec") {
|
|
214
|
+
node.spec = value;
|
|
215
|
+
} else if (known === "acceptance") {
|
|
216
|
+
if (value) node.acceptance.push(value);
|
|
217
|
+
} else {
|
|
218
|
+
node[known] = splitList(value);
|
|
219
|
+
}
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
const item = LIST_ITEM_RE.exec(line);
|
|
223
|
+
if (lastKey === "acceptance" && item) {
|
|
224
|
+
const text = (item[1] ?? "").trim();
|
|
225
|
+
if (text) node.acceptance.push(text);
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
function parseJourney(relPath, text) {
|
|
232
|
+
const errors = [];
|
|
233
|
+
const meta = parseFrontmatter(text, errors);
|
|
234
|
+
const lines = maskFencedCode(text.split(/\r?\n/));
|
|
235
|
+
const start = bodyStart(lines);
|
|
236
|
+
const headings = [];
|
|
237
|
+
for (let i = start; i < lines.length; i++) {
|
|
238
|
+
const h = parseHeading(lines[i] ?? "");
|
|
239
|
+
if (h) headings.push({ index: i, ...h });
|
|
240
|
+
}
|
|
241
|
+
const h1 = headings.find((h) => h.depth === 1);
|
|
242
|
+
let story;
|
|
243
|
+
if (h1) {
|
|
244
|
+
const paragraph = [];
|
|
245
|
+
for (let i = h1.index + 1; i < lines.length; i++) {
|
|
246
|
+
const line = lines[i] ?? "";
|
|
247
|
+
if (line.trim() === "") {
|
|
248
|
+
if (paragraph.length) break;
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
if (line === MASKED_LINE || parseHeading(line)) break;
|
|
252
|
+
paragraph.push(line.trim());
|
|
253
|
+
}
|
|
254
|
+
if (paragraph.length) story = paragraph.join(" ");
|
|
255
|
+
}
|
|
256
|
+
const nodes = [];
|
|
257
|
+
const stack = [];
|
|
258
|
+
for (const [k, h] of headings.entries()) {
|
|
259
|
+
if (h.depth < 2) continue;
|
|
260
|
+
const node = newNode(h.title, h.depth - 1, h.index + 1);
|
|
261
|
+
while (stack.length) {
|
|
262
|
+
const top = nodes[stack[stack.length - 1]];
|
|
263
|
+
if (top && top.level < node.level) break;
|
|
264
|
+
stack.pop();
|
|
265
|
+
}
|
|
266
|
+
const parentIndex = stack[stack.length - 1];
|
|
267
|
+
if (parentIndex !== void 0) {
|
|
268
|
+
node.parent = parentIndex;
|
|
269
|
+
const parent = nodes[parentIndex];
|
|
270
|
+
if (parent) parent.isLeaf = false;
|
|
271
|
+
}
|
|
272
|
+
const next = headings[k + 1];
|
|
273
|
+
parseFields(node, lines, h.index + 1, next ? next.index : lines.length, errors);
|
|
274
|
+
const inherited = parentIndex !== void 0 ? nodes[parentIndex]?.effectiveStatus : meta?.status;
|
|
275
|
+
node.effectiveStatus = node.status ?? inherited;
|
|
276
|
+
stack.push(nodes.length);
|
|
277
|
+
nodes.push(node);
|
|
278
|
+
}
|
|
279
|
+
const title = meta?.title ?? h1?.title ?? basename(relPath, ".md");
|
|
280
|
+
return { ...meta ? { meta } : {}, title, ...story ? { story } : {}, nodes, errors };
|
|
281
|
+
}
|
|
282
|
+
function listJourneyFiles(targetDir) {
|
|
283
|
+
const dir = join(targetDir, JOURNEYS_DIR);
|
|
284
|
+
if (!existsSync(dir) || !statSync(dir).isDirectory()) return [];
|
|
285
|
+
return readdirSync(dir).filter((f) => f.endsWith(".md") && f !== "README.md").filter((f) => statSync(join(dir, f)).isFile()).sort();
|
|
286
|
+
}
|
|
287
|
+
function readJourneys(targetDir) {
|
|
288
|
+
return listJourneyFiles(targetDir).map((file) => {
|
|
289
|
+
const path = `${JOURNEYS_DIR}/${file}`;
|
|
290
|
+
const text = readFileSync2(join(targetDir, path), "utf8");
|
|
291
|
+
return { path, file, ...parseJourney(path, text) };
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
function loadJourneys(targetDir) {
|
|
295
|
+
const journeys = readJourneys(targetDir);
|
|
296
|
+
const problems = journeys.flatMap(
|
|
297
|
+
(j) => j.errors.map((e) => ` - ${j.path}${e.line !== void 0 ? `:${e.line}` : ""}: ${e.message}`)
|
|
298
|
+
);
|
|
299
|
+
if (problems.length) {
|
|
300
|
+
throw new Error(
|
|
301
|
+
`invalid journeys (run \`npx @vaubaan/harness lint --pillar journeys\`):
|
|
302
|
+
${problems.join("\n")}`
|
|
303
|
+
);
|
|
304
|
+
}
|
|
305
|
+
return journeys;
|
|
306
|
+
}
|
|
90
307
|
export {
|
|
308
|
+
JOURNEYS_DIR,
|
|
309
|
+
JOURNEYS_INDEX_PATH,
|
|
310
|
+
JOURNEY_STATUSES,
|
|
311
|
+
LEAF_FIELDS,
|
|
312
|
+
NODE_FIELDS,
|
|
91
313
|
ParseError,
|
|
92
314
|
Schemas,
|
|
315
|
+
listJourneyFiles,
|
|
316
|
+
loadJourneys,
|
|
317
|
+
maskFencedCode,
|
|
93
318
|
parseCmd,
|
|
94
319
|
parseCmdFile,
|
|
320
|
+
parseJourney,
|
|
95
321
|
parseSkill,
|
|
96
|
-
parseSkillFile
|
|
322
|
+
parseSkillFile,
|
|
323
|
+
readJourneys
|
|
97
324
|
};
|
|
98
325
|
//# sourceMappingURL=index.js.map
|
package/dist/parser/index.js.map
CHANGED
|
@@ -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"],"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 Schemas = {\n Skill: SkillFrontmatterSchema,\n Cmd: CmdFrontmatterSchema,\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"],"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;AACrC,CAAC,EACA,OAAO;AAIV,IAAM,mBAAmB,EACtB,OAAO;AAAA,EACN,MAAM,EAAE,OAAO,EAAE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MAAM,MAAM;AAAA,EACpD;AACA,SAAO;AAAA,IACL,MAAM,OAAO;AAAA,IACb,MAAM,OAAO,QAAQ,KAAK;AAAA,IAC1B,YAAY;AAAA,EACd;AACF;AAEO,SAAS,oBACd,UACA,QACwB;AACxB,QAAM,SAAS,aAAa,UAAU,MAAM;AAC5C,SAAO,gBAAgB,UAAU,QAAQ,MAAM;AACjD;;;AG5BO,SAAS,SAAS,UAAkB,QAAqB;AAC9D,SAAO,gBAAgB,UAAU,QAAQ,QAAQ,GAAG;AACtD;AAEO,SAAS,aAAa,UAAuB;AAClD,SAAO,oBAAoB,UAAU,QAAQ,GAAG;AAClD;;;ACNO,SAAS,WAAW,UAAkB,QAAuB;AAClE,SAAO,gBAAgB,UAAU,QAAQ,QAAQ,KAAK;AACxD;AAEO,SAAS,eAAe,UAAyB;AACtD,SAAO,oBAAoB,UAAU,QAAQ,KAAK;AACpD;","names":[]}
|
|
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;\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;AACrC,CAAC,EACA,OAAO;AAIV,IAAM,mBAAmB,EACtB,OAAO;AAAA,EACN,MAAM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
1
|
+
import { Skill, Cmd, ParsedJourney } 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,6 +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
27
|
}
|
|
26
28
|
interface RenderOutput {
|
|
27
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-
|
|
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';
|
|
3
3
|
import 'zod';
|
package/dist/render.js
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
// src/
|
|
2
|
-
import {
|
|
1
|
+
// src/parser/journey.ts
|
|
2
|
+
import { existsSync, readFileSync, readdirSync, statSync } from "fs";
|
|
3
|
+
import { basename, join } from "path";
|
|
4
|
+
import matter from "gray-matter";
|
|
5
|
+
|
|
6
|
+
// src/parser/schemas.ts
|
|
7
|
+
import { z } from "zod";
|
|
3
8
|
|
|
4
9
|
// src/types.ts
|
|
10
|
+
var ENGINES = ["claude-code", "codex-cli", "opencode"];
|
|
11
|
+
var CAPABILITIES = ["multi-step", "slash-command", "inline-exec"];
|
|
5
12
|
var CAPABILITIES_MATRIX = {
|
|
6
13
|
"claude-code": ["multi-step", "slash-command", "inline-exec"],
|
|
7
14
|
"codex-cli": ["multi-step", "slash-command", "inline-exec"],
|
|
@@ -11,7 +18,49 @@ var DEGRADED_CAPABILITIES = {
|
|
|
11
18
|
"codex-cli": ["multi-step"]
|
|
12
19
|
};
|
|
13
20
|
|
|
21
|
+
// src/parser/schemas.ts
|
|
22
|
+
var IdSchema = z.string().min(1).regex(/^[a-z][a-z0-9-]*$/, "id must be kebab-case (lowercase + digits + hyphens)");
|
|
23
|
+
var SkillFrontmatterSchema = z.object({
|
|
24
|
+
id: IdSchema,
|
|
25
|
+
description: z.string().min(1),
|
|
26
|
+
engines: z.array(z.enum(ENGINES)).min(1).optional(),
|
|
27
|
+
requires: z.array(z.enum(CAPABILITIES)).optional(),
|
|
28
|
+
tags: z.array(z.string()).optional()
|
|
29
|
+
}).strict();
|
|
30
|
+
var CmdArgEnumSchema = z.object({
|
|
31
|
+
name: z.string().min(1),
|
|
32
|
+
type: z.literal("enum"),
|
|
33
|
+
values: z.array(z.string()).min(1),
|
|
34
|
+
default: z.string().optional()
|
|
35
|
+
}).strict();
|
|
36
|
+
var CmdArgStringSchema = z.object({
|
|
37
|
+
name: z.string().min(1),
|
|
38
|
+
type: z.literal("string"),
|
|
39
|
+
default: z.string().optional()
|
|
40
|
+
}).strict();
|
|
41
|
+
var CmdArgSchema = z.discriminatedUnion("type", [CmdArgEnumSchema, CmdArgStringSchema]);
|
|
42
|
+
var CmdFrontmatterSchema = z.object({
|
|
43
|
+
id: IdSchema,
|
|
44
|
+
trigger: z.string().regex(/^\/[a-z][a-z0-9-]*$/, "trigger must be /kebab-case"),
|
|
45
|
+
invokes_skill: IdSchema,
|
|
46
|
+
args: z.array(CmdArgSchema).optional(),
|
|
47
|
+
description: z.string().min(1)
|
|
48
|
+
}).strict();
|
|
49
|
+
var JOURNEY_STATUSES = ["proposed", "implemented", "deprecated"];
|
|
50
|
+
var JourneyFrontmatterSchema = z.object({
|
|
51
|
+
title: z.string().min(1),
|
|
52
|
+
status: z.enum(JOURNEY_STATUSES),
|
|
53
|
+
actors: z.array(z.string().min(1)).min(1),
|
|
54
|
+
spec: z.union([z.string().min(1), z.array(z.string().min(1)).min(1)]),
|
|
55
|
+
last_reviewed: z.union([z.date(), z.string().min(1)])
|
|
56
|
+
}).strict();
|
|
57
|
+
|
|
58
|
+
// src/parser/journey.ts
|
|
59
|
+
var JOURNEYS_DIR = "docs/journeys";
|
|
60
|
+
var JOURNEYS_INDEX_PATH = `${JOURNEYS_DIR}/README.md`;
|
|
61
|
+
|
|
14
62
|
// src/renderers/common.ts
|
|
63
|
+
import { stringify as yamlStringify } from "yaml";
|
|
15
64
|
function checkSkillCapabilities(skill, engine) {
|
|
16
65
|
const blockingWarnings = [];
|
|
17
66
|
const degradedWarnings = [];
|
|
@@ -67,12 +116,15 @@ function frontmatterDataForCmd(cmd) {
|
|
|
67
116
|
return data;
|
|
68
117
|
}
|
|
69
118
|
function buildUmbrellaBody(extras) {
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
119
|
+
const triggersBySkill = /* @__PURE__ */ new Map();
|
|
120
|
+
for (const c of extras.availableCommands) {
|
|
121
|
+
const triggers = triggersBySkill.get(c.meta.invokes_skill) ?? [];
|
|
122
|
+
triggers.push(c.meta.trigger);
|
|
123
|
+
triggersBySkill.set(c.meta.invokes_skill, triggers);
|
|
124
|
+
}
|
|
73
125
|
const skillLines = extras.availableSkills.map((s) => {
|
|
74
|
-
const
|
|
75
|
-
const label =
|
|
126
|
+
const triggers = triggersBySkill.get(s.meta.id) ?? [];
|
|
127
|
+
const label = triggers.length > 0 ? `\`${s.meta.id}\` (${triggers.map((t) => `\`${t}\``).join(", ")})` : `\`${s.meta.id}\``;
|
|
76
128
|
return `- ${label} \u2014 ${s.meta.description.split("\n")[0]}`;
|
|
77
129
|
});
|
|
78
130
|
const sections = [
|
|
@@ -92,11 +144,17 @@ function buildUmbrellaBody(extras) {
|
|
|
92
144
|
...extras.hasQualityDoc ? [
|
|
93
145
|
"- `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."
|
|
94
146
|
] : [],
|
|
147
|
+
...extras.hasJourneys ? [
|
|
148
|
+
"- `docs/journeys/<journey>.md` \u2014 user intentions and journeys, anchored to the code. `docs/journeys/README.md` is the generated index."
|
|
149
|
+
] : [],
|
|
95
150
|
"",
|
|
96
151
|
"## Doc-first",
|
|
97
152
|
"",
|
|
98
153
|
"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.",
|
|
99
154
|
"",
|
|
155
|
+
...extras.hasJourneys ? [
|
|
156
|
+
"- Visible change of behavior \u2192 a `proposed` leaf first (`/story <intent>`), never the code first."
|
|
157
|
+
] : [],
|
|
100
158
|
"- Missing spec for a subsystem you touch \u2192 **do not code**, report the gap.",
|
|
101
159
|
"- Implicit structural decision in your changes \u2192 an ADR (`/decision`).",
|
|
102
160
|
"- Changed feature behavior \u2192 update the matching handbook (`/handbook`).",
|
|
@@ -225,6 +283,23 @@ function getRenderer(engine) {
|
|
|
225
283
|
return RENDERERS[engine];
|
|
226
284
|
}
|
|
227
285
|
|
|
286
|
+
// src/renderers/journeys-index.ts
|
|
287
|
+
var INTRO = "User intentions and journeys of this project, anchored to the code. Generated by `@vaubaan/harness` from `docs/journeys/*.md`: edit the journeys, not this file, then run `npx @vaubaan/harness update .`.";
|
|
288
|
+
function buildJourneysIndex(journeys) {
|
|
289
|
+
const lines = ["# Journeys", "", INTRO, ""];
|
|
290
|
+
const sorted = [...journeys].sort((a, b) => a.file < b.file ? -1 : a.file > b.file ? 1 : 0);
|
|
291
|
+
for (const journey of sorted) {
|
|
292
|
+
const status = journey.meta?.status ?? "proposed";
|
|
293
|
+
const actors = journey.meta?.actors.join(", ") ?? "";
|
|
294
|
+
lines.push(`- [${journey.title}](./${journey.file}) \u2014 ${status} \xB7 ${actors}`);
|
|
295
|
+
for (const node of journey.nodes) {
|
|
296
|
+
lines.push(`${" ".repeat(node.level)}- ${node.title} \u2014 ${node.effectiveStatus ?? status}`);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
return `${lines.join("\n")}
|
|
300
|
+
`;
|
|
301
|
+
}
|
|
302
|
+
|
|
228
303
|
// src/render.ts
|
|
229
304
|
var RenderError = class extends Error {
|
|
230
305
|
constructor(message) {
|
|
@@ -294,12 +369,16 @@ function render(input) {
|
|
|
294
369
|
availableSkills: Array.from(exposedSkills.values()),
|
|
295
370
|
availableCommands: Array.from(exposedCmds.values()),
|
|
296
371
|
hasProjectSkills: (input.projectSkills?.length ?? 0) > 0,
|
|
297
|
-
hasQualityDoc: input.hasQualityDoc === true
|
|
372
|
+
hasQualityDoc: input.hasQualityDoc === true,
|
|
373
|
+
hasJourneys: (input.journeys?.length ?? 0) > 0
|
|
298
374
|
});
|
|
299
375
|
files.push({ path: "AGENTS.md", content: umbrellaContent });
|
|
300
376
|
if (engines.includes("claude-code")) {
|
|
301
377
|
files.push({ path: "CLAUDE.md", content: CLAUDE_MD_STUB });
|
|
302
378
|
}
|
|
379
|
+
if (input.journeys && input.journeys.length > 0) {
|
|
380
|
+
files.push({ path: JOURNEYS_INDEX_PATH, content: buildJourneysIndex(input.journeys) });
|
|
381
|
+
}
|
|
303
382
|
return { files, warnings };
|
|
304
383
|
}
|
|
305
384
|
export {
|