@vaubaan/harness 2.4.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +207 -83
- package/dist/cli/index.js +4165 -843
- package/dist/cli/index.js.map +1 -1
- package/dist/commands/harn-canvas.cmd.md +23 -0
- package/dist/commands/{decision.cmd.md → harn-decision.cmd.md} +6 -6
- package/dist/commands/{doc-audit.cmd.md → harn-doc-audit.cmd.md} +7 -7
- package/dist/commands/{drift.cmd.md → harn-drift.cmd.md} +6 -6
- package/dist/commands/{handbook.cmd.md → harn-handbook.cmd.md} +6 -6
- package/dist/commands/harn-improve.cmd.md +20 -0
- package/dist/commands/{intent.cmd.md → harn-intent.cmd.md} +9 -9
- package/dist/commands/{readme.cmd.md → harn-readme.cmd.md} +6 -6
- package/dist/commands/{spec.cmd.md → harn-spec.cmd.md} +6 -6
- package/dist/commands/{test-plan.cmd.md → harn-test-plan.cmd.md} +6 -6
- package/dist/commands/harn-upgrade.cmd.md +22 -0
- package/dist/commands/{workflow.cmd.md → harn-workflow.cmd.md} +6 -6
- package/dist/index.d.ts +32 -3
- package/dist/index.js +533 -96
- package/dist/index.js.map +1 -1
- package/dist/init.d.ts +1 -1
- package/dist/init.js +468 -93
- package/dist/init.js.map +1 -1
- package/dist/linters/index.d.ts +3 -34
- package/dist/linters/index.js +996 -554
- package/dist/linters/index.js.map +1 -1
- package/dist/parser/index.d.ts +96 -6
- package/dist/parser/index.js +220 -10
- package/dist/parser/index.js.map +1 -1
- package/dist/render-BhUar2gf.d.ts +81 -0
- package/dist/render.d.ts +1 -1
- package/dist/render.js +233 -22
- package/dist/render.js.map +1 -1
- package/dist/skills/harn-canvas-review.skill.md +87 -0
- package/dist/skills/{decision-record-writer.skill.md → harn-decision-record-writer.skill.md} +2 -1
- package/dist/skills/{doc-audit.skill.md → harn-doc-audit.skill.md} +75 -26
- package/dist/skills/{drift-detector.skill.md → harn-drift-detector.skill.md} +15 -14
- package/dist/skills/harn-guide.skill.md +137 -0
- package/dist/skills/{handbook-writer.skill.md → harn-handbook-writer.skill.md} +2 -1
- package/dist/skills/{intent-writer.skill.md → harn-intent-writer.skill.md} +83 -16
- package/dist/skills/{readme-writer.skill.md → harn-readme-writer.skill.md} +4 -4
- package/dist/skills/harn-self-improve.skill.md +84 -0
- package/dist/skills/{spec-writer.skill.md → harn-spec-writer.skill.md} +8 -8
- package/dist/skills/{test-plan-writer.skill.md → harn-test-plan-writer.skill.md} +6 -5
- package/dist/skills/harn-upgrade.skill.md +171 -0
- package/dist/skills/{workflow-writer.skill.md → harn-workflow-writer.skill.md} +6 -5
- package/dist/templates/decisions-index.md.tmpl +11 -0
- package/dist/templates/handbook-index.md.tmpl +8 -0
- package/dist/templates/profile.md.tmpl +30 -0
- package/dist/types-CfUByAIr.d.ts +35 -0
- package/dist/view/index.d.ts +117 -0
- package/dist/view/index.js +3987 -0
- package/dist/view/index.js.map +1 -0
- package/package.json +5 -1
- package/dist/render-CTx7VNOK.d.ts +0 -45
package/dist/parser/index.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","../../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,S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EAAE,SAAS,SAAY,IAAI,EAAE,IAAI,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE;AAAA,EAC9F;AACA,MAAI,SAAS,QAAQ;AACnB,UAAM,IAAI;AAAA,MACR;AAAA,EAA0E,SAAS,KAAK,IAAI,CAAC;AAAA,IAC/F;AAAA,EACF;AACA,SAAO;AACT;","names":["readFileSync","matter","matter","readFileSync"]}
|
|
1
|
+
{"version":3,"sources":["../../src/parser/common.ts","../../src/parser/schemas.ts","../../src/pillars.ts","../../src/types.ts","../../src/parser/cmd.ts","../../src/parser/skill.ts","../../src/parser/intent.ts","../../src/parser/profile.ts","../../src/parser/docs.ts","../../src/linters/intent-util.ts","../../src/linters/util.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 { PILLAR_IDS } from \"../pillars.js\";\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 /** Rendered while one of these pillars is active; omitted = always. */\n pillars: z.array(z.enum(PILLAR_IDS)).min(1).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 PROFILE_STATUSES = [\"hypothesis\", \"validated\"] as const;\nexport type ProfileStatus = (typeof PROFILE_STATUSES)[number];\n\nconst ProfileFrontmatterSchema = z\n .object({\n title: z.string().min(1),\n status: z.enum(PROFILE_STATUSES),\n evidence: z.union([z.string().min(1), z.array(z.string().min(1)).min(1)]).optional(),\n last_reviewed: z.union([z.date(), z.string().min(1)]),\n })\n .strict();\n\nexport type ProfileFrontmatter = z.infer<typeof ProfileFrontmatterSchema>;\n\nexport const Schemas = {\n Skill: SkillFrontmatterSchema,\n Cmd: CmdFrontmatterSchema,\n Intent: IntentFrontmatterSchema,\n Profile: ProfileFrontmatterSchema,\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","import { existsSync, readdirSync, statSync } from \"node:fs\";\nimport { join } from \"node:path\";\n\n/**\n * The pillars of the meta database (docs/spec/coding-agent-harness.md\n * §9.1.2). README and spec are the core, always active; every other pillar\n * is active when its folder under `docs/` exists\n * (docs/decisions/pillars-on-demand.md).\n */\nexport const PILLAR_IDS = [\n \"readme\",\n \"spec\",\n \"decisions\",\n \"handbook\",\n \"tests\",\n \"workflow\",\n \"quality\",\n \"skills\",\n \"intents\",\n \"profiles\",\n] as const;\nexport type PillarId = (typeof PILLAR_IDS)[number];\n\nexport interface StarterFile {\n /** Template under the package's `templates/`. */\n template: string;\n /** Destination from the repo root. */\n path: string;\n}\n\nexport interface Pillar {\n id: PillarId;\n /** Folder from the repo root; the README pillar has none. */\n dir?: string;\n /** Always active: its absence never deactivates anything. */\n core: boolean;\n /** Written by `add`, never over an existing file. Absent: `add` does not apply. */\n starters?: ReadonlyArray<StarterFile>;\n /** What to do once the pillar is added. */\n next?: string;\n}\n\nexport const PILLARS: ReadonlyArray<Pillar> = [\n { id: \"readme\", core: true },\n { id: \"spec\", dir: \"docs/spec\", core: true },\n {\n id: \"decisions\",\n dir: \"docs/decisions\",\n core: false,\n starters: [{ template: \"decisions-index.md.tmpl\", path: \"docs/decisions/README.md\" }],\n next: \"write the first decision with the `harn-decision-record-writer` skill (`/harn-decision`)\",\n },\n {\n id: \"handbook\",\n dir: \"docs/handbook\",\n core: false,\n starters: [{ template: \"handbook-index.md.tmpl\", path: \"docs/handbook/README.md\" }],\n next: \"write the first handbook with the `harn-handbook-writer` skill (`/harn-handbook`)\",\n },\n {\n id: \"tests\",\n dir: \"docs/tests\",\n core: false,\n starters: [\n { template: \"integration-tests.md.tmpl\", path: \"docs/tests/integration-tests.md\" },\n { template: \"e2e-tests.md.tmpl\", path: \"docs/tests/e2e-tests.md\" },\n ],\n next: \"fill both test plans with the `harn-test-plan-writer` skill (`/harn-test-plan`); the lint fails on their placeholders until then\",\n },\n {\n id: \"workflow\",\n dir: \"docs/workflow\",\n core: false,\n starters: [{ template: \"coding-workflow.md.tmpl\", path: \"docs/workflow/coding-workflow.md\" }],\n next: \"fill the workflow with the `harn-workflow-writer` skill (`/harn-workflow`); the lint fails on its placeholders until then\",\n },\n {\n id: \"quality\",\n dir: \"docs/quality\",\n core: false,\n starters: [{ template: \"code-quality.md.tmpl\", path: \"docs/quality/code-quality.md\" }],\n next: \"fill docs/quality/code-quality.md by hand: the tools, the project's rules, the accepted deviations\",\n },\n // Active as soon as it holds a `*.skill.md`: nothing to add.\n { id: \"skills\", dir: \"docs/skills\", core: false },\n {\n id: \"intents\",\n dir: \"docs/intents\",\n core: false,\n starters: [],\n next: \"write the first intent with the `harn-intent-writer` skill (`/harn-intent <verb + object>`)\",\n },\n {\n id: \"profiles\",\n dir: \"docs/profiles\",\n core: false,\n starters: [],\n next: \"describe the first profile with the `harn-intent-writer` skill, from the research you point it to\",\n },\n];\n\n/** The pillars `add` accepts. */\nexport const ADDABLE_PILLARS: ReadonlyArray<Pillar> = PILLARS.filter(\n (pillar) => pillar.starters !== undefined,\n);\n\nexport function getPillar(id: string): Pillar | undefined {\n return PILLARS.find((pillar) => pillar.id === id);\n}\n\nfunction isDirectory(path: string): boolean {\n return existsSync(path) && statSync(path).isDirectory();\n}\n\n/** A pillar is active when it is core or when its folder exists. */\nexport function isPillarActive(repoRoot: string, id: PillarId): boolean {\n const pillar = getPillar(id);\n if (!pillar) return false;\n if (pillar.core) return true;\n return pillar.dir !== undefined && isDirectory(join(repoRoot, pillar.dir));\n}\n\nexport function activePillars(repoRoot: string): Set<PillarId> {\n return new Set(PILLARS.filter((p) => isPillarActive(repoRoot, p.id)).map((p) => p.id));\n}\n\n/** Every pillar: what a preview render shows, with no project to read. */\nexport function allPillars(): Set<PillarId> {\n return new Set(PILLAR_IDS);\n}\n\n/**\n * Pillar folders that exist and hold no file at any depth. Git does not\n * record them, so the pillar would be active on one machine only.\n */\nexport function emptyPillarDirs(repoRoot: string): string[] {\n const holdsFile = (dir: string): boolean =>\n readdirSync(dir, { withFileTypes: true }).some((entry) =>\n entry.isDirectory() ? holdsFile(join(dir, entry.name)) : true,\n );\n return PILLARS.flatMap((pillar) => {\n if (!pillar.dir) return [];\n const full = join(repoRoot, pillar.dir);\n return isDirectory(full) && !holdsFile(full) ? [pillar.dir] : [];\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 \"relieves\",\n \"delivers\",\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 \"relieves\",\n \"delivers\",\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 /** Pains relieved and gains delivered: slugs of the actors' profiles (§9.1.4). */\n relieves: string[];\n delivers: 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 relieves: [],\n delivers: [],\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","import { existsSync, readFileSync, readdirSync, statSync } from \"node:fs\";\nimport { basename, join } from \"node:path\";\nimport matter from \"gray-matter\";\nimport { entitySlug } from \"../linters/intent-vocabulary.js\";\nimport { maskFencedCode, parseHeading } from \"./intent.js\";\nimport { type ProfileFrontmatter, Schemas } from \"./schemas.js\";\n\n/** The profiles pillar (docs/spec/coding-agent-harness.md §9.1.4). */\nexport const PROFILES_DIR = \"docs/profiles\";\n/** The generated index of the pillar; never a profile file. */\nexport const PROFILES_INDEX_PATH = `${PROFILES_DIR}/README.md`;\n\nexport interface ProfileError {\n line?: number;\n message: string;\n}\n\n/** A pain or a gain: a bullet that opens with its name in bold. */\nexport interface ProfileItem {\n name: string;\n /** `**Context rot**` gives `context-rot`, like an entity of the spec. */\n slug: string;\n /** 1-based line of the bullet. */\n line: number;\n}\n\nexport interface ProfileFile {\n meta?: ProfileFrontmatter;\n title: string;\n /** In rank order: the first is the most severe. */\n pains: ProfileItem[];\n gains: ProfileItem[];\n errors: ProfileError[];\n}\n\nexport interface ParsedProfileFile extends ProfileFile {\n /** Path from the repo root, e.g. `docs/profiles/lead-developer.md`. */\n path: string;\n /** File name, e.g. `lead-developer.md`. */\n file: string;\n /** The profile's name wherever it is referred to: the file name without `.md`. */\n slug: string;\n}\n\n// English headings are canonical; the French ones are accepted like the\n// ADR and quality headings.\nconst PAINS_HEADING = /^(Pains|Irritants|Douleurs)\\s*$/i;\nconst GAINS_HEADING = /^(Gains|B[ée]n[ée]fices)\\s*$/i;\nconst BULLET = /^[-*]\\s+(.*)$/;\nconst NAMED = /^\\*\\*([^*]+)\\*\\*/;\n\nfunction parseFrontmatter(text: string, errors: ProfileError[]): ProfileFrontmatter | 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.Profile.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\n/**\n * Parses one profile file. Never throws: problems are collected in `errors`\n * so a linter reports everything at once and the index still renders.\n */\nexport function parseProfileFile(relPath: string, text: string): ProfileFile {\n const errors: ProfileError[] = [];\n const meta = parseFrontmatter(text, errors);\n const lines = maskFencedCode(text.split(/\\r?\\n/));\n const pains: ProfileItem[] = [];\n const gains: ProfileItem[] = [];\n let h1: string | undefined;\n let current: { kind: \"pain\" | \"gain\"; depth: number; items: ProfileItem[] } | undefined;\n // Skip the frontmatter block: its `---` lines and keys are not body.\n let start = 0;\n if (lines[0]?.trim() === \"---\") {\n const end = lines.findIndex((line, i) => i > 0 && /^(---|\\.\\.\\.)\\s*$/.test(line));\n start = end < 0 ? lines.length : end + 1;\n }\n for (let i = start; i < lines.length; i++) {\n const line = lines[i] ?? \"\";\n const heading = parseHeading(line);\n if (heading) {\n if (heading.depth === 1 && h1 === undefined) h1 = heading.title;\n if (current && heading.depth > current.depth) continue;\n if (PAINS_HEADING.test(heading.title)) {\n current = { kind: \"pain\", depth: heading.depth, items: pains };\n } else if (GAINS_HEADING.test(heading.title)) {\n current = { kind: \"gain\", depth: heading.depth, items: gains };\n } else {\n current = undefined;\n }\n continue;\n }\n if (!current) continue;\n const bullet = BULLET.exec(line)?.[1];\n if (bullet === undefined) continue;\n const name = NAMED.exec(bullet)?.[1]?.trim();\n const slug = name ? entitySlug(name) : \"\";\n if (!name || !slug) {\n errors.push({ line: i + 1, message: `a ${current.kind} opens with its name in bold` });\n continue;\n }\n if (current.items.some((item) => item.slug === slug)) {\n errors.push({ line: i + 1, message: `duplicate ${current.kind} \\`${slug}\\`` });\n continue;\n }\n current.items.push({ name, slug, line: i + 1 });\n }\n if (pains.length === 0 && gains.length === 0) {\n errors.push({ message: \"a profile names at least one pain or one gain\" });\n }\n const title = meta?.title ?? h1 ?? basename(relPath, \".md\");\n return { ...(meta ? { meta } : {}), title, pains, gains, errors };\n}\n\n/** Profile files: `docs/profiles/*.md` minus the generated index, sorted by file name. */\nexport function listProfileFiles(targetDir: string): string[] {\n const dir = join(targetDir, PROFILES_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 profile file without throwing; linters read their `errors`. */\nexport function readProfileFiles(targetDir: string): ParsedProfileFile[] {\n return listProfileFiles(targetDir).map((file) => {\n const path = `${PROFILES_DIR}/${file}`;\n const text = readFileSync(join(targetDir, path), \"utf8\");\n return { path, file, slug: basename(file, \".md\"), ...parseProfileFile(path, text) };\n });\n}\n\n/** The frontmatter `evidence:` as a list. */\nexport function profileEvidence(meta: ProfileFrontmatter | undefined): string[] {\n if (!meta?.evidence) return [];\n return typeof meta.evidence === \"string\" ? [meta.evidence] : [...meta.evidence];\n}\n","/**\n * Readers of the doc pillars shared by the linters and the context graph\n * (docs/spec/coding-agent-harness.md §10.4): a fact the view shows comes from\n * a reader a linter uses, never from a reader of its own.\n */\nimport { maskFencedCode, parseHeading } from \"./intent.js\";\n\nexport interface Heading {\n depth: number;\n title: string;\n /** 1-based line in the file. */\n line: number;\n /** GitHub-style anchor: `10.4 View and review` gives `104-view-and-review`. */\n slug: string;\n}\n\n/** The GitHub-style anchor of a heading. */\nexport function headingSlug(title: string): string {\n return title\n .toLowerCase()\n .replace(/[`*_]/g, \"\")\n .replace(/[^\\p{L}\\p{N}\\s-]/gu, \"\")\n .trim()\n .replace(/\\s/g, \"-\");\n}\n\n/** The headings of a Markdown file, fenced code excluded. */\nexport function readHeadings(text: string): Heading[] {\n const lines = maskFencedCode(text.split(/\\r?\\n/));\n const out: Heading[] = [];\n for (const [i, line] of lines.entries()) {\n const h = parseHeading(line);\n if (h) out.push({ depth: h.depth, title: h.title, line: i + 1, slug: headingSlug(h.title) });\n }\n return out;\n}\n\n// ---------------------------------------------------------------- vocabulary\n\nconst VOCABULARY_HEADING = /^#+\\s*(\\d+(\\.\\d+)*\\.?\\s*)?(Vocabulary|Vocabulaire)\\b/i;\nconst TERM = /^\\s*[-*]\\s+\\*\\*([^*]+)\\*\\*\\s*(?:[—–:-]+\\s*)?(.*)$/;\nconst TABLE_ROW = /^\\s*\\|(.+)\\|\\s*$/;\nconst TABLE_SEPARATOR = /^\\s*\\|?\\s*:?-{3,}/;\n\n/** `**Generated file**` gives `generated-file`. */\nexport function entitySlug(term: string): string {\n return term\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\");\n}\n\nexport interface VocabularyTerm {\n term: string;\n slug: string;\n line: number;\n /** The rest of the bullet, or the second cell of the row. */\n definition: string;\n}\n\n/** A Vocabulary table row: its first cell, without emphasis; `undefined` for a header or a placeholder. */\nfunction tableTerm(line: string, next: string | undefined): [string, string] | undefined {\n const row = TABLE_ROW.exec(line)?.[1];\n if (row === undefined || TABLE_SEPARATOR.test(line)) return undefined;\n // The header row is the one right above the separator.\n if (next !== undefined && TABLE_SEPARATOR.test(next)) return undefined;\n const cells = row.split(\"|\").map((c) => c.trim());\n const cell = (cells[0] ?? \"\").replace(/[*_`]/g, \"\").trim();\n if (!cell || /^<.*>$/.test(cell)) return undefined;\n return [cell, cells[1] ?? \"\"];\n}\n\n/**\n * The terms of a spec's Vocabulary section: the bold terms opening a bullet,\n * and the first cell of each table row (the spec template's form), up to the\n * next heading of the same or a higher level. `undefined` when the spec has\n * no Vocabulary section.\n */\nexport function vocabularyTerms(specText: string): VocabularyTerm[] | undefined {\n const lines = maskFencedCode(specText.split(/\\r?\\n/));\n let depth: number | undefined;\n let terms: VocabularyTerm[] | undefined;\n for (const [i, line] of lines.entries()) {\n const heading = parseHeading(line);\n if (depth !== undefined) {\n if (heading && heading.depth <= depth) break;\n const bullet = TERM.exec(line);\n const found: [string, string] | undefined = bullet?.[1]\n ? [bullet[1], bullet[2] ?? \"\"]\n : tableTerm(line, lines[i + 1]);\n if (found) {\n const [term, definition] = found;\n terms?.push({ term: term.trim(), slug: entitySlug(term), line: i + 1, definition });\n }\n continue;\n }\n if (heading && VOCABULARY_HEADING.test(line)) {\n depth = heading.depth;\n terms = [];\n }\n }\n return terms;\n}\n\n/** The entity slugs of a spec's Vocabulary section, `undefined` without one. */\nexport function vocabularyOf(specText: string): Set<string> | undefined {\n const terms = vocabularyTerms(specText);\n return terms ? new Set(terms.map((t) => t.slug)) : undefined;\n}\n\n// --------------------------------------------------------------------- links\n\nconst LINK_REGEX = /\\[([^\\]]+)\\]\\(([^)]+)\\)/g;\n\nfunction maskCodeSpans(text: string): string {\n return text\n .replace(/```[\\s\\S]*?```/g, (m) => m.replace(/[^\\n]/g, \" \"))\n .replace(/`[^`\\n]*`/g, (m) => \" \".repeat(m.length));\n}\n\nexport interface DocLink {\n url: string;\n line: number;\n}\n\n/** Every Markdown link outside code, with its line. */\nexport function readLinks(text: string): DocLink[] {\n const lines = maskCodeSpans(text).split(\"\\n\");\n const out: DocLink[] = [];\n for (const [i, line] of lines.entries()) {\n LINK_REGEX.lastIndex = 0;\n let match = LINK_REGEX.exec(line);\n while (match !== null) {\n if (match[2]) out.push({ url: match[2], line: i + 1 });\n match = LINK_REGEX.exec(line);\n }\n }\n return out;\n}\n\n/** A link that leaves the repository or stays in the same page. */\nexport function isExternalOrAnchor(url: string): boolean {\n return /^(https?:|mailto:|#)/.test(url);\n}\n\nexport function stripFragment(url: string): string {\n const i = url.indexOf(\"#\");\n return i < 0 ? url : url.slice(0, i);\n}\n\n// ---------------------------------------------------------------------- ADRs\n\n// English headings are canonical; the French ones are still accepted so\n// projects written before the switch to English keep passing.\nexport const ADR_SECTIONS: ReadonlyArray<{ label: string; pattern: RegExp }> = [\n { label: \"Context\", pattern: /^##\\s+(Context|Contexte)\\b/m },\n { label: \"Decision\", pattern: /^##\\s+(Decision|D[ée]cision)\\b/m },\n { label: \"Consequences\", pattern: /^##\\s+(Consequences|Cons[ée]quences)\\b/m },\n {\n label: \"Rejected alternatives\",\n pattern: /^##\\s+(Rejected\\s+alternatives|Alternatives(\\s+rejet[ée]es)?)\\b/im,\n },\n];\n\nexport interface AdrDoc {\n /** Required sections the ADR lacks, by English label. */\n missing: string[];\n /** The first paragraph of the Decision section, on one line. */\n decision?: string;\n /** The `###` headings under Rejected alternatives. */\n alternatives: Array<{ title: string; line: number; text: string }>;\n}\n\nexport function readAdr(text: string): AdrDoc {\n const missing = ADR_SECTIONS.filter((s) => !s.pattern.test(text)).map((s) => s.label);\n const lines = maskFencedCode(text.split(/\\r?\\n/));\n const decisionPattern = ADR_SECTIONS[1]?.pattern;\n const alternativesPattern = ADR_SECTIONS[3]?.pattern;\n let section: \"decision\" | \"alternatives\" | undefined;\n const paragraph: string[] = [];\n let paragraphDone = false;\n const alternatives: AdrDoc[\"alternatives\"] = [];\n for (const [i, line] of lines.entries()) {\n const heading = parseHeading(line);\n if (heading && heading.depth <= 2) {\n section = decisionPattern?.test(line)\n ? \"decision\"\n : alternativesPattern?.test(line)\n ? \"alternatives\"\n : undefined;\n continue;\n }\n if (section === \"decision\" && !paragraphDone) {\n if (line.trim() === \"\") {\n if (paragraph.length) paragraphDone = true;\n } else paragraph.push(line.trim());\n }\n if (section === \"alternatives\") {\n if (heading && heading.depth === 3) {\n alternatives.push({ title: heading.title, line: i + 1, text: \"\" });\n } else if (line.trim() && alternatives.length) {\n const last = alternatives[alternatives.length - 1];\n if (last) last.text = last.text ? `${last.text} ${line.trim()}` : line.trim();\n }\n }\n }\n return {\n missing,\n ...(paragraph.length ? { decision: paragraph.join(\" \") } : {}),\n alternatives,\n };\n}\n\n// -------------------------------------------------------------- known gaps\n\nexport interface KnownGap {\n line: number;\n text: string;\n links: string[];\n}\n\nconst KNOWN_GAPS_HEADING = /^#+\\s*(\\d+(\\.\\d+)*\\.?\\s*)?(Known gaps|Lacunes connues|Trous connus)\\b/i;\n\n/** The bullets of a test plan's Known gaps section. */\nexport function readKnownGaps(text: string): KnownGap[] {\n const lines = maskFencedCode(text.split(/\\r?\\n/));\n let depth: number | undefined;\n const out: KnownGap[] = [];\n for (const [i, line] of lines.entries()) {\n const heading = parseHeading(line);\n if (depth !== undefined) {\n if (heading && heading.depth <= depth) break;\n const bullet = /^\\s*[-*]\\s+(.*)$/.exec(line);\n if (bullet?.[1]) {\n out.push({\n line: i + 1,\n text: bullet[1].trim(),\n links: readLinks(line).map((l) => l.url),\n });\n }\n continue;\n }\n if (heading && KNOWN_GAPS_HEADING.test(line)) depth = heading.depth;\n }\n return out;\n}\n\n/** The first non-empty paragraph after the H1, on one line. */\nexport function readLede(text: string): string | undefined {\n const lines = maskFencedCode(text.split(/\\r?\\n/));\n let afterTitle = false;\n const paragraph: string[] = [];\n let inFrontmatter = lines[0]?.trim() === \"---\";\n for (const [i, line] of lines.entries()) {\n if (inFrontmatter) {\n if (i > 0 && line.trim() === \"---\") inFrontmatter = false;\n continue;\n }\n const heading = parseHeading(line);\n if (!afterTitle) {\n if (heading?.depth === 1) afterTitle = true;\n continue;\n }\n if (heading) break;\n if (line.trim() === \"\" || line.startsWith(\">\") || line.startsWith(\"<!--\")) {\n if (paragraph.length) break;\n continue;\n }\n if (line === \"\\u0000\") break;\n paragraph.push(line.trim());\n }\n return paragraph.length ? paragraph.join(\" \") : undefined;\n}\n","import { posix } from \"node:path\";\nimport type { IntentFrontmatter } from \"../parser/schemas.js\";\n\n/** The frontmatter `spec:` as a list. */\nexport function intentFileSpecs(meta: IntentFrontmatter | undefined): string[] {\n if (!meta) return [];\n return typeof meta.spec === \"string\" ? [meta.spec] : [...meta.spec];\n}\n\n/** A `spec:` path, relative to the intent file, as a path from the repo root (fragment stripped). */\nexport function resolveSpecPath(filePath: string, spec: string): string {\n const withoutFragment = spec.split(\"#\")[0] ?? \"\";\n return posix.normalize(posix.join(posix.dirname(filePath), withoutFragment));\n}\n","import { execFileSync } from \"node:child_process\";\nimport { existsSync, readFileSync, statSync } from \"node:fs\";\nimport { join, relative } from \"node:path\";\nimport fg from \"fast-glob\";\nimport matter from \"gray-matter\";\n\nexport function fileExists(repoRoot: string, relativePath: string): boolean {\n return existsSync(join(repoRoot, relativePath));\n}\n\nexport function readText(repoRoot: string, relativePath: string): string {\n return readFileSync(join(repoRoot, relativePath), \"utf8\");\n}\n\n/**\n * A `tracks:` entry or an intent anchor: a path from the repo root, or a glob\n * (any `*`) that must match at least one file.\n */\nexport function trackedPathExists(repoRoot: string, pattern: string): boolean {\n if (pattern.includes(\"*\")) {\n return fg.sync(pattern, { cwd: repoRoot, absolute: false }).length > 0;\n }\n return existsSync(join(repoRoot, pattern));\n}\n\nexport function listMarkdown(repoRoot: string, dir: string): string[] {\n const cwd = join(repoRoot, dir);\n if (!existsSync(cwd)) return [];\n return fg\n .sync(\"**/*.md\", { cwd, absolute: false, ignore: [\"**/node_modules/**\", \"**/dist/**\"] })\n .filter((f) => !f.endsWith(\"README.md\"))\n .map((f) => join(dir, f));\n}\n\nexport function listAllMarkdown(repoRoot: string, dir: string): string[] {\n const cwd = join(repoRoot, dir);\n if (!existsSync(cwd)) return [];\n return fg\n .sync(\"**/*.md\", { cwd, absolute: false, ignore: [\"**/node_modules/**\", \"**/dist/**\"] })\n .map((f) => join(dir, f));\n}\n\nexport function dirExists(repoRoot: string, relativePath: string): boolean {\n const full = join(repoRoot, relativePath);\n if (!existsSync(full)) return false;\n return statSync(full).isDirectory();\n}\n\nexport function parseFrontmatter(text: string): { data: Record<string, unknown>; body: string } {\n const m = matter(text);\n return { data: m.data, body: m.content };\n}\n\nexport interface GitLogEntry {\n hash: string;\n timestamp: number;\n}\n\nexport function gitLastCommitForPath(\n repoRoot: string,\n relativePath: string,\n): GitLogEntry | undefined {\n try {\n const out = execFileSync(\"git\", [\"log\", \"-1\", \"--format=%H:%ct\", \"--\", relativePath], {\n cwd: repoRoot,\n encoding: \"utf8\",\n stdio: [\"ignore\", \"pipe\", \"ignore\"],\n }).trim();\n if (!out) return undefined;\n const idx = out.indexOf(\":\");\n if (idx < 0) return undefined;\n const hash = out.slice(0, idx);\n const ts = Number.parseInt(out.slice(idx + 1), 10);\n return { hash, timestamp: ts };\n } catch {\n return undefined;\n }\n}\n\nexport function gitCommitsSince(\n repoRoot: string,\n relativePath: string,\n sinceCommit: string,\n): number {\n try {\n const out = execFileSync(\n \"git\",\n [\"log\", `${sinceCommit}..HEAD`, \"--format=%H\", \"--\", relativePath],\n {\n cwd: repoRoot,\n encoding: \"utf8\",\n stdio: [\"ignore\", \"pipe\", \"ignore\"],\n },\n ).trim();\n if (!out) return 0;\n return out.split(\"\\n\").filter(Boolean).length;\n } catch {\n return 0;\n }\n}\n\nexport function relPath(repoRoot: string, abs: string): string {\n return relative(repoRoot, abs);\n}\n\nexport function findLineNumber(text: string, needle: string | RegExp): number | undefined {\n const lines = text.split(\"\\n\");\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i] ?? \"\";\n if (typeof needle === \"string\" ? line.includes(needle) : needle.test(line)) {\n return i + 1;\n }\n }\n return undefined;\n}\n"],"mappings":";AAAA,SAAS,oBAAoB;AAC7B,OAAO,YAAY;;;ACDnB,SAAS,SAAS;;;ACAlB,SAAS,YAAY,aAAa,gBAAgB;AAClD,SAAS,YAAY;AAQd,IAAM,aAAa;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAsBO,IAAM,UAAiC;AAAA,EAC5C,EAAE,IAAI,UAAU,MAAM,KAAK;AAAA,EAC3B,EAAE,IAAI,QAAQ,KAAK,aAAa,MAAM,KAAK;AAAA,EAC3C;AAAA,IACE,IAAI;AAAA,IACJ,KAAK;AAAA,IACL,MAAM;AAAA,IACN,UAAU,CAAC,EAAE,UAAU,2BAA2B,MAAM,2BAA2B,CAAC;AAAA,IACpF,MAAM;AAAA,EACR;AAAA,EACA;AAAA,IACE,IAAI;AAAA,IACJ,KAAK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,EAChD;AACA,MAAI,MAAM,WAAW,KAAK,MAAM,WAAW,GAAG;AAC5C,WAAO,KAAK,EAAE,SAAS,gDAAgD,CAAC;AAAA,EAC1E;AACA,QAAM,QAAQ,MAAM,SAAS,MAAME,UAAS,SAAS,KAAK;AAC1D,SAAO,EAAE,GAAI,OAAO,EAAE,KAAK,IAAI,CAAC,GAAI,OAAO,OAAO,OAAO,OAAO;AAClE;AAGO,SAAS,iBAAiB,WAA6B;AAC5D,QAAM,MAAMC,MAAK,WAAW,YAAY;AACxC,MAAI,CAACC,YAAW,GAAG,KAAK,CAACC,UAAS,GAAG,EAAE,YAAY,EAAG,QAAO,CAAC;AAC9D,SAAOC,aAAY,GAAG,EACnB,OAAO,CAAC,MAAM,EAAE,SAAS,KAAK,KAAK,MAAM,WAAW,EACpD,OAAO,CAAC,MAAMD,UAASF,MAAK,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,EAC7C,KAAK;AACV;AAGO,SAAS,iBAAiB,WAAwC;AACvE,SAAO,iBAAiB,SAAS,EAAE,IAAI,CAAC,SAAS;AAC/C,UAAM,OAAO,GAAG,YAAY,IAAI,IAAI;AACpC,UAAM,OAAOI,cAAaJ,MAAK,WAAW,IAAI,GAAG,MAAM;AACvD,WAAO,EAAE,MAAM,MAAM,MAAMD,UAAS,MAAM,KAAK,GAAG,GAAG,iBAAiB,MAAM,IAAI,EAAE;AAAA,EACpF,CAAC;AACH;AAGO,SAAS,gBAAgB,MAAgD;AAC9E,MAAI,CAAC,MAAM,SAAU,QAAO,CAAC;AAC7B,SAAO,OAAO,KAAK,aAAa,WAAW,CAAC,KAAK,QAAQ,IAAI,CAAC,GAAG,KAAK,QAAQ;AAChF;","names":["existsSync","readFileSync","readdirSync","statSync","join","matter","matter","join","existsSync","statSync","readdirSync","readFileSync","existsSync","readFileSync","readdirSync","statSync","basename","join","matter","existsSync","readFileSync","statSync","join","matter","parseFrontmatter","matter","basename","join","existsSync","statSync","readdirSync","readFileSync"]}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { Skill, Cmd, ParsedIntentFile, ParsedProfileFile } from './parser/index.js';
|
|
2
|
+
|
|
3
|
+
declare const ENGINES: readonly ["claude-code", "codex-cli", "opencode"];
|
|
4
|
+
type Engine = (typeof ENGINES)[number];
|
|
5
|
+
interface RenderedFile {
|
|
6
|
+
path: string;
|
|
7
|
+
content: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The pillars of the meta database (docs/spec/coding-agent-harness.md
|
|
12
|
+
* §9.1.2). README and spec are the core, always active; every other pillar
|
|
13
|
+
* is active when its folder under `docs/` exists
|
|
14
|
+
* (docs/decisions/pillars-on-demand.md).
|
|
15
|
+
*/
|
|
16
|
+
declare const PILLAR_IDS: readonly ["readme", "spec", "decisions", "handbook", "tests", "workflow", "quality", "skills", "intents", "profiles"];
|
|
17
|
+
type PillarId = (typeof PILLAR_IDS)[number];
|
|
18
|
+
interface StarterFile {
|
|
19
|
+
/** Template under the package's `templates/`. */
|
|
20
|
+
template: string;
|
|
21
|
+
/** Destination from the repo root. */
|
|
22
|
+
path: string;
|
|
23
|
+
}
|
|
24
|
+
interface Pillar {
|
|
25
|
+
id: PillarId;
|
|
26
|
+
/** Folder from the repo root; the README pillar has none. */
|
|
27
|
+
dir?: string;
|
|
28
|
+
/** Always active: its absence never deactivates anything. */
|
|
29
|
+
core: boolean;
|
|
30
|
+
/** Written by `add`, never over an existing file. Absent: `add` does not apply. */
|
|
31
|
+
starters?: ReadonlyArray<StarterFile>;
|
|
32
|
+
/** What to do once the pillar is added. */
|
|
33
|
+
next?: string;
|
|
34
|
+
}
|
|
35
|
+
declare const PILLARS: ReadonlyArray<Pillar>;
|
|
36
|
+
/** The pillars `add` accepts. */
|
|
37
|
+
declare const ADDABLE_PILLARS: ReadonlyArray<Pillar>;
|
|
38
|
+
declare function activePillars(repoRoot: string): Set<PillarId>;
|
|
39
|
+
|
|
40
|
+
interface Harness {
|
|
41
|
+
skills: ReadonlyArray<Skill>;
|
|
42
|
+
cmds: ReadonlyArray<Cmd>;
|
|
43
|
+
}
|
|
44
|
+
interface HarnessOverrides {
|
|
45
|
+
add?: Partial<Harness>;
|
|
46
|
+
disable?: ReadonlyArray<string>;
|
|
47
|
+
}
|
|
48
|
+
interface RenderInput {
|
|
49
|
+
harness: Harness;
|
|
50
|
+
engines: ReadonlyArray<Engine>;
|
|
51
|
+
overrides?: HarnessOverrides;
|
|
52
|
+
projectSkills?: ReadonlyArray<Skill>;
|
|
53
|
+
/**
|
|
54
|
+
* The pillars active in the target project (spec §9.1.2). A skill that
|
|
55
|
+
* declares `pillars:` is rendered while one of them is active. Omitted:
|
|
56
|
+
* every pillar, which is what a preview with no project shows.
|
|
57
|
+
*/
|
|
58
|
+
activePillars?: ReadonlySet<PillarId>;
|
|
59
|
+
/** The project's parsed `docs/intents/*.md`; given, their index is rendered. */
|
|
60
|
+
intentFiles?: ReadonlyArray<ParsedIntentFile>;
|
|
61
|
+
/** The project's parsed `docs/profiles/*.md`; given, their index is rendered. */
|
|
62
|
+
profileFiles?: ReadonlyArray<ParsedProfileFile>;
|
|
63
|
+
}
|
|
64
|
+
interface RenderOutput {
|
|
65
|
+
files: RenderedFile[];
|
|
66
|
+
warnings: string[];
|
|
67
|
+
}
|
|
68
|
+
declare class RenderError extends Error {
|
|
69
|
+
constructor(message: string);
|
|
70
|
+
}
|
|
71
|
+
declare function applyOverrides(harness: Harness, overrides: HarnessOverrides | undefined): Harness;
|
|
72
|
+
/**
|
|
73
|
+
* Pure transformation `(catalog, engines, overrides, active pillars) → files`. The harness
|
|
74
|
+
* ships no agent persona and no engine hook: only the doc skills, their
|
|
75
|
+
* commands, and the engine-neutral umbrella
|
|
76
|
+
* (docs/decisions/no-personas-no-code-judgment.md,
|
|
77
|
+
* docs/decisions/lint-in-ci-and-pre-commit.md).
|
|
78
|
+
*/
|
|
79
|
+
declare function render(input: RenderInput): RenderOutput;
|
|
80
|
+
|
|
81
|
+
export { ADDABLE_PILLARS as A, type Engine as E, type Harness as H, PILLARS as P, RenderError as R, type HarnessOverrides as a, PILLAR_IDS as b, type Pillar as c, type PillarId as d, type RenderInput as e, type RenderOutput as f, type RenderedFile as g, activePillars as h, applyOverrides as i, render as r };
|
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,
|
|
2
|
+
export { H as Harness, a as HarnessOverrides, R as RenderError, e as RenderInput, f as RenderOutput, i as applyOverrides, r as render } from './render-BhUar2gf.js';
|
|
3
3
|
import 'zod';
|
package/dist/render.js
CHANGED
|
@@ -1,11 +1,91 @@
|
|
|
1
1
|
// src/parser/intent.ts
|
|
2
|
-
import { existsSync, readFileSync, readdirSync, statSync } from "fs";
|
|
3
|
-
import { basename, join } from "path";
|
|
2
|
+
import { existsSync as existsSync2, readFileSync, readdirSync as readdirSync2, statSync as statSync2 } from "fs";
|
|
3
|
+
import { basename, join as join2 } from "path";
|
|
4
4
|
import matter from "gray-matter";
|
|
5
5
|
|
|
6
6
|
// src/parser/schemas.ts
|
|
7
7
|
import { z } from "zod";
|
|
8
8
|
|
|
9
|
+
// src/pillars.ts
|
|
10
|
+
import { existsSync, readdirSync, statSync } from "fs";
|
|
11
|
+
import { join } from "path";
|
|
12
|
+
var PILLAR_IDS = [
|
|
13
|
+
"readme",
|
|
14
|
+
"spec",
|
|
15
|
+
"decisions",
|
|
16
|
+
"handbook",
|
|
17
|
+
"tests",
|
|
18
|
+
"workflow",
|
|
19
|
+
"quality",
|
|
20
|
+
"skills",
|
|
21
|
+
"intents",
|
|
22
|
+
"profiles"
|
|
23
|
+
];
|
|
24
|
+
var PILLARS = [
|
|
25
|
+
{ id: "readme", core: true },
|
|
26
|
+
{ id: "spec", dir: "docs/spec", core: true },
|
|
27
|
+
{
|
|
28
|
+
id: "decisions",
|
|
29
|
+
dir: "docs/decisions",
|
|
30
|
+
core: false,
|
|
31
|
+
starters: [{ template: "decisions-index.md.tmpl", path: "docs/decisions/README.md" }],
|
|
32
|
+
next: "write the first decision with the `harn-decision-record-writer` skill (`/harn-decision`)"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
id: "handbook",
|
|
36
|
+
dir: "docs/handbook",
|
|
37
|
+
core: false,
|
|
38
|
+
starters: [{ template: "handbook-index.md.tmpl", path: "docs/handbook/README.md" }],
|
|
39
|
+
next: "write the first handbook with the `harn-handbook-writer` skill (`/harn-handbook`)"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
id: "tests",
|
|
43
|
+
dir: "docs/tests",
|
|
44
|
+
core: false,
|
|
45
|
+
starters: [
|
|
46
|
+
{ template: "integration-tests.md.tmpl", path: "docs/tests/integration-tests.md" },
|
|
47
|
+
{ template: "e2e-tests.md.tmpl", path: "docs/tests/e2e-tests.md" }
|
|
48
|
+
],
|
|
49
|
+
next: "fill both test plans with the `harn-test-plan-writer` skill (`/harn-test-plan`); the lint fails on their placeholders until then"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
id: "workflow",
|
|
53
|
+
dir: "docs/workflow",
|
|
54
|
+
core: false,
|
|
55
|
+
starters: [{ template: "coding-workflow.md.tmpl", path: "docs/workflow/coding-workflow.md" }],
|
|
56
|
+
next: "fill the workflow with the `harn-workflow-writer` skill (`/harn-workflow`); the lint fails on its placeholders until then"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
id: "quality",
|
|
60
|
+
dir: "docs/quality",
|
|
61
|
+
core: false,
|
|
62
|
+
starters: [{ template: "code-quality.md.tmpl", path: "docs/quality/code-quality.md" }],
|
|
63
|
+
next: "fill docs/quality/code-quality.md by hand: the tools, the project's rules, the accepted deviations"
|
|
64
|
+
},
|
|
65
|
+
// Active as soon as it holds a `*.skill.md`: nothing to add.
|
|
66
|
+
{ id: "skills", dir: "docs/skills", core: false },
|
|
67
|
+
{
|
|
68
|
+
id: "intents",
|
|
69
|
+
dir: "docs/intents",
|
|
70
|
+
core: false,
|
|
71
|
+
starters: [],
|
|
72
|
+
next: "write the first intent with the `harn-intent-writer` skill (`/harn-intent <verb + object>`)"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
id: "profiles",
|
|
76
|
+
dir: "docs/profiles",
|
|
77
|
+
core: false,
|
|
78
|
+
starters: [],
|
|
79
|
+
next: "describe the first profile with the `harn-intent-writer` skill, from the research you point it to"
|
|
80
|
+
}
|
|
81
|
+
];
|
|
82
|
+
var ADDABLE_PILLARS = PILLARS.filter(
|
|
83
|
+
(pillar) => pillar.starters !== void 0
|
|
84
|
+
);
|
|
85
|
+
function allPillars() {
|
|
86
|
+
return new Set(PILLAR_IDS);
|
|
87
|
+
}
|
|
88
|
+
|
|
9
89
|
// src/types.ts
|
|
10
90
|
var ENGINES = ["claude-code", "codex-cli", "opencode"];
|
|
11
91
|
var CAPABILITIES = ["multi-step", "slash-command", "inline-exec"];
|
|
@@ -25,6 +105,8 @@ var SkillFrontmatterSchema = z.object({
|
|
|
25
105
|
description: z.string().min(1),
|
|
26
106
|
engines: z.array(z.enum(ENGINES)).min(1).optional(),
|
|
27
107
|
requires: z.array(z.enum(CAPABILITIES)).optional(),
|
|
108
|
+
/** Rendered while one of these pillars is active; omitted = always. */
|
|
109
|
+
pillars: z.array(z.enum(PILLAR_IDS)).min(1).optional(),
|
|
28
110
|
tags: z.array(z.string()).optional()
|
|
29
111
|
}).strict();
|
|
30
112
|
var CmdArgEnumSchema = z.object({
|
|
@@ -58,11 +140,37 @@ var IntentFrontmatterSchema = z.object({
|
|
|
58
140
|
spec: z.union([z.string().min(1), z.array(z.string().min(1)).min(1)]),
|
|
59
141
|
last_reviewed: z.union([z.date(), z.string().min(1)])
|
|
60
142
|
}).strict();
|
|
143
|
+
var PROFILE_STATUSES = ["hypothesis", "validated"];
|
|
144
|
+
var ProfileFrontmatterSchema = z.object({
|
|
145
|
+
title: z.string().min(1),
|
|
146
|
+
status: z.enum(PROFILE_STATUSES),
|
|
147
|
+
evidence: z.union([z.string().min(1), z.array(z.string().min(1)).min(1)]).optional(),
|
|
148
|
+
last_reviewed: z.union([z.date(), z.string().min(1)])
|
|
149
|
+
}).strict();
|
|
61
150
|
|
|
62
151
|
// src/parser/intent.ts
|
|
63
152
|
var INTENTS_DIR = "docs/intents";
|
|
64
153
|
var INTENTS_INDEX_PATH = `${INTENTS_DIR}/README.md`;
|
|
65
154
|
|
|
155
|
+
// src/parser/profile.ts
|
|
156
|
+
import { existsSync as existsSync4, readFileSync as readFileSync3, readdirSync as readdirSync3, statSync as statSync4 } from "fs";
|
|
157
|
+
import { basename as basename2, join as join4 } from "path";
|
|
158
|
+
import matter3 from "gray-matter";
|
|
159
|
+
|
|
160
|
+
// src/linters/intent-util.ts
|
|
161
|
+
import { posix } from "path";
|
|
162
|
+
|
|
163
|
+
// src/linters/util.ts
|
|
164
|
+
import { execFileSync } from "child_process";
|
|
165
|
+
import { existsSync as existsSync3, readFileSync as readFileSync2, statSync as statSync3 } from "fs";
|
|
166
|
+
import { join as join3, relative } from "path";
|
|
167
|
+
import fg from "fast-glob";
|
|
168
|
+
import matter2 from "gray-matter";
|
|
169
|
+
|
|
170
|
+
// src/parser/profile.ts
|
|
171
|
+
var PROFILES_DIR = "docs/profiles";
|
|
172
|
+
var PROFILES_INDEX_PATH = `${PROFILES_DIR}/README.md`;
|
|
173
|
+
|
|
66
174
|
// src/renderers/common.ts
|
|
67
175
|
import { stringify as yamlStringify } from "yaml";
|
|
68
176
|
function checkSkillCapabilities(skill, engine) {
|
|
@@ -132,6 +240,10 @@ function buildUmbrellaBody(extras) {
|
|
|
132
240
|
const label = triggers.length > 0 ? `\`${s.meta.id}\` (${triggers.map((t) => `\`${t}\``).join(", ")})` : `\`${s.meta.id}\``;
|
|
133
241
|
return `- ${label} \u2014 ${s.meta.description.split("\n")[0]}`;
|
|
134
242
|
});
|
|
243
|
+
const has = (pillar) => extras.activePillars.has(pillar);
|
|
244
|
+
const exposes = (id) => extras.availableSkills.some((s) => s.meta.id === id);
|
|
245
|
+
const when = (condition, ...lines) => condition ? lines : [];
|
|
246
|
+
const inactive = ADDABLE_PILLARS.filter((pillar) => !has(pillar.id)).map((p) => `\`${p.id}\``);
|
|
135
247
|
const sections = [
|
|
136
248
|
"# How we work",
|
|
137
249
|
"",
|
|
@@ -141,29 +253,65 @@ function buildUmbrellaBody(extras) {
|
|
|
141
253
|
"",
|
|
142
254
|
"- `README.md` \u2014 pitch, quick start, scripts. Entry point.",
|
|
143
255
|
"- `docs/spec/<subsystem>.md` \u2014 *what* and *why* (tech-agnostic).",
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
...
|
|
149
|
-
|
|
256
|
+
...when(
|
|
257
|
+
has("handbook"),
|
|
258
|
+
"- `docs/handbook/<feature>.md` \u2014 what the code does not say: entry points, traps, settings outside the repo, manual procedures."
|
|
259
|
+
),
|
|
260
|
+
...when(
|
|
261
|
+
has("decisions"),
|
|
262
|
+
"- `docs/decisions/<slug>.md` \u2014 ADRs: structural choices and rejected alternatives."
|
|
263
|
+
),
|
|
264
|
+
...when(
|
|
265
|
+
has("tests"),
|
|
266
|
+
"- `docs/tests/integration-tests.md` & `e2e-tests.md` \u2014 test scope, stack, conventions, known gaps."
|
|
267
|
+
),
|
|
268
|
+
...when(
|
|
269
|
+
has("workflow"),
|
|
270
|
+
"- `docs/workflow/coding-workflow.md` \u2014 CI, branches, PR, release. How this team works: follow it."
|
|
271
|
+
),
|
|
272
|
+
...when(
|
|
273
|
+
extras.hasProjectSkills === true,
|
|
274
|
+
"- `docs/skills/*.skill.md` \u2014 the project's domain skills."
|
|
275
|
+
),
|
|
276
|
+
...when(
|
|
277
|
+
has("quality"),
|
|
150
278
|
"- `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."
|
|
151
|
-
|
|
152
|
-
...
|
|
279
|
+
),
|
|
280
|
+
...when(
|
|
281
|
+
has("intents"),
|
|
153
282
|
"- `docs/intents/<intent>.md` \u2014 user intents, one tree per level-1 intent, anchored to the code. `docs/intents/README.md` is the generated index."
|
|
154
|
-
|
|
283
|
+
),
|
|
284
|
+
...when(
|
|
285
|
+
has("profiles"),
|
|
286
|
+
"- `docs/profiles/<profile>.md` \u2014 who the project serves, their pains and gains. `docs/profiles/README.md` is the generated index: which intent serves which pain."
|
|
287
|
+
),
|
|
288
|
+
...when(
|
|
289
|
+
inactive.length > 0,
|
|
290
|
+
"",
|
|
291
|
+
`Not in this project yet: ${inactive.join(", ")}. A pillar is added the day the project needs it, with \`npx @vaubaan/harness add <pillar>\`${exposes("harn-guide") ? "; the `harn-guide` skill says when each one is worth it" : ""}. Propose it to the human, never create the folder unasked.`
|
|
292
|
+
),
|
|
155
293
|
"",
|
|
156
294
|
"## Doc-first",
|
|
157
295
|
"",
|
|
158
296
|
"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.",
|
|
159
297
|
"",
|
|
160
|
-
...
|
|
161
|
-
"
|
|
162
|
-
|
|
298
|
+
...when(
|
|
299
|
+
has("intents"),
|
|
300
|
+
"- Visible change of behavior \u2192 a `proposed` intent first (`/harn-intent <verb + object>`), never the code first."
|
|
301
|
+
),
|
|
163
302
|
"- Missing spec for a subsystem you touch \u2192 **do not code**, report the gap.",
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
303
|
+
...when(
|
|
304
|
+
has("decisions"),
|
|
305
|
+
"- Implicit structural decision in your changes \u2192 an ADR (`/harn-decision`)."
|
|
306
|
+
),
|
|
307
|
+
...when(
|
|
308
|
+
has("handbook"),
|
|
309
|
+
"- Changed feature behavior \u2192 update the matching handbook (`/harn-handbook`)."
|
|
310
|
+
),
|
|
311
|
+
...when(
|
|
312
|
+
exposes("harn-drift-detector"),
|
|
313
|
+
"- Suspected code \u2194 doc drift \u2192 `/harn-drift` before moving on."
|
|
314
|
+
),
|
|
167
315
|
"",
|
|
168
316
|
"## Checks",
|
|
169
317
|
"",
|
|
@@ -172,7 +320,7 @@ function buildUmbrellaBody(extras) {
|
|
|
172
320
|
"The files the harness generates (`AGENTS.md`, `CLAUDE.md`, the `.claude/`, `.agents/` and `.opencode/` folders, `.harness-manifest.json`) are committed. Never edit them by hand: change their source in `docs/` or `.harness-overrides/`, run `npx @vaubaan/harness update .`, and commit the result. The linter fails when a generated file no longer matches its render."
|
|
173
321
|
];
|
|
174
322
|
if (skillLines.length > 0) {
|
|
175
|
-
sections.push("", "##
|
|
323
|
+
sections.push("", "## Skills", "", skillLines.join("\n"));
|
|
176
324
|
}
|
|
177
325
|
return `${sections.join("\n")}
|
|
178
326
|
`;
|
|
@@ -290,8 +438,10 @@ function getRenderer(engine) {
|
|
|
290
438
|
|
|
291
439
|
// src/renderers/intents-index.ts
|
|
292
440
|
var INTRO = "User intents of this project, anchored to the code. Generated by `@vaubaan/harness` from `docs/intents/*.md`: edit the intents, not this file, then run `npx @vaubaan/harness update .`.";
|
|
441
|
+
var EMPTY = "No intent yet. `/harn-intent <verb + object>` writes the first one, before the code.";
|
|
293
442
|
function buildIntentsIndex(intentFiles) {
|
|
294
443
|
const lines = ["# Intents", "", INTRO, ""];
|
|
444
|
+
if (intentFiles.length === 0) lines.push(EMPTY);
|
|
295
445
|
const sorted = [...intentFiles].sort((a, b) => a.file < b.file ? -1 : a.file > b.file ? 1 : 0);
|
|
296
446
|
for (const intentFile of sorted) {
|
|
297
447
|
const status = intentFile.meta?.status ?? "proposed";
|
|
@@ -305,6 +455,54 @@ function buildIntentsIndex(intentFiles) {
|
|
|
305
455
|
`;
|
|
306
456
|
}
|
|
307
457
|
|
|
458
|
+
// src/renderers/profiles-index.ts
|
|
459
|
+
var INTRO2 = "Who this project serves, and what the intents do for them. Generated by `@vaubaan/harness` from `docs/profiles/*.md` and `docs/intents/*.md`: edit those, not this file, then run `npx @vaubaan/harness update .`.";
|
|
460
|
+
var EMPTY2 = "No profile yet. The `harn-intent-writer` skill writes the first one from the research you point it to.";
|
|
461
|
+
function buildProfilesIndex(profiles, intentFiles = []) {
|
|
462
|
+
const lines = ["# Profiles", "", INTRO2];
|
|
463
|
+
if (profiles.length === 0) lines.push("", EMPTY2);
|
|
464
|
+
const sortedIntents = [...intentFiles].sort(
|
|
465
|
+
(a, b) => a.file < b.file ? -1 : a.file > b.file ? 1 : 0
|
|
466
|
+
);
|
|
467
|
+
for (const profile of [...profiles].sort((a, b) => a.file < b.file ? -1 : 1)) {
|
|
468
|
+
const theirs = sortedIntents.filter((file) => file.meta?.actors.includes(profile.slug));
|
|
469
|
+
lines.push(
|
|
470
|
+
"",
|
|
471
|
+
`## [${profile.title}](./${profile.file}) \u2014 ${profile.meta?.status ?? "hypothesis"}`,
|
|
472
|
+
""
|
|
473
|
+
);
|
|
474
|
+
lines.push(
|
|
475
|
+
theirs.length ? `Intents: ${theirs.map((f) => `[${f.title}](../intents/${f.file})`).join(", ")}.` : "Intents: none names this profile yet."
|
|
476
|
+
);
|
|
477
|
+
const served = (kind, item) => {
|
|
478
|
+
const by = [];
|
|
479
|
+
for (const file of theirs) {
|
|
480
|
+
for (const node of file.nodes) {
|
|
481
|
+
if (node[kind].includes(item.slug)) {
|
|
482
|
+
by.push(`[${node.title}](../intents/${file.file})`);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
if (by.length) return by.join(", ");
|
|
487
|
+
return kind === "relieves" ? "*no intent relieves it yet*" : "*no intent delivers it yet*";
|
|
488
|
+
};
|
|
489
|
+
if (profile.pains.length) {
|
|
490
|
+
lines.push("", "Pains, most severe first:", "");
|
|
491
|
+
for (const pain of profile.pains) {
|
|
492
|
+
lines.push(`- **${pain.name}** (\`${pain.slug}\`) \u2014 ${served("relieves", pain)}`);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
if (profile.gains.length) {
|
|
496
|
+
lines.push("", "Gains:", "");
|
|
497
|
+
for (const gain of profile.gains) {
|
|
498
|
+
lines.push(`- **${gain.name}** (\`${gain.slug}\`) \u2014 ${served("delivers", gain)}`);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
return `${lines.join("\n")}
|
|
503
|
+
`;
|
|
504
|
+
}
|
|
505
|
+
|
|
308
506
|
// src/render.ts
|
|
309
507
|
var RenderError = class extends Error {
|
|
310
508
|
constructor(message) {
|
|
@@ -336,13 +534,21 @@ var CLAUDE_MD_STUB = "@AGENTS.md\n";
|
|
|
336
534
|
function opencodeLast(engines) {
|
|
337
535
|
return [...engines].sort((a, b) => Number(a === "opencode") - Number(b === "opencode"));
|
|
338
536
|
}
|
|
537
|
+
function servesAnActivePillar(skill, active) {
|
|
538
|
+
return !skill.meta.pillars || skill.meta.pillars.some((pillar) => active.has(pillar));
|
|
539
|
+
}
|
|
339
540
|
function render(input) {
|
|
340
541
|
const { engines } = input;
|
|
341
542
|
if (engines.length === 0) {
|
|
342
543
|
throw new RenderError("at least one engine must be selected");
|
|
343
544
|
}
|
|
344
545
|
const base = input.projectSkills?.length ? { ...input.harness, skills: mergeById(input.harness.skills, input.projectSkills) } : input.harness;
|
|
345
|
-
const
|
|
546
|
+
const active = input.activePillars ?? allPillars();
|
|
547
|
+
const merged = applyOverrides(base, input.overrides);
|
|
548
|
+
const harness = {
|
|
549
|
+
...merged,
|
|
550
|
+
skills: merged.skills.filter((skill) => servesAnActivePillar(skill, active))
|
|
551
|
+
};
|
|
346
552
|
const files = [];
|
|
347
553
|
const warnings = [];
|
|
348
554
|
const exposedSkills = /* @__PURE__ */ new Map();
|
|
@@ -374,16 +580,21 @@ function render(input) {
|
|
|
374
580
|
availableSkills: Array.from(exposedSkills.values()),
|
|
375
581
|
availableCommands: Array.from(exposedCmds.values()),
|
|
376
582
|
hasProjectSkills: (input.projectSkills?.length ?? 0) > 0,
|
|
377
|
-
|
|
378
|
-
hasIntents: (input.intentFiles?.length ?? 0) > 0
|
|
583
|
+
activePillars: active
|
|
379
584
|
});
|
|
380
585
|
files.push({ path: "AGENTS.md", content: umbrellaContent });
|
|
381
586
|
if (engines.includes("claude-code")) {
|
|
382
587
|
files.push({ path: "CLAUDE.md", content: CLAUDE_MD_STUB });
|
|
383
588
|
}
|
|
384
|
-
if (input.intentFiles
|
|
589
|
+
if (input.intentFiles) {
|
|
385
590
|
files.push({ path: INTENTS_INDEX_PATH, content: buildIntentsIndex(input.intentFiles) });
|
|
386
591
|
}
|
|
592
|
+
if (input.profileFiles) {
|
|
593
|
+
files.push({
|
|
594
|
+
path: PROFILES_INDEX_PATH,
|
|
595
|
+
content: buildProfilesIndex(input.profileFiles, input.intentFiles ?? [])
|
|
596
|
+
});
|
|
597
|
+
}
|
|
387
598
|
return { files, warnings };
|
|
388
599
|
}
|
|
389
600
|
export {
|