@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
package/src/onboarding/doctor.ts
CHANGED
|
@@ -8,16 +8,12 @@ Checks for forge.yaml, AGENTS.md, PREFERENCES.md, .agents/skills/, docs/rfcs/,
|
|
|
8
8
|
</non-goals>
|
|
9
9
|
</MODULE_CONTRACT>
|
|
10
10
|
<CHANGE_SUMMARY>
|
|
11
|
-
<item>RFC-1097: step 6 — compass.migrate codemod run
|
|
12
|
-
|
|
13
|
-
Mechanical v1 to v2 header migration across the workspace: 942 files rewritten — CHANGE_SUMMARY windows collapsed into history, forbidden v1 blocks stripped, KEY_DECISIONS seeded from @ai-invariant comments (5 files) or TODO placeholders (103 files), blocks reordered to canonical order.</item>
|
|
14
|
-
<item>RFC-1097: sweep — packages/forge + services clean
|
|
15
|
-
|
|
16
|
-
Sweep batch 2: real KEY_DECISIONS on 10 files, expanded purposes (CONTRACT-02/PURPOSE-02), headers on mission/index + gen-upstreams, sanitizeItemText in summary.record (literal Compass tags corrupted history), excludedPaths for wrangler types, test-fixtures testPattern. forge+services now 0 diagnostics under --mode error.</item>
|
|
17
11
|
<item>RFC-1224: preserve operator forge.yaml content on upgrade, promote adrImplementStamp binding</item>
|
|
18
12
|
<item>RFC-1226: skills-unmanaged check — warn on SKILL.md-bearing dirs without .forge-managed marker</item>
|
|
19
13
|
<item>RFC-1249: wire werkstatt.commands.validate into packages.check + retire CMD-OUTPUT debt</item>
|
|
20
|
-
<
|
|
14
|
+
<item>forge-version-sync check — warns when the installed @warpgogol/forge version diverges from forge.yaml syncedVersion (pnpm up drifts it silently); nested wsTypes resolution moved to shared resolveWorkspaceTypes.</item>
|
|
15
|
+
<item>agents.generate remediation counts marker-guarded semantic-layer injections as fixes — a hand-written file that only gained the region reports fixed instead of skipped (consumer field report follow-up to RFC-1253).</item>
|
|
16
|
+
<history>RFC-0391, RFC-0393, RFC-0524, RFC-0539, RFC-0540, RFC-0611, RFC-0640, RFC-0660, RFC-0661, RFC-0663, RFC-0664, RFC-0675, RFC-0704, RFC-0941, RFC-1097, RFC-1224</history>
|
|
21
17
|
</CHANGE_SUMMARY>
|
|
22
18
|
*/
|
|
23
19
|
|
|
@@ -35,7 +31,7 @@ import type {
|
|
|
35
31
|
} from "../types.ts";
|
|
36
32
|
import { resolveForgeRoot, loadForgeConfig, resolveBinding, resolveTerminology, FORGE_CLI_BINDING_DEFAULTS, resolvePmRunner } from "../config/forge-config.ts";
|
|
37
33
|
import { FORGE_SKILLS, discoverPackSkills } from "../registry.ts";
|
|
38
|
-
import { discoverWorkspaces } from "./workspace-discovery.ts";
|
|
34
|
+
import { discoverWorkspaces, resolveWorkspaceTypes } from "./workspace-discovery.ts";
|
|
39
35
|
import { buildNestedAgentsMd, selectNestedTemplate } from "./nested-agents-templates.ts";
|
|
40
36
|
import { readPackageInfo, generateNestedAgentsMd } from "./nested-agents-generate.ts";
|
|
41
37
|
import { listStackProfiles, type StackProfile } from "../profiles/stack-profile.ts";
|
|
@@ -876,6 +872,66 @@ async function checkPackManifests(workspaceRoot: string, _io: WorkspaceIO): Prom
|
|
|
876
872
|
};
|
|
877
873
|
}
|
|
878
874
|
|
|
875
|
+
// ---------------------------------------------------------------------------
|
|
876
|
+
// Forge version sync — installed package vs forge.yaml syncedVersion
|
|
877
|
+
// ---------------------------------------------------------------------------
|
|
878
|
+
|
|
879
|
+
/**
|
|
880
|
+
* `pnpm up`/`npm update` bumps the installed @warpgogol/forge package but never
|
|
881
|
+
* touches forge.yaml — syncedVersion goes stale silently and the next
|
|
882
|
+
* `forge.upgrade` (or stale-skill sync) runs against a wrong baseline. Warn so
|
|
883
|
+
* the drift surfaces; pass when either side is unreadable (first init,
|
|
884
|
+
* source checkout without forge.yaml).
|
|
885
|
+
*/
|
|
886
|
+
function checkForgeVersionSync(workspaceRoot: string, forgeRoot: string): DoctorCheck {
|
|
887
|
+
let config;
|
|
888
|
+
try {
|
|
889
|
+
config = loadForgeConfig(workspaceRoot);
|
|
890
|
+
} catch {
|
|
891
|
+
return {
|
|
892
|
+
name: "forge-version-sync",
|
|
893
|
+
status: "pass",
|
|
894
|
+
message: "forge.yaml not loadable — version sync check skipped",
|
|
895
|
+
};
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
const synced = config.forge?.syncedVersion ?? null;
|
|
899
|
+
if (synced === null) {
|
|
900
|
+
return {
|
|
901
|
+
name: "forge-version-sync",
|
|
902
|
+
status: "pass",
|
|
903
|
+
message: "no syncedVersion recorded — version sync check skipped",
|
|
904
|
+
};
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
let installed: string | null = null;
|
|
908
|
+
try {
|
|
909
|
+
const pkg = JSON.parse(readFileSync(join(forgeRoot, "package.json"), "utf8")) as {
|
|
910
|
+
version?: unknown;
|
|
911
|
+
};
|
|
912
|
+
if (typeof pkg.version === "string") installed = pkg.version;
|
|
913
|
+
} catch {
|
|
914
|
+
// package.json unreadable — treated as unresolvable below
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
if (installed === null) {
|
|
918
|
+
return {
|
|
919
|
+
name: "forge-version-sync",
|
|
920
|
+
status: "pass",
|
|
921
|
+
message: "installed forge version unreadable — version sync check skipped",
|
|
922
|
+
};
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
const inSync = installed === synced;
|
|
926
|
+
return {
|
|
927
|
+
name: "forge-version-sync",
|
|
928
|
+
status: inSync ? "pass" : "warn",
|
|
929
|
+
message: inSync
|
|
930
|
+
? `syncedVersion matches installed v${installed}`
|
|
931
|
+
: `installed @warpgogol/forge v${installed} ≠ forge.yaml syncedVersion ${synced} — run 'forge upgrade'`,
|
|
932
|
+
};
|
|
933
|
+
}
|
|
934
|
+
|
|
879
935
|
// ---------------------------------------------------------------------------
|
|
880
936
|
// Nested AGENTS.md diagnostics (RFC-0611)
|
|
881
937
|
// ---------------------------------------------------------------------------
|
|
@@ -1484,6 +1540,10 @@ export async function runDoctor(
|
|
|
1484
1540
|
: `Bindings: ${bindingsResult.invalid.length} invalid — ${bindingsResult.invalid.join(", ")}`,
|
|
1485
1541
|
});
|
|
1486
1542
|
|
|
1543
|
+
// Installed forge version vs forge.yaml syncedVersion — `pnpm up` bumps the
|
|
1544
|
+
// package without running forge.upgrade, leaving syncedVersion stale.
|
|
1545
|
+
checks.push(checkForgeVersionSync(workspaceRoot, forgeRoot));
|
|
1546
|
+
|
|
1487
1547
|
// Check stale knowledge files (RFC-0524, RFC-0539)
|
|
1488
1548
|
const staleCheck = await checkStaleKnowledgeFiles(workspaceRoot, forgeRoot, fio);
|
|
1489
1549
|
checks.push(staleCheck);
|
|
@@ -1531,28 +1591,14 @@ export async function runDoctor(
|
|
|
1531
1591
|
// entirely for non-software domains. Now runs for all domains — profile-driven
|
|
1532
1592
|
// wsTypes replace hardcoded detection when present.
|
|
1533
1593
|
let wsTypes: ProfileWorkspaceType[] | undefined;
|
|
1534
|
-
{
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
} else {
|
|
1541
|
-
const profiles = listStackProfiles(forgeRoot);
|
|
1542
|
-
for (const stackId of config.project.stack) {
|
|
1543
|
-
const profile = profiles.find((p) => p.id === stackId);
|
|
1544
|
-
if (profile?.workspaceTypes && profile.workspaceTypes.length > 0) {
|
|
1545
|
-
wsTypes = profile.workspaceTypes;
|
|
1546
|
-
break;
|
|
1547
|
-
}
|
|
1548
|
-
}
|
|
1549
|
-
}
|
|
1550
|
-
} catch {
|
|
1551
|
-
// profiles not loadable
|
|
1552
|
-
}
|
|
1553
|
-
const nestedCheck = await checkNestedAgentsMd(workspaceRoot, wsTypes, fio);
|
|
1554
|
-
checks.push(nestedCheck);
|
|
1594
|
+
try {
|
|
1595
|
+
// RFC-0643: resolveWorkspaceTypes prefers config.profile (loaded by
|
|
1596
|
+
// loadForgeConfig), falls back to the stack-based catalog lookup.
|
|
1597
|
+
wsTypes = resolveWorkspaceTypes(loadForgeConfig(workspaceRoot), forgeRoot);
|
|
1598
|
+
} catch {
|
|
1599
|
+
// config/profiles not loadable — nested check runs without profile types
|
|
1555
1600
|
}
|
|
1601
|
+
checks.push(await checkNestedAgentsMd(workspaceRoot, wsTypes, fio));
|
|
1556
1602
|
|
|
1557
1603
|
// RFC-0640: --strict flag elevates warn to fail for domain-related checks
|
|
1558
1604
|
const finalChecks = strict
|
|
@@ -1660,8 +1706,8 @@ async function applyDoctorRemediation(
|
|
|
1660
1706
|
const res = await generateNestedAgentsMd(workspaceRoot, config, dryRun, workspaceTypes, io);
|
|
1661
1707
|
return {
|
|
1662
1708
|
check: check.name,
|
|
1663
|
-
action: res.generated.length > 0 ? "fixed" : "skipped",
|
|
1664
|
-
detail: `${res.generated.length} file(s) ${dryRun ? "would be " : ""}regenerated, ${res.skipped.length} skipped`,
|
|
1709
|
+
action: res.generated.length > 0 || res.injected.length > 0 ? "fixed" : "skipped",
|
|
1710
|
+
detail: `${res.generated.length} file(s) ${dryRun ? "would be " : ""}regenerated, ${res.skipped.length} skipped${res.injected.length > 0 ? `, ${res.injected.length} semantic-layer injected` : ""}`,
|
|
1665
1711
|
};
|
|
1666
1712
|
} catch (err) {
|
|
1667
1713
|
return { check: check.name, action: "failed", detail: (err as Error).message };
|
package/src/onboarding/init.ts
CHANGED
|
@@ -7,16 +7,16 @@
|
|
|
7
7
|
</non-goals>
|
|
8
8
|
</MODULE_CONTRACT>
|
|
9
9
|
<CHANGE_SUMMARY>
|
|
10
|
-
<item>RFC-0663: added syncSharedKnowledge step to sync shared knowledge layer to .agents/skills/shared-knowledge/.</item>
|
|
11
|
-
<item>RFC-0941: create forge.plugin.yaml manifests for skill packs that lack them before calling discoverPackSkills.</item>
|
|
12
10
|
<item>RFC-1019: extend PREFERENCES.md with formOfAddress, session-end protocol, skill invocation tracking, plan confirmation vs implementation, commit granularity rules.</item>
|
|
11
|
+
<item>fix: copy skills/_shared/ convention docs to .agents/skills/_shared/ on init — fo-* SKILL.md references dangled without it</item>
|
|
13
12
|
<item>RFC-1097: step 6 — compass.migrate codemod run
|
|
14
13
|
|
|
15
14
|
Mechanical v1 to v2 header migration across the workspace: 942 files rewritten — CHANGE_SUMMARY windows collapsed into history, forbidden v1 blocks stripped, KEY_DECISIONS seeded from @ai-invariant comments (5 files) or TODO placeholders (103 files), blocks reordered to canonical order.</item>
|
|
16
15
|
<item>RFC-1097: sweep — packages/forge + services clean
|
|
17
16
|
|
|
18
17
|
Sweep batch 2: real KEY_DECISIONS on 10 files, expanded purposes (CONTRACT-02/PURPOSE-02), headers on mission/index + gen-upstreams, sanitizeItemText in summary.record (literal Compass tags corrupted history), excludedPaths for wrangler types, test-fixtures testPattern. forge+services now 0 diagnostics under --mode error.</item>
|
|
19
|
-
<
|
|
18
|
+
<item>Prettierignore plan on init now enumerates generated AGENTS.md paths (workspace types resolved via shared resolveWorkspaceTypes).</item>
|
|
19
|
+
<history>RFC-0374, RFC-0391, RFC-0392, RFC-0393, RFC-0524, RFC-0539, RFC-0543, RFC-0544, RFC-0552, RFC-0640, RFC-0643, RFC-0663, RFC-0941</history>
|
|
20
20
|
</CHANGE_SUMMARY>
|
|
21
21
|
*/
|
|
22
22
|
|
|
@@ -27,6 +27,7 @@ import { FORGE_SKILLS, discoverPackSkills } from "../registry.ts";
|
|
|
27
27
|
import { syncKnowledgeFile } from "../knowledge/index.ts";
|
|
28
28
|
import { writeSkillMarkerSync } from "./skill-markers.ts";
|
|
29
29
|
import { planPrettierignoreSync, applyPrettierignoreSync } from "./prettierignore.ts";
|
|
30
|
+
import { resolveWorkspaceTypes } from "./workspace-discovery.ts";
|
|
30
31
|
import { defaultForgeConfig, loadForgeConfig, resolveForgeRoot, type ForgeConfig } from "../config/forge-config.ts";
|
|
31
32
|
import { listStackProfiles, detectStack } from "../profiles/stack-profile.ts";
|
|
32
33
|
|
|
@@ -418,13 +419,43 @@ export function runInit(
|
|
|
418
419
|
);
|
|
419
420
|
}
|
|
420
421
|
|
|
422
|
+
// Sync skills/_shared/ convention docs to .agents/skills/_shared/ — fo-*
|
|
423
|
+
// SKILL.md files link these by relative path. Verbatim copy, forge-managed
|
|
424
|
+
// via marker (mirrors the upgrade-path syncSharedConventions step).
|
|
425
|
+
const sharedConvSrc = path.join(forgeRoot, "skills", "_shared");
|
|
426
|
+
if (fs.existsSync(sharedConvSrc)) {
|
|
427
|
+
const sharedConvDestDir = path.join(agentsSkillsDir, "_shared");
|
|
428
|
+
fs.mkdirSync(sharedConvDestDir, { recursive: true });
|
|
429
|
+
const sharedFiles: string[] = [];
|
|
430
|
+
const walk = (dir: string, prefix: string): void => {
|
|
431
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
432
|
+
const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
433
|
+
if (entry.isDirectory()) {
|
|
434
|
+
walk(path.join(dir, entry.name), rel);
|
|
435
|
+
} else {
|
|
436
|
+
sharedFiles.push(rel);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
};
|
|
440
|
+
walk(sharedConvSrc, "");
|
|
441
|
+
for (const rel of sharedFiles) {
|
|
442
|
+
fs.mkdirSync(path.dirname(path.join(sharedConvDestDir, rel)), { recursive: true });
|
|
443
|
+
fs.copyFileSync(path.join(sharedConvSrc, rel), path.join(sharedConvDestDir, rel));
|
|
444
|
+
created.push(`${config.paths.skillsDir}/_shared/${rel}`);
|
|
445
|
+
}
|
|
446
|
+
writeSkillMarkerSync(sharedConvDestDir, sharedFiles);
|
|
447
|
+
}
|
|
448
|
+
|
|
421
449
|
// RFC-1154: reconcile the forge-managed .prettierignore block (prettier
|
|
422
450
|
// consumers only; additive + idempotent, no-op otherwise). Non-fatal —
|
|
423
451
|
// a prettierignore write failure must not fail init.
|
|
424
452
|
try {
|
|
425
453
|
applyPrettierignoreSync(
|
|
426
454
|
workspaceRoot,
|
|
427
|
-
planPrettierignoreSync(workspaceRoot, config.paths.skillsDir
|
|
455
|
+
planPrettierignoreSync(workspaceRoot, config.paths.skillsDir, {
|
|
456
|
+
workspaceTypes: resolveWorkspaceTypes(config, forgeRoot),
|
|
457
|
+
workspaceSkipDirs: config.bindings?.workspaces?.skipDirs,
|
|
458
|
+
}),
|
|
428
459
|
);
|
|
429
460
|
} catch (err) {
|
|
430
461
|
errors.push(`.prettierignore reconcile failed: ${(err as Error).message}`);
|
|
@@ -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
|
|
|
@@ -16,12 +15,16 @@ Mechanical v1 to v2 header migration across the workspace: 942 files rewritten
|
|
|
16
15
|
<item>RFC-1097: sweep — werkstatt-engine clean
|
|
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>
|
|
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>
|
|
19
21
|
</CHANGE_SUMMARY>
|
|
20
22
|
*/
|
|
21
23
|
|
|
22
24
|
import { alignMarkdownTable, buildGeneratedHeader } from "../utils/index.ts";
|
|
23
|
-
import { resolveForgePackageRoot } from "../config/forge-config.ts";
|
|
25
|
+
import { resolveBinding, resolveForgePackageRoot } from "../config/forge-config.ts";
|
|
24
26
|
import type { ForgeConfig } from "../config/forge-config.ts";
|
|
27
|
+
import { semanticLayerLines } from "./compass-docs/semantic-layer-block.ts";
|
|
25
28
|
import type { WorkspaceDir, WorkspaceType } from "./workspace-discovery.ts";
|
|
26
29
|
import type { ProfileWorkspaceType } from "../profiles/profile-schema.ts";
|
|
27
30
|
import type { StackProfile } from "../profiles/stack-profile.ts";
|
|
@@ -53,6 +56,13 @@ const TYPE_LABEL: Record<WorkspaceType, string> = {
|
|
|
53
56
|
service: "Service",
|
|
54
57
|
};
|
|
55
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
|
+
|
|
56
66
|
interface EntryPoint {
|
|
57
67
|
name: string;
|
|
58
68
|
module: string;
|
|
@@ -187,7 +197,7 @@ function substituteNestedTemplate(
|
|
|
187
197
|
|
|
188
198
|
export function buildNestedAgentsMd(
|
|
189
199
|
workspace: WorkspaceDir,
|
|
190
|
-
|
|
200
|
+
config: ForgeConfig,
|
|
191
201
|
packageInfo?: PackageInfo,
|
|
192
202
|
): string {
|
|
193
203
|
const header = buildGeneratedHeader({
|
|
@@ -199,7 +209,6 @@ export function buildNestedAgentsMd(
|
|
|
199
209
|
|
|
200
210
|
const lines: string[] = [];
|
|
201
211
|
lines.push(header);
|
|
202
|
-
lines.push("");
|
|
203
212
|
|
|
204
213
|
const displayName = packageInfo?.name ?? workspace.path;
|
|
205
214
|
lines.push(`# \`${displayName}\` — Agent Guide`);
|
|
@@ -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");
|
|
@@ -21,6 +21,7 @@ operator-owned.
|
|
|
21
21
|
</MODULE_CONTRACT>
|
|
22
22
|
<CHANGE_SUMMARY>
|
|
23
23
|
<item>RFC-1154: initial implementation — plan/apply + delimited-block reconcile.</item>
|
|
24
|
+
<item>Enumerate generated AGENTS.md paths (root + nested workspaces via discoverWorkspaces) in the managed block — prettier normalization byte-diverges from the generator render and trips doctor's stale check on every format-on-commit.</item>
|
|
24
25
|
</CHANGE_SUMMARY>
|
|
25
26
|
*/
|
|
26
27
|
|
|
@@ -31,6 +32,9 @@ import { writeFileIfChanged } from "../utils/fs-idempotent.ts";
|
|
|
31
32
|
import { fileExists } from "../utils/fs.ts";
|
|
32
33
|
import * as sfs from "../utils/sync-fs.ts";
|
|
33
34
|
import { SKILL_MARKER_FILE } from "./skill-markers.ts";
|
|
35
|
+
import { discoverWorkspaces } from "./workspace-discovery.ts";
|
|
36
|
+
import { hasGeneratedMarker } from "../utils/index.ts";
|
|
37
|
+
import type { ProfileWorkspaceType } from "../profiles/profile-schema.ts";
|
|
34
38
|
|
|
35
39
|
export const PRETTIERIGNORE_BLOCK_BEGIN = "# forge-managed generated paths (RFC-1154)";
|
|
36
40
|
export const PRETTIERIGNORE_BLOCK_END = "# end forge-managed";
|
|
@@ -65,6 +69,12 @@ export interface PrettierignorePlan {
|
|
|
65
69
|
fileExists: boolean;
|
|
66
70
|
}
|
|
67
71
|
|
|
72
|
+
/** Optional discovery inputs for generated-AGENTS.md enumeration. */
|
|
73
|
+
export interface PrettierignorePlanOptions {
|
|
74
|
+
workspaceTypes?: ProfileWorkspaceType[];
|
|
75
|
+
workspaceSkipDirs?: readonly string[];
|
|
76
|
+
}
|
|
77
|
+
|
|
68
78
|
export type PrettierignoreResult = "written" | "updated" | "unchanged" | "skipped";
|
|
69
79
|
|
|
70
80
|
function packageJsonUsesPrettier(pkg: Record<string, unknown>): boolean {
|
|
@@ -153,19 +163,50 @@ function listManagedSkillEntriesSync(workspaceRoot: string, skillsDirRel: string
|
|
|
153
163
|
return entries.sort();
|
|
154
164
|
}
|
|
155
165
|
|
|
166
|
+
/**
|
|
167
|
+
* Generated AGENTS.md paths — root file plus per-workspace nested guides.
|
|
168
|
+
* Only marker-bearing files are listed: generated AGENTS.md is forge-owned
|
|
169
|
+
* head + operator tail (RFC-1153), and prettier normalization in the head
|
|
170
|
+
* (blank-line collapse, table realign) byte-diverges from the generator's
|
|
171
|
+
* render, tripping doctor's stale check on every format-on-commit. Excluding
|
|
172
|
+
* them keeps the drift class out; hand-written AGENTS.md (no marker) stays
|
|
173
|
+
* operator-owned and prettier-covered.
|
|
174
|
+
*/
|
|
175
|
+
function listGeneratedAgentsMdEntries(
|
|
176
|
+
workspaceRoot: string,
|
|
177
|
+
opts: PrettierignorePlanOptions,
|
|
178
|
+
): string[] {
|
|
179
|
+
const entries: string[] = [];
|
|
180
|
+
try {
|
|
181
|
+
if (hasGeneratedMarker(sfs.readFileSync(path.join(workspaceRoot, "AGENTS.md"), "utf8"))) {
|
|
182
|
+
// Anchored — a bare "AGENTS.md" pattern matches at every depth and would
|
|
183
|
+
// also ignore hand-written nested guides.
|
|
184
|
+
entries.push("/AGENTS.md");
|
|
185
|
+
}
|
|
186
|
+
} catch {
|
|
187
|
+
// root AGENTS.md absent or unreadable
|
|
188
|
+
}
|
|
189
|
+
for (const ws of discoverWorkspaces(workspaceRoot, opts.workspaceTypes, opts.workspaceSkipDirs)) {
|
|
190
|
+
if (ws.isGenerated) entries.push(`${ws.path}/AGENTS.md`);
|
|
191
|
+
}
|
|
192
|
+
return entries.sort();
|
|
193
|
+
}
|
|
194
|
+
|
|
156
195
|
export async function planPrettierignore(
|
|
157
196
|
workspaceRoot: string,
|
|
158
197
|
skillsDirRel = ".agents/skills",
|
|
159
198
|
io?: WorkspaceIO,
|
|
199
|
+
opts: PrettierignorePlanOptions = {},
|
|
160
200
|
): Promise<PrettierignorePlan> {
|
|
161
201
|
const fio = resolveIo(io);
|
|
162
202
|
const applies = await detectPrettier(workspaceRoot, fio);
|
|
163
203
|
const skillEntries = applies
|
|
164
204
|
? await listManagedSkillEntries(workspaceRoot, skillsDirRel, fio)
|
|
165
205
|
: [];
|
|
206
|
+
const agentsMdEntries = applies ? listGeneratedAgentsMdEntries(workspaceRoot, opts) : [];
|
|
166
207
|
return {
|
|
167
208
|
applies,
|
|
168
|
-
entries: [...skillEntries, ...FIXED_ENTRIES],
|
|
209
|
+
entries: [...skillEntries, ...agentsMdEntries, ...FIXED_ENTRIES],
|
|
169
210
|
fileExists: await fileExists(path.join(workspaceRoot, ".prettierignore")),
|
|
170
211
|
};
|
|
171
212
|
}
|
|
@@ -174,12 +215,14 @@ export async function planPrettierignore(
|
|
|
174
215
|
export function planPrettierignoreSync(
|
|
175
216
|
workspaceRoot: string,
|
|
176
217
|
skillsDirRel = ".agents/skills",
|
|
218
|
+
opts: PrettierignorePlanOptions = {},
|
|
177
219
|
): PrettierignorePlan {
|
|
178
220
|
const applies = detectPrettierSync(workspaceRoot);
|
|
179
221
|
const skillEntries = applies ? listManagedSkillEntriesSync(workspaceRoot, skillsDirRel) : [];
|
|
222
|
+
const agentsMdEntries = applies ? listGeneratedAgentsMdEntries(workspaceRoot, opts) : [];
|
|
180
223
|
return {
|
|
181
224
|
applies,
|
|
182
|
-
entries: [...skillEntries, ...FIXED_ENTRIES],
|
|
225
|
+
entries: [...skillEntries, ...agentsMdEntries, ...FIXED_ENTRIES],
|
|
183
226
|
fileExists: sfs.existsSync(path.join(workspaceRoot, ".prettierignore")),
|
|
184
227
|
};
|
|
185
228
|
}
|
|
@@ -147,7 +147,11 @@ export async function pruneStaleSkillDirs(
|
|
|
147
147
|
return result;
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
async function listFilesRecursive(
|
|
150
|
+
export async function listFilesRecursive(
|
|
151
|
+
dir: string,
|
|
152
|
+
io: WorkspaceIO,
|
|
153
|
+
prefix = "",
|
|
154
|
+
): Promise<string[]> {
|
|
151
155
|
const out: string[] = [];
|
|
152
156
|
const entries = await io.readdir(dir);
|
|
153
157
|
for (const entry of entries) {
|
|
@@ -24,6 +24,7 @@ When the operator describes a significant idea or change, the agent SHOULD proac
|
|
|
24
24
|
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.
|
|
25
25
|
|
|
26
26
|
Session save mechanism:
|
|
27
|
+
|
|
27
28
|
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).
|
|
28
29
|
2. Run `ref(forge.yaml bindings.commands.sessionSave)` to convert the raw file to structured markdown in `docs/sessions/`.
|
|
29
30
|
3. If the command fails or the binding is null, create the session file manually in `docs/sessions/` with frontmatter (id, date, type, relatedRfcs).
|
|
@@ -68,6 +69,7 @@ The agent reads `.agents/operator-profile.md` at the start of each session and c
|
|
|
68
69
|
The agent offers proactive guidance at the right moment — at most once per session per topic. If declined, the suggestion is not repeated.
|
|
69
70
|
|
|
70
71
|
Built-in guidance triggers:
|
|
72
|
+
|
|
71
73
|
- **Long session** (>2 hours): suggest a break or session save.
|
|
72
74
|
- **Complex change** (3+ files in one area): suggest grilling or planning.
|
|
73
75
|
- **Multiple topics** in one session: suggest splitting into separate sessions.
|