@warpgogol/forge 6.3.0 → 6.3.2
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 +153 -0
- package/bin/cli.js +13 -2
- 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 +213 -13
- package/dist/os/core/handlers/package-health.js.map +1 -1
- package/dist/src/onboarding/agents-generate.d.ts.map +1 -1
- package/dist/src/onboarding/agents-generate.js +14 -25
- package/dist/src/onboarding/agents-generate.js.map +1 -1
- package/dist/src/onboarding/doctor.d.ts.map +1 -1
- package/dist/src/onboarding/doctor.js +69 -28
- 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-templates.d.ts.map +1 -1
- package/dist/src/onboarding/nested-agents-templates.js +1 -1
- 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/os/core/core.module.ts +6 -8
- package/os/core/docs-archive.test.ts +2 -5
- package/os/core/handlers/package-health.test.ts +262 -4
- package/os/core/handlers/package-health.ts +223 -13
- 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 +14 -25
- package/src/onboarding/doctor.ts +74 -26
- package/src/onboarding/init.ts +35 -4
- package/src/onboarding/nested-agents-templates.ts +1 -1
- 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/bindings-schema.test.ts +1 -0
- package/src/tests/compass-docs-flag.test.ts +2 -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 +4 -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
|
@@ -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.
|
|
@@ -11,8 +11,6 @@ With --update-npm, also updates @warpgogol/forge from npm before syncing (skippe
|
|
|
11
11
|
</non-goals>
|
|
12
12
|
</MODULE_CONTRACT>
|
|
13
13
|
<CHANGE_SUMMARY>
|
|
14
|
-
<item>RFC-0663: added syncSharedKnowledge step to sync shared knowledge layer to .agents/skills/shared-knowledge/.</item>
|
|
15
|
-
<item>RFC-0664: added scaffoldMemoryLayer step to scaffold .agents/memory/ and .gitignore block.</item>
|
|
16
14
|
<item>RFC-1097: step 6 — compass.migrate codemod run
|
|
17
15
|
|
|
18
16
|
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>
|
|
@@ -20,7 +18,9 @@ Mechanical v1 to v2 header migration across the workspace: 942 files rewritten
|
|
|
20
18
|
|
|
21
19
|
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
20
|
<item>RFC-1224: preserve operator forge.yaml content on upgrade, promote adrImplementStamp binding</item>
|
|
23
|
-
<
|
|
21
|
+
<item>fix: sync skills/_shared/ convention docs to .agents/skills/_shared/ — fo-* SKILL.md references dangled for npm consumers</item>
|
|
22
|
+
<item>Knowledge conflicts land in .forge/knowledge-conflicts.txt (summary + path in console instead of a 60+ entry dump); exposed as knowledgeConflicts/knowledgeConflictsReport on UpgradeResult. Prettierignore plan now enumerates generated AGENTS.md paths.</item>
|
|
23
|
+
<history>RFC-0543, RFC-0611, RFC-0663, RFC-0664, RFC-1224</history>
|
|
24
24
|
</CHANGE_SUMMARY>
|
|
25
25
|
*/
|
|
26
26
|
|
|
@@ -45,13 +45,19 @@ import {
|
|
|
45
45
|
import { FORGE_SKILLS, discoverPackSkills } from "../registry.ts";
|
|
46
46
|
import { syncKnowledgeFile } from "../knowledge/index.ts";
|
|
47
47
|
import { writeFileIfChanged } from "../utils/fs-idempotent.ts";
|
|
48
|
-
import {
|
|
48
|
+
import {
|
|
49
|
+
writeSkillMarker,
|
|
50
|
+
pruneStaleSkillDirs,
|
|
51
|
+
listFilesRecursive,
|
|
52
|
+
type PruneResult,
|
|
53
|
+
} from "./skill-markers.ts";
|
|
49
54
|
import {
|
|
50
55
|
planPrettierignore,
|
|
51
56
|
applyPrettierignore,
|
|
52
57
|
type PrettierignoreResult,
|
|
53
58
|
} from "./prettierignore.ts";
|
|
54
59
|
import { generateNestedAgentsMd } from "./nested-agents-generate.ts";
|
|
60
|
+
import { resolveWorkspaceTypes } from "./workspace-discovery.ts";
|
|
55
61
|
import { scaffoldMemoryLayer } from "./memory-scaffold.ts";
|
|
56
62
|
import type { SkippedSkill } from "./init.ts";
|
|
57
63
|
import type { ForgeCommandInput, ForgeCommandResult, ForgeNextStep, ForgeRuntimeContext } from "../types.ts";
|
|
@@ -81,6 +87,10 @@ export interface UpgradeResult {
|
|
|
81
87
|
skillsPruned: string[];
|
|
82
88
|
skillsKeptWithConsumerFiles: string[];
|
|
83
89
|
prettierignore: PrettierignoreResult;
|
|
90
|
+
/** Knowledge entries diverging between package and project — local kept. */
|
|
91
|
+
knowledgeConflicts?: string[];
|
|
92
|
+
/** Repo-relative path of the written conflicts report, when any. */
|
|
93
|
+
knowledgeConflictsReport?: string | null;
|
|
84
94
|
}
|
|
85
95
|
|
|
86
96
|
async function isMonorepoForge(workspaceRoot: string, io: WorkspaceIO): Promise<boolean> {
|
|
@@ -258,6 +268,37 @@ async function syncSharedKnowledge(
|
|
|
258
268
|
return { updated, knowledgeConflicts };
|
|
259
269
|
}
|
|
260
270
|
|
|
271
|
+
/**
|
|
272
|
+
* Sync `_shared/` convention docs (fo-pipeline-conventions.md et al.) into
|
|
273
|
+
* `.agents/skills/_shared/`. fo-* SKILL.md files link these by relative path —
|
|
274
|
+
* without the copy the references dangle for npm consumers. Verbatim sync like
|
|
275
|
+
* SKILL.md, forge-managed via marker so a dropped upstream dir prunes cleanly.
|
|
276
|
+
*/
|
|
277
|
+
async function syncSharedConventions(
|
|
278
|
+
workspaceRoot: string,
|
|
279
|
+
forgeRoot: string,
|
|
280
|
+
skillsDir: string,
|
|
281
|
+
dryRun: boolean,
|
|
282
|
+
io: WorkspaceIO,
|
|
283
|
+
): Promise<{ updated: string[] }> {
|
|
284
|
+
const srcDir = path.join(forgeRoot, "skills", "_shared");
|
|
285
|
+
if (!(await io.exists(srcDir))) return { updated: [] };
|
|
286
|
+
|
|
287
|
+
const files = await listFilesRecursive(srcDir, io);
|
|
288
|
+
if (files.length === 0) return { updated: [] };
|
|
289
|
+
|
|
290
|
+
if (!dryRun) {
|
|
291
|
+
const destDir = path.join(workspaceRoot, skillsDir, "_shared");
|
|
292
|
+
await io.mkdir(destDir);
|
|
293
|
+
for (const rel of files) {
|
|
294
|
+
const content = await io.readFile(path.join(srcDir, rel));
|
|
295
|
+
await writeFileIfChanged(path.join(destDir, rel), content, io);
|
|
296
|
+
}
|
|
297
|
+
await writeSkillMarker(destDir, files, io);
|
|
298
|
+
}
|
|
299
|
+
return { updated: ["_shared"] };
|
|
300
|
+
}
|
|
301
|
+
|
|
261
302
|
async function syncPackSkills(
|
|
262
303
|
workspaceRoot: string,
|
|
263
304
|
config: ForgeConfig,
|
|
@@ -370,11 +411,19 @@ async function reconcileGeneratedSurface(
|
|
|
370
411
|
dryRun,
|
|
371
412
|
io,
|
|
372
413
|
);
|
|
414
|
+
const sharedConventionsResult = await syncSharedConventions(
|
|
415
|
+
workspaceRoot,
|
|
416
|
+
forgeRoot,
|
|
417
|
+
config.paths.skillsDir,
|
|
418
|
+
dryRun,
|
|
419
|
+
io,
|
|
420
|
+
);
|
|
373
421
|
|
|
374
422
|
const currentSyncSet = new Set([
|
|
375
423
|
...forgeSkillsResult.updated,
|
|
376
424
|
...packResult.updated,
|
|
377
425
|
...sharedKnowledgeResult.updated,
|
|
426
|
+
...sharedConventionsResult.updated,
|
|
378
427
|
]);
|
|
379
428
|
|
|
380
429
|
const warnings: string[] = [];
|
|
@@ -397,7 +446,10 @@ async function reconcileGeneratedSurface(
|
|
|
397
446
|
try {
|
|
398
447
|
prettierignore = await applyPrettierignore(
|
|
399
448
|
workspaceRoot,
|
|
400
|
-
await planPrettierignore(workspaceRoot, config.paths.skillsDir, io
|
|
449
|
+
await planPrettierignore(workspaceRoot, config.paths.skillsDir, io, {
|
|
450
|
+
workspaceTypes: resolveWorkspaceTypes(config, forgeRoot),
|
|
451
|
+
workspaceSkipDirs: config.bindings?.workspaces?.skipDirs,
|
|
452
|
+
}),
|
|
401
453
|
io,
|
|
402
454
|
);
|
|
403
455
|
} catch (err) {
|
|
@@ -410,6 +462,7 @@ async function reconcileGeneratedSurface(
|
|
|
410
462
|
...forgeSkillsResult.updated,
|
|
411
463
|
...packResult.updated,
|
|
412
464
|
...sharedKnowledgeResult.updated,
|
|
465
|
+
...sharedConventionsResult.updated,
|
|
413
466
|
],
|
|
414
467
|
knowledgeConflicts: [
|
|
415
468
|
...forgeSkillsResult.knowledgeConflicts,
|
|
@@ -423,6 +476,52 @@ async function reconcileGeneratedSurface(
|
|
|
423
476
|
};
|
|
424
477
|
}
|
|
425
478
|
|
|
479
|
+
/**
|
|
480
|
+
* Knowledge-conflict report — the full divergence list lands in
|
|
481
|
+
* `.forge/knowledge-conflicts.txt` (overwritten each run, no churn); the
|
|
482
|
+
* console keeps a one-line summary + path instead of a 60+ entry dump.
|
|
483
|
+
*/
|
|
484
|
+
async function writeKnowledgeConflictsReport(
|
|
485
|
+
workspaceRoot: string,
|
|
486
|
+
conflicts: string[],
|
|
487
|
+
io: WorkspaceIO,
|
|
488
|
+
): Promise<string | null> {
|
|
489
|
+
const rel = ".forge/knowledge-conflicts.txt";
|
|
490
|
+
try {
|
|
491
|
+
await io.writeFile(
|
|
492
|
+
path.join(workspaceRoot, rel),
|
|
493
|
+
[
|
|
494
|
+
"# forge.upgrade knowledge conflicts — local project versions were kept.",
|
|
495
|
+
"# Review and merge the package entries manually, then delete this file.",
|
|
496
|
+
`# generated: ${new Date().toISOString()}`,
|
|
497
|
+
"",
|
|
498
|
+
...conflicts.map((c) => `- ${c}`),
|
|
499
|
+
"",
|
|
500
|
+
].join("\n"),
|
|
501
|
+
);
|
|
502
|
+
return rel;
|
|
503
|
+
} catch {
|
|
504
|
+
return null;
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
async function reportKnowledgeConflicts(
|
|
509
|
+
workspaceRoot: string,
|
|
510
|
+
conflicts: string[],
|
|
511
|
+
isDryRun: boolean,
|
|
512
|
+
io: WorkspaceIO,
|
|
513
|
+
logger: ForgeRuntimeContext["logger"],
|
|
514
|
+
): Promise<string | null> {
|
|
515
|
+
if (conflicts.length === 0) return null;
|
|
516
|
+
const reportPath = isDryRun ? null : await writeKnowledgeConflictsReport(workspaceRoot, conflicts, io);
|
|
517
|
+
logger.warn(
|
|
518
|
+
`forge.upgrade: ${conflicts.length} knowledge entr${conflicts.length === 1 ? "y" : "ies"} ` +
|
|
519
|
+
`diverge between package and project — local versions kept` +
|
|
520
|
+
(reportPath ? `; list: ${reportPath}` : ""),
|
|
521
|
+
);
|
|
522
|
+
return reportPath;
|
|
523
|
+
}
|
|
524
|
+
|
|
426
525
|
function addMissingBindingDefaults(
|
|
427
526
|
config: ForgeConfig,
|
|
428
527
|
dryRun: boolean,
|
|
@@ -643,6 +742,13 @@ export async function runUpgrade(
|
|
|
643
742
|
for (const warn of reconcile.warnings) {
|
|
644
743
|
context.logger.warn(`forge.upgrade: ${warn}`);
|
|
645
744
|
}
|
|
745
|
+
const noopConflictsReport = await reportKnowledgeConflicts(
|
|
746
|
+
workspaceRoot,
|
|
747
|
+
reconcile.knowledgeConflicts,
|
|
748
|
+
isDryRun,
|
|
749
|
+
fio,
|
|
750
|
+
context.logger,
|
|
751
|
+
);
|
|
646
752
|
return {
|
|
647
753
|
data: {
|
|
648
754
|
command: "forge.upgrade",
|
|
@@ -665,6 +771,8 @@ export async function runUpgrade(
|
|
|
665
771
|
skillsPruned: reconcile.prune.pruned,
|
|
666
772
|
skillsKeptWithConsumerFiles: reconcile.prune.keptWithConsumerFiles,
|
|
667
773
|
prettierignore: reconcile.prettierignore,
|
|
774
|
+
knowledgeConflicts: reconcile.knowledgeConflicts,
|
|
775
|
+
knowledgeConflictsReport: noopConflictsReport,
|
|
668
776
|
},
|
|
669
777
|
nextSteps: npmCheck.warning
|
|
670
778
|
? [{ action: npmCheck.warning, kind: "optional" }]
|
|
@@ -696,12 +804,13 @@ export async function runUpgrade(
|
|
|
696
804
|
for (const warn of reconcile.warnings) {
|
|
697
805
|
context.logger.warn(`forge.upgrade: ${warn}`);
|
|
698
806
|
}
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
807
|
+
const knowledgeConflictsReport = await reportKnowledgeConflicts(
|
|
808
|
+
workspaceRoot,
|
|
809
|
+
knowledgeConflicts,
|
|
810
|
+
isDryRun,
|
|
811
|
+
fio,
|
|
812
|
+
context.logger,
|
|
813
|
+
);
|
|
705
814
|
|
|
706
815
|
// Step 3d: Scaffold memory layer (RFC-0664)
|
|
707
816
|
const memoryScaffold = isDryRun ? { created: [], gitignoreUpdated: false, skipped: [] } : scaffoldMemoryLayer(workspaceRoot);
|
|
@@ -812,6 +921,8 @@ export async function runUpgrade(
|
|
|
812
921
|
skillsPruned: reconcile.prune.pruned,
|
|
813
922
|
skillsKeptWithConsumerFiles: reconcile.prune.keptWithConsumerFiles,
|
|
814
923
|
prettierignore: reconcile.prettierignore,
|
|
924
|
+
knowledgeConflicts,
|
|
925
|
+
knowledgeConflictsReport,
|
|
815
926
|
},
|
|
816
927
|
nextSteps,
|
|
817
928
|
exitCode: 0,
|
|
@@ -12,6 +12,7 @@ workspace type (app, service, package) by content markers.</purpose>
|
|
|
12
12
|
<CHANGE_SUMMARY>
|
|
13
13
|
<item>RFC-0611: initial workspace discovery and type auto-detection.</item>
|
|
14
14
|
<item>RFC-0640: accept optional workspaceTypes from profile for profile-driven detection, falling back to hardcoded detection when absent.</item>
|
|
15
|
+
<item>Extracted shared resolveWorkspaceTypes — config.profile wins, then stack-catalog lookup; deduplicates the resolution inlined in runAgentsGenerate/runDoctor and reused by the prettierignore plan.</item>
|
|
15
16
|
</CHANGE_SUMMARY>
|
|
16
17
|
*/
|
|
17
18
|
|
|
@@ -19,6 +20,8 @@ import * as fs from "../utils/sync-fs.ts";
|
|
|
19
20
|
import path from "node:path";
|
|
20
21
|
import { hasGeneratedMarker } from "../utils/index.ts";
|
|
21
22
|
import type { ProfileWorkspaceType } from "../profiles/profile-schema.ts";
|
|
23
|
+
import { listStackProfiles, type StackProfile } from "../profiles/stack-profile.ts";
|
|
24
|
+
import type { ForgeConfig } from "../config/forge-config.ts";
|
|
22
25
|
|
|
23
26
|
export type WorkspaceType = "app" | "service" | "package" | string;
|
|
24
27
|
|
|
@@ -45,6 +48,36 @@ const SKIP_DIRS = new Set([
|
|
|
45
48
|
".stryker-tmp",
|
|
46
49
|
]);
|
|
47
50
|
|
|
51
|
+
/**
|
|
52
|
+
* Resolve the effective workspace-type catalog for discovery/nested-AGENTS.md:
|
|
53
|
+
* the loaded `config.profile` wins, then the first `project.stack` id whose
|
|
54
|
+
* profile declares workspaceTypes, else undefined (hardcoded fallback).
|
|
55
|
+
* Previously inlined in runAgentsGenerate/runDoctor — shared so every
|
|
56
|
+
* discoverWorkspaces consumer classifies workspaces identically.
|
|
57
|
+
*/
|
|
58
|
+
export function resolveWorkspaceTypes(
|
|
59
|
+
config: ForgeConfig,
|
|
60
|
+
forgeRoot: string | undefined,
|
|
61
|
+
): ProfileWorkspaceType[] | undefined {
|
|
62
|
+
const profile = config.profile as StackProfile | undefined;
|
|
63
|
+
if (profile?.workspaceTypes && profile.workspaceTypes.length > 0) {
|
|
64
|
+
return profile.workspaceTypes;
|
|
65
|
+
}
|
|
66
|
+
if (!forgeRoot) return undefined;
|
|
67
|
+
try {
|
|
68
|
+
const profiles = listStackProfiles(forgeRoot);
|
|
69
|
+
for (const stackId of config.project.stack) {
|
|
70
|
+
const stackProfile = profiles.find((p) => p.id === stackId);
|
|
71
|
+
if (stackProfile?.workspaceTypes && stackProfile.workspaceTypes.length > 0) {
|
|
72
|
+
return stackProfile.workspaceTypes;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
} catch {
|
|
76
|
+
// profile catalog not loadable — hardcoded detection applies
|
|
77
|
+
}
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
|
|
48
81
|
export function detectWorkspaceType(
|
|
49
82
|
dirPath: string,
|
|
50
83
|
workspaceTypes?: ProfileWorkspaceType[],
|
|
@@ -73,6 +73,7 @@ describe("--compass-docs lifecycle flag (RFC-1253)", () => {
|
|
|
73
73
|
const init = mod.commands.find((c) => c.name === "forge.init")!;
|
|
74
74
|
|
|
75
75
|
const result = await init.execute(makeInput({ "compass-docs": true }), makeContext(root));
|
|
76
|
+
if (!result) throw new Error("forge.init returned no result");
|
|
76
77
|
expect(result.exitCode).toBe(0);
|
|
77
78
|
|
|
78
79
|
const req = await readFile(join(root, "docs", "requirements.xml"), "utf8");
|
|
@@ -88,6 +89,7 @@ describe("--compass-docs lifecycle flag (RFC-1253)", () => {
|
|
|
88
89
|
const init = mod.commands.find((c) => c.name === "forge.init")!;
|
|
89
90
|
|
|
90
91
|
const result = await init.execute(makeInput({}), makeContext(root));
|
|
92
|
+
if (!result) throw new Error("forge.init returned no result");
|
|
91
93
|
expect(result.exitCode).toBe(0);
|
|
92
94
|
|
|
93
95
|
await expect(readFile(join(root, "docs", "requirements.xml"), "utf8")).rejects.toThrow();
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>Unit tests for the forge-version-sync doctor check — installed
|
|
4
|
+
@warpgogol/forge package version vs forge.yaml forge.syncedVersion. Drift is
|
|
5
|
+
a warn (pnpm up bumps the package without running forge.upgrade); missing
|
|
6
|
+
sides pass with a skipped note.</purpose>
|
|
7
|
+
</MODULE_CONTRACT>
|
|
8
|
+
<CHANGE_SUMMARY>
|
|
9
|
+
<item>Initial forge-version-sync doctor check tests.</item>
|
|
10
|
+
</CHANGE_SUMMARY>
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { test, expect, beforeEach, afterEach } from "vitest";
|
|
14
|
+
import { mkdtemp, rm, mkdir, writeFile } from "node:fs/promises";
|
|
15
|
+
import { tmpdir } from "node:os";
|
|
16
|
+
import { join } from "node:path";
|
|
17
|
+
import { runDoctor } from "../onboarding/doctor.ts";
|
|
18
|
+
import { createForgeCoreModule } from "../../os/core/core.module.ts";
|
|
19
|
+
import { ambientIo } from "../utils/io.ts";
|
|
20
|
+
import type { ForgeCommandInput, ForgeRuntimeContext } from "../types.ts";
|
|
21
|
+
|
|
22
|
+
let tempDir: string;
|
|
23
|
+
|
|
24
|
+
beforeEach(async () => {
|
|
25
|
+
tempDir = await mkdtemp(join(tmpdir(), "doctor-version-sync-"));
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
afterEach(async () => {
|
|
29
|
+
await rm(tempDir, { recursive: true, force: true });
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
function makeContext(): ForgeRuntimeContext {
|
|
33
|
+
return {
|
|
34
|
+
workspaceRoot: tempDir,
|
|
35
|
+
logger: {
|
|
36
|
+
section: () => {},
|
|
37
|
+
success: () => {},
|
|
38
|
+
warn: () => {},
|
|
39
|
+
error: () => {},
|
|
40
|
+
info: () => {},
|
|
41
|
+
},
|
|
42
|
+
dryRun: false,
|
|
43
|
+
outputFormat: "json",
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function forgeYaml(syncedVersion: string | null): string {
|
|
48
|
+
const forgeSection =
|
|
49
|
+
syncedVersion !== null ? `\nforge:\n syncedVersion: ${syncedVersion}\n` : "";
|
|
50
|
+
return `schema: "forge/config@1"
|
|
51
|
+
project:
|
|
52
|
+
name: test-project
|
|
53
|
+
stack: []
|
|
54
|
+
packageManager: pnpm
|
|
55
|
+
paths:
|
|
56
|
+
rfcsDir: docs/rfcs
|
|
57
|
+
adrsDir: docs/adrs
|
|
58
|
+
plansDir: docs/plans
|
|
59
|
+
auditsDir: docs/audits
|
|
60
|
+
specsDir: docs/specs
|
|
61
|
+
skillsDir: .agents/skills
|
|
62
|
+
sessionsDir: docs/sessions
|
|
63
|
+
bindings:
|
|
64
|
+
schema: forge/bindings@1
|
|
65
|
+
commands:
|
|
66
|
+
validateRfc: null
|
|
67
|
+
validateAdr: null
|
|
68
|
+
implementStamp: null
|
|
69
|
+
typecheck: null
|
|
70
|
+
test: null
|
|
71
|
+
scopedBuild: null
|
|
72
|
+
specValidate: null
|
|
73
|
+
sessionSave: null
|
|
74
|
+
paths:
|
|
75
|
+
invariantsFile: null
|
|
76
|
+
compassDocs: []
|
|
77
|
+
reviewsDir: null
|
|
78
|
+
handoffsDir: null
|
|
79
|
+
sessionsDir: null${forgeSection}
|
|
80
|
+
`;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async function installForgePackage(version: string): Promise<void> {
|
|
84
|
+
const pkgDir = join(tempDir, "node_modules", "@warpgogol", "forge");
|
|
85
|
+
await mkdir(pkgDir, { recursive: true });
|
|
86
|
+
await writeFile(
|
|
87
|
+
join(pkgDir, "package.json"),
|
|
88
|
+
JSON.stringify({ name: "@warpgogol/forge", version }),
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const input: ForgeCommandInput = { argv: [], flags: {} };
|
|
93
|
+
|
|
94
|
+
test("forge-version-sync passes when installed version matches syncedVersion", async () => {
|
|
95
|
+
await installForgePackage("1.2.3");
|
|
96
|
+
await writeFile(join(tempDir, "forge.yaml"), forgeYaml("1.2.3"), "utf8");
|
|
97
|
+
|
|
98
|
+
const result = await runDoctor(input, makeContext());
|
|
99
|
+
const check = result.data!.checks.find((c) => c.name === "forge-version-sync");
|
|
100
|
+
expect(check).toBeDefined();
|
|
101
|
+
expect(check!.status).toBe("pass");
|
|
102
|
+
expect(check!.message).toContain("1.2.3");
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
test("forge-version-sync warns when installed version diverges from syncedVersion", async () => {
|
|
106
|
+
await installForgePackage("9.9.9");
|
|
107
|
+
await writeFile(join(tempDir, "forge.yaml"), forgeYaml("1.0.0"), "utf8");
|
|
108
|
+
|
|
109
|
+
const result = await runDoctor(input, makeContext());
|
|
110
|
+
const check = result.data!.checks.find((c) => c.name === "forge-version-sync");
|
|
111
|
+
expect(check).toBeDefined();
|
|
112
|
+
expect(check!.status).toBe("warn");
|
|
113
|
+
expect(check!.message).toContain("9.9.9");
|
|
114
|
+
expect(check!.message).toContain("1.0.0");
|
|
115
|
+
expect(check!.message).toContain("forge upgrade");
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
test("forge-version-sync passes when no syncedVersion recorded", async () => {
|
|
119
|
+
await installForgePackage("1.2.3");
|
|
120
|
+
await writeFile(join(tempDir, "forge.yaml"), forgeYaml(null), "utf8");
|
|
121
|
+
|
|
122
|
+
const result = await runDoctor(input, makeContext());
|
|
123
|
+
const check = result.data!.checks.find((c) => c.name === "forge-version-sync");
|
|
124
|
+
expect(check).toBeDefined();
|
|
125
|
+
expect(check!.status).toBe("pass");
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
test("forge.doctor wraps warn-only results as optional next-steps, fails as required", async () => {
|
|
129
|
+
await installForgePackage("9.9.9");
|
|
130
|
+
await writeFile(join(tempDir, "forge.yaml"), forgeYaml("1.0.0"), "utf8");
|
|
131
|
+
// .agents/skills missing is the only hard fail on a minimal workspace —
|
|
132
|
+
// everything else warns or passes, so the run lands warn-only.
|
|
133
|
+
await mkdir(join(tempDir, ".agents", "skills"), { recursive: true });
|
|
134
|
+
|
|
135
|
+
const mod = await createForgeCoreModule();
|
|
136
|
+
const doctor = mod.commands.find((c) => c.name === "forge.doctor")!;
|
|
137
|
+
const ctx: ForgeRuntimeContext = {
|
|
138
|
+
...makeContext(),
|
|
139
|
+
io: ambientIo,
|
|
140
|
+
} as unknown as ForgeRuntimeContext;
|
|
141
|
+
const result = await doctor.execute(input, ctx);
|
|
142
|
+
expect(result).toBeDefined();
|
|
143
|
+
if (!result) return;
|
|
144
|
+
|
|
145
|
+
const data = result.data as { checks?: { status: string }[]; allPass?: boolean } | undefined;
|
|
146
|
+
const checks = data?.checks ?? [];
|
|
147
|
+
const allPass = data?.allPass === true;
|
|
148
|
+
const hasFails = checks.some((c) => c.status === "fail");
|
|
149
|
+
// This workspace should surface warnings (version mismatch at minimum)
|
|
150
|
+
// without hard failures — if the fixture ever drifts, update the scenario.
|
|
151
|
+
expect(allPass).toBe(false);
|
|
152
|
+
expect(hasFails).toBe(false);
|
|
153
|
+
expect(result.nextSteps).toHaveLength(1);
|
|
154
|
+
expect(result.nextSteps![0].kind).toBe("optional");
|
|
155
|
+
});
|
|
@@ -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`.
|
|
@@ -158,6 +158,7 @@ When the operator describes a significant idea or change, the agent SHOULD proac
|
|
|
158
158
|
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
159
|
|
|
160
160
|
Session save mechanism:
|
|
161
|
+
|
|
161
162
|
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
163
|
2. Run `ref(forge.yaml bindings.commands.sessionSave)` to convert the raw file to structured markdown in `docs/sessions/`.
|
|
163
164
|
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 +203,7 @@ The agent reads `.agents/operator-profile.md` at the start of each session and c
|
|
|
202
203
|
The agent offers proactive guidance at the right moment — at most once per session per topic. If declined, the suggestion is not repeated.
|
|
203
204
|
|
|
204
205
|
Built-in guidance triggers:
|
|
206
|
+
|
|
205
207
|
- **Long session** (>2 hours): suggest a break or session save.
|
|
206
208
|
- **Complex change** (3+ files in one area): suggest grilling or planning.
|
|
207
209
|
- **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/"]);
|