@warpgogol/forge 6.2.0 → 6.3.1
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/dist/os/compass/compass.module.d.ts.map +1 -1
- package/dist/os/compass/compass.module.js +44 -7
- package/dist/os/compass/compass.module.js.map +1 -1
- package/dist/os/compass/handlers/compass-docs-scaffold.d.ts +22 -0
- package/dist/os/compass/handlers/compass-docs-scaffold.d.ts.map +1 -0
- package/dist/os/compass/handlers/compass-docs-scaffold.js +304 -0
- package/dist/os/compass/handlers/compass-docs-scaffold.js.map +1 -0
- package/dist/os/compass/handlers/compass-docs-validate.d.ts.map +1 -1
- package/dist/os/compass/handlers/compass-docs-validate.js +62 -10
- package/dist/os/compass/handlers/compass-docs-validate.js.map +1 -1
- package/dist/os/core/core.module.d.ts.map +1 -1
- package/dist/os/core/core.module.js +40 -11
- package/dist/os/core/core.module.js.map +1 -1
- package/dist/os/core/handlers/package-health.d.ts +6 -1
- package/dist/os/core/handlers/package-health.d.ts.map +1 -1
- package/dist/os/core/handlers/package-health.js +91 -25
- package/dist/os/core/handlers/package-health.js.map +1 -1
- package/dist/os/core/handlers/validate.d.ts +11 -1
- package/dist/os/core/handlers/validate.d.ts.map +1 -1
- package/dist/os/core/handlers/validate.js +29 -1
- package/dist/os/core/handlers/validate.js.map +1 -1
- package/dist/src/onboarding/agents-generate.d.ts.map +1 -1
- package/dist/src/onboarding/agents-generate.js +17 -2
- package/dist/src/onboarding/agents-generate.js.map +1 -1
- package/dist/src/onboarding/compass-docs/constants.d.ts +9 -0
- package/dist/src/onboarding/compass-docs/constants.d.ts.map +1 -0
- package/dist/src/onboarding/compass-docs/constants.js +35 -0
- package/dist/src/onboarding/compass-docs/constants.js.map +1 -0
- package/dist/src/onboarding/doctor.d.ts.map +1 -1
- package/dist/src/onboarding/doctor.js +18 -0
- package/dist/src/onboarding/doctor.js.map +1 -1
- package/docs/reference/cli.md +6 -0
- package/docs/reference/compass-docs.md +102 -0
- package/docs/reference/forge-yaml.md +15 -0
- package/os/compass/compass.module.ts +46 -7
- package/os/compass/handlers/compass-docs-scaffold.ts +396 -0
- package/os/compass/handlers/compass-docs-validate.ts +67 -10
- package/os/core/core.module.ts +50 -11
- package/os/core/handlers/package-health.test.ts +92 -9
- package/os/core/handlers/package-health.ts +99 -24
- package/os/core/handlers/validate.ts +40 -1
- package/package.json +1 -1
- package/src/onboarding/agents-generate.ts +22 -2
- package/src/onboarding/compass-docs/constants.ts +42 -0
- package/src/onboarding/doctor.ts +18 -0
- package/src/onboarding/templates/compass-docs/development-plan.xml +29 -0
- package/src/onboarding/templates/compass-docs/knowledge-graph.xml +57 -0
- package/src/onboarding/templates/compass-docs/requirements.xml +28 -0
- package/src/onboarding/templates/compass-docs/source-markup.xml +121 -0
- package/src/onboarding/templates/compass-docs/technology.xml +30 -0
- package/src/onboarding/templates/compass-docs/verification-plan.xml +25 -0
- package/src/tests/agents-generate.test.ts +30 -0
- package/src/tests/compass-docs-flag.test.ts +99 -0
- package/src/tests/compass-docs-scaffold.test.ts +196 -0
- package/src/tests/compass-docs-validate-scope.test.ts +178 -0
- package/src/tests/doctor-bindings.test.ts +79 -0
- package/src/tests/fixtures/agents-generate-business-before.txt +8 -0
- package/src/tests/forge-validate-compass-docs.test.ts +154 -0
- package/src/tests/package-files.test.ts +3 -0
- package/src/tests/package-health-lint-surface.test.ts +153 -0
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
<item>Link targets resolve to declared node ids OR file/dir conventions (DOC-03) — dangling-by-convention stays a warning, never an error.</item>
|
|
13
13
|
</KEY_DECISIONS>
|
|
14
14
|
<CHANGE_SUMMARY>
|
|
15
|
+
<item>RFC-1253: scan-set union — docs/*.xml ∪ bindings.paths.compassDocs (deduped, missing bound paths skipped; doctor owns missing-path diagnostics) + COMPASS-DOC-04 schema-marker warning scoped to corpus docs (canonical basenames ∪ bound paths).</item>
|
|
15
16
|
<item>RFC-1242: review fixes — self-close detection strips quoted attr values first (a="foo/" no longer fakes a self-close), non-backticked path tokens get the same ellipsis strip, docs.* link slugs keep their basename prefix (docs.plans.plan-rfc-* resolves).</item>
|
|
16
17
|
<item>RFC-1242: created — scan docs/*.xml for unresolvable paths, workspace ids, and link targets (COMPASS-DOC-00..03).</item>
|
|
17
18
|
<item>RFC-1249: wire werkstatt.commands.validate into packages.check + retire CMD-OUTPUT debt</item>
|
|
@@ -20,6 +21,11 @@
|
|
|
20
21
|
|
|
21
22
|
import { resolve } from "node:path";
|
|
22
23
|
import { resolveIo } from "../../../src/utils/io.ts";
|
|
24
|
+
import { loadForgeConfig, resolveBinding } from "../../../src/config/forge-config.ts";
|
|
25
|
+
import {
|
|
26
|
+
CANONICAL_CORPUS_DOCS,
|
|
27
|
+
COMPASS_DOCS_SCHEMA_ID,
|
|
28
|
+
} from "../../../src/onboarding/compass-docs/constants.ts";
|
|
23
29
|
import type { Diagnostic, WorkspaceIO } from "../../../src/types.ts";
|
|
24
30
|
import type {
|
|
25
31
|
ForgeCommandInput,
|
|
@@ -258,23 +264,54 @@ export async function runCompassDocsValidate(
|
|
|
258
264
|
}
|
|
259
265
|
}
|
|
260
266
|
|
|
261
|
-
|
|
267
|
+
// RFC-1253: scan set = docs/*.xml ∪ bindings.paths.compassDocs (deduped by
|
|
268
|
+
// absolute path). Bound paths may live outside docs/; missing bound files are
|
|
269
|
+
// skipped — doctor owns missing-path diagnostics. A config that fails to
|
|
270
|
+
// load degrades to glob-only scanning.
|
|
271
|
+
let declared: string[] = [];
|
|
272
|
+
try {
|
|
273
|
+
const config = loadForgeConfig(context.workspaceRoot, context.forgeRoot);
|
|
274
|
+
const raw = resolveBinding(config, "paths.compassDocs");
|
|
275
|
+
declared = (Array.isArray(raw) ? raw : []).filter((p): p is string => typeof p === "string");
|
|
276
|
+
} catch {
|
|
277
|
+
declared = [];
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
const canonicalBasenames = new Set(CANONICAL_CORPUS_DOCS.map((n) => `${n}.xml`));
|
|
281
|
+
const declaredAbs = new Set(declared.map((p) => resolve(context.workspaceRoot, p)));
|
|
282
|
+
|
|
283
|
+
const scanEntries: Array<{ abs: string; file: string; corpus: boolean }> = [];
|
|
284
|
+
const seen = new Set<string>();
|
|
285
|
+
for (const rel of (await io.glob(DOCS_GLOB, { cwd: docsDir })).sort()) {
|
|
286
|
+
const abs = resolve(docsDir, rel);
|
|
287
|
+
seen.add(abs);
|
|
288
|
+
scanEntries.push({
|
|
289
|
+
abs,
|
|
290
|
+
file: `docs/${rel}`,
|
|
291
|
+
corpus: canonicalBasenames.has(rel) || declaredAbs.has(abs),
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
for (const declaredPath of declared) {
|
|
295
|
+
const abs = resolve(context.workspaceRoot, declaredPath);
|
|
296
|
+
if (seen.has(abs) || !(await io.exists(abs))) continue;
|
|
297
|
+
scanEntries.push({ abs, file: declaredPath, corpus: true });
|
|
298
|
+
}
|
|
299
|
+
|
|
262
300
|
const declaredNodeIds = new Set<string>();
|
|
263
301
|
|
|
264
302
|
// Pass 1: collect declared node ids so link targets can resolve across files.
|
|
265
303
|
const sources = new Map<string, string>();
|
|
266
|
-
for (const
|
|
267
|
-
const
|
|
268
|
-
|
|
269
|
-
sources.set(rel, source);
|
|
304
|
+
for (const entry of scanEntries) {
|
|
305
|
+
const source = await io.readFile(entry.abs);
|
|
306
|
+
sources.set(entry.file, source);
|
|
270
307
|
for (const m of source.matchAll(/<node\s[^>]*?id="([^"]+)"/g)) {
|
|
271
308
|
declaredNodeIds.add(m[1]!);
|
|
272
309
|
}
|
|
273
310
|
}
|
|
274
311
|
|
|
275
|
-
for (const
|
|
276
|
-
const file =
|
|
277
|
-
const source = sources.get(
|
|
312
|
+
for (const entry of scanEntries) {
|
|
313
|
+
const file = entry.file;
|
|
314
|
+
const source = sources.get(file)!;
|
|
278
315
|
|
|
279
316
|
const malformed = checkWellFormed(file, source);
|
|
280
317
|
if (malformed) {
|
|
@@ -288,6 +325,26 @@ export async function runCompassDocsValidate(
|
|
|
288
325
|
continue; // refs from a broken file are noise
|
|
289
326
|
}
|
|
290
327
|
|
|
328
|
+
// COMPASS-DOC-04 (warning, corpus docs only): <meta><schema> must carry
|
|
329
|
+
// forge/compass-docs@1 — missing marker or unknown schema id warns.
|
|
330
|
+
if (entry.corpus) {
|
|
331
|
+
const metaBlock = /<meta>[\s\S]*?<\/meta>/.exec(source)?.[0] ?? "";
|
|
332
|
+
const schemaId = /<schema>([^<]*)<\/schema>/.exec(metaBlock)?.[1]?.trim();
|
|
333
|
+
if (schemaId !== COMPASS_DOCS_SCHEMA_ID) {
|
|
334
|
+
const metaLine = /<meta>/.exec(source)?.index;
|
|
335
|
+
diagnostics.push({
|
|
336
|
+
ruleId: "COMPASS-DOC-04",
|
|
337
|
+
severity: "warning",
|
|
338
|
+
file,
|
|
339
|
+
line: metaLine === undefined ? 1 : source.slice(0, metaLine).split("\n").length,
|
|
340
|
+
message: schemaId
|
|
341
|
+
? `corpus document declares schema '${schemaId}' — expected '${COMPASS_DOCS_SCHEMA_ID}'`
|
|
342
|
+
: `corpus document lacks <meta><schema>${COMPASS_DOCS_SCHEMA_ID}</schema> marker`,
|
|
343
|
+
fixHint: "Add <schema>forge/compass-docs@1</schema> inside the <meta> block",
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
291
348
|
const refs = extractRefs(source);
|
|
292
349
|
|
|
293
350
|
for (const { value, line } of refs.paths) {
|
|
@@ -349,13 +406,13 @@ export async function runCompassDocsValidate(
|
|
|
349
406
|
data: {
|
|
350
407
|
command: "compass.docs.validate",
|
|
351
408
|
status: errors.length === 0 ? "pass" : "fail",
|
|
352
|
-
scanned: { xmlFiles:
|
|
409
|
+
scanned: { xmlFiles: scanEntries.length, pathsChecked, idsChecked },
|
|
353
410
|
diagnostics,
|
|
354
411
|
},
|
|
355
412
|
exitCode: errors.length > 0 ? 1 : 0,
|
|
356
413
|
summary:
|
|
357
414
|
errors.length === 0
|
|
358
|
-
? `[compass.docs.validate] OK (${
|
|
415
|
+
? `[compass.docs.validate] OK (${scanEntries.length} files, ${pathsChecked} paths, ${idsChecked} ids)`
|
|
359
416
|
: `[compass.docs.validate] ${errors.length} error(s)`,
|
|
360
417
|
};
|
|
361
418
|
}
|
package/os/core/core.module.ts
CHANGED
|
@@ -6,8 +6,6 @@
|
|
|
6
6
|
</non-goals>
|
|
7
7
|
</MODULE_CONTRACT>
|
|
8
8
|
<CHANGE_SUMMARY>
|
|
9
|
-
<item>RFC-1230: docs.archive post-loop merges only RFCs moved this run (collectLiveMergeTargets on rfc.archive moved[] instead of a full-tree rescan); declared docs/specs/live/*.md in writes/reads.</item>
|
|
10
|
-
<item>RFC-1230: review findings — scoped droppedSections to namespaced headings, warn on unreadable spec, fail-fast merge on corrupt frontmatter, CHANGE_SUMMARY dedupe</item>
|
|
11
9
|
<item>RFC-1231: step 1 — rename supportsAllSites to acceptsAllFlag
|
|
12
10
|
|
|
13
11
|
Mechanical sweep: the field only ever gated --all argv acceptance; fan-out
|
|
@@ -16,7 +14,9 @@ assertAllFlagAccepted, message updated. 417 declaration sites + type
|
|
|
16
14
|
surfaces (KernelCommandMetadata, ForgeCommandMetadata) in one atomic pass.</item>
|
|
17
15
|
<item>RFC-1235: docs.archive post-loop records merge outcomes by exit code — exit-nonzero merges (incl. RFC-1230 fail-fast with populated data) land in failed[] with the merge summary as error, thrown errors record via liveMergeFailureEntry, and the spec.live.merge result block emits whenever anything was attempted; top-level result gains liveSpecFailures.</item>
|
|
18
16
|
<item>RFC-1248: VITE-CLIENT-DEP-02 lazy-import gate + SCAN-02 validator reads-root existence check (RFC-1248)</item>
|
|
19
|
-
<
|
|
17
|
+
<item>RFC-1251: step 3 — diagnostic.rule-id.validate gate + RULEID-CANONICAL-01, pipeline-wired</item>
|
|
18
|
+
<item>RFC-1254: forge.package.health lint-surface probe (PKG-HEALTH-06) + --compass-docs generates marked conditional for OWN-DUP-01 parity</item>
|
|
19
|
+
<history>ADR-0021, RFC-0374, RFC-0521, RFC-0539, RFC-0542, RFC-0543, RFC-0544, RFC-0546, RFC-0640, RFC-0662, RFC-0674, RFC-0678, RFC-0679, RFC-0680, RFC-0711, RFC-0733, RFC-0877, RFC-0940, RFC-1080, RFC-1088, RFC-1089, RFC-1097, RFC-1173, RFC-1230</history>
|
|
20
20
|
</CHANGE_SUMMARY>
|
|
21
21
|
*/
|
|
22
22
|
|
|
@@ -62,6 +62,28 @@ export async function createForgeCoreModule(): Promise<ForgeModule> {
|
|
|
62
62
|
const { runForgeAutonomyValidate } = await import("./handlers/forge-autonomy-validate.ts");
|
|
63
63
|
const { runPublicSurfaceValidate } = await import("./handlers/public-surface.ts");
|
|
64
64
|
const { runFileSizeLint } = await import("./handlers/file-size-lint.ts");
|
|
65
|
+
const { runCompassDocsScaffold } = await import("../compass/handlers/compass-docs-scaffold.ts");
|
|
66
|
+
|
|
67
|
+
// RFC-1253: --compass-docs on lifecycle commands runs the corpus scaffold
|
|
68
|
+
// after the primary operation (idempotent — re-invocation is a no-op).
|
|
69
|
+
const maybeScaffoldCompassDocs = async (
|
|
70
|
+
input: ForgeCommandInput,
|
|
71
|
+
context: ForgeRuntimeContext,
|
|
72
|
+
result: ForgeCommandResult,
|
|
73
|
+
): Promise<ForgeCommandResult> => {
|
|
74
|
+
if (input.flags["compass-docs"] !== true) return result;
|
|
75
|
+
const docs = await runCompassDocsScaffold(input, context);
|
|
76
|
+
const ok = (docs.exitCode ?? 0) === 0;
|
|
77
|
+
return {
|
|
78
|
+
...result,
|
|
79
|
+
data: { ...(result.data as Record<string, unknown>), compassDocs: docs.data },
|
|
80
|
+
exitCode: ok ? result.exitCode : 1,
|
|
81
|
+
summary: result.summary
|
|
82
|
+
? `${result.summary}; compassDocs scaffold ${ok ? "applied" : "FAILED"}`
|
|
83
|
+
: result.summary,
|
|
84
|
+
nextSteps: [...(result.nextSteps ?? []), ...(docs.nextSteps ?? [])],
|
|
85
|
+
};
|
|
86
|
+
};
|
|
65
87
|
|
|
66
88
|
const scaffoldWrapper = async (
|
|
67
89
|
input: ForgeCommandInput,
|
|
@@ -332,12 +354,18 @@ export async function createForgeCoreModule(): Promise<ForgeModule> {
|
|
|
332
354
|
description:
|
|
333
355
|
"Update @warpgogol/forge from npm before syncing. Skipped in monorepo (local package).",
|
|
334
356
|
},
|
|
357
|
+
"compass-docs": {
|
|
358
|
+
kind: "boolean",
|
|
359
|
+
description:
|
|
360
|
+
"After syncing, run compass.docs.scaffold to materialize/merge the Compass corpus (RFC-1253).",
|
|
361
|
+
},
|
|
335
362
|
},
|
|
336
|
-
writes: [".agents/skills/**", "forge.yaml"],
|
|
337
|
-
generates: [],
|
|
363
|
+
writes: [".agents/skills/**", "forge.yaml", "docs/*.xml"],
|
|
364
|
+
generates: [{ path: "docs/*.xml", phase: "on-demand", conditional: true }],
|
|
338
365
|
reads: ["forge.yaml", "packages/forge/skills/**", "packages/forge/package.json"],
|
|
339
366
|
cacheable: false,
|
|
340
|
-
execute:
|
|
367
|
+
execute: async (input, context) =>
|
|
368
|
+
maybeScaffoldCompassDocs(input, context, await runUpgrade(input, context)),
|
|
341
369
|
},
|
|
342
370
|
{
|
|
343
371
|
name: "forge.scaffold",
|
|
@@ -395,9 +423,15 @@ export async function createForgeCoreModule(): Promise<ForgeModule> {
|
|
|
395
423
|
kind: "string",
|
|
396
424
|
description: "Template id for multi-template profiles (e.g. react, html).",
|
|
397
425
|
},
|
|
426
|
+
"compass-docs": {
|
|
427
|
+
kind: "boolean",
|
|
428
|
+
description:
|
|
429
|
+
"After create, run compass.docs.scaffold to materialize the Compass corpus (RFC-1253).",
|
|
430
|
+
},
|
|
398
431
|
},
|
|
399
432
|
cacheable: false,
|
|
400
|
-
execute:
|
|
433
|
+
execute: async (input, context) =>
|
|
434
|
+
maybeScaffoldCompassDocs(input, context, await createWrapper(input, context)),
|
|
401
435
|
},
|
|
402
436
|
{
|
|
403
437
|
name: "forge.init",
|
|
@@ -417,9 +451,15 @@ export async function createForgeCoreModule(): Promise<ForgeModule> {
|
|
|
417
451
|
description: "Documentation language (default: en).",
|
|
418
452
|
},
|
|
419
453
|
from: { kind: "string", description: "Detect stack from existing project path." },
|
|
454
|
+
"compass-docs": {
|
|
455
|
+
kind: "boolean",
|
|
456
|
+
description:
|
|
457
|
+
"After init, run compass.docs.scaffold to materialize the Compass corpus (RFC-1253).",
|
|
458
|
+
},
|
|
420
459
|
},
|
|
421
460
|
cacheable: false,
|
|
422
|
-
execute:
|
|
461
|
+
execute: async (input, context) =>
|
|
462
|
+
maybeScaffoldCompassDocs(input, context, await initWrapper(input, context)),
|
|
423
463
|
},
|
|
424
464
|
{
|
|
425
465
|
name: "forge.profile.validate",
|
|
@@ -487,8 +527,6 @@ export async function createForgeCoreModule(): Promise<ForgeModule> {
|
|
|
487
527
|
},
|
|
488
528
|
{
|
|
489
529
|
name: "forge.validate",
|
|
490
|
-
coverage: "operator" as const,
|
|
491
|
-
coverageNote: "artifact validator — typescript profile declares no artifacts by design",
|
|
492
530
|
mutatesState: false,
|
|
493
531
|
contract: "forge",
|
|
494
532
|
rules: [],
|
|
@@ -768,7 +806,8 @@ export async function createForgeCoreModule(): Promise<ForgeModule> {
|
|
|
768
806
|
description:
|
|
769
807
|
"Validate all published packages (private: false) for standalone extraction readiness. " +
|
|
770
808
|
"Checks engines.node, embedded .github/workflows/ci.yml, extract.config.yaml, " +
|
|
771
|
-
"
|
|
809
|
+
"devDependencies completeness (no hoisted tool deps), and per-package lint-surface " +
|
|
810
|
+
"(extractable packages run their own lint contract). " +
|
|
772
811
|
"Exits non-zero on errors. Use --json for machine-readable output.",
|
|
773
812
|
scope: "workspace",
|
|
774
813
|
acceptsAllFlag: false,
|
|
@@ -69,9 +69,15 @@ test("passes when all published packages are healthy", async () => {
|
|
|
69
69
|
});
|
|
70
70
|
mkdirSync(join(pkgDir, ".github", "workflows"), { recursive: true });
|
|
71
71
|
writeFileSync(join(pkgDir, ".github", "workflows", "ci.yml"), "name: CI\n");
|
|
72
|
-
writeFileSync(
|
|
72
|
+
writeFileSync(
|
|
73
|
+
join(pkgDir, "extract.config.yaml"),
|
|
74
|
+
"source: .\nci:\n provider: github-actions\n",
|
|
75
|
+
);
|
|
73
76
|
|
|
74
|
-
const result = await runPackageHealth(makeInput(), makeContext(tmpDir))
|
|
77
|
+
const result = await runPackageHealth(makeInput(), makeContext(tmpDir), () => ({
|
|
78
|
+
ok: true,
|
|
79
|
+
detail: "",
|
|
80
|
+
}));
|
|
75
81
|
expect(result.exitCode).toBe(0);
|
|
76
82
|
expect(result.data?.passed).toBe(true);
|
|
77
83
|
expect(result.data?.packagesChecked).toBe(1);
|
|
@@ -93,7 +99,10 @@ test("skips private packages", async () => {
|
|
|
93
99
|
private: true,
|
|
94
100
|
});
|
|
95
101
|
|
|
96
|
-
const result = await runPackageHealth(makeInput(), makeContext(tmpDir))
|
|
102
|
+
const result = await runPackageHealth(makeInput(), makeContext(tmpDir), () => ({
|
|
103
|
+
ok: true,
|
|
104
|
+
detail: "",
|
|
105
|
+
}));
|
|
97
106
|
expect(result.exitCode).toBe(0);
|
|
98
107
|
expect(result.data?.packagesChecked).toBe(0);
|
|
99
108
|
expect(result.data?.passed).toBe(true);
|
|
@@ -119,7 +128,10 @@ test("reports PKG-HEALTH-01 when engines.node is missing", async () => {
|
|
|
119
128
|
writeFileSync(join(pkgDir, ".github", "workflows", "ci.yml"), "name: CI\n");
|
|
120
129
|
writeFileSync(join(pkgDir, "extract.config.yaml"), "source: .\n");
|
|
121
130
|
|
|
122
|
-
const result = await runPackageHealth(makeInput(), makeContext(tmpDir))
|
|
131
|
+
const result = await runPackageHealth(makeInput(), makeContext(tmpDir), () => ({
|
|
132
|
+
ok: true,
|
|
133
|
+
detail: "",
|
|
134
|
+
}));
|
|
123
135
|
expect(result.exitCode).toBe(1);
|
|
124
136
|
expect(result.data?.passed).toBe(false);
|
|
125
137
|
const v01 = result.data?.violations.find((v) => v.ruleId === "PKG-HEALTH-01");
|
|
@@ -128,7 +140,66 @@ test("reports PKG-HEALTH-01 when engines.node is missing", async () => {
|
|
|
128
140
|
expect(v01?.packageName).toBe("@test/no-engines");
|
|
129
141
|
});
|
|
130
142
|
|
|
131
|
-
test("
|
|
143
|
+
test("accepts generated CI — extractable package with ci: provider needs no in-package workflow", async () => {
|
|
144
|
+
writePkgJson(tmpDir, {
|
|
145
|
+
name: "test-workspace",
|
|
146
|
+
private: true,
|
|
147
|
+
engines: { node: ">=24 <25" },
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
const pkgDir = join(tmpDir, "packages", "generated-ci");
|
|
151
|
+
mkdirSync(pkgDir, { recursive: true });
|
|
152
|
+
writePkgJson(pkgDir, {
|
|
153
|
+
name: "@test/generated-ci",
|
|
154
|
+
version: "1.0.0",
|
|
155
|
+
private: false,
|
|
156
|
+
type: "module",
|
|
157
|
+
engines: { node: ">=24 <25" },
|
|
158
|
+
scripts: {},
|
|
159
|
+
});
|
|
160
|
+
// No .github/workflows/ci.yml — repo-extract generates it from the ci: block.
|
|
161
|
+
writeFileSync(
|
|
162
|
+
join(pkgDir, "extract.config.yaml"),
|
|
163
|
+
"source: .\nci:\n provider: github-actions\n publish: true\n",
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
const result = await runPackageHealth(makeInput(), makeContext(tmpDir), () => ({
|
|
167
|
+
ok: true,
|
|
168
|
+
detail: "",
|
|
169
|
+
}));
|
|
170
|
+
expect(result.exitCode).toBe(0);
|
|
171
|
+
expect(result.data?.violations.find((v) => v.ruleId === "PKG-HEALTH-02")).toBeUndefined();
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
test("accepts in-package CI as fallback — extractable package without ci: provider keeps shipped workflow", async () => {
|
|
175
|
+
writePkgJson(tmpDir, {
|
|
176
|
+
name: "test-workspace",
|
|
177
|
+
private: true,
|
|
178
|
+
engines: { node: ">=24 <25" },
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
const pkgDir = join(tmpDir, "packages", "shipped-ci");
|
|
182
|
+
mkdirSync(pkgDir, { recursive: true });
|
|
183
|
+
writePkgJson(pkgDir, {
|
|
184
|
+
name: "@test/shipped-ci",
|
|
185
|
+
version: "1.0.0",
|
|
186
|
+
private: false,
|
|
187
|
+
type: "module",
|
|
188
|
+
engines: { node: ">=24 <25" },
|
|
189
|
+
scripts: {},
|
|
190
|
+
});
|
|
191
|
+
mkdirSync(join(pkgDir, ".github", "workflows"), { recursive: true });
|
|
192
|
+
writeFileSync(join(pkgDir, ".github", "workflows", "ci.yml"), "name: CI\n");
|
|
193
|
+
writeFileSync(join(pkgDir, "extract.config.yaml"), "source: .\n");
|
|
194
|
+
|
|
195
|
+
const result = await runPackageHealth(makeInput(), makeContext(tmpDir), () => ({
|
|
196
|
+
ok: true,
|
|
197
|
+
detail: "",
|
|
198
|
+
}));
|
|
199
|
+
expect(result.data?.violations.find((v) => v.ruleId === "PKG-HEALTH-02")).toBeUndefined();
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
test("reports PKG-HEALTH-02 when extracted repo would ship no CI", async () => {
|
|
132
203
|
writePkgJson(tmpDir, {
|
|
133
204
|
name: "test-workspace",
|
|
134
205
|
private: true,
|
|
@@ -147,7 +218,10 @@ test("reports PKG-HEALTH-02 when CI workflow is missing", async () => {
|
|
|
147
218
|
});
|
|
148
219
|
writeFileSync(join(pkgDir, "extract.config.yaml"), "source: .\n");
|
|
149
220
|
|
|
150
|
-
const result = await runPackageHealth(makeInput(), makeContext(tmpDir))
|
|
221
|
+
const result = await runPackageHealth(makeInput(), makeContext(tmpDir), () => ({
|
|
222
|
+
ok: true,
|
|
223
|
+
detail: "",
|
|
224
|
+
}));
|
|
151
225
|
expect(result.exitCode).toBe(1);
|
|
152
226
|
const v02 = result.data?.violations.find((v) => v.ruleId === "PKG-HEALTH-02");
|
|
153
227
|
expect(v02).toBeDefined();
|
|
@@ -174,7 +248,10 @@ test("reports PKG-HEALTH-03 when extract.config.yaml is missing", async () => {
|
|
|
174
248
|
mkdirSync(join(pkgDir, ".github", "workflows"), { recursive: true });
|
|
175
249
|
writeFileSync(join(pkgDir, ".github", "workflows", "ci.yml"), "name: CI\n");
|
|
176
250
|
|
|
177
|
-
const result = await runPackageHealth(makeInput(), makeContext(tmpDir))
|
|
251
|
+
const result = await runPackageHealth(makeInput(), makeContext(tmpDir), () => ({
|
|
252
|
+
ok: true,
|
|
253
|
+
detail: "",
|
|
254
|
+
}));
|
|
178
255
|
const v03 = result.data?.violations.find((v) => v.ruleId === "PKG-HEALTH-03");
|
|
179
256
|
expect(v03).toBeDefined();
|
|
180
257
|
expect(v03?.severity).toBe("warning");
|
|
@@ -207,7 +284,10 @@ test("reports PKG-HEALTH-04 when script tool is not in devDependencies", async (
|
|
|
207
284
|
writeFileSync(join(pkgDir, ".github", "workflows", "ci.yml"), "name: CI\n");
|
|
208
285
|
writeFileSync(join(pkgDir, "extract.config.yaml"), "source: .\n");
|
|
209
286
|
|
|
210
|
-
const result = await runPackageHealth(makeInput(), makeContext(tmpDir))
|
|
287
|
+
const result = await runPackageHealth(makeInput(), makeContext(tmpDir), () => ({
|
|
288
|
+
ok: true,
|
|
289
|
+
detail: "",
|
|
290
|
+
}));
|
|
211
291
|
expect(result.exitCode).toBe(1);
|
|
212
292
|
const v04s = result.data?.violations.filter((v) => v.ruleId === "PKG-HEALTH-04");
|
|
213
293
|
expect(v04s).toHaveLength(2);
|
|
@@ -219,7 +299,10 @@ test("reports PKG-HEALTH-04 when script tool is not in devDependencies", async (
|
|
|
219
299
|
test("handles no packages/ directory gracefully", async () => {
|
|
220
300
|
writePkgJson(tmpDir, { name: "empty", private: true });
|
|
221
301
|
|
|
222
|
-
const result = await runPackageHealth(makeInput(), makeContext(tmpDir))
|
|
302
|
+
const result = await runPackageHealth(makeInput(), makeContext(tmpDir), () => ({
|
|
303
|
+
ok: true,
|
|
304
|
+
detail: "",
|
|
305
|
+
}));
|
|
223
306
|
expect(result.exitCode).toBe(0);
|
|
224
307
|
expect(result.data?.packagesChecked).toBe(0);
|
|
225
308
|
expect(result.data?.passed).toBe(true);
|
|
@@ -14,6 +14,8 @@ Mechanical v1 to v2 header migration across the workspace: 942 files rewritten
|
|
|
14
14
|
<item>RFC-1097: sweep — werkstatt-engine clean
|
|
15
15
|
|
|
16
16
|
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>
|
|
17
|
+
<item>RFC-1254: PKG-HEALTH-06 lint-surface probe — extractable packages run `pnpm --dir <projectDir> run lint` (eslint fallback), per-package pass/fail, error-severity violation</item>
|
|
18
|
+
<item>RFC-1254: retune PKG-HEALTH-02 — repo-extract generates ci.yml from the config `ci:` provider block, so the check now flags only extractable packages whose exported repo would ship no CI (no ci: provider AND no in-package workflow)</item>
|
|
17
19
|
</CHANGE_SUMMARY>
|
|
18
20
|
*/
|
|
19
21
|
|
|
@@ -39,6 +41,26 @@ export interface PackageHealthResult {
|
|
|
39
41
|
packagesChecked: number;
|
|
40
42
|
violations: PackageHealthViolation[];
|
|
41
43
|
passed: boolean;
|
|
44
|
+
lintSurface: Record<string, "pass" | "fail">;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface LintProbeOutcome {
|
|
48
|
+
ok: boolean;
|
|
49
|
+
detail: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function defaultLintRunner(projectDir: string, hasLintScript: boolean): LintProbeOutcome {
|
|
53
|
+
const args = hasLintScript
|
|
54
|
+
? ["--dir", projectDir, "run", "lint"]
|
|
55
|
+
: ["--dir", projectDir, "exec", "eslint", "src/**/*.ts"];
|
|
56
|
+
try {
|
|
57
|
+
fs.execFileSync("pnpm", args, { stdio: "pipe" });
|
|
58
|
+
return { ok: true, detail: "" };
|
|
59
|
+
} catch (err) {
|
|
60
|
+
const stderr =
|
|
61
|
+
err instanceof Error && "stderr" in err ? String((err as { stderr?: unknown }).stderr) : "";
|
|
62
|
+
return { ok: false, detail: (stderr || String(err)).slice(0, 400) };
|
|
63
|
+
}
|
|
42
64
|
}
|
|
43
65
|
|
|
44
66
|
const KNOWN_SCRIPT_TOOLS: Record<string, string> = {
|
|
@@ -72,9 +94,25 @@ function readJsonFile(filePath: string): Record<string, unknown> | null {
|
|
|
72
94
|
}
|
|
73
95
|
}
|
|
74
96
|
|
|
97
|
+
// Reads the `provider:` scalar out of the top-level `ci:` mapping block in an
|
|
98
|
+
// extract.config.yaml. Returns null when the block or the key is absent.
|
|
99
|
+
function extractCiProvider(raw: string): string | null {
|
|
100
|
+
const ciMatch = raw.match(/^ci:[ \t]*$/m);
|
|
101
|
+
if (!ciMatch || ciMatch.index === undefined) return null;
|
|
102
|
+
const after = raw.slice(ciMatch.index + ciMatch[0].length);
|
|
103
|
+
for (const line of after.split("\n")) {
|
|
104
|
+
if (line.trim() === "") continue;
|
|
105
|
+
if (!/^\s/.test(line)) break;
|
|
106
|
+
const m = line.match(/^\s+provider:\s*(\S+)\s*$/);
|
|
107
|
+
if (m) return m[1];
|
|
108
|
+
}
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
|
|
75
112
|
export async function runPackageHealth(
|
|
76
113
|
_input: ForgeCommandInput,
|
|
77
114
|
context: ForgeRuntimeContext,
|
|
115
|
+
lintRunner: (projectDir: string, hasLintScript: boolean) => LintProbeOutcome = defaultLintRunner,
|
|
78
116
|
): Promise<ForgeCommandResult<PackageHealthResult>> {
|
|
79
117
|
const { workspaceRoot, logger } = context;
|
|
80
118
|
const packagesDir = path.join(workspaceRoot, "packages");
|
|
@@ -86,6 +124,7 @@ export async function runPackageHealth(
|
|
|
86
124
|
packagesChecked: 0,
|
|
87
125
|
violations: [],
|
|
88
126
|
passed: true,
|
|
127
|
+
lintSurface: {},
|
|
89
128
|
},
|
|
90
129
|
exitCode: 0,
|
|
91
130
|
summary: "No packages/ directory found — nothing to check.",
|
|
@@ -97,6 +136,7 @@ export async function runPackageHealth(
|
|
|
97
136
|
const rootNodeRange = rootEngines?.["node"];
|
|
98
137
|
|
|
99
138
|
const violations: PackageHealthViolation[] = [];
|
|
139
|
+
const lintSurface: Record<string, "pass" | "fail"> = {};
|
|
100
140
|
let packagesChecked = 0;
|
|
101
141
|
|
|
102
142
|
const entries = fs.readdirSync(packagesDir, { withFileTypes: true });
|
|
@@ -138,22 +178,40 @@ export async function runPackageHealth(
|
|
|
138
178
|
});
|
|
139
179
|
}
|
|
140
180
|
|
|
141
|
-
//
|
|
142
|
-
|
|
143
|
-
|
|
181
|
+
// Read extract.config.yaml once — CHECK 2 (generated-vs-shipped CI),
|
|
182
|
+
// CHECK 3 (config presence), CHECK 3b (versionBump), CHECK 5 (lint probe)
|
|
183
|
+
// all consume it.
|
|
184
|
+
const extractConfigPath = path.join(pkgDir, "extract.config.yaml");
|
|
185
|
+
let extractConfigRaw: string | null = null;
|
|
186
|
+
if (fs.existsSync(extractConfigPath)) {
|
|
187
|
+
try {
|
|
188
|
+
extractConfigRaw = fs.readFileSync(extractConfigPath, "utf8");
|
|
189
|
+
} catch {
|
|
190
|
+
extractConfigRaw = null;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// CHECK 2: the extracted repo must carry CI. repo-extract generates
|
|
195
|
+
// .github/workflows/ci.yml from the config `ci:` provider block, so an
|
|
196
|
+
// in-package workflow is only required when no provider is declared.
|
|
197
|
+
const ciProvider = extractConfigRaw === null ? null : extractCiProvider(extractConfigRaw);
|
|
198
|
+
const hasGeneratedCi = ciProvider !== null && ciProvider !== "none";
|
|
199
|
+
const hasInPackageCi = fs.existsSync(path.join(pkgDir, ".github", "workflows", "ci.yml"));
|
|
200
|
+
if (extractConfigRaw !== null && !hasGeneratedCi && !hasInPackageCi) {
|
|
144
201
|
violations.push({
|
|
145
202
|
ruleId: "PKG-HEALTH-02",
|
|
146
203
|
packageName,
|
|
147
204
|
severity: "error",
|
|
148
|
-
message:
|
|
149
|
-
|
|
150
|
-
|
|
205
|
+
message:
|
|
206
|
+
"Extracted repo will have no CI — extract.config.yaml declares no ci: provider and no .github/workflows/ci.yml ships in-package.",
|
|
207
|
+
file: extractConfigPath,
|
|
208
|
+
fixHint:
|
|
209
|
+
'Add "ci:\\n provider: github-actions" to extract.config.yaml (repo-extract generates the workflow), or commit .github/workflows/ci.yml inside the package directory.',
|
|
151
210
|
});
|
|
152
211
|
}
|
|
153
212
|
|
|
154
213
|
// CHECK 3: extract.config.yaml exists
|
|
155
|
-
|
|
156
|
-
if (!fs.existsSync(extractConfigPath)) {
|
|
214
|
+
if (extractConfigRaw === null) {
|
|
157
215
|
violations.push({
|
|
158
216
|
ruleId: "PKG-HEALTH-03",
|
|
159
217
|
packageName,
|
|
@@ -164,22 +222,17 @@ export async function runPackageHealth(
|
|
|
164
222
|
});
|
|
165
223
|
} else {
|
|
166
224
|
// CHECK 3b: versionBump must be absent — version in package.json is source of truth
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
"Remove the versionBump line. Manually bump package.json version to the target before extracting.",
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
} catch {
|
|
182
|
-
// Read error — skip this check
|
|
225
|
+
const versionBumpMatch = extractConfigRaw.match(/^versionBump:\s*(\S+)/m);
|
|
226
|
+
if (versionBumpMatch) {
|
|
227
|
+
violations.push({
|
|
228
|
+
ruleId: "PKG-HEALTH-05",
|
|
229
|
+
packageName,
|
|
230
|
+
severity: "error",
|
|
231
|
+
message: `extract.config.yaml has versionBump: ${versionBumpMatch[1]} — this auto-increments the version on every extract. The version in package.json is the source of truth.`,
|
|
232
|
+
file: extractConfigPath,
|
|
233
|
+
fixHint:
|
|
234
|
+
"Remove the versionBump line. Manually bump package.json version to the target before extracting.",
|
|
235
|
+
});
|
|
183
236
|
}
|
|
184
237
|
}
|
|
185
238
|
|
|
@@ -202,6 +255,27 @@ export async function runPackageHealth(
|
|
|
202
255
|
});
|
|
203
256
|
}
|
|
204
257
|
}
|
|
258
|
+
|
|
259
|
+
// CHECK 5: lint-surface — extractable packages must pass their own lint contract (RFC-1254)
|
|
260
|
+
if (extractConfigRaw !== null) {
|
|
261
|
+
const projectDirMatch = extractConfigRaw.match(/^projectDir:\s*(\S+)\s*$/m);
|
|
262
|
+
const projectDir = projectDirMatch ? path.resolve(workspaceRoot, projectDirMatch[1]) : pkgDir;
|
|
263
|
+
const hasLintScript = typeof scripts["lint"] === "string" && scripts["lint"].length > 0;
|
|
264
|
+
const outcome = lintRunner(projectDir, hasLintScript);
|
|
265
|
+
lintSurface[packageName] = outcome.ok ? "pass" : "fail";
|
|
266
|
+
if (!outcome.ok) {
|
|
267
|
+
violations.push({
|
|
268
|
+
ruleId: "PKG-HEALTH-06",
|
|
269
|
+
packageName,
|
|
270
|
+
severity: "error",
|
|
271
|
+
message: `Lint fails in ${path.relative(workspaceRoot, projectDir) || projectDir} — standalone extraction CI will fail.`,
|
|
272
|
+
file: projectDir,
|
|
273
|
+
fixHint: hasLintScript
|
|
274
|
+
? `Run "pnpm --dir ${projectDir} run lint" and drain the reported errors.`
|
|
275
|
+
: `Run "pnpm --dir ${projectDir} exec eslint \"src/**/*.ts\"" and drain the reported errors.`,
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
}
|
|
205
279
|
}
|
|
206
280
|
|
|
207
281
|
const errors = violations.filter((v) => v.severity === "error");
|
|
@@ -245,6 +319,7 @@ export async function runPackageHealth(
|
|
|
245
319
|
packagesChecked,
|
|
246
320
|
violations,
|
|
247
321
|
passed,
|
|
322
|
+
lintSurface,
|
|
248
323
|
},
|
|
249
324
|
exitCode: passed ? 0 : 1,
|
|
250
325
|
summary: passed
|