@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
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>Probe tests for the forge.package.health lint-surface check (PKG-HEALTH-06, RFC-1254):
|
|
4
|
+
extractable packages run their own lint contract via an injected runner; failures surface as
|
|
5
|
+
per-package lint-surface: fail and flip passed/exitCode.</purpose>
|
|
6
|
+
<non-goals>
|
|
7
|
+
<item>Does not exercise the real pnpm execFileSync runner — the lint subprocess is stubbed via the injected lintRunner seam.</item>
|
|
8
|
+
</non-goals>
|
|
9
|
+
</MODULE_CONTRACT>
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { test, expect, beforeEach, afterEach } from "vitest";
|
|
13
|
+
import { join } from "node:path";
|
|
14
|
+
import { writeFileSync, mkdirSync, rmSync } from "node:fs";
|
|
15
|
+
import { tmpdir } from "node:os";
|
|
16
|
+
import type { ForgeCommandInput, ForgeRuntimeContext } from "../types.ts";
|
|
17
|
+
import { runPackageHealth } from "../../os/core/handlers/package-health.ts";
|
|
18
|
+
|
|
19
|
+
function makeContext(workspaceRoot: string): ForgeRuntimeContext {
|
|
20
|
+
return {
|
|
21
|
+
workspaceRoot,
|
|
22
|
+
logger: {
|
|
23
|
+
section: () => {},
|
|
24
|
+
info: () => {},
|
|
25
|
+
warn: () => {},
|
|
26
|
+
error: () => {},
|
|
27
|
+
success: () => {},
|
|
28
|
+
},
|
|
29
|
+
dryRun: false,
|
|
30
|
+
outputFormat: "pretty",
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function makeInput(): ForgeCommandInput {
|
|
35
|
+
return { argv: [], flags: {} };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function writePkgJson(dir: string, pkg: Record<string, unknown>) {
|
|
39
|
+
writeFileSync(join(dir, "package.json"), JSON.stringify(pkg, null, 2) + "\n");
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function seedHealthyPackage(
|
|
43
|
+
tmpDir: string,
|
|
44
|
+
dirName: string,
|
|
45
|
+
opts: { projectDir?: string; lintScript?: boolean } = {},
|
|
46
|
+
): void {
|
|
47
|
+
const pkgDir = join(tmpDir, "packages", dirName);
|
|
48
|
+
mkdirSync(pkgDir, { recursive: true });
|
|
49
|
+
writePkgJson(pkgDir, {
|
|
50
|
+
name: `@test/${dirName}`,
|
|
51
|
+
version: "1.0.0",
|
|
52
|
+
private: false,
|
|
53
|
+
type: "module",
|
|
54
|
+
engines: { node: ">=24 <25" },
|
|
55
|
+
scripts: opts.lintScript ? { lint: "eslint src" } : {},
|
|
56
|
+
devDependencies: opts.lintScript ? { eslint: "^9.0.0" } : {},
|
|
57
|
+
});
|
|
58
|
+
mkdirSync(join(pkgDir, ".github", "workflows"), { recursive: true });
|
|
59
|
+
writeFileSync(join(pkgDir, ".github", "workflows", "ci.yml"), "name: CI\n");
|
|
60
|
+
const projectDirLine = opts.projectDir ? `projectDir: ${opts.projectDir}\n` : "";
|
|
61
|
+
writeFileSync(join(pkgDir, "extract.config.yaml"), `${projectDirLine}standalone: true\n`);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
let tmpDir: string;
|
|
65
|
+
|
|
66
|
+
beforeEach(() => {
|
|
67
|
+
tmpDir = join(
|
|
68
|
+
tmpdir(),
|
|
69
|
+
`forge-pkg-health-lint-${Date.now()}-${Math.random().toString(36).slice(2)}`,
|
|
70
|
+
);
|
|
71
|
+
mkdirSync(tmpDir, { recursive: true });
|
|
72
|
+
writePkgJson(tmpDir, {
|
|
73
|
+
name: "test-workspace",
|
|
74
|
+
private: true,
|
|
75
|
+
engines: { node: ">=24 <25" },
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
afterEach(() => {
|
|
80
|
+
rmSync(tmpDir, { recursive: true, force: true });
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test("reports lint-surface pass when the injected runner succeeds", async () => {
|
|
84
|
+
seedHealthyPackage(tmpDir, "clean-pkg", { lintScript: true });
|
|
85
|
+
|
|
86
|
+
const calls: Array<{ dir: string; hasScript: boolean }> = [];
|
|
87
|
+
const result = await runPackageHealth(makeInput(), makeContext(tmpDir), (dir, hasScript) => {
|
|
88
|
+
calls.push({ dir, hasScript });
|
|
89
|
+
return { ok: true, detail: "" };
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
expect(result.exitCode).toBe(0);
|
|
93
|
+
expect(result.data?.passed).toBe(true);
|
|
94
|
+
expect(result.data?.lintSurface).toEqual({ "@test/clean-pkg": "pass" });
|
|
95
|
+
expect(result.data?.violations.find((v) => v.ruleId === "PKG-HEALTH-06")).toBeUndefined();
|
|
96
|
+
// pnpm run lint — the package declares a lint script
|
|
97
|
+
expect(calls).toEqual([{ dir: join(tmpDir, "packages", "clean-pkg"), hasScript: true }]);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
test("reports lint-surface fail and PKG-HEALTH-06 when the runner rejects", async () => {
|
|
101
|
+
seedHealthyPackage(tmpDir, "dirty-pkg");
|
|
102
|
+
|
|
103
|
+
const result = await runPackageHealth(makeInput(), makeContext(tmpDir), () => ({
|
|
104
|
+
ok: false,
|
|
105
|
+
detail: "eslint: 3 errors",
|
|
106
|
+
}));
|
|
107
|
+
|
|
108
|
+
expect(result.exitCode).toBe(1);
|
|
109
|
+
expect(result.data?.passed).toBe(false);
|
|
110
|
+
expect(result.data?.lintSurface).toEqual({ "@test/dirty-pkg": "fail" });
|
|
111
|
+
const v06 = result.data?.violations.find((v) => v.ruleId === "PKG-HEALTH-06");
|
|
112
|
+
expect(v06).toBeDefined();
|
|
113
|
+
expect(v06?.severity).toBe("error");
|
|
114
|
+
expect(v06?.packageName).toBe("@test/dirty-pkg");
|
|
115
|
+
// no lint script → eslint fallback flag surfaced in fixHint
|
|
116
|
+
expect(v06?.fixHint).toContain("exec eslint");
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
test("uses projectDir from extract.config.yaml when declared", async () => {
|
|
120
|
+
seedHealthyPackage(tmpDir, "mapped-pkg", { projectDir: "packages/mapped-pkg" });
|
|
121
|
+
|
|
122
|
+
const calls: string[] = [];
|
|
123
|
+
await runPackageHealth(makeInput(), makeContext(tmpDir), (dir) => {
|
|
124
|
+
calls.push(dir);
|
|
125
|
+
return { ok: true, detail: "" };
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
expect(calls).toEqual([join(tmpDir, "packages", "mapped-pkg")]);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
test("skips the probe for packages without extract.config.yaml", async () => {
|
|
132
|
+
const pkgDir = join(tmpDir, "packages", "no-extract");
|
|
133
|
+
mkdirSync(pkgDir, { recursive: true });
|
|
134
|
+
writePkgJson(pkgDir, {
|
|
135
|
+
name: "@test/no-extract",
|
|
136
|
+
version: "1.0.0",
|
|
137
|
+
private: false,
|
|
138
|
+
type: "module",
|
|
139
|
+
engines: { node: ">=24 <25" },
|
|
140
|
+
scripts: {},
|
|
141
|
+
});
|
|
142
|
+
mkdirSync(join(pkgDir, ".github", "workflows"), { recursive: true });
|
|
143
|
+
writeFileSync(join(pkgDir, ".github", "workflows", "ci.yml"), "name: CI\n");
|
|
144
|
+
|
|
145
|
+
let invoked = false;
|
|
146
|
+
const result = await runPackageHealth(makeInput(), makeContext(tmpDir), () => {
|
|
147
|
+
invoked = true;
|
|
148
|
+
return { ok: true, detail: "" };
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
expect(invoked).toBe(false);
|
|
152
|
+
expect(result.data?.lintSurface).toEqual({});
|
|
153
|
+
});
|