@warpgogol/forge 6.3.2 → 6.3.3
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/CHANGELOG.md +9 -0
- package/dist/os/compass/handlers/compass-docs-scaffold.d.ts.map +1 -1
- package/dist/os/compass/handlers/compass-docs-scaffold.js +26 -3
- package/dist/os/compass/handlers/compass-docs-scaffold.js.map +1 -1
- package/dist/src/onboarding/agents-generate.d.ts +2 -0
- package/dist/src/onboarding/agents-generate.d.ts.map +1 -1
- package/dist/src/onboarding/agents-generate.js +33 -14
- package/dist/src/onboarding/agents-generate.js.map +1 -1
- package/dist/src/onboarding/compass-docs/semantic-layer-block.d.ts +40 -0
- package/dist/src/onboarding/compass-docs/semantic-layer-block.d.ts.map +1 -0
- package/dist/src/onboarding/compass-docs/semantic-layer-block.js +116 -0
- package/dist/src/onboarding/compass-docs/semantic-layer-block.js.map +1 -0
- package/dist/src/onboarding/doctor.d.ts.map +1 -1
- package/dist/src/onboarding/doctor.js +3 -5
- package/dist/src/onboarding/doctor.js.map +1 -1
- package/dist/src/onboarding/nested-agents-generate.d.ts +2 -0
- package/dist/src/onboarding/nested-agents-generate.d.ts.map +1 -1
- package/dist/src/onboarding/nested-agents-generate.js +31 -6
- package/dist/src/onboarding/nested-agents-generate.js.map +1 -1
- package/dist/src/onboarding/nested-agents-templates.d.ts +6 -1
- package/dist/src/onboarding/nested-agents-templates.d.ts.map +1 -1
- package/dist/src/onboarding/nested-agents-templates.js +19 -4
- package/dist/src/onboarding/nested-agents-templates.js.map +1 -1
- package/docs/reference/compass-docs.md +57 -39
- package/os/compass/handlers/compass-docs-scaffold.ts +26 -3
- package/package.json +1 -1
- package/src/onboarding/agents-generate.ts +36 -18
- package/src/onboarding/compass-docs/semantic-layer-block.test.ts +137 -0
- package/src/onboarding/compass-docs/semantic-layer-block.ts +132 -0
- package/src/onboarding/doctor.ts +3 -5
- package/src/onboarding/nested-agents-generate.ts +40 -6
- package/src/onboarding/nested-agents-templates.ts +24 -4
- package/src/tests/agents-generate.test.ts +128 -0
- package/src/tests/compass-docs-scaffold.test.ts +67 -0
- package/src/tests/fixtures/agents-generate-business-before.txt +4 -0
|
@@ -10,7 +10,6 @@ runAgentsGenerate, runUpgrade, and runDoctor (staleness check via dryRun).</purp
|
|
|
10
10
|
</non-goals>
|
|
11
11
|
</MODULE_CONTRACT>
|
|
12
12
|
<CHANGE_SUMMARY>
|
|
13
|
-
<item>RFC-0640: accept optional workspaceTypes from profile and pass to discoverWorkspaces for profile-driven detection.</item>
|
|
14
13
|
<item>RFC-0643: return workspaceTypeMap for per-file workspace type metadata in details field.</item>
|
|
15
14
|
<item>RFC-0643: use selectNestedTemplate for profile-driven nested templates with terminology substitution.</item>
|
|
16
15
|
<item>RFC-1097: step 6 — compass.migrate codemod run
|
|
@@ -19,7 +18,8 @@ Mechanical v1 to v2 header migration across the workspace: 942 files rewritten
|
|
|
19
18
|
<item>RFC-1097: sweep — werkstatt-engine clean
|
|
20
19
|
|
|
21
20
|
Sweep batch 4: 73 Compass headers on headerless engine files (certification, component-runtime, isolation, evolution, testing), real KEY_DECISIONS on 75 files (kernel, cache, dht, swim, gitmesh, runtime), ~80 purpose expansions (CONTRACT-02/PURPOSE-02), non-goals on 13 CONTRACT-03 files, CS-07 history literal fix repo-wide (253 files). Policy: .template.ts/.template.astro excludedPaths. werkstatt-engine now 0 diagnostics.</item>
|
|
22
|
-
<
|
|
21
|
+
<item>Result gains injected[]: hand-written nested guides carrying the forge:semantic-layer sentinel or a pasted marked region get the read-first block refreshed in place; ensureSemanticLayerBlock guards renders that bypass the fallback template, e.g. profile-authored nested templates (consumer field report follow-up to RFC-1253).</item>
|
|
22
|
+
<history>RFC-0611, RFC-0640</history>
|
|
23
23
|
</CHANGE_SUMMARY>
|
|
24
24
|
*/
|
|
25
25
|
|
|
@@ -34,7 +34,9 @@ import {
|
|
|
34
34
|
} from "../utils/index.ts";
|
|
35
35
|
import { resolveIo } from "../utils/io.ts";
|
|
36
36
|
import { discoverWorkspaces } from "./workspace-discovery.ts";
|
|
37
|
-
import { buildNestedAgentsMd, selectNestedTemplate, type PackageInfo } from "./nested-agents-templates.ts";
|
|
37
|
+
import { buildNestedAgentsMd, NESTED_AGENTS_FOOTER, selectNestedTemplate, type PackageInfo } from "./nested-agents-templates.ts";
|
|
38
|
+
import { ensureSemanticLayerBlock, injectSemanticLayerBlock, semanticLayerLines } from "./compass-docs/semantic-layer-block.ts";
|
|
39
|
+
import { resolveBinding } from "../config/forge-config.ts";
|
|
38
40
|
import type { ForgeConfig } from "../config/forge-config.ts";
|
|
39
41
|
import type { ProfileWorkspaceType } from "../profiles/profile-schema.ts";
|
|
40
42
|
import type { StackProfile } from "../profiles/stack-profile.ts";
|
|
@@ -46,6 +48,8 @@ export interface NestedGenerateResult {
|
|
|
46
48
|
skipped: string[];
|
|
47
49
|
/** RFC-1153: files merged with a carried custom tail below the boundary. */
|
|
48
50
|
preserved: string[];
|
|
51
|
+
/** Hand-written files that accepted the marker-guarded semantic-layer block. */
|
|
52
|
+
injected: string[];
|
|
49
53
|
renderedFiles: { [relPath: string]: string };
|
|
50
54
|
workspaceTypeMap?: { [relPath: string]: string };
|
|
51
55
|
}
|
|
@@ -75,6 +79,7 @@ export async function generateNestedAgentsMd(
|
|
|
75
79
|
const generated: string[] = [];
|
|
76
80
|
const skipped: string[] = [];
|
|
77
81
|
const preserved: string[] = [];
|
|
82
|
+
const injected: string[] = [];
|
|
78
83
|
const renderedFiles: { [relPath: string]: string } = {};
|
|
79
84
|
const fio = resolveIo(io);
|
|
80
85
|
const workspaceTypeMap: { [relPath: string]: string } = {};
|
|
@@ -83,6 +88,14 @@ export async function generateNestedAgentsMd(
|
|
|
83
88
|
const profile = config.profile as StackProfile | undefined;
|
|
84
89
|
const terminology = resolveAllTerminology(config, profile);
|
|
85
90
|
|
|
91
|
+
// RFC-1253: marker-wrapped read-first block for hand-written opt-in injection.
|
|
92
|
+
const compassDocs = resolveBinding(config, "paths.compassDocs");
|
|
93
|
+
const semanticLayerDocs = (Array.isArray(compassDocs) ? compassDocs : []).filter(
|
|
94
|
+
(d): d is string => typeof d === "string",
|
|
95
|
+
);
|
|
96
|
+
const semanticLayerBlock =
|
|
97
|
+
semanticLayerDocs.length > 0 ? semanticLayerLines(semanticLayerDocs).join("\n") : "";
|
|
98
|
+
|
|
86
99
|
for (const ws of workspaces) {
|
|
87
100
|
const agentsMdPath = path.join(workspaceRoot, ws.path, "AGENTS.md");
|
|
88
101
|
const packageInfo = readPackageInfo(workspaceRoot, ws.path);
|
|
@@ -90,7 +103,11 @@ export async function generateNestedAgentsMd(
|
|
|
90
103
|
|
|
91
104
|
// RFC-0643: use profile-driven template when available
|
|
92
105
|
const wsType = workspaceTypes?.find((wt) => wt.id === ws.type);
|
|
93
|
-
const content =
|
|
106
|
+
const content = ensureSemanticLayerBlock(
|
|
107
|
+
selectNestedTemplate(wsType, profile, terminology, fallback),
|
|
108
|
+
semanticLayerBlock,
|
|
109
|
+
NESTED_AGENTS_FOOTER,
|
|
110
|
+
);
|
|
94
111
|
const relPath = path.join(ws.path, "AGENTS.md");
|
|
95
112
|
|
|
96
113
|
if (dryRun) {
|
|
@@ -99,7 +116,24 @@ export async function generateNestedAgentsMd(
|
|
|
99
116
|
}
|
|
100
117
|
|
|
101
118
|
if (ws.hasAgentsMd && !ws.isGenerated) {
|
|
102
|
-
|
|
119
|
+
// Marker-guarded opt-in: a hand-written guide carrying the
|
|
120
|
+
// forge:semantic-layer sentinel (or a pasted marked region) gets the
|
|
121
|
+
// block refreshed — surrounding prose is never touched.
|
|
122
|
+
let injectedHit = false;
|
|
123
|
+
if (semanticLayerBlock) {
|
|
124
|
+
try {
|
|
125
|
+
const existing = await fio.readFile(agentsMdPath);
|
|
126
|
+
const injection = injectSemanticLayerBlock(existing, semanticLayerBlock);
|
|
127
|
+
if (injection.changed) {
|
|
128
|
+
await writeFileIfChanged(agentsMdPath, injection.content, fio);
|
|
129
|
+
injected.push(relPath);
|
|
130
|
+
injectedHit = true;
|
|
131
|
+
}
|
|
132
|
+
} catch {
|
|
133
|
+
// Unreadable — leave the hand-written file alone.
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
skipped.push(`${relPath} (hand-written${injectedHit ? " — semantic-layer injected" : ""})`);
|
|
103
137
|
continue;
|
|
104
138
|
}
|
|
105
139
|
|
|
@@ -136,7 +170,7 @@ export async function generateNestedAgentsMd(
|
|
|
136
170
|
}
|
|
137
171
|
}
|
|
138
172
|
|
|
139
|
-
return { generated, skipped, preserved, renderedFiles, workspaceTypeMap };
|
|
173
|
+
return { generated, skipped, preserved, injected, renderedFiles, workspaceTypeMap };
|
|
140
174
|
}
|
|
141
175
|
|
|
142
176
|
export { discoverWorkspaces, type WorkspaceDir, type WorkspaceType } from "./workspace-discovery.ts";
|
|
@@ -8,7 +8,6 @@ content-rich AGENTS.md for a workspace from its package.json metadata. No I/O.</
|
|
|
8
8
|
</non-goals>
|
|
9
9
|
</MODULE_CONTRACT>
|
|
10
10
|
<CHANGE_SUMMARY>
|
|
11
|
-
<item>RFC-0611: initial minimal stub template for app, package, service workspaces.</item>
|
|
12
11
|
<item>RFC-0643: selectNestedTemplate() for profile-driven template selection with path traversal guard.</item>
|
|
13
12
|
<item>RFC-1097: step 6 — compass.migrate codemod run
|
|
14
13
|
|
|
@@ -17,12 +16,15 @@ Mechanical v1 to v2 header migration across the workspace: 942 files rewritten
|
|
|
17
16
|
|
|
18
17
|
Sweep batch 4: 73 Compass headers on headerless engine files (certification, component-runtime, isolation, evolution, testing), real KEY_DECISIONS on 75 files (kernel, cache, dht, swim, gitmesh, runtime), ~80 purpose expansions (CONTRACT-02/PURPOSE-02), non-goals on 13 CONTRACT-03 files, CS-07 history literal fix repo-wide (253 files). Policy: .template.ts/.template.astro excludedPaths. werkstatt-engine now 0 diagnostics.</item>
|
|
19
18
|
<item>Drop the blank line pushed after the generated header — the header ends in a newline so the extra line rendered two blank lines that prettier collapsed, ping-ponging doctor's stale check.</item>
|
|
19
|
+
<item>Emit the marker-wrapped semantic-layer read-first block ahead of the footer when paths.compassDocs is bound; footer literal exported as NESTED_AGENTS_FOOTER (consumer field report follow-up to RFC-1253).</item>
|
|
20
|
+
<history>RFC-0611</history>
|
|
20
21
|
</CHANGE_SUMMARY>
|
|
21
22
|
*/
|
|
22
23
|
|
|
23
24
|
import { alignMarkdownTable, buildGeneratedHeader } from "../utils/index.ts";
|
|
24
|
-
import { resolveForgePackageRoot } from "../config/forge-config.ts";
|
|
25
|
+
import { resolveBinding, resolveForgePackageRoot } from "../config/forge-config.ts";
|
|
25
26
|
import type { ForgeConfig } from "../config/forge-config.ts";
|
|
27
|
+
import { semanticLayerLines } from "./compass-docs/semantic-layer-block.ts";
|
|
26
28
|
import type { WorkspaceDir, WorkspaceType } from "./workspace-discovery.ts";
|
|
27
29
|
import type { ProfileWorkspaceType } from "../profiles/profile-schema.ts";
|
|
28
30
|
import type { StackProfile } from "../profiles/stack-profile.ts";
|
|
@@ -54,6 +56,13 @@ const TYPE_LABEL: Record<WorkspaceType, string> = {
|
|
|
54
56
|
service: "Service",
|
|
55
57
|
};
|
|
56
58
|
|
|
59
|
+
/**
|
|
60
|
+
* Canonical nested-guide footer — the last substantive line of every render.
|
|
61
|
+
* Legacy marker-less files merge against this boundary; it must stay last.
|
|
62
|
+
*/
|
|
63
|
+
export const NESTED_AGENTS_FOOTER =
|
|
64
|
+
"See the root `AGENTS.md` for project-wide rules, skills, and capabilities.";
|
|
65
|
+
|
|
57
66
|
interface EntryPoint {
|
|
58
67
|
name: string;
|
|
59
68
|
module: string;
|
|
@@ -188,7 +197,7 @@ function substituteNestedTemplate(
|
|
|
188
197
|
|
|
189
198
|
export function buildNestedAgentsMd(
|
|
190
199
|
workspace: WorkspaceDir,
|
|
191
|
-
|
|
200
|
+
config: ForgeConfig,
|
|
192
201
|
packageInfo?: PackageInfo,
|
|
193
202
|
): string {
|
|
194
203
|
const header = buildGeneratedHeader({
|
|
@@ -241,7 +250,18 @@ export function buildNestedAgentsMd(
|
|
|
241
250
|
lines.push(...buildScriptsTable(packageInfo?.scripts));
|
|
242
251
|
lines.push(...buildDependenciesSection(packageInfo?.dependencies));
|
|
243
252
|
|
|
244
|
-
|
|
253
|
+
// Compass corpus read-first block (RFC-1253): emitted ahead of the footer —
|
|
254
|
+
// the footer line is the canonical merge boundary for legacy marker-less
|
|
255
|
+
// files and must stay the render's last non-empty line.
|
|
256
|
+
const compassDocs = resolveBinding(config, "paths.compassDocs");
|
|
257
|
+
const semanticLayerDocs = (Array.isArray(compassDocs) ? compassDocs : []).filter(
|
|
258
|
+
(d): d is string => typeof d === "string",
|
|
259
|
+
);
|
|
260
|
+
if (semanticLayerDocs.length > 0) {
|
|
261
|
+
lines.push(...semanticLayerLines(semanticLayerDocs), "");
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
lines.push(NESTED_AGENTS_FOOTER);
|
|
245
265
|
lines.push("");
|
|
246
266
|
|
|
247
267
|
return lines.join("\n");
|
|
@@ -532,3 +532,131 @@ test("agents-generate omits the read-first block when compassDocs is absent (RFC
|
|
|
532
532
|
const agentsMd = await readFile(join(tempDir, "AGENTS.md"), "utf8");
|
|
533
533
|
expect(agentsMd).not.toContain("## Semantic layer — read first");
|
|
534
534
|
});
|
|
535
|
+
|
|
536
|
+
// Consumer field report: the block must reach every surface an agent reads —
|
|
537
|
+
// nested generated guides and opt-in hand-written files, not only generated roots.
|
|
538
|
+
|
|
539
|
+
test("agents-generate emits the read-first block into nested workspace guides", async () => {
|
|
540
|
+
await makeForgeYaml(tempDir);
|
|
541
|
+
await mkdir(join(tempDir, "packages", "my-pkg"), { recursive: true });
|
|
542
|
+
await writeFile(
|
|
543
|
+
join(tempDir, "packages", "my-pkg", "package.json"),
|
|
544
|
+
JSON.stringify({ name: "@test/my-pkg" }),
|
|
545
|
+
);
|
|
546
|
+
|
|
547
|
+
const result = await runAgentsGenerate({ argv: [], flags: {} }, makeContext(tempDir));
|
|
548
|
+
expect(result.exitCode).toBe(0);
|
|
549
|
+
|
|
550
|
+
const nested = await readFile(join(tempDir, "packages", "my-pkg", "AGENTS.md"), "utf8");
|
|
551
|
+
expect(nested).toContain("<!-- forge:begin semantic-layer -->");
|
|
552
|
+
expect(nested).toContain("## Semantic layer — read first");
|
|
553
|
+
expect(nested).toContain("`docs/requirements.xml`");
|
|
554
|
+
expect(nested).toContain("<!-- forge:end semantic-layer -->");
|
|
555
|
+
// the footer stays the last substantive line — it is the merge boundary
|
|
556
|
+
// for legacy marker-less files and must not move below the block
|
|
557
|
+
expect(nested.indexOf("## Semantic layer — read first")).toBeLessThan(
|
|
558
|
+
nested.indexOf("See the root `AGENTS.md`"),
|
|
559
|
+
);
|
|
560
|
+
});
|
|
561
|
+
|
|
562
|
+
test("agents-generate expands the forge:semantic-layer sentinel in a hand-written root", async () => {
|
|
563
|
+
await makeForgeYaml(tempDir);
|
|
564
|
+
await writeFile(
|
|
565
|
+
join(tempDir, "AGENTS.md"),
|
|
566
|
+
"# Hand-written\n\nCustom intro.\n\n<!-- forge:semantic-layer -->\n\nCustom tail.\n",
|
|
567
|
+
"utf8",
|
|
568
|
+
);
|
|
569
|
+
|
|
570
|
+
const result = await runAgentsGenerate({ argv: [], flags: {} }, makeContext(tempDir));
|
|
571
|
+
expect(result.exitCode).toBe(0);
|
|
572
|
+
expect(result.data?.rootSkipped).toBe(true);
|
|
573
|
+
expect(result.data?.injected).toContain("AGENTS.md");
|
|
574
|
+
|
|
575
|
+
const agentsMd = await readFile(join(tempDir, "AGENTS.md"), "utf8");
|
|
576
|
+
expect(agentsMd).toContain("<!-- forge:begin semantic-layer -->");
|
|
577
|
+
expect(agentsMd).toContain("## Semantic layer — read first");
|
|
578
|
+
expect(agentsMd).toContain("`docs/requirements.xml`");
|
|
579
|
+
expect(agentsMd).toContain("<!-- forge:end semantic-layer -->");
|
|
580
|
+
expect(agentsMd).toContain("Custom intro.");
|
|
581
|
+
expect(agentsMd).toContain("Custom tail.");
|
|
582
|
+
expect(agentsMd).not.toContain("<!-- forge:semantic-layer -->");
|
|
583
|
+
expect(agentsMd.match(/## Semantic layer — read first/g)).toHaveLength(1);
|
|
584
|
+
});
|
|
585
|
+
|
|
586
|
+
test("agents-generate refreshes a pasted semantic-layer region in a hand-written root", async () => {
|
|
587
|
+
await makeForgeYaml(tempDir);
|
|
588
|
+
const staleRegion = [
|
|
589
|
+
"<!-- forge:begin semantic-layer -->",
|
|
590
|
+
"",
|
|
591
|
+
"## Semantic layer — read first",
|
|
592
|
+
"",
|
|
593
|
+
"STALE",
|
|
594
|
+
"",
|
|
595
|
+
"<!-- forge:end semantic-layer -->",
|
|
596
|
+
].join("\n");
|
|
597
|
+
await writeFile(join(tempDir, "AGENTS.md"), `# Hand-written\n\n${staleRegion}\n`, "utf8");
|
|
598
|
+
|
|
599
|
+
const result = await runAgentsGenerate({ argv: [], flags: {} }, makeContext(tempDir));
|
|
600
|
+
const agentsMd = await readFile(join(tempDir, "AGENTS.md"), "utf8");
|
|
601
|
+
expect(agentsMd).not.toContain("STALE");
|
|
602
|
+
expect(agentsMd).toContain("`docs/requirements.xml`");
|
|
603
|
+
expect(result.data?.injected).toContain("AGENTS.md");
|
|
604
|
+
|
|
605
|
+
// idempotent — a current region reports no further injection
|
|
606
|
+
const second = await runAgentsGenerate({ argv: [], flags: {} }, makeContext(tempDir));
|
|
607
|
+
expect(second.data?.injected).toEqual([]);
|
|
608
|
+
});
|
|
609
|
+
|
|
610
|
+
test("agents-generate leaves a hand-written root without the sentinel untouched", async () => {
|
|
611
|
+
await makeForgeYaml(tempDir);
|
|
612
|
+
const original = "# Hand-written\nNo marker, no sentinel — fully authored.\n";
|
|
613
|
+
await writeFile(join(tempDir, "AGENTS.md"), original, "utf8");
|
|
614
|
+
|
|
615
|
+
const result = await runAgentsGenerate({ argv: [], flags: {} }, makeContext(tempDir));
|
|
616
|
+
expect(result.exitCode).toBe(0);
|
|
617
|
+
expect(result.data?.injected).toEqual([]);
|
|
618
|
+
|
|
619
|
+
const agentsMd = await readFile(join(tempDir, "AGENTS.md"), "utf8");
|
|
620
|
+
expect(agentsMd).toBe(original);
|
|
621
|
+
});
|
|
622
|
+
|
|
623
|
+
test("agents-generate expands the sentinel in a hand-written nested guide", async () => {
|
|
624
|
+
await makeForgeYaml(tempDir);
|
|
625
|
+
await mkdir(join(tempDir, "packages", "my-pkg"), { recursive: true });
|
|
626
|
+
await writeFile(
|
|
627
|
+
join(tempDir, "packages", "my-pkg", "package.json"),
|
|
628
|
+
JSON.stringify({ name: "@test/my-pkg" }),
|
|
629
|
+
);
|
|
630
|
+
await writeFile(
|
|
631
|
+
join(tempDir, "packages", "my-pkg", "AGENTS.md"),
|
|
632
|
+
"# Custom\n\n<!-- forge:semantic-layer -->\n",
|
|
633
|
+
"utf8",
|
|
634
|
+
);
|
|
635
|
+
|
|
636
|
+
const result = await runAgentsGenerate({ argv: [], flags: {} }, makeContext(tempDir));
|
|
637
|
+
expect(result.data?.injected).toContain(join("packages", "my-pkg", "AGENTS.md"));
|
|
638
|
+
|
|
639
|
+
const nested = await readFile(join(tempDir, "packages", "my-pkg", "AGENTS.md"), "utf8");
|
|
640
|
+
expect(nested).toContain("## Semantic layer — read first");
|
|
641
|
+
expect(nested).toContain("# Custom");
|
|
642
|
+
});
|
|
643
|
+
|
|
644
|
+
test("agents-generate emits no read-first block in nested guides when compassDocs is absent", async () => {
|
|
645
|
+
await makeForgeYaml(tempDir);
|
|
646
|
+
const yaml = (await readFile(join(tempDir, "forge.yaml"), "utf8")).replace(
|
|
647
|
+
" compassDocs: [docs/requirements.xml]\n",
|
|
648
|
+
"",
|
|
649
|
+
);
|
|
650
|
+
await writeFile(join(tempDir, "forge.yaml"), yaml, "utf8");
|
|
651
|
+
await mkdir(join(tempDir, "packages", "my-pkg"), { recursive: true });
|
|
652
|
+
await writeFile(
|
|
653
|
+
join(tempDir, "packages", "my-pkg", "package.json"),
|
|
654
|
+
JSON.stringify({ name: "@test/my-pkg" }),
|
|
655
|
+
);
|
|
656
|
+
|
|
657
|
+
const result = await runAgentsGenerate({ argv: [], flags: {} }, makeContext(tempDir));
|
|
658
|
+
expect(result.exitCode).toBe(0);
|
|
659
|
+
|
|
660
|
+
const nested = await readFile(join(tempDir, "packages", "my-pkg", "AGENTS.md"), "utf8");
|
|
661
|
+
expect(nested).not.toContain("## Semantic layer — read first");
|
|
662
|
+
});
|
|
@@ -14,6 +14,7 @@ import { mkdtemp, mkdir, writeFile, readFile, rm } from "node:fs/promises";
|
|
|
14
14
|
import { tmpdir } from "node:os";
|
|
15
15
|
import { join } from "node:path";
|
|
16
16
|
import { runCompassDocsScaffold } from "../../os/compass/handlers/compass-docs-scaffold.ts";
|
|
17
|
+
import { runCompassDocsValidate } from "../../os/compass/handlers/compass-docs-validate.ts";
|
|
17
18
|
import { forgeYaml } from "../../os/compass/handlers/tests/forge-yaml-fixture.ts";
|
|
18
19
|
import { ambientIo } from "../utils/io.ts";
|
|
19
20
|
import type { ForgeCommandInput, ForgeRuntimeContext } from "../types.ts";
|
|
@@ -169,6 +170,72 @@ describe("compass.docs.scaffold — RFC-1253", () => {
|
|
|
169
170
|
expect(forgeYaml).toContain("docs/knowledge-graph.xml");
|
|
170
171
|
});
|
|
171
172
|
|
|
173
|
+
it("consumer field report: mixed-layout repo — ids derive from location, scaffold → validate needs zero manual edits", async () => {
|
|
174
|
+
// apps/ workspaces without astro/Dockerfile/service.config markers detect
|
|
175
|
+
// as "package" — under the old type-derived prefix they would emit pkg-*
|
|
176
|
+
// ids that COMPASS-DOC-02 resolves to nonexistent packages/<name> paths.
|
|
177
|
+
// The prefix must follow the location convention the validator enforces.
|
|
178
|
+
await mkdir(join(root, "apps", "api"), { recursive: true });
|
|
179
|
+
await writeFile(
|
|
180
|
+
join(root, "apps", "api", "package.json"),
|
|
181
|
+
JSON.stringify({ name: "@fixture/api" }),
|
|
182
|
+
);
|
|
183
|
+
await mkdir(join(root, "apps", "api-staging"), { recursive: true });
|
|
184
|
+
await writeFile(
|
|
185
|
+
join(root, "apps", "api-staging", "package.json"),
|
|
186
|
+
JSON.stringify({ name: "@fixture/api-staging" }),
|
|
187
|
+
);
|
|
188
|
+
await mkdir(join(root, "apps", "dashboard"), { recursive: true });
|
|
189
|
+
await writeFile(
|
|
190
|
+
join(root, "apps", "dashboard", "package.json"),
|
|
191
|
+
JSON.stringify({ name: "@fixture/dashboard" }),
|
|
192
|
+
);
|
|
193
|
+
await writeFile(join(root, "apps", "dashboard", "astro.config.mjs"), "export default {};\n");
|
|
194
|
+
await mkdir(join(root, "services", "beta"), { recursive: true });
|
|
195
|
+
await writeFile(
|
|
196
|
+
join(root, "services", "beta", "package.json"),
|
|
197
|
+
JSON.stringify({ name: "@fixture/beta" }),
|
|
198
|
+
);
|
|
199
|
+
await writeFile(join(root, "services", "beta", "service.config.yaml"), "name: beta\n");
|
|
200
|
+
// Locations the prefixed convention cannot express fall back to dotted ids.
|
|
201
|
+
await mkdir(join(root, "tools", "hammer"), { recursive: true });
|
|
202
|
+
await writeFile(
|
|
203
|
+
join(root, "tools", "hammer", "package.json"),
|
|
204
|
+
JSON.stringify({ name: "@fixture/hammer" }),
|
|
205
|
+
);
|
|
206
|
+
await mkdir(join(root, "packages", "alpha", "modules", "deep"), { recursive: true });
|
|
207
|
+
await writeFile(
|
|
208
|
+
join(root, "packages", "alpha", "modules", "deep", "package.json"),
|
|
209
|
+
JSON.stringify({ name: "@fixture/deep" }),
|
|
210
|
+
);
|
|
211
|
+
// knowledge-graph's root.rules node references AGENTS.md.
|
|
212
|
+
await writeFile(join(root, "AGENTS.md"), "# fixture\n");
|
|
213
|
+
|
|
214
|
+
const scaffold = await runCompassDocsScaffold(makeInput(), makeContext(root));
|
|
215
|
+
expect(scaffold.exitCode).toBe(0);
|
|
216
|
+
|
|
217
|
+
const kg = await readFile(join(root, "docs", "knowledge-graph.xml"), "utf8");
|
|
218
|
+
expect(kg).toContain('id="app-api"');
|
|
219
|
+
expect(kg).toContain('id="app-api-staging"');
|
|
220
|
+
expect(kg).toContain('id="app-dashboard"');
|
|
221
|
+
expect(kg).toContain('id="svc-beta"');
|
|
222
|
+
expect(kg).toContain('id="pkg-alpha"');
|
|
223
|
+
expect(kg).toContain('id="tools.hammer"');
|
|
224
|
+
expect(kg).toContain('id="packages.alpha.modules.deep"');
|
|
225
|
+
expect(kg).not.toContain('id="pkg-api"');
|
|
226
|
+
|
|
227
|
+
const tech = await readFile(join(root, "docs", "technology.xml"), "utf8");
|
|
228
|
+
expect(tech).toContain('id="app-api"');
|
|
229
|
+
expect(tech).not.toContain('id="pkg-api"');
|
|
230
|
+
|
|
231
|
+
const validation = await runCompassDocsValidate(makeInput(), makeContext(root));
|
|
232
|
+
expect(
|
|
233
|
+
validation.data?.diagnostics.filter((d) => d.severity === "error"),
|
|
234
|
+
"scaffold output must validate clean — check workspaceNodeId prefix derivation",
|
|
235
|
+
).toEqual([]);
|
|
236
|
+
expect(validation.exitCode).toBe(0);
|
|
237
|
+
});
|
|
238
|
+
|
|
172
239
|
it("dry-run reports the manifest without writing", async () => {
|
|
173
240
|
const result = await runCompassDocsScaffold(
|
|
174
241
|
makeInput({ "dry-run": true }),
|
|
@@ -33,6 +33,8 @@
|
|
|
33
33
|
- Specs: `docs/specs`
|
|
34
34
|
- Skills: `.agents/skills`
|
|
35
35
|
|
|
36
|
+
<!-- forge:begin semantic-layer -->
|
|
37
|
+
|
|
36
38
|
## Semantic layer — read first
|
|
37
39
|
|
|
38
40
|
This repository carries a machine-readable Compass corpus — the semantic layer that answers “what reads X, what breaks if I change Y” without a full repository re-scan. For repository-wide, cross-workspace, architectural, shared-package, or high-risk tasks, read these documents before planning or editing code:
|
|
@@ -41,6 +43,8 @@ This repository carries a machine-readable Compass corpus — the semantic layer
|
|
|
41
43
|
|
|
42
44
|
Treat these XML documents as the primary semantic layer for AI work and keep them synchronized with code, architecture, and verification changes.
|
|
43
45
|
|
|
46
|
+
<!-- forge:end semantic-layer -->
|
|
47
|
+
|
|
44
48
|
## Skills
|
|
45
49
|
|
|
46
50
|
| Name | Category | Invocation | Concerns |
|