@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
package/os/core/core.module.ts
CHANGED
|
@@ -6,17 +6,12 @@
|
|
|
6
6
|
</non-goals>
|
|
7
7
|
</MODULE_CONTRACT>
|
|
8
8
|
<CHANGE_SUMMARY>
|
|
9
|
-
<item>RFC-1231: step 1 — rename supportsAllSites to acceptsAllFlag
|
|
10
|
-
|
|
11
|
-
Mechanical sweep: the field only ever gated --all argv acceptance; fan-out
|
|
12
|
-
follows the parsed selector. Guard renamed assertAllSitesAllowed ->
|
|
13
|
-
assertAllFlagAccepted, message updated. 417 declaration sites + type
|
|
14
|
-
surfaces (KernelCommandMetadata, ForgeCommandMetadata) in one atomic pass.</item>
|
|
15
9
|
<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>
|
|
16
10
|
<item>RFC-1248: VITE-CLIENT-DEP-02 lazy-import gate + SCAN-02 validator reads-root existence check (RFC-1248)</item>
|
|
17
11
|
<item>RFC-1251: step 3 — diagnostic.rule-id.validate gate + RULEID-CANONICAL-01, pipeline-wired</item>
|
|
18
12
|
<item>RFC-1254: forge.package.health lint-surface probe (PKG-HEALTH-06) + --compass-docs generates marked conditional for OWN-DUP-01 parity</item>
|
|
19
|
-
<
|
|
13
|
+
<item>forge.doctor next-steps are severity-aware — warn-only runs emit an optional "review the warnings" step instead of a required "fix the violations" one.</item>
|
|
14
|
+
<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, RFC-1231</history>
|
|
20
15
|
</CHANGE_SUMMARY>
|
|
21
16
|
*/
|
|
22
17
|
|
|
@@ -176,9 +171,12 @@ export async function createForgeCoreModule(): Promise<ForgeModule> {
|
|
|
176
171
|
): Promise<ForgeCommandResult> => {
|
|
177
172
|
const result = await runDoctor(input, context);
|
|
178
173
|
const allPass = result.data?.allPass === true;
|
|
174
|
+
const hasFails = (result.data?.checks ?? []).some((c) => c.status === "fail");
|
|
179
175
|
const nextSteps: ForgeNextStep[] = allPass
|
|
180
176
|
? []
|
|
181
|
-
:
|
|
177
|
+
: hasFails
|
|
178
|
+
? [{ action: "Fix the violations above and re-run forge.doctor", kind: "required" }]
|
|
179
|
+
: [{ action: "Review the warnings above — no action required", kind: "optional" }];
|
|
182
180
|
return { ...result, nextSteps };
|
|
183
181
|
};
|
|
184
182
|
|
|
@@ -106,12 +106,9 @@ describe("docs.archive failed-merge accounting (RFC-1235)", () => {
|
|
|
106
106
|
entry: { id: "RFC-1230", domain: "forge", operation: "modified", conflicts: 0 },
|
|
107
107
|
});
|
|
108
108
|
expect(outcome.kind).toBe("merged");
|
|
109
|
-
|
|
110
|
-
outcome.kind === "merged"
|
|
111
|
-
? outcome.entry
|
|
112
|
-
: liveMergeFailureEntry("RFC-1230", new Error("unreachable"));
|
|
109
|
+
if (outcome.kind !== "merged") throw new Error("unreachable");
|
|
113
110
|
|
|
114
|
-
const block = buildLiveMergeBlock([entry], [], 0, false);
|
|
111
|
+
const block = buildLiveMergeBlock([outcome.entry], [], 0, false);
|
|
115
112
|
expect(block).toEqual({
|
|
116
113
|
merged: [{ id: "RFC-1230", domain: "forge", operation: "modified", conflicts: 0 }],
|
|
117
114
|
failed: [],
|
|
@@ -64,12 +64,24 @@ test("passes when all published packages are healthy", async () => {
|
|
|
64
64
|
private: false,
|
|
65
65
|
type: "module",
|
|
66
66
|
engines: { node: ">=24 <25" },
|
|
67
|
-
scripts: {
|
|
68
|
-
|
|
67
|
+
scripts: {
|
|
68
|
+
build: "tsc --noEmit",
|
|
69
|
+
lint: "eslint src",
|
|
70
|
+
typecheck: "tsc --noEmit",
|
|
71
|
+
test: "vitest run",
|
|
72
|
+
},
|
|
73
|
+
devDependencies: {
|
|
74
|
+
typescript: "^5.0.0",
|
|
75
|
+
eslint: "^9.0.0",
|
|
76
|
+
vitest: "^4.0.0",
|
|
77
|
+
},
|
|
69
78
|
});
|
|
70
79
|
mkdirSync(join(pkgDir, ".github", "workflows"), { recursive: true });
|
|
71
80
|
writeFileSync(join(pkgDir, ".github", "workflows", "ci.yml"), "name: CI\n");
|
|
72
|
-
writeFileSync(
|
|
81
|
+
writeFileSync(
|
|
82
|
+
join(pkgDir, "extract.config.yaml"),
|
|
83
|
+
"source: .\nci:\n provider: github-actions\n",
|
|
84
|
+
);
|
|
73
85
|
|
|
74
86
|
const result = await runPackageHealth(makeInput(), makeContext(tmpDir), () => ({
|
|
75
87
|
ok: true,
|
|
@@ -137,7 +149,67 @@ test("reports PKG-HEALTH-01 when engines.node is missing", async () => {
|
|
|
137
149
|
expect(v01?.packageName).toBe("@test/no-engines");
|
|
138
150
|
});
|
|
139
151
|
|
|
140
|
-
test("
|
|
152
|
+
test("accepts generated CI — extractable package with ci: provider needs no in-package workflow", async () => {
|
|
153
|
+
writePkgJson(tmpDir, {
|
|
154
|
+
name: "test-workspace",
|
|
155
|
+
private: true,
|
|
156
|
+
engines: { node: ">=24 <25" },
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
const pkgDir = join(tmpDir, "packages", "generated-ci");
|
|
160
|
+
mkdirSync(pkgDir, { recursive: true });
|
|
161
|
+
writePkgJson(pkgDir, {
|
|
162
|
+
name: "@test/generated-ci",
|
|
163
|
+
version: "1.0.0",
|
|
164
|
+
private: false,
|
|
165
|
+
type: "module",
|
|
166
|
+
engines: { node: ">=24 <25" },
|
|
167
|
+
scripts: { build: "tsc", lint: "eslint src", typecheck: "tsc --noEmit", test: "vitest run" },
|
|
168
|
+
devDependencies: { eslint: "^9.0.0", typescript: "^5.0.0", vitest: "^4.0.0" },
|
|
169
|
+
});
|
|
170
|
+
// No .github/workflows/ci.yml — repo-extract generates it from the ci: block.
|
|
171
|
+
writeFileSync(
|
|
172
|
+
join(pkgDir, "extract.config.yaml"),
|
|
173
|
+
"source: .\nci:\n provider: github-actions\n publish: true\n",
|
|
174
|
+
);
|
|
175
|
+
|
|
176
|
+
const result = await runPackageHealth(makeInput(), makeContext(tmpDir), () => ({
|
|
177
|
+
ok: true,
|
|
178
|
+
detail: "",
|
|
179
|
+
}));
|
|
180
|
+
expect(result.exitCode).toBe(0);
|
|
181
|
+
expect(result.data?.violations.find((v) => v.ruleId === "PKG-HEALTH-02")).toBeUndefined();
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
test("accepts in-package CI as fallback — extractable package without ci: provider keeps shipped workflow", async () => {
|
|
185
|
+
writePkgJson(tmpDir, {
|
|
186
|
+
name: "test-workspace",
|
|
187
|
+
private: true,
|
|
188
|
+
engines: { node: ">=24 <25" },
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
const pkgDir = join(tmpDir, "packages", "shipped-ci");
|
|
192
|
+
mkdirSync(pkgDir, { recursive: true });
|
|
193
|
+
writePkgJson(pkgDir, {
|
|
194
|
+
name: "@test/shipped-ci",
|
|
195
|
+
version: "1.0.0",
|
|
196
|
+
private: false,
|
|
197
|
+
type: "module",
|
|
198
|
+
engines: { node: ">=24 <25" },
|
|
199
|
+
scripts: {},
|
|
200
|
+
});
|
|
201
|
+
mkdirSync(join(pkgDir, ".github", "workflows"), { recursive: true });
|
|
202
|
+
writeFileSync(join(pkgDir, ".github", "workflows", "ci.yml"), "name: CI\n");
|
|
203
|
+
writeFileSync(join(pkgDir, "extract.config.yaml"), "source: .\n");
|
|
204
|
+
|
|
205
|
+
const result = await runPackageHealth(makeInput(), makeContext(tmpDir), () => ({
|
|
206
|
+
ok: true,
|
|
207
|
+
detail: "",
|
|
208
|
+
}));
|
|
209
|
+
expect(result.data?.violations.find((v) => v.ruleId === "PKG-HEALTH-02")).toBeUndefined();
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
test("reports PKG-HEALTH-02 when extracted repo would ship no CI", async () => {
|
|
141
213
|
writePkgJson(tmpDir, {
|
|
142
214
|
name: "test-workspace",
|
|
143
215
|
private: true,
|
|
@@ -234,6 +306,192 @@ test("reports PKG-HEALTH-04 when script tool is not in devDependencies", async (
|
|
|
234
306
|
expect(depNames).toContain("vitest");
|
|
235
307
|
});
|
|
236
308
|
|
|
309
|
+
test("reports PKG-HEALTH-07 when generated CI invokes a missing script", async () => {
|
|
310
|
+
writePkgJson(tmpDir, {
|
|
311
|
+
name: "test-workspace",
|
|
312
|
+
private: true,
|
|
313
|
+
engines: { node: ">=24 <25" },
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
const pkgDir = join(tmpDir, "packages", "missing-scripts");
|
|
317
|
+
mkdirSync(pkgDir, { recursive: true });
|
|
318
|
+
writePkgJson(pkgDir, {
|
|
319
|
+
name: "@test/missing-scripts",
|
|
320
|
+
version: "1.0.0",
|
|
321
|
+
private: false,
|
|
322
|
+
type: "module",
|
|
323
|
+
engines: { node: ">=24 <25" },
|
|
324
|
+
scripts: { build: "tsc", test: "vitest run" },
|
|
325
|
+
devDependencies: { typescript: "^5.0.0", vitest: "^4.0.0" },
|
|
326
|
+
});
|
|
327
|
+
writeFileSync(
|
|
328
|
+
join(pkgDir, "extract.config.yaml"),
|
|
329
|
+
"source: .\nci:\n provider: github-actions\n",
|
|
330
|
+
);
|
|
331
|
+
|
|
332
|
+
const result = await runPackageHealth(makeInput(), makeContext(tmpDir), () => ({
|
|
333
|
+
ok: true,
|
|
334
|
+
detail: "",
|
|
335
|
+
}));
|
|
336
|
+
const v07 = result.data?.violations
|
|
337
|
+
.filter((v) => v.ruleId === "PKG-HEALTH-07")
|
|
338
|
+
.map((v) => v.message);
|
|
339
|
+
expect(v07?.some((m) => m.includes('"lint"'))).toBe(true);
|
|
340
|
+
expect(v07?.some((m) => m.includes('"typecheck"'))).toBe(true);
|
|
341
|
+
expect(v07?.some((m) => m.includes('"build"'))).toBe(false);
|
|
342
|
+
expect(v07?.some((m) => m.includes('"test"'))).toBe(false);
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
test("PKG-HEALTH-07 respects ci.skipBuild for the build script", async () => {
|
|
346
|
+
writePkgJson(tmpDir, {
|
|
347
|
+
name: "test-workspace",
|
|
348
|
+
private: true,
|
|
349
|
+
engines: { node: ">=24 <25" },
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
const pkgDir = join(tmpDir, "packages", "skip-build");
|
|
353
|
+
mkdirSync(pkgDir, { recursive: true });
|
|
354
|
+
writePkgJson(pkgDir, {
|
|
355
|
+
name: "@test/skip-build",
|
|
356
|
+
version: "1.0.0",
|
|
357
|
+
private: false,
|
|
358
|
+
type: "module",
|
|
359
|
+
engines: { node: ">=24 <25" },
|
|
360
|
+
scripts: { lint: "eslint src", typecheck: "tsc --noEmit", test: "vitest run" },
|
|
361
|
+
devDependencies: { eslint: "^9.0.0", typescript: "^5.0.0", vitest: "^4.0.0" },
|
|
362
|
+
});
|
|
363
|
+
writeFileSync(
|
|
364
|
+
join(pkgDir, "extract.config.yaml"),
|
|
365
|
+
"source: .\nci:\n provider: github-actions\n skipBuild: true\n",
|
|
366
|
+
);
|
|
367
|
+
|
|
368
|
+
const result = await runPackageHealth(makeInput(), makeContext(tmpDir), () => ({
|
|
369
|
+
ok: true,
|
|
370
|
+
detail: "",
|
|
371
|
+
}));
|
|
372
|
+
expect(result.data?.violations.find((v) => v.ruleId === "PKG-HEALTH-07")).toBeUndefined();
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
test("reports PKG-HEALTH-08 when repository.url is missing or mismatched under ci.publish", async () => {
|
|
376
|
+
writePkgJson(tmpDir, {
|
|
377
|
+
name: "test-workspace",
|
|
378
|
+
private: true,
|
|
379
|
+
engines: { node: ">=24 <25" },
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
const scripts = {
|
|
383
|
+
build: "tsc",
|
|
384
|
+
lint: "eslint src",
|
|
385
|
+
typecheck: "tsc --noEmit",
|
|
386
|
+
test: "vitest run",
|
|
387
|
+
};
|
|
388
|
+
const devDependencies = { eslint: "^9.0.0", typescript: "^5.0.0", vitest: "^4.0.0" };
|
|
389
|
+
|
|
390
|
+
const missingDir = join(tmpDir, "packages", "no-repo-field");
|
|
391
|
+
mkdirSync(missingDir, { recursive: true });
|
|
392
|
+
writePkgJson(missingDir, {
|
|
393
|
+
name: "@test/no-repo-field",
|
|
394
|
+
version: "1.0.0",
|
|
395
|
+
private: false,
|
|
396
|
+
type: "module",
|
|
397
|
+
engines: { node: ">=24 <25" },
|
|
398
|
+
scripts,
|
|
399
|
+
devDependencies,
|
|
400
|
+
});
|
|
401
|
+
writeFileSync(
|
|
402
|
+
join(missingDir, "extract.config.yaml"),
|
|
403
|
+
"source: .\nci:\n provider: github-actions\n publish: true\ngit:\n remote: git@github.com:owner/no-repo-field.git\n",
|
|
404
|
+
);
|
|
405
|
+
|
|
406
|
+
const mismatchDir = join(tmpDir, "packages", "bad-repo-field");
|
|
407
|
+
mkdirSync(mismatchDir, { recursive: true });
|
|
408
|
+
writePkgJson(mismatchDir, {
|
|
409
|
+
name: "@test/bad-repo-field",
|
|
410
|
+
version: "1.0.0",
|
|
411
|
+
private: false,
|
|
412
|
+
type: "module",
|
|
413
|
+
engines: { node: ">=24 <25" },
|
|
414
|
+
scripts,
|
|
415
|
+
devDependencies,
|
|
416
|
+
repository: { type: "git", url: "git+https://github.com/someone-else/other.git" },
|
|
417
|
+
});
|
|
418
|
+
writeFileSync(
|
|
419
|
+
join(mismatchDir, "extract.config.yaml"),
|
|
420
|
+
"source: .\nci:\n provider: github-actions\n publish: true\ngit:\n remote: git@github.com:owner/bad-repo-field.git\n",
|
|
421
|
+
);
|
|
422
|
+
|
|
423
|
+
const result = await runPackageHealth(makeInput(), makeContext(tmpDir), () => ({
|
|
424
|
+
ok: true,
|
|
425
|
+
detail: "",
|
|
426
|
+
}));
|
|
427
|
+
const v08 = result.data?.violations.filter((v) => v.ruleId === "PKG-HEALTH-08");
|
|
428
|
+
expect(v08).toHaveLength(2);
|
|
429
|
+
expect(v08?.map((v) => v.packageName).sort()).toEqual([
|
|
430
|
+
"@test/bad-repo-field",
|
|
431
|
+
"@test/no-repo-field",
|
|
432
|
+
]);
|
|
433
|
+
});
|
|
434
|
+
|
|
435
|
+
test("reports PKG-HEALTH-09 when files[] omits a reachable src file", async () => {
|
|
436
|
+
writePkgJson(tmpDir, {
|
|
437
|
+
name: "test-workspace",
|
|
438
|
+
private: true,
|
|
439
|
+
engines: { node: ">=24 <25" },
|
|
440
|
+
});
|
|
441
|
+
|
|
442
|
+
const pkgDir = join(tmpDir, "packages", "files-gap");
|
|
443
|
+
mkdirSync(join(pkgDir, "src"), { recursive: true });
|
|
444
|
+
writePkgJson(pkgDir, {
|
|
445
|
+
name: "@test/files-gap",
|
|
446
|
+
version: "1.0.0",
|
|
447
|
+
private: false,
|
|
448
|
+
type: "module",
|
|
449
|
+
engines: { node: ">=24 <25" },
|
|
450
|
+
files: ["dist/", "src/index.ts"],
|
|
451
|
+
scripts: { build: "tsc", lint: "eslint src", typecheck: "tsc --noEmit", test: "vitest run" },
|
|
452
|
+
devDependencies: { eslint: "^9.0.0", typescript: "^5.0.0", vitest: "^4.0.0" },
|
|
453
|
+
});
|
|
454
|
+
writeFileSync(join(pkgDir, "src", "index.ts"), 'export * from "./helper.ts";\n');
|
|
455
|
+
writeFileSync(join(pkgDir, "src", "helper.ts"), "export const x = 1;\n");
|
|
456
|
+
writeFileSync(join(pkgDir, "extract.config.yaml"), "source: .\n");
|
|
457
|
+
|
|
458
|
+
const result = await runPackageHealth(makeInput(), makeContext(tmpDir), () => ({
|
|
459
|
+
ok: true,
|
|
460
|
+
detail: "",
|
|
461
|
+
}));
|
|
462
|
+
const v09 = result.data?.violations.find((v) => v.ruleId === "PKG-HEALTH-09");
|
|
463
|
+
expect(v09).toBeDefined();
|
|
464
|
+
expect(v09?.message).toContain("src/helper.ts");
|
|
465
|
+
});
|
|
466
|
+
|
|
467
|
+
test('"extractable": false suppresses extract-dependent checks', async () => {
|
|
468
|
+
writePkgJson(tmpDir, {
|
|
469
|
+
name: "test-workspace",
|
|
470
|
+
private: true,
|
|
471
|
+
engines: { node: ">=24 <25" },
|
|
472
|
+
});
|
|
473
|
+
|
|
474
|
+
const pkgDir = join(tmpDir, "packages", "opted-out");
|
|
475
|
+
mkdirSync(pkgDir, { recursive: true });
|
|
476
|
+
writePkgJson(pkgDir, {
|
|
477
|
+
name: "@test/opted-out",
|
|
478
|
+
version: "1.0.0",
|
|
479
|
+
private: false,
|
|
480
|
+
extractable: false,
|
|
481
|
+
type: "module",
|
|
482
|
+
engines: { node: ">=24 <25" },
|
|
483
|
+
scripts: {},
|
|
484
|
+
});
|
|
485
|
+
// No extract.config.yaml, no CI — all extract checks suppressed.
|
|
486
|
+
|
|
487
|
+
const result = await runPackageHealth(makeInput(), makeContext(tmpDir), () => ({
|
|
488
|
+
ok: true,
|
|
489
|
+
detail: "",
|
|
490
|
+
}));
|
|
491
|
+
expect(result.exitCode).toBe(0);
|
|
492
|
+
expect(result.data?.violations).toHaveLength(0);
|
|
493
|
+
});
|
|
494
|
+
|
|
237
495
|
test("handles no packages/ directory gracefully", async () => {
|
|
238
496
|
writePkgJson(tmpDir, { name: "empty", private: true });
|
|
239
497
|
|
|
@@ -15,6 +15,8 @@ Mechanical v1 to v2 header migration across the workspace: 942 files rewritten
|
|
|
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
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>
|
|
19
|
+
<item>RFC-1255: PKG-HEALTH-07 generated-CI script contract (build/lint/typecheck/test), PKG-HEALTH-08 repository.url vs git.remote for provenance publish, PKG-HEALTH-09 files[] src-reachability coverage; "extractable": false opt-out suppresses all extract-dependent checks</item>
|
|
18
20
|
</CHANGE_SUMMARY>
|
|
19
21
|
*/
|
|
20
22
|
|
|
@@ -93,6 +95,134 @@ function readJsonFile(filePath: string): Record<string, unknown> | null {
|
|
|
93
95
|
}
|
|
94
96
|
}
|
|
95
97
|
|
|
98
|
+
// Reads the `provider:` scalar out of the top-level `ci:` mapping block in an
|
|
99
|
+
// extract.config.yaml. Returns null when the block or the key is absent.
|
|
100
|
+
function extractCiProvider(raw: string): string | null {
|
|
101
|
+
return extractYamlBlockScalar(raw, "ci", "provider");
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Reads a `<subKey>:` scalar nested under a top-level `<topKey>:` mapping block
|
|
105
|
+
// in extract.config.yaml. Returns null when the block or key is absent.
|
|
106
|
+
function extractYamlBlockScalar(raw: string, topKey: string, subKey: string): string | null {
|
|
107
|
+
const blockMatch = raw.match(new RegExp(`^${topKey}:[ \\t]*$`, "m"));
|
|
108
|
+
if (!blockMatch || blockMatch.index === undefined) return null;
|
|
109
|
+
const after = raw.slice(blockMatch.index + blockMatch[0].length);
|
|
110
|
+
for (const line of after.split("\n")) {
|
|
111
|
+
if (line.trim() === "") continue;
|
|
112
|
+
if (!/^\s/.test(line)) break;
|
|
113
|
+
const m = line.match(new RegExp(`^\\s+${subKey}:\\s*(\\S+)\\s*$`));
|
|
114
|
+
if (m) return m[1];
|
|
115
|
+
}
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// RFC-1255 CHECK 9: compute which src/ paths the package.json `files[]`
|
|
120
|
+
// whitelist ships. Returns { fullSrc } when `src`/`src/` ships wholesale, or
|
|
121
|
+
// the set of shipped dir prefixes + exact file paths otherwise.
|
|
122
|
+
function shippedSrcSet(files: string[]): {
|
|
123
|
+
fullSrc: boolean;
|
|
124
|
+
prefixes: string[];
|
|
125
|
+
files: Set<string>;
|
|
126
|
+
} {
|
|
127
|
+
const prefixes: string[] = [];
|
|
128
|
+
const exact = new Set<string>();
|
|
129
|
+
let fullSrc = false;
|
|
130
|
+
for (const entry of files) {
|
|
131
|
+
const e = entry.replace(/^\.\//, "");
|
|
132
|
+
if (e === "src" || e === "src/") {
|
|
133
|
+
fullSrc = true;
|
|
134
|
+
} else if (e === "src/" || e.endsWith("/")) {
|
|
135
|
+
if (e.startsWith("src/")) prefixes.push(e.endsWith("/") ? e : `${e}/`);
|
|
136
|
+
} else if (e.startsWith("src/")) {
|
|
137
|
+
exact.add(e);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return { fullSrc, prefixes, files: exact };
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const SRC_IMPORT_RE =
|
|
144
|
+
/(?:import|export)[^'"]*from\s+["'](\.[^"']+)["']|import\s*\(\s*["'](\.[^"']+)["']/g;
|
|
145
|
+
|
|
146
|
+
// RFC-1255 CHECK 9: walk the relative import graph from every shipped src file;
|
|
147
|
+
// report src/ files reachable but absent from the files[] whitelist.
|
|
148
|
+
function filesSrcGaps(
|
|
149
|
+
pkgDir: string,
|
|
150
|
+
shipped: { fullSrc: boolean; prefixes: string[]; files: Set<string> },
|
|
151
|
+
): string[] {
|
|
152
|
+
if (shipped.fullSrc) return [];
|
|
153
|
+
const isShipped = (p: string): boolean =>
|
|
154
|
+
shipped.prefixes.some((pre) => p.startsWith(pre)) || shipped.files.has(p);
|
|
155
|
+
|
|
156
|
+
const collect = (dir: string, acc: string[]): void => {
|
|
157
|
+
let entries: fs.Dirent[];
|
|
158
|
+
try {
|
|
159
|
+
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
160
|
+
} catch {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
for (const e of entries) {
|
|
164
|
+
if (e.name === "node_modules" || e.name.startsWith(".")) continue;
|
|
165
|
+
const rel = path.relative(pkgDir, path.join(dir, e.name)).split(path.sep).join("/");
|
|
166
|
+
if (e.isDirectory()) {
|
|
167
|
+
collect(path.join(dir, e.name), acc);
|
|
168
|
+
} else if (/\.tsx?$/.test(e.name) && isShipped(rel)) {
|
|
169
|
+
acc.push(rel);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
const seeds: string[] = [];
|
|
174
|
+
collect(path.join(pkgDir, "src"), seeds);
|
|
175
|
+
|
|
176
|
+
const gaps = new Set<string>();
|
|
177
|
+
const visited = new Set<string>();
|
|
178
|
+
const queue = [...seeds];
|
|
179
|
+
while (queue.length > 0) {
|
|
180
|
+
const rel = queue.pop()!;
|
|
181
|
+
if (visited.has(rel)) continue;
|
|
182
|
+
visited.add(rel);
|
|
183
|
+
let source: string;
|
|
184
|
+
try {
|
|
185
|
+
source = fs.readFileSync(path.join(pkgDir, rel), "utf8");
|
|
186
|
+
} catch {
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
for (const m of source.matchAll(SRC_IMPORT_RE)) {
|
|
190
|
+
const spec = m[1] ?? m[2];
|
|
191
|
+
if (!spec) continue;
|
|
192
|
+
const base = path.posix.normalize(path.posix.join(path.posix.dirname(rel), spec));
|
|
193
|
+
for (const cand of [base, `${base}.ts`, `${base}.tsx`, `${base}/index.ts`]) {
|
|
194
|
+
const disk = path.join(pkgDir, cand);
|
|
195
|
+
if (!cand.startsWith("src/") || !fs.existsSync(disk)) continue;
|
|
196
|
+
if (!isShipped(cand)) gaps.add(cand);
|
|
197
|
+
else if (!visited.has(cand)) queue.push(cand);
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return [...gaps];
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// RFC-1255 CHECK 8: normalize a git remote (ssh or https) to "host/owner/repo".
|
|
206
|
+
function remoteSlug(remote: string): string | null {
|
|
207
|
+
const m =
|
|
208
|
+
remote.match(/^[a-z]+@([^:/]+):([^/]+)\/(.+?)(?:\.git)?$/) ??
|
|
209
|
+
remote.match(/^https?:\/\/([^/]+)\/([^/]+)\/(.+?)(?:\.git)?$/);
|
|
210
|
+
return m ? `${m[1]}/${m[2]}/${m[3]}` : null;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// RFC-1255 CHECK 8: extract "host/owner/repo" from a repository.url of the
|
|
214
|
+
// `git+https://host/owner/repo.git` (or plain https/ssh) form.
|
|
215
|
+
function repositorySlug(repo: unknown): string | null {
|
|
216
|
+
const url =
|
|
217
|
+
typeof repo === "string" ? repo : ((repo as { url?: unknown })?.url as string | undefined);
|
|
218
|
+
if (typeof url !== "string") return null;
|
|
219
|
+
const m =
|
|
220
|
+
url.match(/^[a-z]+@([^:/]+):([^/]+)\/(.+?)(?:\.git)?$/) ??
|
|
221
|
+
url.match(/^(?:git\+)?https?:\/\/([^/]+)\/([^/]+)\/(.+?)(?:\.git)?$/) ??
|
|
222
|
+
url.match(/^(?:git\+)?ssh:\/\/[^@]+@([^/]+)\/([^/]+)\/(.+?)(?:\.git)?$/);
|
|
223
|
+
return m ? `${m[1]}/${m[2]}/${m[3]}` : null;
|
|
224
|
+
}
|
|
225
|
+
|
|
96
226
|
export async function runPackageHealth(
|
|
97
227
|
_input: ForgeCommandInput,
|
|
98
228
|
context: ForgeRuntimeContext,
|
|
@@ -162,20 +292,16 @@ export async function runPackageHealth(
|
|
|
162
292
|
});
|
|
163
293
|
}
|
|
164
294
|
|
|
165
|
-
//
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
severity: "error",
|
|
172
|
-
message: "Missing .github/workflows/ci.yml — standalone extraction repo will have no CI.",
|
|
173
|
-
file: pkgDir,
|
|
174
|
-
fixHint: "Create .github/workflows/ci.yml inside the package directory with Node 24 setup.",
|
|
175
|
-
});
|
|
176
|
-
}
|
|
295
|
+
// RFC-1255: "extractable": false declares a published package that is
|
|
296
|
+
// deliberately NOT extractable (e.g. depends on a private workspace
|
|
297
|
+
// package). Suppresses every extract-dependent check (02,03,05,06,07,08,09)
|
|
298
|
+
// — the alternative, a config that can never succeed, is worse than none.
|
|
299
|
+
const extractable = pkg["extractable"] !== false;
|
|
300
|
+
if (!extractable) continue;
|
|
177
301
|
|
|
178
|
-
//
|
|
302
|
+
// Read extract.config.yaml once — CHECK 2 (generated-vs-shipped CI),
|
|
303
|
+
// CHECK 3 (config presence), CHECK 3b (versionBump), CHECK 5 (lint probe)
|
|
304
|
+
// all consume it.
|
|
179
305
|
const extractConfigPath = path.join(pkgDir, "extract.config.yaml");
|
|
180
306
|
let extractConfigRaw: string | null = null;
|
|
181
307
|
if (fs.existsSync(extractConfigPath)) {
|
|
@@ -185,6 +311,27 @@ export async function runPackageHealth(
|
|
|
185
311
|
extractConfigRaw = null;
|
|
186
312
|
}
|
|
187
313
|
}
|
|
314
|
+
|
|
315
|
+
// CHECK 2: the extracted repo must carry CI. repo-extract generates
|
|
316
|
+
// .github/workflows/ci.yml from the config `ci:` provider block, so an
|
|
317
|
+
// in-package workflow is only required when no provider is declared.
|
|
318
|
+
const ciProvider = extractConfigRaw === null ? null : extractCiProvider(extractConfigRaw);
|
|
319
|
+
const hasGeneratedCi = ciProvider !== null && ciProvider !== "none";
|
|
320
|
+
const hasInPackageCi = fs.existsSync(path.join(pkgDir, ".github", "workflows", "ci.yml"));
|
|
321
|
+
if (extractConfigRaw !== null && !hasGeneratedCi && !hasInPackageCi) {
|
|
322
|
+
violations.push({
|
|
323
|
+
ruleId: "PKG-HEALTH-02",
|
|
324
|
+
packageName,
|
|
325
|
+
severity: "error",
|
|
326
|
+
message:
|
|
327
|
+
"Extracted repo will have no CI — extract.config.yaml declares no ci: provider and no .github/workflows/ci.yml ships in-package.",
|
|
328
|
+
file: extractConfigPath,
|
|
329
|
+
fixHint:
|
|
330
|
+
'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.',
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// CHECK 3: extract.config.yaml exists
|
|
188
335
|
if (extractConfigRaw === null) {
|
|
189
336
|
violations.push({
|
|
190
337
|
ruleId: "PKG-HEALTH-03",
|
|
@@ -249,6 +396,69 @@ export async function runPackageHealth(
|
|
|
249
396
|
: `Run "pnpm --dir ${projectDir} exec eslint \"src/**/*.ts\"" and drain the reported errors.`,
|
|
250
397
|
});
|
|
251
398
|
}
|
|
399
|
+
|
|
400
|
+
// RFC-1255 CHECK 7: generated CI runs build (unless ci.skipBuild),
|
|
401
|
+
// lint, typecheck, test — every missing script is a guaranteed
|
|
402
|
+
// first-run CI failure (ERR_PNPM_NO_SCRIPT). Fires only for the
|
|
403
|
+
// generated contract; an in-package workflow's steps are authored
|
|
404
|
+
// and unknowable here.
|
|
405
|
+
if (hasGeneratedCi) {
|
|
406
|
+
const skipBuild = extractYamlBlockScalar(extractConfigRaw, "ci", "skipBuild") === "true";
|
|
407
|
+
const required = ["lint", "typecheck", "test", ...(skipBuild ? [] : ["build"])];
|
|
408
|
+
const missing = required.filter((s) => typeof scripts[s] !== "string" || !scripts[s]);
|
|
409
|
+
for (const s of missing) {
|
|
410
|
+
violations.push({
|
|
411
|
+
ruleId: "PKG-HEALTH-07",
|
|
412
|
+
packageName,
|
|
413
|
+
severity: "error",
|
|
414
|
+
message: `Generated CI invokes "run ${s}" but package.json has no "${s}" script.`,
|
|
415
|
+
file: pkgJsonPath,
|
|
416
|
+
fixHint:
|
|
417
|
+
s === "typecheck"
|
|
418
|
+
? 'Add "typecheck": "pnpm exec tsc -p tsconfig.json --noEmit" to scripts.'
|
|
419
|
+
: `Add a "${s}" script to package.json.`,
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
// RFC-1255 CHECK 8: provenance verifies repository.url against the
|
|
425
|
+
// Actions repo slug — a missing or mismatched field 422s at publish.
|
|
426
|
+
const ciPublish = extractYamlBlockScalar(extractConfigRaw, "ci", "publish");
|
|
427
|
+
const gitRemote = extractYamlBlockScalar(extractConfigRaw, "git", "remote");
|
|
428
|
+
if (hasGeneratedCi && ciPublish !== "false" && gitRemote) {
|
|
429
|
+
const expected = remoteSlug(gitRemote);
|
|
430
|
+
const actual = repositorySlug(pkg["repository"]);
|
|
431
|
+
if (expected && actual !== expected) {
|
|
432
|
+
violations.push({
|
|
433
|
+
ruleId: "PKG-HEALTH-08",
|
|
434
|
+
packageName,
|
|
435
|
+
severity: "error",
|
|
436
|
+
message: actual
|
|
437
|
+
? `repository.url resolves to "${actual}" but git.remote is "${expected}" — npm publish --provenance will 422.`
|
|
438
|
+
: `Missing repository.url — npm publish --provenance verifies it against the GitHub repo "${expected}".`,
|
|
439
|
+
file: pkgJsonPath,
|
|
440
|
+
fixHint: `Add "repository": { "type": "git", "url": "git+https://${expected}.git" } to package.json.`,
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
// RFC-1255 CHECK 9: a selective files[] whitelist must ship every src/
|
|
446
|
+
// file reachable from the shipped src set — consumers follow shipped
|
|
447
|
+
// sources and hit TS2307 on the gap.
|
|
448
|
+
const filesField = pkg["files"];
|
|
449
|
+
if (Array.isArray(filesField)) {
|
|
450
|
+
const gaps = filesSrcGaps(pkgDir, shippedSrcSet(filesField as string[]));
|
|
451
|
+
for (const gap of gaps) {
|
|
452
|
+
violations.push({
|
|
453
|
+
ruleId: "PKG-HEALTH-09",
|
|
454
|
+
packageName,
|
|
455
|
+
severity: "error",
|
|
456
|
+
message: `"${gap}" is reachable from shipped src/ entries but missing from files[] — published consumers hit TS2307.`,
|
|
457
|
+
file: pkgJsonPath,
|
|
458
|
+
fixHint: `Add "${gap}" (or its parent directory) to the files[] array in package.json.`,
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
}
|
|
252
462
|
}
|
|
253
463
|
}
|
|
254
464
|
|
|
@@ -49,7 +49,7 @@ function makeEnvelope(rfcId: string, overall: "pass" | "fail"): Record<string, u
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
async function setupWorkspace(opts: {
|
|
52
|
-
rfcs: Array<{ id: string; status: string; probes?: unknown[] }>;
|
|
52
|
+
rfcs: Array<{ id: string; status: string; probes?: Record<string, unknown>[] }>;
|
|
53
53
|
envelopes?: Array<{ id: string; overall: "pass" | "fail" }>;
|
|
54
54
|
}): Promise<{ workspaceRoot: string; cleanup: () => Promise<void> }> {
|
|
55
55
|
const tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), "rfc-emit-test-"));
|
|
@@ -67,7 +67,7 @@ function makeEnvelope(
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
async function setupWorkspace(opts: {
|
|
70
|
-
rfcs: Array<{ id: string; status: string; probes?: unknown[] }>;
|
|
70
|
+
rfcs: Array<{ id: string; status: string; probes?: Record<string, unknown>[] }>;
|
|
71
71
|
envelopes?: Array<{ id: string; emittedAt?: string; overall?: "pass" | "fail" }>;
|
|
72
72
|
}): Promise<{ workspaceRoot: string; cleanup: () => Promise<void> }> {
|
|
73
73
|
const tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), "rfc-refresh-test-"));
|
|
@@ -58,8 +58,8 @@ ${consumersYaml}waves:
|
|
|
58
58
|
await writeConsumerSpec(workspaceRoot, " consumers:\n - personal-agent\n");
|
|
59
59
|
const result = await runSpecValidate({ argv: [], flags: { spec: "example" } }, ctx(workspaceRoot));
|
|
60
60
|
expect(result.exitCode).toBe(0);
|
|
61
|
-
expect(result.data
|
|
62
|
-
const warnings = result.data
|
|
61
|
+
expect(result.data!.status).toBe("pass");
|
|
62
|
+
const warnings = result.data!.specs[0]!.violations.filter((v) => v.severity === "warning");
|
|
63
63
|
expect(warnings.map((v) => v.rule)).toEqual(["SPEC-13"]);
|
|
64
64
|
expect(warnings[0]!.message).toContain("EX-001");
|
|
65
65
|
});
|
|
@@ -72,7 +72,7 @@ ${consumersYaml}waves:
|
|
|
72
72
|
await writeConsumerSpec(workspaceRoot, " consumers:\n - personal-agent\n");
|
|
73
73
|
const result = await runSpecValidate({ argv: [], flags: { spec: "example" } }, ctx(workspaceRoot));
|
|
74
74
|
expect(result.exitCode).toBe(0);
|
|
75
|
-
expect(result.data
|
|
75
|
+
expect(result.data!.specs[0]!.violations).toEqual([]);
|
|
76
76
|
});
|
|
77
77
|
|
|
78
78
|
it("fails with SPEC-12 on duplicate consumer entries", async () => {
|
|
@@ -81,7 +81,7 @@ ${consumersYaml}waves:
|
|
|
81
81
|
await writeConsumerSpec(workspaceRoot, " consumers:\n - werkstatt\n - werkstatt\n");
|
|
82
82
|
const result = await runSpecValidate({ argv: [], flags: { spec: "example" } }, ctx(workspaceRoot));
|
|
83
83
|
expect(result.exitCode).toBe(1);
|
|
84
|
-
expect(result.data
|
|
84
|
+
expect(result.data!.specs[0]!.violations.map((v) => v.rule)).toContain("SPEC-12");
|
|
85
85
|
});
|
|
86
86
|
});
|
|
87
87
|
|