@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,128 +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
|
-
import { resolve, sep } from 'path';
|
|
28
|
-
/** Error code emitted when a write is refused. Stable string for tests. */
|
|
29
|
-
export const SETUP_PERIMETER_VIOLATION = 'setup-perimeter-violation';
|
|
30
|
-
/**
|
|
31
|
-
* Hard-coded authoring root. Always allowed in addition to manifest surfaces.
|
|
32
|
-
* Resolved at call time against `process.cwd()` so the perimeter shifts
|
|
33
|
-
* correctly when tests override the working directory.
|
|
34
|
-
*/
|
|
35
|
-
const HARD_CODED_ALLOWED = '.productbrain';
|
|
36
|
-
/**
|
|
37
|
-
* Resolve `pathSpec` against a base. Treats `pathSpec` as relative to `base`
|
|
38
|
-
* unless it is already absolute. Mirrors `path.resolve(base, spec)` semantics
|
|
39
|
-
* but is spelled out for clarity at the call site below.
|
|
40
|
-
*/
|
|
41
|
-
function resolveUnder(base, pathSpec) {
|
|
42
|
-
return resolve(base, pathSpec);
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Returns true iff `candidate` is at or beneath `root`.
|
|
46
|
-
*
|
|
47
|
-
* Compares the resolved (canonical) forms with a path-separator-aware suffix
|
|
48
|
-
* check so `…/.productbrain` does not accidentally match `…/.productbrain-backup/`.
|
|
49
|
-
*/
|
|
50
|
-
function isWithin(root, candidate) {
|
|
51
|
-
if (candidate === root)
|
|
52
|
-
return true;
|
|
53
|
-
const rootWithSep = root.endsWith(sep) ? root : root + sep;
|
|
54
|
-
return candidate.startsWith(rootWithSep);
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Asserts that `absPath` is inside the setup write perimeter for the supplied
|
|
58
|
-
* `cwd` (or `process.cwd()` when omitted) + manifest. Throws an Error with
|
|
59
|
-
* `code === 'setup-perimeter-violation'` (and a descriptive message containing
|
|
60
|
-
* the offending path) when the write is refused.
|
|
61
|
-
*
|
|
62
|
-
* The function is synchronous and pure aside from the optional `process.cwd()`
|
|
63
|
-
* read — adapters call it inline before every write.
|
|
64
|
-
*
|
|
65
|
-
* Per STD-236 the path argument MUST already be absolute. Callers pass the
|
|
66
|
-
* fully-resolved on-disk path they intend to write to; the guard does the
|
|
67
|
-
* containment check from that point. (Resolving relative paths inside the
|
|
68
|
-
* guard would mask call-site bugs where the caller meant to write inside the
|
|
69
|
-
* repo but accidentally produced an absolute path elsewhere.)
|
|
70
|
-
*/
|
|
71
|
-
export function assertSetupWritePath(absPath, manifest, options = {}) {
|
|
72
|
-
// Defensive: refuse non-absolute paths outright. The contract is "the
|
|
73
|
-
// caller resolves first, the guard checks containment" — accepting a
|
|
74
|
-
// relative path here would make the perimeter dependent on whatever
|
|
75
|
-
// `process.cwd()` happens to be when the guard runs.
|
|
76
|
-
if (!absPath || typeof absPath !== 'string') {
|
|
77
|
-
throw createPerimeterError('Empty or non-string path supplied to assertSetupWritePath.', absPath);
|
|
78
|
-
}
|
|
79
|
-
// Reject any path with NUL bytes outright — catches accidental binary
|
|
80
|
-
// payloads and also POSIX path-canonicalization tricks.
|
|
81
|
-
if (absPath.includes('\0')) {
|
|
82
|
-
throw createPerimeterError('Path contains NUL byte.', absPath);
|
|
83
|
-
}
|
|
84
|
-
if (isSetupWritePathAllowed(absPath, manifest, options))
|
|
85
|
-
return;
|
|
86
|
-
const surfaces = manifest.surfaces ?? [];
|
|
87
|
-
throw createPerimeterError(`Setup write refused: path is outside the declared perimeter ` +
|
|
88
|
-
`(.productbrain/ + manifest.surfaces[${surfaces.join(', ')}]).`, resolve(absPath));
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* isSetupWritePathAllowed — non-throwing companion to assertSetupWritePath.
|
|
92
|
-
*
|
|
93
|
-
* Returns true iff `absPath` resolves inside the perimeter (.productbrain/ plus the
|
|
94
|
-
* manifest's declared surfaces). Use it to filter candidate paths BEFORE asserting —
|
|
95
|
-
* e.g. surface paths a workspace hasn't enabled — so excluded surfaces are skipped
|
|
96
|
-
* silently instead of throwing and being logged as a false warning on every run.
|
|
97
|
-
* Empty/non-string/NUL paths return false (the assert variant throws on those).
|
|
98
|
-
*/
|
|
99
|
-
export function isSetupWritePathAllowed(absPath, manifest, options = {}) {
|
|
100
|
-
if (!absPath || typeof absPath !== 'string')
|
|
101
|
-
return false;
|
|
102
|
-
if (absPath.includes('\0'))
|
|
103
|
-
return false;
|
|
104
|
-
const resolvedTarget = resolve(absPath);
|
|
105
|
-
// WP-431 S3 review fix #5: prefer the explicit cwd argument so callers can
|
|
106
|
-
// validate against an absolute repo root without mutating global state via
|
|
107
|
-
// `process.chdir`. Falls back to `process.cwd()` for legacy adapter callers.
|
|
108
|
-
const cwd = options.cwd ?? process.cwd();
|
|
109
|
-
const allowedRoots = [resolveUnder(cwd, HARD_CODED_ALLOWED)];
|
|
110
|
-
const surfaces = manifest.surfaces ?? [];
|
|
111
|
-
for (const surface of surfaces) {
|
|
112
|
-
if (typeof surface !== 'string' || surface.length === 0)
|
|
113
|
-
continue;
|
|
114
|
-
allowedRoots.push(resolveUnder(cwd, surface));
|
|
115
|
-
}
|
|
116
|
-
return allowedRoots.some((root) => isWithin(root, resolvedTarget));
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Build a tagged Error for a perimeter violation. The `code` field is the
|
|
120
|
-
* stable string tests assert against; the `message` carries human context.
|
|
121
|
-
*/
|
|
122
|
-
function createPerimeterError(reason, path) {
|
|
123
|
-
const err = new Error(`${reason} [path=${String(path)}]`);
|
|
124
|
-
err.code = SETUP_PERIMETER_VIOLATION;
|
|
125
|
-
err.path = path;
|
|
126
|
-
return err;
|
|
127
|
-
}
|
|
128
|
-
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C;AAED;;;GAGG;AACH,SAAS,oBAAoB,CAAC,MAAc,EAAE,IAAa;IACzD,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,GAAG,MAAM,UAAU,MAAM,CAAC,IAAI,CAAC,GAAG,CAGvD,CAAC;IACF,GAAG,CAAC,IAAI,GAAG,yBAAyB,CAAC;IACrC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC;IAChB,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.test.d.ts","sourceRoot":"","sources":["../../../src/surfaces/__tests__/adapter.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SurfaceAdapter contract tests — WP-421 S2c (DEC-952).
|
|
3
|
-
*
|
|
4
|
-
* Verifies every adapter:
|
|
5
|
-
* - has identity, displayName, detect, paths, transform, goldens, canonicalPathFor.
|
|
6
|
-
* - has at least one golden fixture and transform(canonical) === expected.
|
|
7
|
-
* - canonicalPathFor returns null for paths not belonging to that surface.
|
|
8
|
-
*/
|
|
9
|
-
import { describe, expect, it } from 'vitest';
|
|
10
|
-
import { SURFACE_ADAPTERS, SURFACE_ADAPTER_LIST } from '../registry.js';
|
|
11
|
-
import { claudeAdapter } from '../adapters/claude.js';
|
|
12
|
-
import { cursorAdapter } from '../adapters/cursor.js';
|
|
13
|
-
import { codexAdapter } from '../adapters/codex.js';
|
|
14
|
-
import { copilotAdapter } from '../adapters/copilot.js';
|
|
15
|
-
describe('SurfaceAdapter contract', () => {
|
|
16
|
-
it('registers all four adapters', () => {
|
|
17
|
-
expect(SURFACE_ADAPTER_LIST).toHaveLength(4);
|
|
18
|
-
expect(Object.keys(SURFACE_ADAPTERS).sort()).toEqual(['claude', 'codex', 'copilot', 'cursor']);
|
|
19
|
-
});
|
|
20
|
-
it.each(SURFACE_ADAPTER_LIST.map((a) => [a.name, a]))('%s adapter exposes the full interface', (_name, adapter) => {
|
|
21
|
-
expect(typeof adapter.name).toBe('string');
|
|
22
|
-
expect(typeof adapter.displayName).toBe('string');
|
|
23
|
-
expect(typeof adapter.detect).toBe('function');
|
|
24
|
-
expect(typeof adapter.paths).toBe('function');
|
|
25
|
-
expect(typeof adapter.transform).toBe('function');
|
|
26
|
-
expect(typeof adapter.canonicalPathFor).toBe('function');
|
|
27
|
-
expect(Array.isArray(adapter.goldens)).toBe(true);
|
|
28
|
-
expect(adapter.goldens.length).toBeGreaterThan(0);
|
|
29
|
-
});
|
|
30
|
-
it.each(SURFACE_ADAPTER_LIST.map((a) => [a.name, a]))('%s goldens round-trip transform === expected', (_name, adapter) => {
|
|
31
|
-
for (const golden of adapter.goldens) {
|
|
32
|
-
const out = adapter.transform({ canonical: golden.canonical });
|
|
33
|
-
expect(out).toBe(golden.expected);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
describe('canonicalPathFor — per-surface mapping', () => {
|
|
38
|
-
it('claude maps .claude/skills/orient.md → .productbrain/skills/orient.md', () => {
|
|
39
|
-
expect(claudeAdapter.canonicalPathFor('.claude/skills/orient.md')).toBe('.productbrain/skills/orient.md');
|
|
40
|
-
});
|
|
41
|
-
it('claude returns null for the rule kind (DEC-1736 — no claude rule projection) and non-claude paths', () => {
|
|
42
|
-
expect(claudeAdapter.canonicalPathFor('.claude/rules/foo.md')).toBeNull();
|
|
43
|
-
expect(claudeAdapter.canonicalPathFor('.cursor/rules/foo.mdc')).toBeNull();
|
|
44
|
-
expect(claudeAdapter.canonicalPathFor('.github/copilot-instructions.md')).toBeNull();
|
|
45
|
-
expect(claudeAdapter.canonicalPathFor('AGENTS.md')).toBeNull();
|
|
46
|
-
});
|
|
47
|
-
it('cursor flips .mdc → .md (the headline cursor signature)', () => {
|
|
48
|
-
expect(cursorAdapter.canonicalPathFor('.cursor/rules/foo.mdc')).toBe('.productbrain/rules/foo.md');
|
|
49
|
-
});
|
|
50
|
-
it('cursor maps .cursor/skills/<name>/SKILL.md → .productbrain/skills/<name>.md', () => {
|
|
51
|
-
expect(cursorAdapter.canonicalPathFor('.cursor/skills/sample/SKILL.md')).toBe('.productbrain/skills/sample.md');
|
|
52
|
-
});
|
|
53
|
-
it('cursor returns null for non-cursor paths and the wrong extension', () => {
|
|
54
|
-
expect(cursorAdapter.canonicalPathFor('.cursor/rules/foo.md')).toBeNull();
|
|
55
|
-
expect(cursorAdapter.canonicalPathFor('.claude/rules/foo.md')).toBeNull();
|
|
56
|
-
});
|
|
57
|
-
it('codex maps .codex/skills/orient.md → .productbrain/skills/orient.md', () => {
|
|
58
|
-
expect(codexAdapter.canonicalPathFor('.codex/skills/orient.md')).toBe('.productbrain/skills/orient.md');
|
|
59
|
-
});
|
|
60
|
-
it('codex returns null for AGENTS.md and non-codex paths', () => {
|
|
61
|
-
expect(codexAdapter.canonicalPathFor('AGENTS.md')).toBeNull();
|
|
62
|
-
expect(codexAdapter.canonicalPathFor('.cursor/rules/foo.mdc')).toBeNull();
|
|
63
|
-
});
|
|
64
|
-
it('copilot returns null for its aggregate file (no defensible 1:1 reverse map)', () => {
|
|
65
|
-
expect(copilotAdapter.canonicalPathFor('.github/copilot-instructions.md')).toBeNull();
|
|
66
|
-
expect(copilotAdapter.canonicalPathFor('.claude/rules/foo.md')).toBeNull();
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
describe('canonicalPathFor — forward project then reverse map round-trips', () => {
|
|
70
|
-
it.each([
|
|
71
|
-
[cursorAdapter, 'rule', 'foo'],
|
|
72
|
-
[cursorAdapter, 'skill', 'sample'],
|
|
73
|
-
[codexAdapter, 'skill', 'orient'],
|
|
74
|
-
])('%s adapter %s "%s" projects forward then reverse-maps back to .productbrain', (adapter, kind, basename) => {
|
|
75
|
-
const projection = adapter.paths({ kind, basename }).projectionPath;
|
|
76
|
-
const reverse = adapter.canonicalPathFor(projection);
|
|
77
|
-
const expected = `.productbrain/${kind === 'rule' ? 'rules' : 'skills'}/${basename}.md`;
|
|
78
|
-
expect(reverse).toBe(expected);
|
|
79
|
-
});
|
|
80
|
-
it('copilot forward-projects to the aggregate file but reverse-maps to null (telemetry fallback)', () => {
|
|
81
|
-
const projection = copilotAdapter.paths({ kind: 'rule', basename: 'foo' }).projectionPath;
|
|
82
|
-
expect(projection).toBe('.github/copilot-instructions.md');
|
|
83
|
-
expect(copilotAdapter.canonicalPathFor(projection)).toBeNull();
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
//# sourceMappingURL=adapter.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.test.js","sourceRoot":"","sources":["../../../src/surfaces/__tests__/adapter.test.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;IACvC,EAAE,CAAC,6BAA6B,EAAE,GAAG,EAAE;QACrC,MAAM,CAAC,oBAAoB,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;QAC7C,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,CAClD,CAAC,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC,CACzC,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAA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CAAC;QACpE,MAAM,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;QACrD,MAAM,QAAQ,GAAG,iBAAiB,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,IAAI,QAAQ,KAAK,CAAC;QACxF,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC,CACF,CAAC;IAEF,EAAE,CAAC,8FAA8F,EAAE,GAAG,EAAE;QACtG,MAAM,UAAU,GAAG,cAAc,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC,cAAc,CAAC;QAC1F,MAAM,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;QAC3D,MAAM,CAAC,cAAc,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;IACjE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"claude-skill-pointer-drift.test.d.ts","sourceRoot":"","sources":["../../../src/surfaces/__tests__/claude-skill-pointer-drift.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Claude skill pointer drift test — WP-761 E4a (TASK-251).
|
|
3
|
-
*
|
|
4
|
-
* PR #1039 review round 2 found three canonical skill bodies wrong or
|
|
5
|
-
* dangerous to invoke (git-cleanup, create-blog, prototype). Round 3 found
|
|
6
|
-
* three more (flag-cleanup, community-post, retro) plus a fourth
|
|
7
|
-
* (triage) already fixed content-wise but never load-bearing for this WP,
|
|
8
|
-
* plus a real gap in this test's own body-match assertion. The mechanism
|
|
9
|
-
* that kept drawing these findings — "expose every canonical skill as a
|
|
10
|
-
* Claude pointer, unaudited" — is cut here, not patched again: **a delivery
|
|
11
|
-
* route ships ONLY the skills WP-761 itself makes load-bearing.**
|
|
12
|
-
*
|
|
13
|
-
* INCLUDED is the whole population. Four skills today — `shaping` (WP-761
|
|
14
|
-
* TASK-245 / E1 edits this file directly), `defect-driven-review` (WP-761
|
|
15
|
-
* TASK-242 / E2 edits this file directly), and `after-merge` / `handover`
|
|
16
|
-
* (WP-761 E0 moved both out of `.claude/rules/` and into
|
|
17
|
-
* `.productbrain/skills/` as on-demand skills — landed). No other canonical
|
|
18
|
-
* skill gets a pointer from this test's population, regardless of how good
|
|
19
|
-
* its content is — being exposed here is not "this skill happens to be
|
|
20
|
-
* fine," it's "this WP depends on it," and nothing else has been audited
|
|
21
|
-
* well enough yet to make that claim.
|
|
22
|
-
*
|
|
23
|
-
* EXCLUDED_SKILLS is kept as the historical record of skills that were
|
|
24
|
-
* exposed and then found broken (round 2's three) — not consulted by the
|
|
25
|
-
* population logic below (INCLUDED already leaves them out), but still
|
|
26
|
-
* asserted to have no pointer, so a future edit can't silently re-expose
|
|
27
|
-
* a known-broken skill by, say, copy-pasting an old INCLUDED entry.
|
|
28
|
-
*
|
|
29
|
-
* Each pointer's frontmatter `name` and `description`, and its body's
|
|
30
|
-
* target line, are a deliberate denormalized copy of the canonical's
|
|
31
|
-
* (constitution §12):
|
|
32
|
-
*
|
|
33
|
-
* - Source of truth: .productbrain/skills/<name>.md's `name:`/`description:`
|
|
34
|
-
* and its being the file the pointer's body names.
|
|
35
|
-
* - Query need: the loader must see a name and description in the pointer
|
|
36
|
-
* to auto-match a request, and it cannot read a file it has not loaded.
|
|
37
|
-
* - Sync contract: this test. It parses both frontmatter blocks and
|
|
38
|
-
* asserts the name and description strings are equal, and that the
|
|
39
|
-
* pointer body (frontmatter stripped) is EXACTLY the expected one-line
|
|
40
|
-
* target — not merely contains it, so nothing can be prepended,
|
|
41
|
-
* appended, or hidden in frontmatter — in both directions, naming the
|
|
42
|
-
* skill on drift.
|
|
43
|
-
*
|
|
44
|
-
* Never imports the production frontmatter parser (WP-431 S4 precedent, see
|
|
45
|
-
* pb-setup-passthrough.test.ts) — an independent reader means this test
|
|
46
|
-
* doesn't share a blind spot with whatever a future generator produces.
|
|
47
|
-
* It does use the generic `yaml` library (already a repo dependency,
|
|
48
|
-
* root package.json, resolved via workspace hoisting) to parse the
|
|
49
|
-
* frontmatter block itself — that's a third-party parser, not production
|
|
50
|
-
* code, so it doesn't reintroduce the shared-blind-spot risk WP-431 S4
|
|
51
|
-
* guarded against; see readFrontmatter below (TEN-3784 finding 4: the old
|
|
52
|
-
* whitespace-joining reader couldn't tell a folded (`>-`) description from
|
|
53
|
-
* a literal (`|-`) one, or preserve a paragraph break).
|
|
54
|
-
*/
|
|
55
|
-
import { describe, expect, it } from 'vitest';
|
|
56
|
-
import { existsSync, readFileSync, readdirSync } from 'fs';
|
|
57
|
-
import { dirname, join } from 'path';
|
|
58
|
-
import { fileURLToPath } from 'url';
|
|
59
|
-
import { parse as parseYaml } from 'yaml';
|
|
60
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
61
|
-
// repo root: packages/cli/src/surfaces/__tests__ -> ../../../../..
|
|
62
|
-
const REPO_ROOT = join(__dirname, '..', '..', '..', '..', '..');
|
|
63
|
-
const CANONICAL_DIR = join(REPO_ROOT, '.productbrain', 'skills');
|
|
64
|
-
const POINTER_ROOT = join(REPO_ROOT, '.claude', 'skills');
|
|
65
|
-
/**
|
|
66
|
-
* The whole pointer population: name -> which WP-761 slice makes it
|
|
67
|
-
* load-bearing. Add an entry only when a slice of THIS work package edits
|
|
68
|
-
* or depends on the file directly — never for "this skill looks fine."
|
|
69
|
-
*/
|
|
70
|
-
const INCLUDED_SKILLS = {
|
|
71
|
-
shaping: 'WP-761 TASK-245 (E1) edits this file directly — adds a canonical subtraction step and RULE-288/RULE-419 citations.',
|
|
72
|
-
'defect-driven-review': 'WP-761 TASK-242 (E2) edits this file directly — adds Reviewer 2 item 9 and the Artifact clause.',
|
|
73
|
-
'after-merge': 'WP-761 E0 moves this rule out of .claude/rules/ into .productbrain/skills/ as an on-demand skill — the largest single subtraction of always-loaded bytes available to this WP.',
|
|
74
|
-
handover: 'WP-761 E0 moves this rule out of .claude/rules/ into .productbrain/skills/ as an on-demand skill, alongside after-merge.',
|
|
75
|
-
'autonomous-shipping-run': 'WP-847 TASK-979 moves the lead run skill out of the founder global skills folder into the repo: the canonical body is the order a shipping run moves in, read on demand by the lead session; its playbook, DHH brief and shape template sit beside it in .productbrain/skills/autonomous-shipping-run/.',
|
|
76
|
-
};
|
|
77
|
-
/**
|
|
78
|
-
* Historical record only (PR #1039 review round 2) — these were exposed,
|
|
79
|
-
* found wrong or dangerous to invoke, and removed. Not consulted by
|
|
80
|
-
* INCLUDED_SKILLS above (which already excludes them by omission); asserted
|
|
81
|
-
* below so a future edit can't silently re-expose one.
|
|
82
|
-
*
|
|
83
|
-
* `prototype` (round 2's third finding) is NOT here: E4a-2 deleted the
|
|
84
|
-
* canonical skill outright (no scaffold/manifest/sync-script has ever
|
|
85
|
-
* existed in this repo — confirmed live), so there is no file left to
|
|
86
|
-
* exclude a pointer for. https://github.com/ProductBrain/Product-OS/pull/1039#discussion_r4070378892
|
|
87
|
-
*/
|
|
88
|
-
const EXCLUDED_SKILLS = {
|
|
89
|
-
'git-cleanup': 'Step 7 pushes `git push origin main` directly — the forbidden direct-to-main path (worktree contract, .claude/rules/git-workflow.md). https://github.com/ProductBrain/Product-OS/pull/1039#discussion_r4070378871',
|
|
90
|
-
'create-blog': 'Step 3 hardcodes an absolute Mac path ("/Users/randyhereman/Coding/Product-OS/docs/blog/readme.md") for the mandatory voice-guide gate — fails on any other checkout. https://github.com/ProductBrain/Product-OS/pull/1039#discussion_r4070378884',
|
|
91
|
-
};
|
|
92
|
-
/**
|
|
93
|
-
* Parses one canonical/pointer file's frontmatter block via the `yaml`
|
|
94
|
-
* library (TEN-3784 finding 4) and returns it as a plain object. Folded
|
|
95
|
-
* (`>-`) vs literal (`|-`) block scalars and paragraph breaks are resolved
|
|
96
|
-
* per real YAML semantics, unlike the old whitespace-joining reader this
|
|
97
|
-
* replaces.
|
|
98
|
-
*/
|
|
99
|
-
function readFrontmatter(raw) {
|
|
100
|
-
const fmMatch = raw.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?/);
|
|
101
|
-
if (!fmMatch)
|
|
102
|
-
return {};
|
|
103
|
-
const parsed = parseYaml(fmMatch[1]);
|
|
104
|
-
return parsed && typeof parsed === 'object' ? parsed : {};
|
|
105
|
-
}
|
|
106
|
-
/** Strips the frontmatter block, returning only the body, trimmed. */
|
|
107
|
-
function stripFrontmatter(raw) {
|
|
108
|
-
const fmMatch = raw.match(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/);
|
|
109
|
-
return (fmMatch ? raw.slice(fmMatch[0].length) : raw).trim();
|
|
110
|
-
}
|
|
111
|
-
describe('Claude skill pointer drift (WP-761 E4a)', () => {
|
|
112
|
-
it('INCLUDED_SKILLS <-> pointer: every listed skill has a pointer with matching name, description, and exact body', () => {
|
|
113
|
-
const names = Object.keys(INCLUDED_SKILLS).sort();
|
|
114
|
-
const mismatches = [];
|
|
115
|
-
const failedNames = new Set();
|
|
116
|
-
for (const name of names) {
|
|
117
|
-
const canonicalPath = join(CANONICAL_DIR, `${name}.md`);
|
|
118
|
-
const pointerPath = join(POINTER_ROOT, name, 'SKILL.md');
|
|
119
|
-
if (!existsSync(canonicalPath)) {
|
|
120
|
-
mismatches.push(`${name}: INCLUDED but no canonical file at .productbrain/skills/${name}.md`);
|
|
121
|
-
failedNames.add(name);
|
|
122
|
-
continue;
|
|
123
|
-
}
|
|
124
|
-
if (!existsSync(pointerPath)) {
|
|
125
|
-
mismatches.push(`${name}: INCLUDED but no pointer at .claude/skills/${name}/SKILL.md`);
|
|
126
|
-
failedNames.add(name);
|
|
127
|
-
continue;
|
|
128
|
-
}
|
|
129
|
-
const canonicalRaw = readFileSync(canonicalPath, 'utf8');
|
|
130
|
-
const pointerRaw = readFileSync(pointerPath, 'utf8');
|
|
131
|
-
const canonicalFm = readFrontmatter(canonicalRaw);
|
|
132
|
-
const pointerFm = readFrontmatter(pointerRaw);
|
|
133
|
-
const canonicalName = canonicalFm.name;
|
|
134
|
-
const pointerName = pointerFm.name;
|
|
135
|
-
if (pointerName !== name) {
|
|
136
|
-
mismatches.push(`${name}: pointer name field is "${String(pointerName)}", expected "${name}"`);
|
|
137
|
-
failedNames.add(name);
|
|
138
|
-
}
|
|
139
|
-
if (canonicalName !== name) {
|
|
140
|
-
mismatches.push(`${name}: canonical name field is "${String(canonicalName)}", expected "${name}"`);
|
|
141
|
-
failedNames.add(name);
|
|
142
|
-
}
|
|
143
|
-
const canonicalDesc = canonicalFm.description;
|
|
144
|
-
const pointerDesc = pointerFm.description;
|
|
145
|
-
if (canonicalDesc !== pointerDesc) {
|
|
146
|
-
mismatches.push(`${name}: description drift — canonical="${canonicalDesc}" pointer="${pointerDesc}"`);
|
|
147
|
-
failedNames.add(name);
|
|
148
|
-
}
|
|
149
|
-
// Exact body match (frontmatter stripped) — not `.includes()`. A
|
|
150
|
-
// pointer that prepends/appends stale or unsafe instructions, or
|
|
151
|
-
// hides the target line inside frontmatter, must go red here.
|
|
152
|
-
const expectedBody = `Read and follow .productbrain/skills/${name}.md`;
|
|
153
|
-
const actualBody = stripFrontmatter(pointerRaw);
|
|
154
|
-
if (actualBody !== expectedBody) {
|
|
155
|
-
mismatches.push(`${name}: pointer body is "${actualBody}", expected exactly "${expectedBody}"`);
|
|
156
|
-
failedNames.add(name);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
const matched = names.length - failedNames.size;
|
|
160
|
-
expect(mismatches, `${matched}/${names.length} INCLUDED skills have a fully matching pointer`).toEqual([]);
|
|
161
|
-
expect(names.length).toBeGreaterThan(0);
|
|
162
|
-
});
|
|
163
|
-
it('pointer -> INCLUDED_SKILLS: every pointer directory is a declared INCLUDED entry (no undeclared exposure)', () => {
|
|
164
|
-
const includedNames = new Set(Object.keys(INCLUDED_SKILLS));
|
|
165
|
-
const pointerNames = existsSync(POINTER_ROOT)
|
|
166
|
-
? readdirSync(POINTER_ROOT, { withFileTypes: true })
|
|
167
|
-
.filter((e) => e.isDirectory())
|
|
168
|
-
.map((e) => e.name)
|
|
169
|
-
.sort()
|
|
170
|
-
: [];
|
|
171
|
-
const undeclared = pointerNames.filter((name) => !includedNames.has(name));
|
|
172
|
-
expect(undeclared, `${pointerNames.length - undeclared.length}/${pointerNames.length} pointers are declared in INCLUDED_SKILLS`).toEqual([]);
|
|
173
|
-
expect(pointerNames.length, `pointer count (${pointerNames.length}) vs INCLUDED count (${includedNames.size})`).toBe(includedNames.size);
|
|
174
|
-
});
|
|
175
|
-
it('EXCLUDED_SKILLS stay excluded: no pointer directory exists for any historical-record entry', () => {
|
|
176
|
-
const stillExposed = Object.keys(EXCLUDED_SKILLS).filter((name) => existsSync(join(POINTER_ROOT, name, 'SKILL.md')));
|
|
177
|
-
expect(stillExposed, `${Object.keys(EXCLUDED_SKILLS).length - stillExposed.length}/${Object.keys(EXCLUDED_SKILLS).length} excluded skills correctly have no pointer`).toEqual([]);
|
|
178
|
-
});
|
|
179
|
-
});
|
|
180
|
-
//# sourceMappingURL=claude-skill-pointer-drift.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"claude-skill-pointer-drift.test.js","sourceRoot":"","sources":["../../../src/surfaces/__tests__/claude-skill-pointer-drift.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAA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AAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAChE,UAAU,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC,CACjD,CAAC;QACF,MAAM,CACJ,YAAY,EACZ,GAAG,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,MAAM,GAAG,YAAY,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,MAAM,4CAA4C,CAChJ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAChB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry.test.d.ts","sourceRoot":"","sources":["../../../src/surfaces/__tests__/telemetry.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Reverse-map telemetry fallback — WP-421 S2c.
|
|
3
|
-
* When canonicalPathFor returns null on a known surface, the consumer must
|
|
4
|
-
* write a `surface-reverse-map-missing` warning and surface the generic upstream
|
|
5
|
-
* message ("edit upstream in .productbrain/skills|rules|hooks/").
|
|
6
|
-
*/
|
|
7
|
-
import { describe, expect, it } from 'vitest';
|
|
8
|
-
import { reportReverseMapMissing, getReverseMapFallbackMessage, } from '../telemetry.js';
|
|
9
|
-
import { canonicalPathForAnySurface } from '../registry.js';
|
|
10
|
-
describe('reportReverseMapMissing', () => {
|
|
11
|
-
it('warns surface-reverse-map-missing with surface + projectionPath', () => {
|
|
12
|
-
const warnings = [];
|
|
13
|
-
reportReverseMapMissing({ surface: 'copilot', projectionPath: '.github/copilot-instructions.md' }, (msg) => warnings.push(msg));
|
|
14
|
-
expect(warnings).toHaveLength(1);
|
|
15
|
-
expect(warnings[0]).toContain('[surface-reverse-map-missing]');
|
|
16
|
-
expect(warnings[0]).toContain('copilot');
|
|
17
|
-
expect(warnings[0]).toContain(getReverseMapFallbackMessage());
|
|
18
|
-
});
|
|
19
|
-
it('exposes the canonical fallback message', () => {
|
|
20
|
-
expect(getReverseMapFallbackMessage()).toContain('.productbrain/skills');
|
|
21
|
-
expect(getReverseMapFallbackMessage()).toContain('rules');
|
|
22
|
-
expect(getReverseMapFallbackMessage()).toContain('hooks');
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
describe('canonicalPathForAnySurface', () => {
|
|
26
|
-
it('returns the first matching adapter for a known projection path', () => {
|
|
27
|
-
const cursorMatch = canonicalPathForAnySurface('.cursor/rules/foo.mdc');
|
|
28
|
-
expect(cursorMatch).toEqual({
|
|
29
|
-
surface: 'cursor',
|
|
30
|
-
canonicalPath: '.productbrain/rules/foo.md',
|
|
31
|
-
});
|
|
32
|
-
const claudeMatch = canonicalPathForAnySurface('.claude/skills/orient.md');
|
|
33
|
-
expect(claudeMatch).toEqual({
|
|
34
|
-
surface: 'claude',
|
|
35
|
-
canonicalPath: '.productbrain/skills/orient.md',
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
it('returns null for an unknown projection path (caller warns)', () => {
|
|
39
|
-
expect(canonicalPathForAnySurface('some/unknown/path.txt')).toBeNull();
|
|
40
|
-
// Copilot's aggregate file legitimately has no reverse map → null.
|
|
41
|
-
expect(canonicalPathForAnySurface('.github/copilot-instructions.md')).toBeNull();
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
//# sourceMappingURL=telemetry.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry.test.js","sourceRoot":"","sources":["../../../src/surfaces/__tests__/telemetry.test.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EACL,uBAAuB,EACvB,4BAA4B,GAC7B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EA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AQ;YACjB,aAAa,EAAE,4BAA4B;SAC5C,CAAC,CAAC;QAEH,MAAM,WAAW,GAAG,0BAA0B,CAAC,0BAA0B,CAAC,CAAC;QAC3E,MAAM,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC;YAC1B,OAAO,EAAE,QAAQ;YACjB,aAAa,EAAE,gCAAgC;SAChD,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4DAA4D,EAAE,GAAG,EAAE;QACpE,MAAM,CAAC,0BAA0B,CAAC,uBAAuB,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;QACvE,mEAAmE;QACnE,MAAM,CAAC,0BAA0B,CAAC,iCAAiC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;IACnF,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SurfaceAdapter — WP-421 S2c (DEC-952).
|
|
3
|
-
*
|
|
4
|
-
* One canonical asset in `.productbrain/{skills,rules,hooks}/`; per-surface adapters
|
|
5
|
-
* detect/paths/transform/goldens. New surface = adapter file + registry line.
|
|
6
|
-
*
|
|
7
|
-
* canonicalPathFor is the REVERSE map: given a projection path on a surface
|
|
8
|
-
* (e.g. `.cursor/rules/foo.mdc`), return the canonical authoring path
|
|
9
|
-
* (e.g. `.productbrain/rules/foo.md`). Returns null when the path does not
|
|
10
|
-
* belong to this adapter — callers should use the telemetry fallback in
|
|
11
|
-
* `surfaces/telemetry.ts` to emit `surface-reverse-map-missing`.
|
|
12
|
-
*/
|
|
13
|
-
import type { CanonicalRule, CanonicalSkill } from '../generators/portable-knowledge.js';
|
|
14
|
-
/** Discriminated union covering canonical asset bodies the adapters consume. */
|
|
15
|
-
export type CanonicalAssetBody = ({
|
|
16
|
-
kind: 'skill';
|
|
17
|
-
} & CanonicalSkill) | ({
|
|
18
|
-
kind: 'rule';
|
|
19
|
-
} & CanonicalRule);
|
|
20
|
-
/** Optional Chain grounding context the transform may consult when shaping output. */
|
|
21
|
-
export interface ChainGroundingContext {
|
|
22
|
-
workspaceStage?: string;
|
|
23
|
-
totalRelations?: number;
|
|
24
|
-
detectedStack?: string[];
|
|
25
|
-
/** Free-form context bag for future grounding signals — adapters MUST tolerate unknown keys. */
|
|
26
|
-
[key: string]: unknown;
|
|
27
|
-
}
|
|
28
|
-
export interface SurfaceAssetRef {
|
|
29
|
-
kind: 'skill' | 'rule' | 'hook';
|
|
30
|
-
basename: string;
|
|
31
|
-
}
|
|
32
|
-
export interface SurfacePaths {
|
|
33
|
-
/** Path relative to repoRoot where the projection is written. */
|
|
34
|
-
projectionPath: string;
|
|
35
|
-
}
|
|
36
|
-
export interface SurfaceAdapter {
|
|
37
|
-
/** Stable machine identity (matches SurfaceName in registry.ts). */
|
|
38
|
-
name: string;
|
|
39
|
-
/** Human-friendly display label. */
|
|
40
|
-
displayName: string;
|
|
41
|
-
/**
|
|
42
|
-
* Does this surface exist in the project? Used to decide whether to project at all.
|
|
43
|
-
* Pure: only inspects repoRoot — no network, no Chain calls.
|
|
44
|
-
*/
|
|
45
|
-
detect(repoRoot: string): Promise<boolean> | boolean;
|
|
46
|
-
/** Where the projection is written for a given canonical asset. */
|
|
47
|
-
paths(asset: SurfaceAssetRef): SurfacePaths;
|
|
48
|
-
/** Take a canonical asset (+ optional grounding) and produce surface-formatted content. */
|
|
49
|
-
transform(input: {
|
|
50
|
-
canonical: CanonicalAssetBody;
|
|
51
|
-
grounding?: ChainGroundingContext;
|
|
52
|
-
}): string;
|
|
53
|
-
/**
|
|
54
|
-
* Round-trip golden fixtures: pinned (canonical, expected) pairs.
|
|
55
|
-
* Each adapter MUST define at least one. Tests assert transform(canonical) === expected.
|
|
56
|
-
*/
|
|
57
|
-
goldens: SurfaceGolden[];
|
|
58
|
-
/**
|
|
59
|
-
* REVERSE map from a projection path back to the canonical authoring path
|
|
60
|
-
* in `.productbrain/`. Used by tampered-bucket prompts to point users at the
|
|
61
|
-
* upstream source. Returns null when the path is unknown to this adapter.
|
|
62
|
-
*/
|
|
63
|
-
canonicalPathFor(projectionPath: string): string | null;
|
|
64
|
-
}
|
|
65
|
-
export interface SurfaceGolden {
|
|
66
|
-
name: string;
|
|
67
|
-
canonical: CanonicalAssetBody;
|
|
68
|
-
expected: string;
|
|
69
|
-
}
|
|
70
|
-
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/surfaces/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAEzF,gFAAgF;AAChF,MAAM,MAAM,kBAAkB,GAC1B,CAAC;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GAAG,cAAc,CAAC,GACpC,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,aAAa,CAAC,CAAC;AAEvC,sFAAsF;AACtF,MAAM,WAAW,qBAAqB;IACpC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,gGAAgG;IAChG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;IAChC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,YAAY;IAC3B,iEAAiE;IACjE,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,cAAc;IAC7B,oEAAoE;IACpE,IAAI,EAAE,MAAM,CAAC;IACb,oCAAoC;IACpC,WAAW,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IAErD,mEAAmE;IACnE,KAAK,CAAC,KAAK,EAAE,eAAe,GAAG,YAAY,CAAC;IAE5C,2FAA2F;IAC3F,SAAS,CAAC,KAAK,EAAE;QAAE,SAAS,EAAE,kBAAkB,CAAC;QAAC,SAAS,CAAC,EAAE,qBAAqB,CAAA;KAAE,GAAG,MAAM,CAAC;IAE/F;;;OAGG;IACH,OAAO,EAAE,aAAa,EAAE,CAAC;IAEzB;;;;OAIG;IACH,gBAAgB,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;CACzD;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,kBAAkB,CAAC;IAC9B,QAAQ,EAAE,MAAM,CAAC;CAClB"}
|
package/dist/surfaces/adapter.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../src/surfaces/adapter.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"claude.d.ts","sourceRoot":"","sources":["../../../src/surfaces/adapters/claude.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAGV,cAAc,EAIf,MAAM,eAAe,CAAC;AAoDvB,eAAO,MAAM,aAAa,EAAE,cAQ3B,CAAC"}
|