@productbrain/cli 0.1.0-beta.11522 → 0.1.0-beta.11531
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 +1 -1
- package/dist/commands/scoreboard.d.ts +1 -1
- package/dist/commands/scoreboard.d.ts.map +1 -1
- package/dist/commands/scoreboard.js +3 -2
- package/dist/commands/scoreboard.js.map +1 -1
- package/dist/commands/scoreboard.test.d.ts +2 -0
- package/dist/commands/scoreboard.test.d.ts.map +1 -0
- package/dist/commands/scoreboard.test.js +54 -0
- package/dist/commands/scoreboard.test.js.map +1 -0
- package/dist/formatters/scoreboard.test.js +0 -1
- package/dist/formatters/scoreboard.test.js.map +1 -1
- package/dist/lib/ruleListRender.d.ts +0 -5
- package/dist/lib/ruleListRender.d.ts.map +1 -1
- package/dist/lib/ruleListRender.js +1 -26
- package/dist/lib/ruleListRender.js.map +1 -1
- package/dist/scoreboard/diagnose.d.ts +0 -6
- package/dist/scoreboard/diagnose.d.ts.map +1 -1
- package/dist/scoreboard/diagnose.js +1 -1
- package/dist/scoreboard/diagnose.js.map +1 -1
- package/dist/scoreboard/diagnose.test.js +0 -1
- package/dist/scoreboard/diagnose.test.js.map +1 -1
- package/package.json +1 -1
- package/dist/__tests__/adapters.test.d.ts +0 -2
- package/dist/__tests__/adapters.test.d.ts.map +0 -1
- package/dist/__tests__/adapters.test.js +0 -443
- package/dist/__tests__/adapters.test.js.map +0 -1
- package/dist/__tests__/batch-transformations.test.d.ts +0 -2
- package/dist/__tests__/batch-transformations.test.d.ts.map +0 -1
- package/dist/__tests__/batch-transformations.test.js +0 -239
- package/dist/__tests__/batch-transformations.test.js.map +0 -1
- package/dist/__tests__/hook-intents.test.d.ts +0 -2
- package/dist/__tests__/hook-intents.test.d.ts.map +0 -1
- package/dist/__tests__/hook-intents.test.js +0 -172
- package/dist/__tests__/hook-intents.test.js.map +0 -1
- package/dist/__tests__/manifest.test.d.ts +0 -6
- package/dist/__tests__/manifest.test.d.ts.map +0 -1
- package/dist/__tests__/manifest.test.js +0 -255
- package/dist/__tests__/manifest.test.js.map +0 -1
- package/dist/__tests__/perimeter.test.d.ts +0 -2
- package/dist/__tests__/perimeter.test.d.ts.map +0 -1
- package/dist/__tests__/perimeter.test.js +0 -165
- package/dist/__tests__/perimeter.test.js.map +0 -1
- package/dist/__tests__/personal-layer.test.d.ts +0 -11
- package/dist/__tests__/personal-layer.test.d.ts.map +0 -1
- package/dist/__tests__/personal-layer.test.js +0 -268
- package/dist/__tests__/personal-layer.test.js.map +0 -1
- package/dist/__tests__/surface-profiles.test.d.ts +0 -2
- package/dist/__tests__/surface-profiles.test.d.ts.map +0 -1
- package/dist/__tests__/surface-profiles.test.js +0 -233
- package/dist/__tests__/surface-profiles.test.js.map +0 -1
- package/dist/__tests__/surfaces.test.d.ts +0 -2
- package/dist/__tests__/surfaces.test.d.ts.map +0 -1
- package/dist/__tests__/surfaces.test.js +0 -45
- package/dist/__tests__/surfaces.test.js.map +0 -1
- package/dist/generators/adapters.d.ts +0 -77
- package/dist/generators/adapters.d.ts.map +0 -1
- package/dist/generators/adapters.js +0 -286
- package/dist/generators/adapters.js.map +0 -1
- package/dist/generators/adapters.test.d.ts +0 -2
- package/dist/generators/adapters.test.d.ts.map +0 -1
- package/dist/generators/adapters.test.js +0 -36
- package/dist/generators/adapters.test.js.map +0 -1
- package/dist/generators/boundary-manifest.d.ts +0 -29
- package/dist/generators/boundary-manifest.d.ts.map +0 -1
- package/dist/generators/boundary-manifest.js +0 -183
- package/dist/generators/boundary-manifest.js.map +0 -1
- package/dist/generators/boundary-manifest.test.d.ts +0 -2
- package/dist/generators/boundary-manifest.test.d.ts.map +0 -1
- package/dist/generators/boundary-manifest.test.js +0 -91
- package/dist/generators/boundary-manifest.test.js.map +0 -1
- package/dist/generators/briefing-projections.test.d.ts +0 -2
- package/dist/generators/briefing-projections.test.d.ts.map +0 -1
- package/dist/generators/briefing-projections.test.js +0 -71
- package/dist/generators/briefing-projections.test.js.map +0 -1
- package/dist/generators/manifest.d.ts +0 -115
- package/dist/generators/manifest.d.ts.map +0 -1
- package/dist/generators/manifest.js +0 -277
- package/dist/generators/manifest.js.map +0 -1
- package/dist/generators/noProjectionAssets.d.ts +0 -15
- package/dist/generators/noProjectionAssets.d.ts.map +0 -1
- package/dist/generators/noProjectionAssets.js +0 -6
- package/dist/generators/noProjectionAssets.js.map +0 -1
- package/dist/generators/portable-knowledge.d.ts +0 -142
- package/dist/generators/portable-knowledge.d.ts.map +0 -1
- package/dist/generators/portable-knowledge.js +0 -482
- package/dist/generators/portable-knowledge.js.map +0 -1
- package/dist/generators/portable-knowledge.test.d.ts +0 -2
- package/dist/generators/portable-knowledge.test.d.ts.map +0 -1
- package/dist/generators/portable-knowledge.test.js +0 -742
- package/dist/generators/portable-knowledge.test.js.map +0 -1
- package/dist/generators/region-projections.d.ts +0 -17
- package/dist/generators/region-projections.d.ts.map +0 -1
- package/dist/generators/region-projections.js +0 -51
- package/dist/generators/region-projections.js.map +0 -1
- package/dist/generators/region-projections.test.d.ts +0 -2
- package/dist/generators/region-projections.test.d.ts.map +0 -1
- package/dist/generators/region-projections.test.js +0 -58
- package/dist/generators/region-projections.test.js.map +0 -1
- package/dist/generators/region.d.ts +0 -24
- package/dist/generators/region.d.ts.map +0 -1
- package/dist/generators/region.js +0 -87
- package/dist/generators/region.js.map +0 -1
- package/dist/generators/region.test.d.ts +0 -2
- package/dist/generators/region.test.d.ts.map +0 -1
- package/dist/generators/region.test.js +0 -125
- package/dist/generators/region.test.js.map +0 -1
- package/dist/generators/surface-profiles.d.ts +0 -48
- package/dist/generators/surface-profiles.d.ts.map +0 -1
- package/dist/generators/surface-profiles.js +0 -98
- package/dist/generators/surface-profiles.js.map +0 -1
- package/dist/lib/frontmatter.d.ts +0 -55
- package/dist/lib/frontmatter.d.ts.map +0 -1
- package/dist/lib/frontmatter.js +0 -92
- package/dist/lib/frontmatter.js.map +0 -1
- package/dist/lib/frontmatter.test.d.ts +0 -15
- package/dist/lib/frontmatter.test.d.ts.map +0 -1
- package/dist/lib/frontmatter.test.js +0 -98
- package/dist/lib/frontmatter.test.js.map +0 -1
- package/dist/lib/hook-intents.d.ts +0 -56
- package/dist/lib/hook-intents.d.ts.map +0 -1
- package/dist/lib/hook-intents.js +0 -84
- package/dist/lib/hook-intents.js.map +0 -1
- package/dist/lib/writePerimeter.d.ts +0 -72
- package/dist/lib/writePerimeter.d.ts.map +0 -1
- package/dist/lib/writePerimeter.js +0 -128
- package/dist/lib/writePerimeter.js.map +0 -1
- package/dist/surfaces/__tests__/adapter.test.d.ts +0 -2
- package/dist/surfaces/__tests__/adapter.test.d.ts.map +0 -1
- package/dist/surfaces/__tests__/adapter.test.js +0 -86
- package/dist/surfaces/__tests__/adapter.test.js.map +0 -1
- package/dist/surfaces/__tests__/claude-skill-pointer-drift.test.d.ts +0 -2
- package/dist/surfaces/__tests__/claude-skill-pointer-drift.test.d.ts.map +0 -1
- package/dist/surfaces/__tests__/claude-skill-pointer-drift.test.js +0 -180
- package/dist/surfaces/__tests__/claude-skill-pointer-drift.test.js.map +0 -1
- package/dist/surfaces/__tests__/telemetry.test.d.ts +0 -2
- package/dist/surfaces/__tests__/telemetry.test.d.ts.map +0 -1
- package/dist/surfaces/__tests__/telemetry.test.js +0 -44
- package/dist/surfaces/__tests__/telemetry.test.js.map +0 -1
- package/dist/surfaces/adapter.d.ts +0 -70
- package/dist/surfaces/adapter.d.ts.map +0 -1
- package/dist/surfaces/adapter.js +0 -2
- package/dist/surfaces/adapter.js.map +0 -1
- package/dist/surfaces/adapters/claude.d.ts +0 -3
- package/dist/surfaces/adapters/claude.d.ts.map +0 -1
- package/dist/surfaces/adapters/claude.js +0 -72
- package/dist/surfaces/adapters/claude.js.map +0 -1
- package/dist/surfaces/adapters/codex.d.ts +0 -3
- package/dist/surfaces/adapters/codex.d.ts.map +0 -1
- package/dist/surfaces/adapters/codex.js +0 -61
- package/dist/surfaces/adapters/codex.js.map +0 -1
- package/dist/surfaces/adapters/copilot.d.ts +0 -3
- package/dist/surfaces/adapters/copilot.d.ts.map +0 -1
- package/dist/surfaces/adapters/copilot.js +0 -59
- package/dist/surfaces/adapters/copilot.js.map +0 -1
- package/dist/surfaces/adapters/cursor.d.ts +0 -3
- package/dist/surfaces/adapters/cursor.d.ts.map +0 -1
- package/dist/surfaces/adapters/cursor.js +0 -78
- package/dist/surfaces/adapters/cursor.js.map +0 -1
- package/dist/surfaces/registry.d.ts +0 -76
- package/dist/surfaces/registry.d.ts.map +0 -1
- package/dist/surfaces/registry.js +0 -117
- package/dist/surfaces/registry.js.map +0 -1
- package/dist/surfaces/telemetry.d.ts +0 -24
- package/dist/surfaces/telemetry.d.ts.map +0 -1
- package/dist/surfaces/telemetry.js +0 -25
- package/dist/surfaces/telemetry.js.map +0 -1
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Adapter file generators — thin pointers for each AI tool.
|
|
3
|
-
* Each function returns the file content as a string.
|
|
4
|
-
*/
|
|
5
|
-
import type { SurfaceProfile } from './surface-profiles.js';
|
|
6
|
-
declare const MARKER = "auto-generated by Product Brain";
|
|
7
|
-
export { MARKER };
|
|
8
|
-
/** TASK-554 (WP-777, DEC-1888): CLAUDE.md only points at the served briefing. Rules are never
|
|
9
|
-
* written into CLAUDE.md (a WP-777 exclusion); the generated projections carry them. Shared by
|
|
10
|
-
* the whole-file CLAUDE.md below and the CLAUDE.md region (region-projections.ts). */
|
|
11
|
-
export declare const CLAUDE_BRIEFING_POINTER = "Your full briefing, including the team and role rules that bind you, is served live by `pb session start` and `pb orient --task \"<what you are doing>\"`; run that orient before substantive work. `.productbrain/context.md` is a snapshot of the spine and the everyone rules only. Rules are never copied into this file.";
|
|
12
|
-
export interface AgentsMdOptions {
|
|
13
|
-
profile?: SurfaceProfile;
|
|
14
|
-
workspaceContext?: {
|
|
15
|
-
focus?: string;
|
|
16
|
-
totalEntries?: number;
|
|
17
|
-
};
|
|
18
|
-
skills?: Array<{
|
|
19
|
-
name: string;
|
|
20
|
-
description: string;
|
|
21
|
-
triggers?: string[];
|
|
22
|
-
}>;
|
|
23
|
-
}
|
|
24
|
-
export declare function generateAgentsMd(timestamp: string, options?: AgentsMdOptions): string;
|
|
25
|
-
export declare function generateClaudeMd(timestamp: string): string;
|
|
26
|
-
export declare function generateCursorMdc(timestamp: string, briefingLines: string[] | null): string;
|
|
27
|
-
export interface CopilotMdOptions {
|
|
28
|
-
profile?: SurfaceProfile;
|
|
29
|
-
workspaceContext?: {
|
|
30
|
-
focus?: string;
|
|
31
|
-
totalEntries?: number;
|
|
32
|
-
};
|
|
33
|
-
skills?: Array<{
|
|
34
|
-
name: string;
|
|
35
|
-
description: string;
|
|
36
|
-
triggers?: string[];
|
|
37
|
-
}>;
|
|
38
|
-
rules?: Array<{
|
|
39
|
-
name: string;
|
|
40
|
-
description: string;
|
|
41
|
-
}>;
|
|
42
|
-
}
|
|
43
|
-
export declare function generateCopilotMd(timestamp: string, options?: CopilotMdOptions): string;
|
|
44
|
-
/** Minimal canonical-rule shape needed to project a path-scoped Copilot instruction file. */
|
|
45
|
-
export interface CopilotInstructionRule {
|
|
46
|
-
name: string;
|
|
47
|
-
body: string;
|
|
48
|
-
/** Path-scope glob, e.g. "convex/**\/*.ts". Rules without it are repo-wide, not projected here. */
|
|
49
|
-
applyTo?: string;
|
|
50
|
-
/** Provenance (filesystem path or `db:<ENTRY-ID>`) — emitted as a breadcrumb comment only. */
|
|
51
|
-
sourcePath?: string;
|
|
52
|
-
}
|
|
53
|
-
export interface GeneratedInstructionFile {
|
|
54
|
-
/** Path relative to repo root, e.g. ".github/instructions/security-boundaries.instructions.md". */
|
|
55
|
-
relativePath: string;
|
|
56
|
-
content: string;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Project path-scoped GitHub Copilot instruction files from canonical rules.
|
|
60
|
-
*
|
|
61
|
-
* One `.github/instructions/<slug>.instructions.md` per rule that declares `applyTo`. Each file
|
|
62
|
-
* carries the `applyTo` frontmatter, the full rule body, and the MARKER.
|
|
63
|
-
*
|
|
64
|
-
* DECISION (DEC-1343, as refined): the committed `.github/instructions/*.instructions.md` are
|
|
65
|
-
* hand-maintained SSOT and carry NO MARKER, so they are classified as user-owned and left
|
|
66
|
-
* them untouched (`shouldWriteAdapter`). This generator therefore only MATERIALIZES a file — with
|
|
67
|
-
* the MARKER, marking it pb-managed — when a Chain rule declares `applyTo` AND no committed file
|
|
68
|
-
* already occupies that path. On this repo no Chain rule declares `applyTo`, so it emits nothing
|
|
69
|
-
* and never dirties the tree; the path-scoped review files are the hand-authored committed ones.
|
|
70
|
-
*
|
|
71
|
-
* A provenance breadcrumb records the source entry/path WITHOUT requiring the consumer to resolve
|
|
72
|
-
* it: Copilot code review is pb-blind, so the body is inlined and the id is reference-only
|
|
73
|
-
* (DEC-1343 / INS-1969). Basenames are de-duped deterministically so two rules never clobber one
|
|
74
|
-
* file.
|
|
75
|
-
*/
|
|
76
|
-
export declare function generateCopilotInstructionFiles(rules: CopilotInstructionRule[], timestamp: string): GeneratedInstructionFile[];
|
|
77
|
-
//# sourceMappingURL=adapters.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"adapters.d.ts","sourceRoot":"","sources":["../../src/generators/adapters.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,QAAA,MAAM,MAAM,oCAAoC,CAAC;AAEjD,OAAO,EAAE,MAAM,EAAE,CAAC;AAOlB;;uFAEuF;AACvF,eAAO,MAAM,uBAAuB,kUAC+G,CAAC;AAEpJ,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,gBAAgB,CAAC,EAAE;QACjB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,MAAM,CAAC,EAAE,KAAK,CAAC;QAAE,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,EAAE,MAAM,CAAC;CACjB;AAYD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,+BAA+B,CAC7C,KAAK,EAAE,sBAAsB,EAAE,EAC/B,SAAS,EAAE,MAAM,GAChB,wBAAwB,EAAE,CAiC5B"}
|
|
@@ -1,286 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Adapter file generators — thin pointers for each AI tool.
|
|
3
|
-
* Each function returns the file content as a string.
|
|
4
|
-
*/
|
|
5
|
-
const MARKER = 'auto-generated by Product Brain';
|
|
6
|
-
export { MARKER };
|
|
7
|
-
/** TASK-670 (WP-820, DEC-1863): every generated adapter file points at the served briefing in place of
|
|
8
|
-
* protocol paragraphs of its own, so session start is the one place an agent learns how to work here. */
|
|
9
|
-
const BRIEFING_POINTER = 'Your full briefing, including the team and role rules that bind you, is served live by `pb session start` and `pb orient --task "<what you are doing>"`; run that orient before substantive work.';
|
|
10
|
-
/** TASK-554 (WP-777, DEC-1888): CLAUDE.md only points at the served briefing. Rules are never
|
|
11
|
-
* written into CLAUDE.md (a WP-777 exclusion); the generated projections carry them. Shared by
|
|
12
|
-
* the whole-file CLAUDE.md below and the CLAUDE.md region (region-projections.ts). */
|
|
13
|
-
export const CLAUDE_BRIEFING_POINTER = `${BRIEFING_POINTER} \`.productbrain/context.md\` is a snapshot of the spine and the everyone rules only. Rules are never copied into this file.`;
|
|
14
|
-
export function generateAgentsMd(timestamp, options) {
|
|
15
|
-
const { workspaceContext, skills } = options ?? {};
|
|
16
|
-
// Workspace context section (only when data is available)
|
|
17
|
-
// TASK-435 (C4c): the readiness stage label ("| Stage | ... |") is deleted from every
|
|
18
|
-
// served surface, including this generated adapter file.
|
|
19
|
-
let workspaceSection = '';
|
|
20
|
-
if (workspaceContext && Object.values(workspaceContext).some((v) => v !== undefined)) {
|
|
21
|
-
const rows = [];
|
|
22
|
-
if (workspaceContext.focus !== undefined)
|
|
23
|
-
rows.push(`| Current focus | ${workspaceContext.focus} |`);
|
|
24
|
-
if (workspaceContext.totalEntries !== undefined)
|
|
25
|
-
rows.push(`| Chain entries | ${workspaceContext.totalEntries} |`);
|
|
26
|
-
workspaceSection = `
|
|
27
|
-
## Workspace Context
|
|
28
|
-
|
|
29
|
-
| Field | Value |
|
|
30
|
-
|-------|-------|
|
|
31
|
-
${rows.join('\n')}
|
|
32
|
-
`;
|
|
33
|
-
}
|
|
34
|
-
// Skill directory section (only when skills provided and non-empty)
|
|
35
|
-
let skillsSection = '';
|
|
36
|
-
if (skills && skills.length > 0) {
|
|
37
|
-
const rows = skills.map((s) => {
|
|
38
|
-
const triggers = s.triggers && s.triggers.length > 0 ? s.triggers.slice(0, 3).join(', ') : '—';
|
|
39
|
-
return `| \`${s.name}\` | ${s.description} | ${triggers} |`;
|
|
40
|
-
});
|
|
41
|
-
skillsSection = `
|
|
42
|
-
## Skill Directory
|
|
43
|
-
|
|
44
|
-
| Skill | Description | Triggers |
|
|
45
|
-
|-------|-------------|----------|
|
|
46
|
-
${rows.join('\n')}
|
|
47
|
-
`;
|
|
48
|
-
}
|
|
49
|
-
return `<!-- ${MARKER} — ${timestamp} -->
|
|
50
|
-
<!-- Do not edit manually. -->
|
|
51
|
-
|
|
52
|
-
# Product Brain Context
|
|
53
|
-
|
|
54
|
-
Read \`.productbrain/soul.md\` when identity, working style, or collaboration preferences matter.
|
|
55
|
-
${workspaceSection}
|
|
56
|
-
## The Chain is the SSOT. Use \`pb\` before everything.
|
|
57
|
-
|
|
58
|
-
| Command | Purpose |
|
|
59
|
-
|---------|---------|
|
|
60
|
-
| \`pb orient -b\` | Current workspace focus |
|
|
61
|
-
| \`pb orient --task "<task>"\` | Task-shaped governance and context before implementation, review, or diagnosis |
|
|
62
|
-
| \`pb get <ID>\` | Full entry (BET, DEC, STD, BR, TEN, ARCH) |
|
|
63
|
-
| \`pb context <ID>\` | Constellation context for an entry |
|
|
64
|
-
| \`pb search <query>\` | Find entries across the Chain |
|
|
65
|
-
|
|
66
|
-
${BRIEFING_POINTER}
|
|
67
|
-
|
|
68
|
-
For reusable Product Brain workflows in Codex, read \`.codex/skills/README.md\` first, then open the matching skill file under \`.codex/skills/\`.
|
|
69
|
-
${skillsSection}`;
|
|
70
|
-
}
|
|
71
|
-
export function generateClaudeMd(timestamp) {
|
|
72
|
-
return `<!-- ${MARKER} — ${timestamp} -->
|
|
73
|
-
<!-- Do not edit manually. -->
|
|
74
|
-
|
|
75
|
-
# Product Brain Context
|
|
76
|
-
|
|
77
|
-
${CLAUDE_BRIEFING_POINTER}
|
|
78
|
-
`;
|
|
79
|
-
}
|
|
80
|
-
// TASK-554 (WP-777, DEC-1888): the workspace briefing (spine and the Everyone rule list) — the SAME
|
|
81
|
-
// lines context.md and everyone-rules.md carry, from formatWorkspaceBriefingLines. `null` means the
|
|
82
|
-
// orient fetch failed this run; the file says so rather than dropping the section silently.
|
|
83
|
-
function cursorBriefingSection(briefingLines) {
|
|
84
|
-
if (briefingLines === null) {
|
|
85
|
-
return '\n## Briefing\n\nThe workspace briefing could not be fetched; run `pb session start` to read it.\n';
|
|
86
|
-
}
|
|
87
|
-
return `\n## Briefing\n\n${briefingLines.join('\n')}\n`;
|
|
88
|
-
}
|
|
89
|
-
export function generateCursorMdc(timestamp, briefingLines) {
|
|
90
|
-
return `---
|
|
91
|
-
description: Product Brain Chain context — workspace knowledge for AI-assisted development
|
|
92
|
-
globs:
|
|
93
|
-
alwaysApply: true
|
|
94
|
-
---
|
|
95
|
-
|
|
96
|
-
# Product Brain Context
|
|
97
|
-
|
|
98
|
-
## The Chain is the SSOT. Use \`pb\` before everything.
|
|
99
|
-
|
|
100
|
-
- \`pb orient -b\` — Current workspace focus
|
|
101
|
-
- \`pb orient --task "<task>"\` — Task-shaped governance and context before implementation, review, or diagnosis
|
|
102
|
-
- \`pb get <ID>\` — Full entry (BET, DEC, STD, BR, TEN, ARCH)
|
|
103
|
-
- \`pb context <ID>\` — Constellation context for an entry
|
|
104
|
-
- \`pb search <query>\` — Find entries across the Chain
|
|
105
|
-
|
|
106
|
-
${BRIEFING_POINTER}
|
|
107
|
-
${cursorBriefingSection(briefingLines)}
|
|
108
|
-
<!-- ${MARKER} — ${timestamp} -->
|
|
109
|
-
`;
|
|
110
|
-
}
|
|
111
|
-
export function generateCopilotMd(timestamp, options) {
|
|
112
|
-
const { profile, workspaceContext, skills, rules } = options ?? {};
|
|
113
|
-
const budget = profile?.tokenBudget ?? 30000;
|
|
114
|
-
// Workspace context section (only when data is available)
|
|
115
|
-
// TASK-435 (C4c): the readiness stage label ("| Stage | ... |") is deleted from every
|
|
116
|
-
// served surface, including this generated adapter file.
|
|
117
|
-
let workspaceSection = '';
|
|
118
|
-
if (workspaceContext && Object.values(workspaceContext).some((v) => v !== undefined)) {
|
|
119
|
-
const rows = [];
|
|
120
|
-
if (workspaceContext.focus !== undefined)
|
|
121
|
-
rows.push(`| Current focus | ${workspaceContext.focus} |`);
|
|
122
|
-
if (workspaceContext.totalEntries !== undefined)
|
|
123
|
-
rows.push(`| Chain entries | ${workspaceContext.totalEntries} |`);
|
|
124
|
-
workspaceSection = `
|
|
125
|
-
## Workspace Context
|
|
126
|
-
|
|
127
|
-
| Field | Value |
|
|
128
|
-
|-------|-------|
|
|
129
|
-
${rows.join('\n')}
|
|
130
|
-
`;
|
|
131
|
-
}
|
|
132
|
-
// Build the invariant base (header + workspace + command ref + session lifecycle)
|
|
133
|
-
const base = `<!-- ${MARKER} — ${timestamp} -->
|
|
134
|
-
<!-- Do not edit manually. -->
|
|
135
|
-
|
|
136
|
-
# Product Brain Context
|
|
137
|
-
${workspaceSection}
|
|
138
|
-
## The Chain is the SSOT. Use \`pb\` before everything.
|
|
139
|
-
|
|
140
|
-
- \`pb orient -b\` — Current workspace focus
|
|
141
|
-
- \`pb orient --task "<task>"\` — Task-shaped governance and context before implementation, review, or diagnosis
|
|
142
|
-
- \`pb get <ID>\` — Full entry (BET, DEC, STD, BR, TEN, ARCH)
|
|
143
|
-
- \`pb context <ID>\` — Constellation context for an entry
|
|
144
|
-
- \`pb search <query>\` — Find entries across the Chain
|
|
145
|
-
|
|
146
|
-
${BRIEFING_POINTER}
|
|
147
|
-
`;
|
|
148
|
-
// When no enrichment options provided, return base for backward compat
|
|
149
|
-
if (!skills?.length && !rules?.length) {
|
|
150
|
-
return base;
|
|
151
|
-
}
|
|
152
|
-
// Build skill summaries and rule summaries as independent chunks
|
|
153
|
-
// so we can truncate from the end if needed
|
|
154
|
-
const skillChunks = [];
|
|
155
|
-
if (skills && skills.length > 0) {
|
|
156
|
-
skillChunks.push('\n## Skills\n');
|
|
157
|
-
for (const s of skills) {
|
|
158
|
-
let chunk = `\n### ${s.name}\n${s.description}\n`;
|
|
159
|
-
if (s.triggers && s.triggers.length > 0) {
|
|
160
|
-
chunk += `Triggers: ${s.triggers.slice(0, 3).join(', ')}\n`;
|
|
161
|
-
}
|
|
162
|
-
skillChunks.push(chunk);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
const ruleChunks = [];
|
|
166
|
-
if (rules && rules.length > 0) {
|
|
167
|
-
ruleChunks.push('\n## Rules\n');
|
|
168
|
-
for (const r of rules) {
|
|
169
|
-
ruleChunks.push(`\n### ${r.name}\n${r.description}\n`);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
// All appendable chunks: skill section header + individual skills, then rule section header + individual rules
|
|
173
|
-
const allChunks = [...skillChunks, ...ruleChunks];
|
|
174
|
-
// Greedily append chunks while staying within budget
|
|
175
|
-
let result = base;
|
|
176
|
-
let omittedCount = 0;
|
|
177
|
-
const truncationNote = (n) => `\n<!-- Truncated: ${n} skills/rules omitted to stay within token budget -->\n`;
|
|
178
|
-
// Check if base already exceeds budget (rare, but handle gracefully)
|
|
179
|
-
if (base.length >= budget) {
|
|
180
|
-
return base;
|
|
181
|
-
}
|
|
182
|
-
// We need to find how many chunks fit. Reserve space for a truncation note if needed.
|
|
183
|
-
const allChunksText = allChunks.join('');
|
|
184
|
-
if (base.length + allChunksText.length <= budget) {
|
|
185
|
-
// Everything fits — no truncation needed
|
|
186
|
-
return base + allChunksText;
|
|
187
|
-
}
|
|
188
|
-
// Need to truncate. Greedy approach: keep adding chunks while they fit,
|
|
189
|
-
// always reserving space for the worst-case truncation note.
|
|
190
|
-
const isHeader = (c) => c.trimStart().startsWith('## ');
|
|
191
|
-
const itemCount = allChunks.filter((c) => !isHeader(c)).length;
|
|
192
|
-
// Worst-case note reserves for the maximum possible omission count
|
|
193
|
-
const worstCaseNoteLen = truncationNote(itemCount).length;
|
|
194
|
-
let accumulated = base;
|
|
195
|
-
let fittedItemCount = 0;
|
|
196
|
-
for (let i = 0; i < allChunks.length; i++) {
|
|
197
|
-
const chunk = allChunks[i];
|
|
198
|
-
const remaining = allChunks.slice(i + 1).join('');
|
|
199
|
-
// If everything from here fits without any note, append and done
|
|
200
|
-
if (accumulated.length + chunk.length + remaining.length <= budget) {
|
|
201
|
-
accumulated += allChunks.slice(i).join('');
|
|
202
|
-
fittedItemCount = itemCount;
|
|
203
|
-
break;
|
|
204
|
-
}
|
|
205
|
-
// Does this chunk fit if we reserve space for the worst-case note?
|
|
206
|
-
if (accumulated.length + chunk.length + worstCaseNoteLen <= budget) {
|
|
207
|
-
accumulated += chunk;
|
|
208
|
-
if (!isHeader(chunk))
|
|
209
|
-
fittedItemCount++;
|
|
210
|
-
}
|
|
211
|
-
else {
|
|
212
|
-
break;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
omittedCount = itemCount - fittedItemCount;
|
|
216
|
-
if (omittedCount > 0) {
|
|
217
|
-
const note = truncationNote(omittedCount);
|
|
218
|
-
// Only append the note if it fits within budget; if the base alone
|
|
219
|
-
// nearly fills the budget, omit the note to honour the hard cap.
|
|
220
|
-
if (accumulated.length + note.length <= budget) {
|
|
221
|
-
accumulated += note;
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
return accumulated;
|
|
225
|
-
}
|
|
226
|
-
/** Slugify a rule name into a filesystem-safe instruction-file basename. */
|
|
227
|
-
function instructionSlug(name) {
|
|
228
|
-
return (name
|
|
229
|
-
.toLowerCase()
|
|
230
|
-
.replace(/[^a-z0-9]+/g, '-')
|
|
231
|
-
.replace(/^-+|-+$/g, '') || 'rule');
|
|
232
|
-
}
|
|
233
|
-
/**
|
|
234
|
-
* Project path-scoped GitHub Copilot instruction files from canonical rules.
|
|
235
|
-
*
|
|
236
|
-
* One `.github/instructions/<slug>.instructions.md` per rule that declares `applyTo`. Each file
|
|
237
|
-
* carries the `applyTo` frontmatter, the full rule body, and the MARKER.
|
|
238
|
-
*
|
|
239
|
-
* DECISION (DEC-1343, as refined): the committed `.github/instructions/*.instructions.md` are
|
|
240
|
-
* hand-maintained SSOT and carry NO MARKER, so they are classified as user-owned and left
|
|
241
|
-
* them untouched (`shouldWriteAdapter`). This generator therefore only MATERIALIZES a file — with
|
|
242
|
-
* the MARKER, marking it pb-managed — when a Chain rule declares `applyTo` AND no committed file
|
|
243
|
-
* already occupies that path. On this repo no Chain rule declares `applyTo`, so it emits nothing
|
|
244
|
-
* and never dirties the tree; the path-scoped review files are the hand-authored committed ones.
|
|
245
|
-
*
|
|
246
|
-
* A provenance breadcrumb records the source entry/path WITHOUT requiring the consumer to resolve
|
|
247
|
-
* it: Copilot code review is pb-blind, so the body is inlined and the id is reference-only
|
|
248
|
-
* (DEC-1343 / INS-1969). Basenames are de-duped deterministically so two rules never clobber one
|
|
249
|
-
* file.
|
|
250
|
-
*/
|
|
251
|
-
export function generateCopilotInstructionFiles(rules, timestamp) {
|
|
252
|
-
const files = [];
|
|
253
|
-
const seen = new Set();
|
|
254
|
-
for (const rule of rules) {
|
|
255
|
-
if (!rule.applyTo || !rule.applyTo.trim())
|
|
256
|
-
continue;
|
|
257
|
-
const slug = instructionSlug(rule.name);
|
|
258
|
-
let unique = slug;
|
|
259
|
-
let n = 2;
|
|
260
|
-
while (seen.has(unique))
|
|
261
|
-
unique = `${slug}-${n++}`;
|
|
262
|
-
seen.add(unique);
|
|
263
|
-
// Portable provenance: keep a `db:<ID>` reference as-is; reduce a filesystem path to its
|
|
264
|
-
// basename so a committed file never leaks an absolute, machine-specific path. Split on BOTH
|
|
265
|
-
// separators — a Windows authoring host yields `C:\…\rules\foo.md`, and splitting on '/' alone
|
|
266
|
-
// would leak the whole backslash path into committed provenance.
|
|
267
|
-
const src = rule.sourcePath
|
|
268
|
-
? rule.sourcePath.startsWith('db:')
|
|
269
|
-
? rule.sourcePath
|
|
270
|
-
: rule.sourcePath.split(/[/\\]/).pop()
|
|
271
|
-
: undefined;
|
|
272
|
-
const provenance = src ? `\n<!-- source: ${src} -->` : '';
|
|
273
|
-
// The rule body conventionally carries its own H1, so no heading is prepended here.
|
|
274
|
-
const content = `---
|
|
275
|
-
applyTo: ${JSON.stringify(rule.applyTo.trim())}
|
|
276
|
-
---
|
|
277
|
-
<!-- ${MARKER} — ${timestamp} -->
|
|
278
|
-
<!-- Edit the rule in the Chain, not this file. -->${provenance}
|
|
279
|
-
|
|
280
|
-
${rule.body.trim()}
|
|
281
|
-
`;
|
|
282
|
-
files.push({ relativePath: `.github/instructions/${unique}.instructions.md`, content });
|
|
283
|
-
}
|
|
284
|
-
return files;
|
|
285
|
-
}
|
|
286
|
-
//# sourceMappingURL=adapters.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"adapters.js","sourceRoot":"","sources":["../../src/generators/adapters.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,MAAM,GAAG,iCAAiC,CAAC;AAEjD,OAAO,EAAE,MAAM,EAAE,CAAC;AAElB;0GAC0G;AAC1G,MAAM,gBAAgB,GACpB,mMAAmM,CAAC;AAEtM;;uFAEuF;AACvF,MAAM,CAAC,MAAM,uBAAuB,GAClC,GAAG,gBAAgB,8HAA8H,CAAC;AAWpJ,MAAM,UAAU,gBAAgB,CAAC,SAAiB,EAAE,OAAyB;IAC3E,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;IAEnD,0DAA0D;IAC1D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AAS;qDACyB,UAAU;;EAE7D,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;CACjB,CAAC;QACE,KAAK,CAAC,IAAI,CAAC,EAAE,YAAY,EAAE,wBAAwB,MAAM,kBAAkB,EAAE,OAAO,EAAE,CAAC,CAAC;IAC1F,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"adapters.test.d.ts","sourceRoot":"","sources":["../../src/generators/adapters.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { generateAgentsMd, generateClaudeMd, generateCopilotMd, generateCursorMdc } from './adapters.js';
|
|
3
|
-
describe('generateAgentsMd', () => {
|
|
4
|
-
it('includes Product Brain bootstrap guidance for Codex-style agents', () => {
|
|
5
|
-
const output = generateAgentsMd('2026-04-02T00:00:00.000Z');
|
|
6
|
-
expect(output).toContain('auto-generated by Product Brain');
|
|
7
|
-
expect(output).not.toContain('handshake');
|
|
8
|
-
expect(output).toContain('Read `.productbrain/soul.md`');
|
|
9
|
-
expect(output).toContain('`.codex/skills/README.md`');
|
|
10
|
-
expect(output).toContain('pb orient -b');
|
|
11
|
-
expect(output).toContain('pb orient --task');
|
|
12
|
-
expect(output).toContain('pb session start');
|
|
13
|
-
});
|
|
14
|
-
});
|
|
15
|
-
// TASK-670 (WP-820, DEC-1863): session start is the one place an agent learns how to work here, so
|
|
16
|
-
// no generated adapter file carries protocol paragraphs of its own; each points at the briefing.
|
|
17
|
-
describe('one protocol source', () => {
|
|
18
|
-
it('no adapter carries the old protocol paragraphs', () => {
|
|
19
|
-
const timestamp = '2026-04-02T00:00:00.000Z';
|
|
20
|
-
for (const output of [generateAgentsMd(timestamp), generateCursorMdc(timestamp, null), generateCopilotMd(timestamp), generateClaudeMd(timestamp)]) {
|
|
21
|
-
for (const gone of ['Session lifecycle', 'All captures are drafts', 'Before implementing any feature', 'Governance Summary', 'pb capture "']) {
|
|
22
|
-
expect(output).not.toContain(gone);
|
|
23
|
-
}
|
|
24
|
-
expect(output).toContain('is served live by `pb session start`');
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
describe('adapter variants', () => {
|
|
29
|
-
it('propagates task-shaped startup guidance across generated adapters', () => {
|
|
30
|
-
const timestamp = '2026-04-02T00:00:00.000Z';
|
|
31
|
-
expect(generateClaudeMd(timestamp)).toContain('pb orient --task');
|
|
32
|
-
expect(generateCursorMdc(timestamp, null)).toContain('pb orient --task');
|
|
33
|
-
expect(generateCopilotMd(timestamp)).toContain('pb orient --task');
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
//# sourceMappingURL=adapters.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"adapters.test.js","sourceRoot":"","sources":["../../src/generators/adapters.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEzG,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,EAAE,CAAC,kEAAkE,EAAE,GAAG,EAAE;QAC1E,MAAM,MAAM,GAAG,gBAAgB,CAAC,0BAA0B,CAAC,CAAC;QAE5D,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,iCAAiC,CAAC,CAAC;QAC5D,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;QAC1C,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,8BAA8B,CAAC,CAAC;QACzD,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,2BAA2B,CAAC,CAAC;QACtD,MAAM,CAAC,MAAM,CAAC,CAAC,S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M,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAC;IACrE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { Manifest } from './manifest.js';
|
|
2
|
-
export type BoundaryEnforcementMode = 'advisory' | 'drift-check' | 'enforced';
|
|
3
|
-
type BoundaryKind = 'policyBoundary' | 'localOnlyTechnical' | 'outOfScopeExisting';
|
|
4
|
-
type BoundaryStatus = 'active' | 'planned' | 'deprecated';
|
|
5
|
-
type BoundaryScope = 'convex' | 'frontend' | 'repo';
|
|
6
|
-
type BoundarySeverity = 'error' | 'warn' | 'info';
|
|
7
|
-
export interface BoundaryRule {
|
|
8
|
-
id: string;
|
|
9
|
-
kind: BoundaryKind;
|
|
10
|
-
status: BoundaryStatus;
|
|
11
|
-
scope: BoundaryScope;
|
|
12
|
-
chainRefs: string[];
|
|
13
|
-
description: string;
|
|
14
|
-
from?: {
|
|
15
|
-
path?: string;
|
|
16
|
-
};
|
|
17
|
-
to?: {
|
|
18
|
-
path?: string;
|
|
19
|
-
};
|
|
20
|
-
severity?: BoundarySeverity;
|
|
21
|
-
enforcement: {
|
|
22
|
-
depcruiseRuleName: string;
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
export declare function getBoundaryEnforcementMode(manifest: Manifest | null): BoundaryEnforcementMode;
|
|
26
|
-
export declare function generateBoundaryManifest(productbrainDir: string): string | null;
|
|
27
|
-
export declare function parseBoundaryRules(markdown: string): BoundaryRule[];
|
|
28
|
-
export {};
|
|
29
|
-
//# sourceMappingURL=boundary-manifest.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"boundary-manifest.d.ts","sourceRoot":"","sources":["../../src/generators/boundary-manifest.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C,MAAM,MAAM,uBAAuB,GAAG,UAAU,GAAG,aAAa,GAAG,UAAU,CAAC;AAE9E,KAAK,YAAY,GAAG,gBAAgB,GAAG,oBAAoB,GAAG,oBAAoB,CAAC;AACnF,KAAK,cAAc,GAAG,QAAQ,GAAG,SAAS,GAAG,YAAY,CAAC;AAC1D,KAAK,aAAa,GAAG,QAAQ,GAAG,UAAU,GAAG,MAAM,CAAC;AACpD,KAAK,gBAAgB,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AAElD,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,YAAY,CAAC;IACnB,MAAM,EAAE,cAAc,CAAC;IACvB,KAAK,EAAE,aAAa,CAAC;IACrB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACzB,EAAE,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACvB,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,WAAW,EAAE;QAAE,iBAAiB,EAAE,MAAM,CAAA;KAAE,CAAC;CAC5C;AASD,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,GAAG,uBAAuB,CAM7F;AAED,wBAAgB,wBAAwB,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAyB/E;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,YAAY,EAAE,CA4EnE"}
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import { createHash } from 'crypto';
|
|
2
|
-
import { existsSync, readFileSync } from 'fs';
|
|
3
|
-
import { join } from 'path';
|
|
4
|
-
const EXPECTED_SOURCE = '.productbrain/rules/architecture-boundaries.md';
|
|
5
|
-
const VALID_MODES = new Set(['advisory', 'drift-check', 'enforced']);
|
|
6
|
-
const VALID_KINDS = new Set(['policyBoundary', 'localOnlyTechnical', 'outOfScopeExisting']);
|
|
7
|
-
const VALID_STATUS = new Set(['active', 'planned', 'deprecated']);
|
|
8
|
-
const VALID_SCOPE = new Set(['convex', 'frontend', 'repo']);
|
|
9
|
-
const VALID_SEVERITY = new Set(['error', 'warn', 'info']);
|
|
10
|
-
export function getBoundaryEnforcementMode(manifest) {
|
|
11
|
-
const raw = manifest?.boundary_enforcement_mode ?? manifest?.boundaryEnforcementMode ?? 'advisory';
|
|
12
|
-
if (VALID_MODES.has(raw))
|
|
13
|
-
return raw;
|
|
14
|
-
throw new Error(`Unsupported boundary enforcement mode "${raw}". Use advisory, drift-check, or enforced.`);
|
|
15
|
-
}
|
|
16
|
-
export function generateBoundaryManifest(productbrainDir) {
|
|
17
|
-
const sourcePath = join(productbrainDir, 'rules', 'architecture-boundaries.md');
|
|
18
|
-
if (!existsSync(sourcePath))
|
|
19
|
-
return null;
|
|
20
|
-
const raw = readFileSync(sourcePath, 'utf8');
|
|
21
|
-
const rules = parseBoundaryRules(raw);
|
|
22
|
-
if (rules.length === 0)
|
|
23
|
-
return null;
|
|
24
|
-
validateBoundaryRules(rules);
|
|
25
|
-
const chainRefs = [...new Set(rules.flatMap((rule) => rule.chainRefs))].sort();
|
|
26
|
-
const manifest = {
|
|
27
|
-
schemaVersion: 1,
|
|
28
|
-
generator: 'pb-handshake-boundary-manifest',
|
|
29
|
-
sources: [
|
|
30
|
-
{
|
|
31
|
-
path: EXPECTED_SOURCE,
|
|
32
|
-
sha256: createHash('sha256').update(raw).digest('hex'),
|
|
33
|
-
},
|
|
34
|
-
],
|
|
35
|
-
chainSources: chainRefs.map((entryId) => ({ entryId })),
|
|
36
|
-
rules: [...rules].sort((a, b) => a.id.localeCompare(b.id)),
|
|
37
|
-
};
|
|
38
|
-
return `${JSON.stringify(manifest, null, 2)}\n`;
|
|
39
|
-
}
|
|
40
|
-
export function parseBoundaryRules(markdown) {
|
|
41
|
-
const frontmatter = extractFrontmatter(markdown);
|
|
42
|
-
if (!frontmatter)
|
|
43
|
-
return [];
|
|
44
|
-
const lines = frontmatter.split('\n');
|
|
45
|
-
const rules = [];
|
|
46
|
-
let inEnforcement = false;
|
|
47
|
-
let inBoundaries = false;
|
|
48
|
-
let current = null;
|
|
49
|
-
let nestedKey = null;
|
|
50
|
-
const commit = () => {
|
|
51
|
-
if (current)
|
|
52
|
-
rules.push(current);
|
|
53
|
-
current = null;
|
|
54
|
-
nestedKey = null;
|
|
55
|
-
};
|
|
56
|
-
for (const line of lines) {
|
|
57
|
-
const trimmed = line.trim();
|
|
58
|
-
if (!trimmed || trimmed.startsWith('#'))
|
|
59
|
-
continue;
|
|
60
|
-
if (/^\S/.test(line) && !line.startsWith('enforcement:')) {
|
|
61
|
-
if (inEnforcement) {
|
|
62
|
-
commit();
|
|
63
|
-
inEnforcement = false;
|
|
64
|
-
inBoundaries = false;
|
|
65
|
-
}
|
|
66
|
-
continue;
|
|
67
|
-
}
|
|
68
|
-
if (line === 'enforcement:') {
|
|
69
|
-
inEnforcement = true;
|
|
70
|
-
continue;
|
|
71
|
-
}
|
|
72
|
-
if (!inEnforcement)
|
|
73
|
-
continue;
|
|
74
|
-
if (/^ {2}boundaries:\s*$/.test(line)) {
|
|
75
|
-
inBoundaries = true;
|
|
76
|
-
continue;
|
|
77
|
-
}
|
|
78
|
-
if (!inBoundaries)
|
|
79
|
-
continue;
|
|
80
|
-
const itemMatch = line.match(/^ {4}-\s+([A-Za-z0-9_.-]+):\s*(.*)$/);
|
|
81
|
-
if (itemMatch) {
|
|
82
|
-
commit();
|
|
83
|
-
current = {};
|
|
84
|
-
nestedKey = null;
|
|
85
|
-
current[itemMatch[1]] = parseScalar(itemMatch[2]);
|
|
86
|
-
continue;
|
|
87
|
-
}
|
|
88
|
-
if (!current)
|
|
89
|
-
continue;
|
|
90
|
-
const topMatch = line.match(/^ {6}([A-Za-z0-9_.-]+):\s*(.*)$/);
|
|
91
|
-
if (topMatch) {
|
|
92
|
-
const key = topMatch[1];
|
|
93
|
-
const value = topMatch[2];
|
|
94
|
-
if (value === '') {
|
|
95
|
-
current[key] = {};
|
|
96
|
-
nestedKey = key;
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
current[key] = parseScalar(value);
|
|
100
|
-
nestedKey = null;
|
|
101
|
-
}
|
|
102
|
-
continue;
|
|
103
|
-
}
|
|
104
|
-
const nestedMatch = line.match(/^ {8}([A-Za-z0-9_.-]+):\s*(.*)$/);
|
|
105
|
-
if (nestedMatch && nestedKey) {
|
|
106
|
-
const nested = current[nestedKey];
|
|
107
|
-
nested[nestedMatch[1]] = parseScalar(nestedMatch[2]);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
commit();
|
|
111
|
-
return rules;
|
|
112
|
-
}
|
|
113
|
-
function extractFrontmatter(markdown) {
|
|
114
|
-
if (!markdown.startsWith('---\n'))
|
|
115
|
-
return null;
|
|
116
|
-
const end = markdown.indexOf('\n---', 4);
|
|
117
|
-
if (end === -1)
|
|
118
|
-
return null;
|
|
119
|
-
return markdown.slice(4, end);
|
|
120
|
-
}
|
|
121
|
-
function parseScalar(raw) {
|
|
122
|
-
const trimmed = raw.trim();
|
|
123
|
-
if (trimmed.startsWith('[') && trimmed.endsWith(']')) {
|
|
124
|
-
const body = trimmed.slice(1, -1).trim();
|
|
125
|
-
if (!body)
|
|
126
|
-
return [];
|
|
127
|
-
return body.split(',').map((part) => stripQuotes(part.trim()));
|
|
128
|
-
}
|
|
129
|
-
return stripQuotes(trimmed);
|
|
130
|
-
}
|
|
131
|
-
function stripQuotes(value) {
|
|
132
|
-
return value.replace(/^['"]|['"]$/g, '');
|
|
133
|
-
}
|
|
134
|
-
function validateBoundaryRules(rules) {
|
|
135
|
-
const ids = new Set();
|
|
136
|
-
const depcruiseNames = new Set();
|
|
137
|
-
const chainSources = new Set(rules.flatMap((rule) => rule.chainRefs ?? []));
|
|
138
|
-
for (const rule of rules) {
|
|
139
|
-
if (!rule.id)
|
|
140
|
-
throw new Error('Boundary rule is missing id.');
|
|
141
|
-
if (ids.has(rule.id))
|
|
142
|
-
throw new Error(`Duplicate boundary id "${rule.id}".`);
|
|
143
|
-
ids.add(rule.id);
|
|
144
|
-
if (!VALID_KINDS.has(rule.kind))
|
|
145
|
-
throw new Error(`Boundary ${rule.id} has unsupported kind.`);
|
|
146
|
-
if (!VALID_STATUS.has(rule.status))
|
|
147
|
-
throw new Error(`Boundary ${rule.id} has unsupported status.`);
|
|
148
|
-
if (!VALID_SCOPE.has(rule.scope))
|
|
149
|
-
throw new Error(`Boundary ${rule.id} has unsupported scope.`);
|
|
150
|
-
if (!Array.isArray(rule.chainRefs))
|
|
151
|
-
throw new Error(`Boundary ${rule.id} has invalid chainRefs.`);
|
|
152
|
-
const depcruiseRuleName = rule.enforcement?.depcruiseRuleName;
|
|
153
|
-
if (!depcruiseRuleName)
|
|
154
|
-
throw new Error(`Boundary ${rule.id} is missing depcruiseRuleName.`);
|
|
155
|
-
if (depcruiseNames.has(depcruiseRuleName)) {
|
|
156
|
-
throw new Error(`Duplicate dependency-cruiser rule name "${depcruiseRuleName}".`);
|
|
157
|
-
}
|
|
158
|
-
depcruiseNames.add(depcruiseRuleName);
|
|
159
|
-
if (rule.kind === 'policyBoundary' && rule.status === 'active') {
|
|
160
|
-
const required = [
|
|
161
|
-
rule.description,
|
|
162
|
-
rule.from?.path,
|
|
163
|
-
rule.to?.path,
|
|
164
|
-
rule.severity,
|
|
165
|
-
depcruiseRuleName,
|
|
166
|
-
];
|
|
167
|
-
if (required.some((value) => typeof value !== 'string' || value.length === 0)) {
|
|
168
|
-
throw new Error(`This active Product Brain boundary has no dependency-cruiser rule. Add enforcement or change the boundary status. Boundary: ${rule.id}`);
|
|
169
|
-
}
|
|
170
|
-
if (!rule.chainRefs.length) {
|
|
171
|
-
throw new Error(`Boundary ${rule.id} is active Product Brain policy but has no chainRefs.`);
|
|
172
|
-
}
|
|
173
|
-
if (!VALID_SEVERITY.has(rule.severity)) {
|
|
174
|
-
throw new Error(`Boundary ${rule.id} has unsupported severity.`);
|
|
175
|
-
}
|
|
176
|
-
for (const ref of rule.chainRefs) {
|
|
177
|
-
if (!chainSources.has(ref))
|
|
178
|
-
throw new Error(`Boundary ${rule.id} references ${ref} without chainSources metadata.`);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
//# sourceMappingURL=boundary-manifest.js.map
|