@warpgogol/forge 6.3.1 → 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 +162 -0
- package/bin/cli.js +13 -2
- 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/os/core/core.module.d.ts.map +1 -1
- package/dist/os/core/core.module.js +6 -8
- package/dist/os/core/core.module.js.map +1 -1
- package/dist/os/core/handlers/package-health.d.ts.map +1 -1
- package/dist/os/core/handlers/package-health.js +178 -4
- package/dist/os/core/handlers/package-health.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 +46 -38
- 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 +72 -33
- package/dist/src/onboarding/doctor.js.map +1 -1
- package/dist/src/onboarding/init.d.ts.map +1 -1
- package/dist/src/onboarding/init.js +35 -4
- package/dist/src/onboarding/init.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 +20 -5
- package/dist/src/onboarding/nested-agents-templates.js.map +1 -1
- package/dist/src/onboarding/prettierignore.d.ts +8 -2
- package/dist/src/onboarding/prettierignore.d.ts.map +1 -1
- package/dist/src/onboarding/prettierignore.js +36 -4
- package/dist/src/onboarding/prettierignore.js.map +1 -1
- package/dist/src/onboarding/skill-markers.d.ts +1 -0
- package/dist/src/onboarding/skill-markers.d.ts.map +1 -1
- package/dist/src/onboarding/skill-markers.js +1 -1
- package/dist/src/onboarding/skill-markers.js.map +1 -1
- package/dist/src/onboarding/upgrade.d.ts +4 -0
- package/dist/src/onboarding/upgrade.d.ts.map +1 -1
- package/dist/src/onboarding/upgrade.js +73 -9
- package/dist/src/onboarding/upgrade.js.map +1 -1
- package/dist/src/onboarding/workspace-discovery.d.ts +9 -0
- package/dist/src/onboarding/workspace-discovery.d.ts.map +1 -1
- package/dist/src/onboarding/workspace-discovery.js +30 -0
- package/dist/src/onboarding/workspace-discovery.js.map +1 -1
- package/dist/src/utils/generated-marker.d.ts.map +1 -1
- package/dist/src/utils/generated-marker.js +14 -6
- package/dist/src/utils/generated-marker.js.map +1 -1
- package/docs/reference/cli.md +1 -1
- package/docs/reference/compass-docs.md +57 -39
- package/os/compass/handlers/compass-docs-scaffold.ts +26 -3
- package/os/core/core.module.ts +6 -8
- package/os/core/docs-archive.test.ts +2 -5
- package/os/core/handlers/package-health.test.ts +199 -3
- package/os/core/handlers/package-health.ts +188 -4
- package/os/rfc/verification-emit.test.ts +1 -1
- package/os/rfc/verification-refresh.test.ts +1 -1
- package/os/spec/spec-validate.test.ts +4 -4
- package/package.json +2 -2
- package/profiles/forge-shell.yaml +5 -14
- package/profiles/godot-game.yaml +5 -14
- package/profiles/phaser-game.yaml +5 -14
- package/profiles/typescript.yaml +5 -14
- package/skills/fo/fo-handoff/SKILL.md +5 -4
- package/skills/fo/fo-step-commit/SKILL.md +4 -1
- package/src/onboarding/agents-generate.ts +49 -42
- 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 +77 -31
- package/src/onboarding/init.ts +35 -4
- package/src/onboarding/nested-agents-generate.ts +40 -6
- package/src/onboarding/nested-agents-templates.ts +25 -5
- package/src/onboarding/prettierignore.ts +45 -2
- package/src/onboarding/skill-markers.ts +5 -1
- package/src/onboarding/templates/behavioral-layer-core.md +2 -0
- package/src/onboarding/templates/root-agents-business.md +1 -0
- package/src/onboarding/templates/root-agents-creative.md +1 -0
- package/src/onboarding/upgrade.ts +122 -11
- package/src/onboarding/workspace-discovery.ts +33 -0
- package/src/tests/agents-generate.test.ts +128 -0
- package/src/tests/bindings-schema.test.ts +1 -0
- package/src/tests/compass-docs-flag.test.ts +2 -0
- package/src/tests/compass-docs-scaffold.test.ts +67 -0
- package/src/tests/doctor-version-sync.test.ts +155 -0
- package/src/tests/file-size-lint.test.ts +7 -5
- package/src/tests/fixtures/agents-generate-business-before.txt +8 -2
- package/src/tests/forge-config.test.ts +2 -3
- package/src/tests/generated-marker.test.ts +17 -0
- package/src/tests/prettierignore-manage.test.ts +30 -0
- package/src/tests/session-handlers.test.ts +2 -2
- package/src/tests/session-pbt.test.ts +1 -1
- package/src/tests/skill-agents-sync.test.ts +25 -0
- package/src/tests/upgrade.test.ts +82 -1
- package/src/utils/generated-marker.ts +15 -6
|
@@ -12,7 +12,12 @@ import { mkdtemp, mkdir, writeFile, rm, readFile } from "node:fs/promises";
|
|
|
12
12
|
import { tmpdir } from "node:os";
|
|
13
13
|
import { join } from "node:path";
|
|
14
14
|
import { runFileSizeLint, countLines } from "../../os/core/handlers/file-size-lint.ts";
|
|
15
|
-
import type {
|
|
15
|
+
import type {
|
|
16
|
+
ForgeRuntimeContext,
|
|
17
|
+
ForgeLogger,
|
|
18
|
+
ForgeCommandInput,
|
|
19
|
+
ForgeFlagValue,
|
|
20
|
+
} from "../types.ts";
|
|
16
21
|
|
|
17
22
|
const logger: ForgeLogger = {
|
|
18
23
|
section() {},
|
|
@@ -31,10 +36,7 @@ function mockContext(workspaceRoot: string): ForgeRuntimeContext {
|
|
|
31
36
|
};
|
|
32
37
|
}
|
|
33
38
|
|
|
34
|
-
function input(flags: Record<string,
|
|
35
|
-
argv: string[];
|
|
36
|
-
flags: Record<string, unknown>;
|
|
37
|
-
} {
|
|
39
|
+
function input(flags: Record<string, ForgeFlagValue> = {}): ForgeCommandInput {
|
|
38
40
|
return { argv: [], flags };
|
|
39
41
|
}
|
|
40
42
|
|
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
This file is generated but editable — your changes are preserved on regeneration.
|
|
4
4
|
Owner command: forge.agents.generate
|
|
5
5
|
Edit instead: the forge.agents.generate generator source (not this file).
|
|
6
|
-
Regenerate: forge
|
|
6
|
+
Regenerate: forge agents.generate
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
|
-
|
|
10
9
|
<!-- Root AGENTS.md template for business register projects.
|
|
11
10
|
Static prose only — dynamic sections (skills, capabilities, behavioral layer)
|
|
12
11
|
are inserted at the dynamicSections marker by runAgentsGenerate.
|
|
13
12
|
Placeholders: projectName, projectStack, projectPm,
|
|
14
13
|
rfcsDir, adrsDir, plansDir, auditsDir, specsDir,
|
|
15
14
|
skillsDir, dynamicSections -->
|
|
15
|
+
|
|
16
16
|
# Agent Guide: test-project
|
|
17
17
|
|
|
18
18
|
> This file is generated by `forge.agents.generate` from `forge.yaml`.
|
|
@@ -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 |
|
|
@@ -158,6 +162,7 @@ When the operator describes a significant idea or change, the agent SHOULD proac
|
|
|
158
162
|
The agent SHOULD auto-save sessions at the end of each session unless opted out via `PREFERENCES.md` (`saveSessions: false`). Companion-mode session saving can be opted out separately.
|
|
159
163
|
|
|
160
164
|
Session save mechanism:
|
|
165
|
+
|
|
161
166
|
1. Export the conversation as a raw ATIF file to `docs/sessions/.raw/` (create the directory with `mkdir -p docs/sessions/.raw` if it does not exist).
|
|
162
167
|
2. Run `ref(forge.yaml bindings.commands.sessionSave)` to convert the raw file to structured markdown in `docs/sessions/`.
|
|
163
168
|
3. If the command fails or the binding is null, create the session file manually in `docs/sessions/` with frontmatter (id, date, type, relatedRfcs).
|
|
@@ -202,6 +207,7 @@ The agent reads `.agents/operator-profile.md` at the start of each session and c
|
|
|
202
207
|
The agent offers proactive guidance at the right moment — at most once per session per topic. If declined, the suggestion is not repeated.
|
|
203
208
|
|
|
204
209
|
Built-in guidance triggers:
|
|
210
|
+
|
|
205
211
|
- **Long session** (>2 hours): suggest a break or session save.
|
|
206
212
|
- **Complex change** (3+ files in one area): suggest grilling or planning.
|
|
207
213
|
- **Multiple topics** in one session: suggest splitting into separate sessions.
|
|
@@ -238,6 +238,7 @@ const configWithBindings: ForgeConfig = {
|
|
|
238
238
|
validateRfc: "pnpm exec werkstatt run rfc.validate --id {id} --json",
|
|
239
239
|
validateAdr: null,
|
|
240
240
|
implementStamp: null,
|
|
241
|
+
adrImplementStamp: null,
|
|
241
242
|
typecheck: "pnpm --filter {workspace} run build:check",
|
|
242
243
|
test: "pnpm --filter {workspace} run test",
|
|
243
244
|
scopedBuild: null,
|
|
@@ -517,8 +518,6 @@ test("RFC-1224: applyForgeYamlPatches creates missing intermediate maps", () =>
|
|
|
517
518
|
});
|
|
518
519
|
|
|
519
520
|
test("RFC-1224: applyForgeYamlPatches returns null on invalid YAML", () => {
|
|
520
|
-
const patched = applyForgeYamlPatches("a: [unclosed\n : :", [
|
|
521
|
-
{ path: ["a"], value: 1 },
|
|
522
|
-
]);
|
|
521
|
+
const patched = applyForgeYamlPatches("a: [unclosed\n : :", [{ path: ["a"], value: 1 }]);
|
|
523
522
|
expect(patched).toBeNull();
|
|
524
523
|
});
|
|
@@ -87,6 +87,23 @@ describe("buildGeneratedHeader", () => {
|
|
|
87
87
|
expect(header.endsWith("\n")).toBe(true);
|
|
88
88
|
});
|
|
89
89
|
|
|
90
|
+
test("regenerate hint dedupes the commandPrefix namespace", () => {
|
|
91
|
+
const header = buildGeneratedHeader({
|
|
92
|
+
filePath: "AGENTS.md",
|
|
93
|
+
ownerCommand: "forge.agents.generate",
|
|
94
|
+
editable: true,
|
|
95
|
+
});
|
|
96
|
+
expect(header).toContain("Regenerate: forge agents.generate");
|
|
97
|
+
expect(header).not.toContain("forge forge.agents.generate");
|
|
98
|
+
// Non-prefixed commands pass through unchanged
|
|
99
|
+
const plain = buildGeneratedHeader({
|
|
100
|
+
filePath: "AGENTS.md",
|
|
101
|
+
ownerCommand: "agents.generate",
|
|
102
|
+
editable: true,
|
|
103
|
+
});
|
|
104
|
+
expect(plain).toContain("Regenerate: forge agents.generate");
|
|
105
|
+
});
|
|
106
|
+
|
|
90
107
|
test("line-hash style for .yml files", () => {
|
|
91
108
|
const header = buildGeneratedHeader({
|
|
92
109
|
filePath: "config/generated.yml",
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
PRETTIERIGNORE_BLOCK_END,
|
|
24
24
|
} from "../onboarding/prettierignore.ts";
|
|
25
25
|
import { SKILL_MARKER_FILE } from "../onboarding/skill-markers.ts";
|
|
26
|
+
import { buildGeneratedHeader } from "../utils/index.ts";
|
|
26
27
|
|
|
27
28
|
let tmpDir: string;
|
|
28
29
|
|
|
@@ -99,6 +100,35 @@ test("skill entries enumerate only marker-carrying dirs (AC-9)", async () => {
|
|
|
99
100
|
expect(plan.entries).not.toContain(".agents/skills/my-own-skill/");
|
|
100
101
|
});
|
|
101
102
|
|
|
103
|
+
test("generated AGENTS.md entries — root + marker-bearing nested, hand-written excluded", async () => {
|
|
104
|
+
await withPrettier(tmpDir);
|
|
105
|
+
const header = buildGeneratedHeader({
|
|
106
|
+
filePath: "AGENTS.md",
|
|
107
|
+
ownerCommand: "agents.generate",
|
|
108
|
+
editable: true,
|
|
109
|
+
});
|
|
110
|
+
// Root generated AGENTS.md
|
|
111
|
+
await writeFile(join(tmpDir, "AGENTS.md"), `${header}\n# Guide\n`);
|
|
112
|
+
// Nested workspace with a generated AGENTS.md
|
|
113
|
+
const genDir = join(tmpDir, "packages", "gen");
|
|
114
|
+
await mkdir(genDir, { recursive: true });
|
|
115
|
+
await writeFile(join(genDir, "package.json"), JSON.stringify({ name: "gen" }));
|
|
116
|
+
await writeFile(join(genDir, "AGENTS.md"), `${header}\n# Gen\n`);
|
|
117
|
+
// Hand-written nested AGENTS.md — stays operator-owned, prettier-covered
|
|
118
|
+
const ownDir = join(tmpDir, "packages", "own");
|
|
119
|
+
await mkdir(ownDir, { recursive: true });
|
|
120
|
+
await writeFile(join(ownDir, "package.json"), JSON.stringify({ name: "own" }));
|
|
121
|
+
await writeFile(join(ownDir, "AGENTS.md"), "# Hand-written\n");
|
|
122
|
+
|
|
123
|
+
const plan = await planPrettierignore(tmpDir);
|
|
124
|
+
expect(plan.entries).toContain("/AGENTS.md");
|
|
125
|
+
expect(plan.entries).toContain("packages/gen/AGENTS.md");
|
|
126
|
+
expect(plan.entries).not.toContain("packages/own/AGENTS.md");
|
|
127
|
+
// A bare "AGENTS.md" entry would ignore hand-written nested guides too —
|
|
128
|
+
// the root entry must stay anchored.
|
|
129
|
+
expect(plan.entries).not.toContain("AGENTS.md");
|
|
130
|
+
});
|
|
131
|
+
|
|
102
132
|
test("reconcile preserves operator content outside the block", async () => {
|
|
103
133
|
const existing = `dist/\nnode_modules/\n${PRETTIERIGNORE_BLOCK_BEGIN}\nold-entry/\n${PRETTIERIGNORE_BLOCK_END}\ncustom/\n`;
|
|
104
134
|
const { next, changed } = reconcilePrettierignoreContent(existing, ["a/", "b/"]);
|
|
@@ -22,7 +22,7 @@ function makeInput(
|
|
|
22
22
|
flags: Record<string, ForgeFlagValue> = {},
|
|
23
23
|
args: string[] = [],
|
|
24
24
|
): ForgeCommandInput {
|
|
25
|
-
return { argv:
|
|
25
|
+
return { argv: args, flags };
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
function makeContext(workspaceRoot: string): ForgeRuntimeContext {
|
|
@@ -125,7 +125,7 @@ Commands: session.save`;
|
|
|
125
125
|
await writeFile(join(rawDir, "keepraw-claim.atif"), uniqueAtif, "utf-8");
|
|
126
126
|
|
|
127
127
|
const result = await runSessionSave(makeInput({ "keep-raw": true }), makeContext(dir));
|
|
128
|
-
expect(result.data
|
|
128
|
+
expect(result.data!.id).not.toBe("");
|
|
129
129
|
|
|
130
130
|
const remaining = await readdir(rawDir);
|
|
131
131
|
expect(remaining).toContain("keepraw-claim.atif");
|
|
@@ -21,7 +21,7 @@ function makeInput(
|
|
|
21
21
|
flags: Record<string, ForgeFlagValue> = {},
|
|
22
22
|
args: string[] = [],
|
|
23
23
|
): ForgeCommandInput {
|
|
24
|
-
return { argv:
|
|
24
|
+
return { argv: args, flags };
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
function makeContext(workspaceRoot: string): ForgeRuntimeContext {
|
|
@@ -164,5 +164,30 @@ describe.runIf(hasForgeWorkspace)(
|
|
|
164
164
|
const plan = planKnowledgeSync(src, dest);
|
|
165
165
|
expect(plan.action, `shared-knowledge drift (sync action: ${plan.action})`).toBe("unchanged");
|
|
166
166
|
});
|
|
167
|
+
|
|
168
|
+
it("_shared convention docs are synced verbatim", () => {
|
|
169
|
+
const srcDir = path.join(forgeRoot, "skills", "_shared");
|
|
170
|
+
if (!fs.existsSync(srcDir)) return; // conventions layer absent — nothing to gate
|
|
171
|
+
const drifted: string[] = [];
|
|
172
|
+
const walk = (dir: string, prefix: string): string[] =>
|
|
173
|
+
fs.readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {
|
|
174
|
+
const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
175
|
+
return entry.isDirectory() ? walk(path.join(dir, entry.name), rel) : [rel];
|
|
176
|
+
});
|
|
177
|
+
for (const rel of walk(srcDir, "")) {
|
|
178
|
+
const dest = path.join(skillsDir, "_shared", rel);
|
|
179
|
+
if (!fs.existsSync(dest)) {
|
|
180
|
+
drifted.push(`_shared/${rel} — missing in .agents/skills (run forge upgrade)`);
|
|
181
|
+
} else if (
|
|
182
|
+
fs.readFileSync(path.join(srcDir, rel), "utf8") !== fs.readFileSync(dest, "utf8")
|
|
183
|
+
) {
|
|
184
|
+
drifted.push(`_shared/${rel} — diverged from source`);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
expect(
|
|
188
|
+
drifted,
|
|
189
|
+
"_shared drift — convention docs sync verbatim via forge upgrade; never edit .agents/skills/_shared/ directly",
|
|
190
|
+
).toEqual([]);
|
|
191
|
+
});
|
|
167
192
|
},
|
|
168
193
|
);
|
|
@@ -19,7 +19,7 @@ import { runUpgrade } from "../onboarding/upgrade.ts";
|
|
|
19
19
|
import { generateNestedAgentsMd } from "../onboarding/nested-agents-generate.ts";
|
|
20
20
|
import { ambientIo } from "../utils/io.ts";
|
|
21
21
|
import { buildGeneratedHeader } from "../utils/index.ts";
|
|
22
|
-
import type { WorkspaceIO } from "
|
|
22
|
+
import type { WorkspaceIO } from "../types.ts";
|
|
23
23
|
import { runInit } from "../onboarding/init.ts";
|
|
24
24
|
import {
|
|
25
25
|
loadForgeConfig,
|
|
@@ -56,6 +56,12 @@ async function setupForgeSource(dir: string, version = "0.2.0"): Promise<void> {
|
|
|
56
56
|
"# RFC Template",
|
|
57
57
|
"utf8",
|
|
58
58
|
);
|
|
59
|
+
await mkdir(join(dir, "packages", "forge", "skills", "_shared"), { recursive: true });
|
|
60
|
+
await writeFile(
|
|
61
|
+
join(dir, "packages", "forge", "skills", "_shared", "fo-pipeline-conventions.md"),
|
|
62
|
+
"# Shared Conventions\n",
|
|
63
|
+
"utf8",
|
|
64
|
+
);
|
|
59
65
|
await mkdir(join(dir, "packages", "forge", "profiles"), { recursive: true });
|
|
60
66
|
}
|
|
61
67
|
|
|
@@ -309,6 +315,75 @@ test("forge.upgrade syncs skills to .agents/skills/", async () => {
|
|
|
309
315
|
expect(content).toContain("fo-idea");
|
|
310
316
|
});
|
|
311
317
|
|
|
318
|
+
test("forge.upgrade syncs _shared convention docs to .agents/skills/_shared/", async () => {
|
|
319
|
+
await setupForgeSource(tempDir, "0.2.0");
|
|
320
|
+
await setupConsumerForgeYaml(tempDir, null);
|
|
321
|
+
|
|
322
|
+
const result = await runUpgrade({ argv: [], flags: {} }, makeContext(tempDir, false));
|
|
323
|
+
|
|
324
|
+
expect(result.data?.status).toBe("pass");
|
|
325
|
+
expect(result.data?.skillsUpdated).toContain("_shared");
|
|
326
|
+
const convPath = join(tempDir, ".agents", "skills", "_shared", "fo-pipeline-conventions.md");
|
|
327
|
+
expect(existsSync(convPath)).toBe(true);
|
|
328
|
+
const content = await readFile(convPath, "utf8");
|
|
329
|
+
expect(content).toBe("# Shared Conventions\n");
|
|
330
|
+
// RFC-1154: the dir is forge-managed — marker lists every synced file.
|
|
331
|
+
const marker = await readFile(
|
|
332
|
+
join(tempDir, ".agents", "skills", "_shared", ".forge-managed"),
|
|
333
|
+
"utf8",
|
|
334
|
+
);
|
|
335
|
+
expect(JSON.parse(marker)).toEqual({ files: ["fo-pipeline-conventions.md"] });
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
test("forge.upgrade _shared sync refreshes a stale consumer copy", async () => {
|
|
339
|
+
await setupForgeSource(tempDir, "0.2.0");
|
|
340
|
+
await setupConsumerForgeYaml(tempDir, null);
|
|
341
|
+
|
|
342
|
+
await mkdir(join(tempDir, ".agents", "skills", "_shared"), { recursive: true });
|
|
343
|
+
await writeFile(
|
|
344
|
+
join(tempDir, ".agents", "skills", "_shared", "fo-pipeline-conventions.md"),
|
|
345
|
+
"# Stale Copy\n",
|
|
346
|
+
"utf8",
|
|
347
|
+
);
|
|
348
|
+
|
|
349
|
+
await runUpgrade({ argv: [], flags: {} }, makeContext(tempDir, false));
|
|
350
|
+
|
|
351
|
+
const content = await readFile(
|
|
352
|
+
join(tempDir, ".agents", "skills", "_shared", "fo-pipeline-conventions.md"),
|
|
353
|
+
"utf8",
|
|
354
|
+
);
|
|
355
|
+
expect(content).toBe("# Shared Conventions\n");
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
test("forge.upgrade --dry-run does not write _shared files", async () => {
|
|
359
|
+
await setupForgeSource(tempDir, "0.2.0");
|
|
360
|
+
await setupConsumerForgeYaml(tempDir, null);
|
|
361
|
+
|
|
362
|
+
const result = await runUpgrade(
|
|
363
|
+
{ argv: [], flags: { "dry-run": true } },
|
|
364
|
+
makeContext(tempDir, true),
|
|
365
|
+
);
|
|
366
|
+
|
|
367
|
+
expect(result.data?.status).toBe("pass");
|
|
368
|
+
expect(existsSync(join(tempDir, ".agents", "skills", "_shared"))).toBe(false);
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
test("forge.init copies _shared convention docs to .agents/skills/_shared/", async () => {
|
|
372
|
+
await setupForgeSource(tempDir, "0.3.0");
|
|
373
|
+
|
|
374
|
+
runInit({ flags: {} }, { workspaceRoot: tempDir });
|
|
375
|
+
|
|
376
|
+
const convPath = join(tempDir, ".agents", "skills", "_shared", "fo-pipeline-conventions.md");
|
|
377
|
+
expect(existsSync(convPath)).toBe(true);
|
|
378
|
+
const content = await readFile(convPath, "utf8");
|
|
379
|
+
expect(content).toBe("# Shared Conventions\n");
|
|
380
|
+
const marker = await readFile(
|
|
381
|
+
join(tempDir, ".agents", "skills", "_shared", ".forge-managed"),
|
|
382
|
+
"utf8",
|
|
383
|
+
);
|
|
384
|
+
expect(JSON.parse(marker)).toEqual({ files: ["fo-pipeline-conventions.md"] });
|
|
385
|
+
});
|
|
386
|
+
|
|
312
387
|
test("RFC-0552: forge.upgrade returns skippedSkills field and syncs non-conflicting pack skills", async () => {
|
|
313
388
|
await setupForgeSource(tempDir, "0.2.0");
|
|
314
389
|
|
|
@@ -589,4 +664,10 @@ test("forge.upgrade preserves project-accumulated knowledge entries (append-only
|
|
|
589
664
|
// New package entry appended
|
|
590
665
|
expect(merged).toContain("K-0003");
|
|
591
666
|
expect(merged).toContain("New package entry.");
|
|
667
|
+
// Divergence is surfaced in result data and a durable report, not a
|
|
668
|
+
// single-line console dump.
|
|
669
|
+
expect(result.data?.knowledgeConflicts).toEqual(["fo-idea/qa-log.md#K-0001"]);
|
|
670
|
+
expect(result.data?.knowledgeConflictsReport).toBe(".forge/knowledge-conflicts.txt");
|
|
671
|
+
const report = await readFile(join(tempDir, ".forge", "knowledge-conflicts.txt"), "utf8");
|
|
672
|
+
expect(report).toContain("fo-idea/qa-log.md#K-0001");
|
|
592
673
|
});
|
|
@@ -15,6 +15,7 @@ source (dependency inversion).</purpose>
|
|
|
15
15
|
<item>Added optional commandPrefix to GeneratedHeaderInput — defaults to "forge" for autonomous mode; site-kernel passes "pnpm exec werkstatt run".</item>
|
|
16
16
|
<item>Added editable flag to GeneratedHeaderInput — when true, emits a permissive marker and advisory that encourages agents to edit the file. AGENTS.md files use editable: true; other generated files keep the restrictive marker.</item>
|
|
17
17
|
<item>RFC-1237: added generatedHeaderFields — structured marker keys for generated YAML files (generatedMarker/doNotEdit/ownerCommand/editInstead/regenerateCommand), the emit-canonical envelope header format.</item>
|
|
18
|
+
<item>Dedupe the commandPrefix namespace in the Regenerate hint — ownerCommand "forge.agents.generate" under prefix "forge" no longer renders "forge forge.agents.generate".</item>
|
|
18
19
|
</CHANGE_SUMMARY>
|
|
19
20
|
*/
|
|
20
21
|
|
|
@@ -170,6 +171,18 @@ export function commentStyleForPath(filePath: string): GeneratedHeaderCommentSty
|
|
|
170
171
|
return "line-slash";
|
|
171
172
|
}
|
|
172
173
|
|
|
174
|
+
/**
|
|
175
|
+
* Regenerate hint: `<prefix> <command>` — when ownerCommand already carries
|
|
176
|
+
* the prefix's own namespace (`forge.agents.generate` under prefix `forge`),
|
|
177
|
+
* the namespace is stripped once so the hint never doubles it
|
|
178
|
+
* (`forge forge.agents.generate` — the deprecated qualified form).
|
|
179
|
+
*/
|
|
180
|
+
function resolveRegenerateCommand(ownerCommand: string, prefix: string, site?: string): string {
|
|
181
|
+
const ns = `${prefix}.`;
|
|
182
|
+
const name = ownerCommand.startsWith(ns) ? ownerCommand.slice(ns.length) : ownerCommand;
|
|
183
|
+
return site ? `${prefix} ${name} --site ${site}` : `${prefix} ${name}`;
|
|
184
|
+
}
|
|
185
|
+
|
|
173
186
|
/**
|
|
174
187
|
* RFC-1237: structured marker fields for generated YAML files — the key-format
|
|
175
188
|
* counterpart of buildGeneratedHeader's comment rendering. Generators whose
|
|
@@ -182,9 +195,7 @@ export function generatedHeaderFields(
|
|
|
182
195
|
): Record<string, string> {
|
|
183
196
|
const prefix = input.commandPrefix ?? "forge";
|
|
184
197
|
const editable = input.editable ?? false;
|
|
185
|
-
const regenerateCommand = input.site
|
|
186
|
-
? `${prefix} ${input.ownerCommand} --site ${input.site}`
|
|
187
|
-
: `${prefix} ${input.ownerCommand}`;
|
|
198
|
+
const regenerateCommand = resolveRegenerateCommand(input.ownerCommand, prefix, input.site);
|
|
188
199
|
return {
|
|
189
200
|
generatedMarker: editable ? EDITABLE_GENERATED_MARKER : GENERATED_MARKER,
|
|
190
201
|
doNotEdit: editable ? SAFE_TO_EDIT_LINE : DO_NOT_EDIT_LINE,
|
|
@@ -200,9 +211,7 @@ export function buildGeneratedHeader(input: GeneratedHeaderInput): string {
|
|
|
200
211
|
const editable = input.editable ?? false;
|
|
201
212
|
const marker = editable ? EDITABLE_GENERATED_MARKER : GENERATED_MARKER;
|
|
202
213
|
const advisoryLine = editable ? SAFE_TO_EDIT_LINE : DO_NOT_EDIT_LINE;
|
|
203
|
-
const regenerateCommand = input.site
|
|
204
|
-
? `${prefix} ${input.ownerCommand} --site ${input.site}`
|
|
205
|
-
: `${prefix} ${input.ownerCommand}`;
|
|
214
|
+
const regenerateCommand = resolveRegenerateCommand(input.ownerCommand, prefix, input.site);
|
|
206
215
|
const editInstead = input.templatePath
|
|
207
216
|
? `Edit instead: ${input.templatePath}`
|
|
208
217
|
: `Edit instead: the ${input.ownerCommand} generator source (not this file).`;
|