@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.
Files changed (166) hide show
  1. package/README.md +1 -1
  2. package/dist/commands/scoreboard.d.ts +1 -1
  3. package/dist/commands/scoreboard.d.ts.map +1 -1
  4. package/dist/commands/scoreboard.js +3 -2
  5. package/dist/commands/scoreboard.js.map +1 -1
  6. package/dist/commands/scoreboard.test.d.ts +2 -0
  7. package/dist/commands/scoreboard.test.d.ts.map +1 -0
  8. package/dist/commands/scoreboard.test.js +54 -0
  9. package/dist/commands/scoreboard.test.js.map +1 -0
  10. package/dist/formatters/scoreboard.test.js +0 -1
  11. package/dist/formatters/scoreboard.test.js.map +1 -1
  12. package/dist/lib/ruleListRender.d.ts +0 -5
  13. package/dist/lib/ruleListRender.d.ts.map +1 -1
  14. package/dist/lib/ruleListRender.js +1 -26
  15. package/dist/lib/ruleListRender.js.map +1 -1
  16. package/dist/scoreboard/diagnose.d.ts +0 -6
  17. package/dist/scoreboard/diagnose.d.ts.map +1 -1
  18. package/dist/scoreboard/diagnose.js +1 -1
  19. package/dist/scoreboard/diagnose.js.map +1 -1
  20. package/dist/scoreboard/diagnose.test.js +0 -1
  21. package/dist/scoreboard/diagnose.test.js.map +1 -1
  22. package/package.json +1 -1
  23. package/dist/__tests__/adapters.test.d.ts +0 -2
  24. package/dist/__tests__/adapters.test.d.ts.map +0 -1
  25. package/dist/__tests__/adapters.test.js +0 -443
  26. package/dist/__tests__/adapters.test.js.map +0 -1
  27. package/dist/__tests__/batch-transformations.test.d.ts +0 -2
  28. package/dist/__tests__/batch-transformations.test.d.ts.map +0 -1
  29. package/dist/__tests__/batch-transformations.test.js +0 -239
  30. package/dist/__tests__/batch-transformations.test.js.map +0 -1
  31. package/dist/__tests__/hook-intents.test.d.ts +0 -2
  32. package/dist/__tests__/hook-intents.test.d.ts.map +0 -1
  33. package/dist/__tests__/hook-intents.test.js +0 -172
  34. package/dist/__tests__/hook-intents.test.js.map +0 -1
  35. package/dist/__tests__/manifest.test.d.ts +0 -6
  36. package/dist/__tests__/manifest.test.d.ts.map +0 -1
  37. package/dist/__tests__/manifest.test.js +0 -255
  38. package/dist/__tests__/manifest.test.js.map +0 -1
  39. package/dist/__tests__/perimeter.test.d.ts +0 -2
  40. package/dist/__tests__/perimeter.test.d.ts.map +0 -1
  41. package/dist/__tests__/perimeter.test.js +0 -165
  42. package/dist/__tests__/perimeter.test.js.map +0 -1
  43. package/dist/__tests__/personal-layer.test.d.ts +0 -11
  44. package/dist/__tests__/personal-layer.test.d.ts.map +0 -1
  45. package/dist/__tests__/personal-layer.test.js +0 -268
  46. package/dist/__tests__/personal-layer.test.js.map +0 -1
  47. package/dist/__tests__/surface-profiles.test.d.ts +0 -2
  48. package/dist/__tests__/surface-profiles.test.d.ts.map +0 -1
  49. package/dist/__tests__/surface-profiles.test.js +0 -233
  50. package/dist/__tests__/surface-profiles.test.js.map +0 -1
  51. package/dist/__tests__/surfaces.test.d.ts +0 -2
  52. package/dist/__tests__/surfaces.test.d.ts.map +0 -1
  53. package/dist/__tests__/surfaces.test.js +0 -45
  54. package/dist/__tests__/surfaces.test.js.map +0 -1
  55. package/dist/generators/adapters.d.ts +0 -77
  56. package/dist/generators/adapters.d.ts.map +0 -1
  57. package/dist/generators/adapters.js +0 -286
  58. package/dist/generators/adapters.js.map +0 -1
  59. package/dist/generators/adapters.test.d.ts +0 -2
  60. package/dist/generators/adapters.test.d.ts.map +0 -1
  61. package/dist/generators/adapters.test.js +0 -36
  62. package/dist/generators/adapters.test.js.map +0 -1
  63. package/dist/generators/boundary-manifest.d.ts +0 -29
  64. package/dist/generators/boundary-manifest.d.ts.map +0 -1
  65. package/dist/generators/boundary-manifest.js +0 -183
  66. package/dist/generators/boundary-manifest.js.map +0 -1
  67. package/dist/generators/boundary-manifest.test.d.ts +0 -2
  68. package/dist/generators/boundary-manifest.test.d.ts.map +0 -1
  69. package/dist/generators/boundary-manifest.test.js +0 -91
  70. package/dist/generators/boundary-manifest.test.js.map +0 -1
  71. package/dist/generators/briefing-projections.test.d.ts +0 -2
  72. package/dist/generators/briefing-projections.test.d.ts.map +0 -1
  73. package/dist/generators/briefing-projections.test.js +0 -71
  74. package/dist/generators/briefing-projections.test.js.map +0 -1
  75. package/dist/generators/manifest.d.ts +0 -115
  76. package/dist/generators/manifest.d.ts.map +0 -1
  77. package/dist/generators/manifest.js +0 -277
  78. package/dist/generators/manifest.js.map +0 -1
  79. package/dist/generators/noProjectionAssets.d.ts +0 -15
  80. package/dist/generators/noProjectionAssets.d.ts.map +0 -1
  81. package/dist/generators/noProjectionAssets.js +0 -6
  82. package/dist/generators/noProjectionAssets.js.map +0 -1
  83. package/dist/generators/portable-knowledge.d.ts +0 -142
  84. package/dist/generators/portable-knowledge.d.ts.map +0 -1
  85. package/dist/generators/portable-knowledge.js +0 -482
  86. package/dist/generators/portable-knowledge.js.map +0 -1
  87. package/dist/generators/portable-knowledge.test.d.ts +0 -2
  88. package/dist/generators/portable-knowledge.test.d.ts.map +0 -1
  89. package/dist/generators/portable-knowledge.test.js +0 -742
  90. package/dist/generators/portable-knowledge.test.js.map +0 -1
  91. package/dist/generators/region-projections.d.ts +0 -17
  92. package/dist/generators/region-projections.d.ts.map +0 -1
  93. package/dist/generators/region-projections.js +0 -51
  94. package/dist/generators/region-projections.js.map +0 -1
  95. package/dist/generators/region-projections.test.d.ts +0 -2
  96. package/dist/generators/region-projections.test.d.ts.map +0 -1
  97. package/dist/generators/region-projections.test.js +0 -58
  98. package/dist/generators/region-projections.test.js.map +0 -1
  99. package/dist/generators/region.d.ts +0 -24
  100. package/dist/generators/region.d.ts.map +0 -1
  101. package/dist/generators/region.js +0 -87
  102. package/dist/generators/region.js.map +0 -1
  103. package/dist/generators/region.test.d.ts +0 -2
  104. package/dist/generators/region.test.d.ts.map +0 -1
  105. package/dist/generators/region.test.js +0 -125
  106. package/dist/generators/region.test.js.map +0 -1
  107. package/dist/generators/surface-profiles.d.ts +0 -48
  108. package/dist/generators/surface-profiles.d.ts.map +0 -1
  109. package/dist/generators/surface-profiles.js +0 -98
  110. package/dist/generators/surface-profiles.js.map +0 -1
  111. package/dist/lib/frontmatter.d.ts +0 -55
  112. package/dist/lib/frontmatter.d.ts.map +0 -1
  113. package/dist/lib/frontmatter.js +0 -92
  114. package/dist/lib/frontmatter.js.map +0 -1
  115. package/dist/lib/frontmatter.test.d.ts +0 -15
  116. package/dist/lib/frontmatter.test.d.ts.map +0 -1
  117. package/dist/lib/frontmatter.test.js +0 -98
  118. package/dist/lib/frontmatter.test.js.map +0 -1
  119. package/dist/lib/hook-intents.d.ts +0 -56
  120. package/dist/lib/hook-intents.d.ts.map +0 -1
  121. package/dist/lib/hook-intents.js +0 -84
  122. package/dist/lib/hook-intents.js.map +0 -1
  123. package/dist/lib/writePerimeter.d.ts +0 -72
  124. package/dist/lib/writePerimeter.d.ts.map +0 -1
  125. package/dist/lib/writePerimeter.js +0 -128
  126. package/dist/lib/writePerimeter.js.map +0 -1
  127. package/dist/surfaces/__tests__/adapter.test.d.ts +0 -2
  128. package/dist/surfaces/__tests__/adapter.test.d.ts.map +0 -1
  129. package/dist/surfaces/__tests__/adapter.test.js +0 -86
  130. package/dist/surfaces/__tests__/adapter.test.js.map +0 -1
  131. package/dist/surfaces/__tests__/claude-skill-pointer-drift.test.d.ts +0 -2
  132. package/dist/surfaces/__tests__/claude-skill-pointer-drift.test.d.ts.map +0 -1
  133. package/dist/surfaces/__tests__/claude-skill-pointer-drift.test.js +0 -180
  134. package/dist/surfaces/__tests__/claude-skill-pointer-drift.test.js.map +0 -1
  135. package/dist/surfaces/__tests__/telemetry.test.d.ts +0 -2
  136. package/dist/surfaces/__tests__/telemetry.test.d.ts.map +0 -1
  137. package/dist/surfaces/__tests__/telemetry.test.js +0 -44
  138. package/dist/surfaces/__tests__/telemetry.test.js.map +0 -1
  139. package/dist/surfaces/adapter.d.ts +0 -70
  140. package/dist/surfaces/adapter.d.ts.map +0 -1
  141. package/dist/surfaces/adapter.js +0 -2
  142. package/dist/surfaces/adapter.js.map +0 -1
  143. package/dist/surfaces/adapters/claude.d.ts +0 -3
  144. package/dist/surfaces/adapters/claude.d.ts.map +0 -1
  145. package/dist/surfaces/adapters/claude.js +0 -72
  146. package/dist/surfaces/adapters/claude.js.map +0 -1
  147. package/dist/surfaces/adapters/codex.d.ts +0 -3
  148. package/dist/surfaces/adapters/codex.d.ts.map +0 -1
  149. package/dist/surfaces/adapters/codex.js +0 -61
  150. package/dist/surfaces/adapters/codex.js.map +0 -1
  151. package/dist/surfaces/adapters/copilot.d.ts +0 -3
  152. package/dist/surfaces/adapters/copilot.d.ts.map +0 -1
  153. package/dist/surfaces/adapters/copilot.js +0 -59
  154. package/dist/surfaces/adapters/copilot.js.map +0 -1
  155. package/dist/surfaces/adapters/cursor.d.ts +0 -3
  156. package/dist/surfaces/adapters/cursor.d.ts.map +0 -1
  157. package/dist/surfaces/adapters/cursor.js +0 -78
  158. package/dist/surfaces/adapters/cursor.js.map +0 -1
  159. package/dist/surfaces/registry.d.ts +0 -76
  160. package/dist/surfaces/registry.d.ts.map +0 -1
  161. package/dist/surfaces/registry.js +0 -117
  162. package/dist/surfaces/registry.js.map +0 -1
  163. package/dist/surfaces/telemetry.d.ts +0 -24
  164. package/dist/surfaces/telemetry.d.ts.map +0 -1
  165. package/dist/surfaces/telemetry.js +0 -25
  166. package/dist/surfaces/telemetry.js.map +0 -1
@@ -1,98 +0,0 @@
1
- /**
2
- * Surface profiles — per-target execution model descriptors.
3
- * Downstream generators receive the profile for the target they're emitting to.
4
- * BET-270 Slice 0: type system + registry only. Generators accept but do not yet use the profile.
5
- * BET-270 Slice 4: pluggable surface registration + fallback.
6
- */
7
- // ── Registry ───────────────────────────────────────────────────────────
8
- export const SURFACE_PROFILES = {
9
- claude: {
10
- executionModel: 'interactive',
11
- format: 'multi-file',
12
- sessionModel: 'conversational',
13
- tokenBudget: 50000,
14
- workflowStyle: 'orchestrated',
15
- },
16
- cursor: {
17
- executionModel: 'interactive',
18
- format: 'multi-file',
19
- sessionModel: 'conversational',
20
- tokenBudget: 50000,
21
- workflowStyle: 'orchestrated',
22
- },
23
- codex: {
24
- executionModel: 'batch',
25
- format: 'multi-file',
26
- sessionModel: 'autonomous',
27
- tokenBudget: 100000,
28
- workflowStyle: 'direct',
29
- },
30
- copilot: {
31
- executionModel: 'passive',
32
- format: 'single-file',
33
- sessionModel: 'stateless',
34
- tokenBudget: 30000,
35
- workflowStyle: 'guided',
36
- },
37
- };
38
- /** Runtime-registered surfaces. Built-ins live in SURFACE_PROFILES and cannot be overwritten. */
39
- const _runtimeRegistry = new Map();
40
- /**
41
- * Reset the runtime registry. Exposed for test isolation only — do not use in production code.
42
- * @internal
43
- */
44
- export function _resetRuntimeRegistryForTesting() {
45
- _runtimeRegistry.clear();
46
- }
47
- // ── Validation ────────────────────────────────────────────────────────
48
- /**
49
- * Type guard that validates a profile object has all required fields with correct types.
50
- * Returns false for missing fields or wrong-type values.
51
- * Use this to validate profiles at registration time.
52
- */
53
- export function validateSurfaceProfile(profile) {
54
- if (!profile || typeof profile !== 'object')
55
- return false;
56
- const p = profile;
57
- return (['batch', 'interactive', 'passive'].includes(p.executionModel) &&
58
- ['multi-file', 'single-file'].includes(p.format) &&
59
- ['stateless', 'conversational', 'autonomous'].includes(p.sessionModel) &&
60
- typeof p.tokenBudget === 'number' &&
61
- p.tokenBudget > 0 &&
62
- ['orchestrated', 'direct', 'guided'].includes(p.workflowStyle));
63
- }
64
- // ── Registration ──────────────────────────────────────────────────────
65
- /**
66
- * Register a new surface at runtime.
67
- * Validates the profile before adding — throws if invalid.
68
- * Cannot overwrite built-in surfaces (claude, cursor, codex, copilot).
69
- */
70
- export function registerSurface(name, profile) {
71
- if (name in SURFACE_PROFILES) {
72
- throw new Error(`Cannot overwrite built-in surface "${name}". Built-in surfaces are immutable.`);
73
- }
74
- if (!validateSurfaceProfile(profile)) {
75
- throw new Error(`Invalid profile for surface "${name}". Ensure all required fields are present with correct types.`);
76
- }
77
- _runtimeRegistry.set(name, profile);
78
- }
79
- /**
80
- * Returns all registered surface names — built-ins plus any runtime-registered surfaces.
81
- */
82
- export function getRegisteredSurfaces() {
83
- return [...Object.keys(SURFACE_PROFILES), ..._runtimeRegistry.keys()];
84
- }
85
- // ── Resolver ──────────────────────────────────────────────────────────
86
- /**
87
- * Resolve a surface profile for the given target name.
88
- * Checks runtime-registered surfaces first, then built-in SURFACE_PROFILES.
89
- * Falls back to the codex profile for unknown targets.
90
- */
91
- export function resolveSurfaceProfile(target) {
92
- const runtime = _runtimeRegistry.get(target);
93
- if (runtime)
94
- return runtime;
95
- const known = SURFACE_PROFILES[target];
96
- return known ?? SURFACE_PROFILES.codex;
97
- }
98
- //# sourceMappingURL=surface-profiles.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"surface-profiles.js","sourceRoot":"","sources":["../../src/generators/surface-profiles.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAmBH,0EAA0E;AAE1E,MAAM,CAAC,MAAM,gBAAgB,GAAuC;IAClE,MAAM,EAAE;QACN,cAAc,EAAE,aAAa;QAC7B,MAAM,EAAE,YAAY;QACpB,YAAY,EAAE,gBAAgB;QAC9B,WAAW,EAAE,KAAK;QAClB,aAAa,EAAE,cAAc;KAC9B;IACD,MAAM,EAAE;QACN,cAAc,EAAE,aAAa;QAC7B,MAAM,EAAE,YAAY;QACpB,YAAY,EAAE,gBAAgB;QAC9B,WAAW,EAAE,KAAK;QAClB,aAAa,EAAE,cAAc;KAC9B;IACD,KAAK,EAAE;QACL,cAAc,EAAE,OAAO;QACvB,MAAM,EAAE,YAAY;QACpB,YAAY,EAAE,YAAY;QAC1B,WAAW,EAAE,MAAM;QACnB,aAAa,EAAE,QAAQ;KACxB;IACD,OAAO,EAAE;QACP,cAAc,EAAE,SAAS;QACzB,MAAM,EAAE,aAAa;QACrB,YAAY,EAAE,WAAW;QACzB,WAAW,EAAE,KAAK;Q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AI,EAAE,OAAO,CAAC,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB;IACnC,OAAO,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAAE,GAAG,gBAAgB,CAAC,IAAI,EAAE,CAAC,CAAC;AACxE,CAAC;AAED,yEAAyE;AAEzE;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAAc;IAClD,MAAM,OAAO,GAAG,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC7C,IAAI,OAAO;QAAE,OAAO,OAAO,CAAC;IAC5B,MAAM,KAAK,GAAG,gBAAgB,CAAC,MAAoB,CAAC,CAAC;IACrD,OAAO,KAAK,IAAI,gBAAgB,CAAC,KAAK,CAAC;AACzC,CAAC"}
@@ -1,55 +0,0 @@
1
- /**
2
- * parseSetupFrontmatter — the single shared YAML-frontmatter parser for setup
3
- * authoring assets (skills / rules / hooks).
4
- *
5
- * Unifies three previously-divergent copies that lived inline in:
6
- * - commands/handshake.ts (parseSetupAuthoringFrontmatter)
7
- * - commands/migrate-setup.ts (parseFrontmatter)
8
- * - commands/setup-ingest.ts (parseFrontmatter)
9
- *
10
- * The three were identical on scalar fields but DIVERGED on array items:
11
- * handshake stripped surrounding quotes from each `- item`, the other two did
12
- * not. That meant a trigger written as `- "triage: [anything]"` survived as
13
- * `triage: [anything]` through handshake but as `"triage: [anything]"` through
14
- * migrate/ingest — the same file produced different DB rows depending on path.
15
- * This parser adopts handshake's quote-stripping as canonical for BOTH scalars
16
- * and array items, closing the divergence.
17
- *
18
- * NOTE — intentionally out of scope: generators/portable-knowledge.ts keeps its own
19
- * `parseFrontmatter`.
20
- * It has different parsing semantics / return shapes and is NOT folded in.
21
- *
22
- * Supported shape (deliberately minimal, matching the originals):
23
- * - YAML-style `---` fences (CRLF or LF). No fence → name from H1, rest empty.
24
- * - Scalar fields: `key: value` (surrounding quotes stripped).
25
- * - Array fields: `key:` followed by indented ` - item` lines (quotes stripped).
26
- * - Multi-line `>-` block scalars are NOT expanded — the literal `>-` token is
27
- * stored as the value and continuation lines are ignored. This matches the
28
- * behavior of all three original parsers (e.g. triage.md's `description: >-`).
29
- *
30
- * Chain: TEN-1459 (handshake reads FS), WP-345.
31
- */
32
- export interface ParsedSetupFrontmatter {
33
- /** The frontmatter `id:` field, if present (handshake/setup-ingest use it). */
34
- frontmatterId?: string;
35
- /** `name:` field, falling back to the body's first H1, else ''. */
36
- name: string;
37
- /** `description:` field, else ''. */
38
- description: string;
39
- /** Everything after the closing `---` fence (the raw markdown body). */
40
- body: string;
41
- /** `triggers:` array (quotes stripped per item). */
42
- triggers: string[];
43
- /** `semanticRefs:` array (quotes stripped per item). */
44
- semanticRefs: string[];
45
- /** `assetKind:` field, if present (setup-ingest uses it). */
46
- assetKind?: string;
47
- }
48
- /**
49
- * Parse minimal YAML frontmatter from a .md file's raw contents.
50
- *
51
- * Returns the union of fields every setup-authoring caller needs. Callers that
52
- * don't use a given field simply ignore it.
53
- */
54
- export declare function parseSetupFrontmatter(raw: string): ParsedSetupFrontmatter;
55
- //# sourceMappingURL=frontmatter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"frontmatter.d.ts","sourceRoot":"","sources":["../../src/lib/frontmatter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,MAAM,WAAW,sBAAsB;IACrC,+EAA+E;IAC/E,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,mEAAmE;IACnE,IAAI,EAAE,MAAM,CAAC;IACb,qCAAqC;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,wEAAwE;IACxE,IAAI,EAAE,MAAM,CAAC;IACb,oDAAoD;IACpD,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,wDAAwD;IACxD,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,6DAA6D;IAC7D,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAOD;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,sBAAsB,CAoDzE"}
@@ -1,92 +0,0 @@
1
- /**
2
- * parseSetupFrontmatter — the single shared YAML-frontmatter parser for setup
3
- * authoring assets (skills / rules / hooks).
4
- *
5
- * Unifies three previously-divergent copies that lived inline in:
6
- * - commands/handshake.ts (parseSetupAuthoringFrontmatter)
7
- * - commands/migrate-setup.ts (parseFrontmatter)
8
- * - commands/setup-ingest.ts (parseFrontmatter)
9
- *
10
- * The three were identical on scalar fields but DIVERGED on array items:
11
- * handshake stripped surrounding quotes from each `- item`, the other two did
12
- * not. That meant a trigger written as `- "triage: [anything]"` survived as
13
- * `triage: [anything]` through handshake but as `"triage: [anything]"` through
14
- * migrate/ingest — the same file produced different DB rows depending on path.
15
- * This parser adopts handshake's quote-stripping as canonical for BOTH scalars
16
- * and array items, closing the divergence.
17
- *
18
- * NOTE — intentionally out of scope: generators/portable-knowledge.ts keeps its own
19
- * `parseFrontmatter`.
20
- * It has different parsing semantics / return shapes and is NOT folded in.
21
- *
22
- * Supported shape (deliberately minimal, matching the originals):
23
- * - YAML-style `---` fences (CRLF or LF). No fence → name from H1, rest empty.
24
- * - Scalar fields: `key: value` (surrounding quotes stripped).
25
- * - Array fields: `key:` followed by indented ` - item` lines (quotes stripped).
26
- * - Multi-line `>-` block scalars are NOT expanded — the literal `>-` token is
27
- * stored as the value and continuation lines are ignored. This matches the
28
- * behavior of all three original parsers (e.g. triage.md's `description: >-`).
29
- *
30
- * Chain: TEN-1459 (handshake reads FS), WP-345.
31
- */
32
- /** Strip a single pair of surrounding single/double quotes. */
33
- function stripQuotes(value) {
34
- return value.replace(/^['"]|['"]$/g, '');
35
- }
36
- /**
37
- * Parse minimal YAML frontmatter from a .md file's raw contents.
38
- *
39
- * Returns the union of fields every setup-authoring caller needs. Callers that
40
- * don't use a given field simply ignore it.
41
- */
42
- export function parseSetupFrontmatter(raw) {
43
- const fmMatch = raw.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/);
44
- if (!fmMatch) {
45
- // No frontmatter — derive name from H1, leave everything else empty.
46
- const h1 = raw.match(/^# (.+)$/m);
47
- return { name: h1?.[1] ?? '', description: '', body: raw, triggers: [], semanticRefs: [] };
48
- }
49
- const fmBlock = fmMatch[1];
50
- const body = fmMatch[2];
51
- const fields = new Map();
52
- const arrayFields = new Map();
53
- // Parse simple `key: value` and `key:\n - item` YAML arrays.
54
- const lines = fmBlock.split('\n');
55
- let currentArrayKey = null;
56
- let currentArrayValues = [];
57
- for (const line of lines) {
58
- const arrayItemMatch = line.match(/^\s+-\s+(.+)$/);
59
- const keyValueMatch = line.match(/^(\w+):\s*(.*)$/);
60
- if (arrayItemMatch && currentArrayKey) {
61
- currentArrayValues.push(stripQuotes(arrayItemMatch[1].trim()));
62
- }
63
- else if (keyValueMatch) {
64
- if (currentArrayKey) {
65
- arrayFields.set(currentArrayKey, currentArrayValues);
66
- currentArrayKey = null;
67
- currentArrayValues = [];
68
- }
69
- const [, key, value] = keyValueMatch;
70
- if (value.trim() === '') {
71
- // Start of an array block.
72
- currentArrayKey = key;
73
- }
74
- else {
75
- fields.set(key, stripQuotes(value.trim()));
76
- }
77
- }
78
- }
79
- if (currentArrayKey) {
80
- arrayFields.set(currentArrayKey, currentArrayValues);
81
- }
82
- return {
83
- frontmatterId: fields.get('id'),
84
- name: fields.get('name') ?? body.match(/^# (.+)$/m)?.[1] ?? '',
85
- description: fields.get('description') ?? '',
86
- body,
87
- triggers: arrayFields.get('triggers') ?? [],
88
- semanticRefs: arrayFields.get('semanticRefs') ?? [],
89
- assetKind: fields.get('assetKind'),
90
- };
91
- }
92
- //# sourceMappingURL=frontmatter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"frontmatter.js","sourceRoot":"","sources":["../../src/lib/frontmatter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAmBH,+DAA+D;AA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stripping divergence between
5
- * handshake (stripped) and migrate-setup / setup-ingest (did not strip) is
6
- * closed. All three now route through this one function, so a trigger written
7
- * as `- "triage: [anything]"` resolves to `triage: [anything]` on every path.
8
- *
9
- * We parse the REAL fixture `.productbrain/skills/triage.md` rather than a
10
- * synthetic string so the test fails if that file's shape drifts.
11
- *
12
- * Chain: TEN-1459, WP-345.
13
- */
14
- export {};
15
- //# sourceMappingURL=frontmatter.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"frontmatter.test.d.ts","sourceRoot":"","sources":["../../src/lib/frontmatter.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG"}
@@ -1,98 +0,0 @@
1
- /**
2
- * parseSetupFrontmatter regression tests.
3
- *
4
- * The load-bearing assertion: the array-item quote-stripping divergence between
5
- * handshake (stripped) and migrate-setup / setup-ingest (did not strip) is
6
- * closed. All three now route through this one function, so a trigger written
7
- * as `- "triage: [anything]"` resolves to `triage: [anything]` on every path.
8
- *
9
- * We parse the REAL fixture `.productbrain/skills/triage.md` rather than a
10
- * synthetic string so the test fails if that file's shape drifts.
11
- *
12
- * Chain: TEN-1459, WP-345.
13
- */
14
- import { describe, expect, it } from 'vitest';
15
- import { readFileSync } from 'node:fs';
16
- import { fileURLToPath } from 'node:url';
17
- import { dirname, join } from 'node:path';
18
- import { parseSetupFrontmatter } from './frontmatter.js';
19
- // repo root: packages/cli/src/lib → up four levels
20
- const here = dirname(fileURLToPath(import.meta.url));
21
- const repoRoot = join(here, '..', '..', '..', '..');
22
- const triagePath = join(repoRoot, '.productbrain', 'skills', 'triage.md');
23
- describe('parseSetupFrontmatter — array-quote divergence is closed', () => {
24
- it('strips surrounding quotes from the triage.md `triggers` list item', () => {
25
- const raw = readFileSync(triagePath, 'utf8');
26
- const parsed = parseSetupFrontmatter(raw);
27
- // The fixture contains a YAML list item: - "triage: [anything]"
28
- // Quotes MUST be stripped (handshake's behavior, now canonical).
29
- expect(parsed.triggers).toContain('triage: [anything]');
30
- // And the un-stripped form must NOT survive.
31
- expect(parsed.triggers).not.toContain('"triage: [anything]"');
32
- });
33
- it('extracts the scalar fields the callers depend on', () => {
34
- const raw = readFileSync(triagePath, 'utf8');
35
- const parsed = parseSetupFrontmatter(raw);
36
- expect(parsed.name).toBe('triage');
37
- // body is everything after the closing fence — contains the H1.
38
- expect(parsed.body).toContain('# Triage');
39
- // The multi-line `>-` block scalar is preserved as the literal token
40
- // (the originals never expanded it; we keep that behavior).
41
- expect(parsed.description).toBe('>-');
42
- });
43
- it('resolves the full triggers list to its canonical (quote-stripped) form', () => {
44
- // The divergence is structurally gone because all three callers now invoke
45
- // this one function. What that function MUST produce is asserted literally
46
- // here: the quoted item `- "triage: [anything]"` strips to `triage:
47
- // [anything]` while every bare item is untouched. Under the old
48
- // migrate-setup / setup-ingest path the third item would have retained its
49
- // quotes — so this exact array is what closes the bug, not a self-comparison.
50
- const raw = readFileSync(triagePath, 'utf8');
51
- const parsed = parseSetupFrontmatter(raw);
52
- expect(parsed.triggers).toEqual([
53
- 'triage',
54
- 'triage this',
55
- 'triage: [anything]',
56
- 'what should I focus on?',
57
- 'what should I work on?',
58
- 'where do I start?',
59
- 'help me think about this',
60
- 'diagnose',
61
- ]);
62
- });
63
- });
64
- describe('parseSetupFrontmatter — boundary cases', () => {
65
- it('returns empty fields and the raw body when there is no `---` fence', () => {
66
- const parsed = parseSetupFrontmatter('# Heading Only\n\nbody text');
67
- expect(parsed.name).toBe('Heading Only');
68
- expect(parsed.description).toBe('');
69
- expect(parsed.triggers).toEqual([]);
70
- expect(parsed.semanticRefs).toEqual([]);
71
- expect(parsed.frontmatterId).toBeUndefined();
72
- expect(parsed.assetKind).toBeUndefined();
73
- expect(parsed.body).toBe('# Heading Only\n\nbody text');
74
- });
75
- it('handles an empty frontmatter block', () => {
76
- const parsed = parseSetupFrontmatter('---\n\n---\n# Title\n');
77
- expect(parsed.name).toBe('Title');
78
- expect(parsed.triggers).toEqual([]);
79
- });
80
- it('extracts id and assetKind scalar fields when present', () => {
81
- const raw = [
82
- '---',
83
- 'id: SETUP-SKILL-EXAMPLE',
84
- 'name: example',
85
- 'assetKind: skill',
86
- 'triggers:',
87
- " - 'quoted trigger'",
88
- ' - bare trigger',
89
- '---',
90
- '# Example',
91
- ].join('\n');
92
- const parsed = parseSetupFrontmatter(raw);
93
- expect(parsed.frontmatterId).toBe('SETUP-SKILL-EXAMPLE');
94
- expect(parsed.assetKind).toBe('skill');
95
- expect(parsed.triggers).toEqual(['quoted trigger', 'bare trigger']);
96
- });
97
- });
98
- //# sourceMappingURL=frontmatter.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"frontmatter.test.js","sourceRoot":"","sources":["../../src/lib/frontmatter.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,mDAAmD;AACnD,MAAM,IAAI,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AACrD,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AACpD,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,EAAE,eAAe,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;AAE1E,QAAQ,CAAC,0DAA0D,EAAE,GAAG,EAAE;IACxE,EAAE,CAAC,mEAAmE,EAAE,GAAG,EAAE;QAC3E,MAAM,GAAG,GAAG,YAAY,CAAC,UAAU,EAAE,MAAM,C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CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACb,MAAM,MAAM,GAAG,qBAAqB,CAAC,GAAG,CAAC,CAAC;QAC1C,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;QACzD,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACvC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,gBAAgB,EAAE,cAAc,CAAC,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,56 +0,0 @@
1
- /**
2
- * Hook intent model — WP-310 E3a.
3
- * Defines the two pb hook intents and a composition function that returns
4
- * only the hook entries not already present in existing settings.
5
- *
6
- * Also exposes getHookStatusForSurface (WP-310 E3b / S4) for multi-surface
7
- * opt-in reporting in runHandshakeInit().
8
- *
9
- * Kept separate from handshake.ts so S4 (multi-surface opt-in) can import
10
- * composeHooksFromIntents without pulling in the full handshake module.
11
- */
12
- import type { SurfaceName } from '../surfaces/registry.js';
13
- export type HookIntent = 'session-start' | 'session-close';
14
- /** TASK-763 (DEC-2038): close runs when the conversation ends (SessionEnd), never after every turn (Stop, TEN-4314). */
15
- export type HookEvent = 'SessionStart' | 'SessionEnd';
16
- export interface HookIntentConfig {
17
- command: string;
18
- statusMessage?: string;
19
- /** Seconds. SessionEnd hooks default to 1.5 s, shorter than one pb session close (about 2 s). */
20
- timeout?: number;
21
- hookEvent: HookEvent;
22
- }
23
- export declare const HOOK_INTENT_CONFIGS: Record<HookIntent, HookIntentConfig>;
24
- export interface HookAddition {
25
- event: HookEvent;
26
- entry: {
27
- hooks: Array<{
28
- type: string;
29
- command: string;
30
- statusMessage?: string;
31
- timeout?: number;
32
- }>;
33
- };
34
- label: string;
35
- }
36
- /**
37
- * Returns the hook additions needed for the given intents.
38
- * Only returns entries whose command is NOT already present in existingHooks.
39
- *
40
- * @param intents - The hook intents to compose.
41
- * @param existingHooks - The current hooks object from settings (e.g. settings.hooks ?? {}).
42
- */
43
- export declare function composeHooksFromIntents(intents: HookIntent[], existingHooks: Record<string, unknown>): HookAddition[];
44
- export interface HookStatusResult {
45
- writable: boolean;
46
- reason: string;
47
- }
48
- /**
49
- * Determines whether hook files can be written for a given surface.
50
- *
51
- * INS-740: Cursor and Copilot have empty hookEvents in SURFACE_REGISTRY,
52
- * so no hook files are written for them. This function reports that status
53
- * so runHandshakeInit() can surface an informational note to the user.
54
- */
55
- export declare function getHookStatusForSurface(surface: SurfaceName): HookStatusResult;
56
- //# sourceMappingURL=hook-intents.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hook-intents.d.ts","sourceRoot":"","sources":["../../src/lib/hook-intents.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,MAAM,MAAM,UAAU,GAAG,eAAe,GAAG,eAAe,CAAC;AAE3D,wHAAwH;AACxH,MAAM,MAAM,SAAS,GAAG,cAAc,GAAG,YAAY,CAAC;AAEtD,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iGAAiG;IACjG,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,SAAS,CAAC;CACtB;AAID,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,UAAU,EAAE,gBAAgB,CAYpE,CAAC;AASF,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,SAAS,CAAC;IACjB,KAAK,EAAE;QAAE,KAAK,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,MAAM,CAAC;YAAC,aAAa,CAAC,EAAE,MAAM,CAAC;YAAC,OAAO,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,CAAC;IACrG,KAAK,EAAE,MAAM,CAAC;CACf;AAOD;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,UAAU,EAAE,EACrB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACrC,YAAY,EAAE,CA4BhB;AAID,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,WAAW,GAAG,gBAAgB,CAS9E"}
@@ -1,84 +0,0 @@
1
- /**
2
- * Hook intent model — WP-310 E3a.
3
- * Defines the two pb hook intents and a composition function that returns
4
- * only the hook entries not already present in existing settings.
5
- *
6
- * Also exposes getHookStatusForSurface (WP-310 E3b / S4) for multi-surface
7
- * opt-in reporting in runHandshakeInit().
8
- *
9
- * Kept separate from handshake.ts so S4 (multi-surface opt-in) can import
10
- * composeHooksFromIntents without pulling in the full handshake module.
11
- */
12
- import { SURFACE_REGISTRY } from '../surfaces/registry.js';
13
- // Hook failure contract (TEN-712): every hook command MUST end with '|| true' so Claude Code always starts even if pb is unavailable.
14
- // session-start keeps stderr (2>&1) so every refusal reaches the agent once (TASK-649, WP-810).
15
- export const HOOK_INTENT_CONFIGS = {
16
- 'session-start': {
17
- command: 'pb session start 2>&1 || true',
18
- statusMessage: 'Opening pb session...',
19
- hookEvent: 'SessionStart',
20
- },
21
- 'session-close': {
22
- command: 'pb session close 2>/dev/null || true',
23
- statusMessage: 'Closing pb session...',
24
- timeout: 15,
25
- hookEvent: 'SessionEnd',
26
- },
27
- };
28
- function hasCommand(groups, cmd) {
29
- return (groups ?? []).some((g) => g.hooks?.some((h) => h.command === cmd));
30
- }
31
- const INTENT_LABELS = {
32
- 'session-start': 'SessionStart → pb session start',
33
- 'session-close': 'SessionEnd → pb session close',
34
- };
35
- /**
36
- * Returns the hook additions needed for the given intents.
37
- * Only returns entries whose command is NOT already present in existingHooks.
38
- *
39
- * @param intents - The hook intents to compose.
40
- * @param existingHooks - The current hooks object from settings (e.g. settings.hooks ?? {}).
41
- */
42
- export function composeHooksFromIntents(intents, existingHooks) {
43
- const additions = [];
44
- for (const intent of intents) {
45
- const cfg = HOOK_INTENT_CONFIGS[intent];
46
- const existing = existingHooks[cfg.hookEvent];
47
- if (hasCommand(existing, cfg.command))
48
- continue;
49
- const hookEntry = {
50
- type: 'command',
51
- command: cfg.command,
52
- };
53
- if (cfg.statusMessage !== undefined) {
54
- hookEntry.statusMessage = cfg.statusMessage;
55
- }
56
- if (cfg.timeout !== undefined) {
57
- hookEntry.timeout = cfg.timeout;
58
- }
59
- additions.push({
60
- event: cfg.hookEvent,
61
- entry: { hooks: [hookEntry] },
62
- label: INTENT_LABELS[intent],
63
- });
64
- }
65
- return additions;
66
- }
67
- /**
68
- * Determines whether hook files can be written for a given surface.
69
- *
70
- * INS-740: Cursor and Copilot have empty hookEvents in SURFACE_REGISTRY,
71
- * so no hook files are written for them. This function reports that status
72
- * so runHandshakeInit() can surface an informational note to the user.
73
- */
74
- export function getHookStatusForSurface(surface) {
75
- const cap = SURFACE_REGISTRY[surface];
76
- if (cap.hookEvents.length > 0) {
77
- return { writable: true, reason: 'native hook events supported' };
78
- }
79
- return {
80
- writable: false,
81
- reason: `${surface} has no session hook events — run \`pb session start\` manually`,
82
- };
83
- }
84
- //# sourceMappingURL=hook-intents.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hook-intents.js","sourceRoot":"","sources":["../../src/lib/hook-intents.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAgB3D,sIAAsI;AACtI,gGAAgG;AAChG,MAAM,CAAC,MAAM,mBAAmB,GAAyC;IACvE,eAAe,EAAE;QACf,OAAO,EAAE,+BAA+B;QACxC,aAAa,EAAE,uBAAuB;QACtC,SAAS,EAAE,cAAc;KA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GAAG,CAAC,SAAS;YACpB,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,SAAS,CAAC,EAAE;YAC7B,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC;SAC7B,CAAC,CAAC;IACL,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AASD;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CAAC,OAAoB;IAC1D,MAAM,GAAG,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACtC,IAAI,GAAG,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC9B,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,8BAA8B,EAAE,CAAC;IACpE,CAAC;IACD,OAAO;QACL,QAAQ,EAAE,KAAK;QACf,MAAM,EAAE,GAAG,OAAO,iEAAiE;KACpF,CAAC;AACJ,CAAC"}
@@ -1,72 +0,0 @@
1
- /**
2
- * Write perimeter — WP-421 S7 (STD-236, doneWhen #22). Re-homed from
3
- * `setup/perimeter.ts` in WP-776 S3d/S3f: despite its original name, this guard was never
4
- * setup-asset-specific — its job ("PB never writes outside its declared surfaces," STD-234)
5
- * covers every adapter write (`.claude/`, `.cursor/`, `.codex/`, etc.), which is why
6
- * it survives the deletion of the setup-assets system while the module it used to live under
7
- * does not.
8
- *
9
- * Single runtime guard for every adapter disk write pb makes. Writes are
10
- * permitted ONLY within paths that the manifest explicitly declares safe:
11
- *
12
- * - `path.resolve(process.cwd(), '.productbrain')` — hard-coded canonical
13
- * authoring root. Always allowed regardless of manifest contents (this is
14
- * where pb itself stores its own state).
15
- * - `path.resolve(process.cwd(), surface)` for every `surface` in
16
- * `manifest.surfaces[]` — explicit per-workspace allowlist.
17
- *
18
- * Anything else throws `setup-perimeter-violation` (name kept stable for tests —
19
- * renaming the error code is a separate, non-mechanical change). This is the single
20
- * choke point the S7 perimeter fixtures exercise (HOME-sandboxed) and is the
21
- * only place we encode the "PB never writes outside its declared surfaces"
22
- * promise (STD-234) as RUNTIME enforcement rather than convention.
23
- *
24
- * Chain: STD-234 (write perimeter), STD-236 (this guard), DEC-952 (adapters),
25
- * DEC-955 (manifest defaults).
26
- */
27
- /**
28
- * The minimal manifest shape this guard consults. Accepts the full
29
- * `Manifest` from `generators/manifest.ts` or any structurally compatible
30
- * subset (e.g. tests that synthesize just `{ surfaces: [...] }`).
31
- */
32
- export interface PerimeterManifest {
33
- surfaces?: string[];
34
- }
35
- /** Error code emitted when a write is refused. Stable string for tests. */
36
- export declare const SETUP_PERIMETER_VIOLATION: "setup-perimeter-violation";
37
- /**
38
- * Optional argument bag — extends the manifest with a `cwd` override so callers
39
- * can validate against an explicit repo root instead of `process.cwd()`. Added
40
- * for WP-431 S3 (review fix #5) so the manifest writer no longer mutates global
41
- * state via `process.chdir` to make the perimeter check land on the right root.
42
- */
43
- export interface PerimeterOptions {
44
- cwd?: string;
45
- }
46
- /**
47
- * Asserts that `absPath` is inside the setup write perimeter for the supplied
48
- * `cwd` (or `process.cwd()` when omitted) + manifest. Throws an Error with
49
- * `code === 'setup-perimeter-violation'` (and a descriptive message containing
50
- * the offending path) when the write is refused.
51
- *
52
- * The function is synchronous and pure aside from the optional `process.cwd()`
53
- * read — adapters call it inline before every write.
54
- *
55
- * Per STD-236 the path argument MUST already be absolute. Callers pass the
56
- * fully-resolved on-disk path they intend to write to; the guard does the
57
- * containment check from that point. (Resolving relative paths inside the
58
- * guard would mask call-site bugs where the caller meant to write inside the
59
- * repo but accidentally produced an absolute path elsewhere.)
60
- */
61
- export declare function assertSetupWritePath(absPath: string, manifest: PerimeterManifest, options?: PerimeterOptions): void;
62
- /**
63
- * isSetupWritePathAllowed — non-throwing companion to assertSetupWritePath.
64
- *
65
- * Returns true iff `absPath` resolves inside the perimeter (.productbrain/ plus the
66
- * manifest's declared surfaces). Use it to filter candidate paths BEFORE asserting —
67
- * e.g. surface paths a workspace hasn't enabled — so excluded surfaces are skipped
68
- * silently instead of throwing and being logged as a false warning on every run.
69
- * Empty/non-string/NUL paths return false (the assert variant throws on those).
70
- */
71
- export declare function isSetupWritePathAllowed(absPath: string, manifest: PerimeterManifest, options?: PerimeterOptions): boolean;
72
- //# sourceMappingURL=writePerimeter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"writePerimeter.d.ts","sourceRoot":"","sources":["../../src/lib/writePerimeter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAIH;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,2EAA2E;AAC3E,eAAO,MAAM,yBAAyB,EAAG,2BAAoC,CAAC;AA8B9E;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,iBAAiB,EAC3B,OAAO,GAAE,gBAAqB,GAC7B,IAAI,CAuBN;AAED;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,iBAAiB,EAC3B,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAmBT"}