@punks/cli 5.1.1 → 5.2.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/AGENTS.md +28 -10
- package/dist/BASELINE_CHANGELOG.md +19 -1
- package/dist/CHANGELOG.md +49 -0
- package/dist/baseline/scaffold-baseline/baseline.json +5 -10
- package/dist/baseline/scaffold-baseline/data/catalog/packs.json +1 -1
- package/dist/baseline/scaffold-baseline/data/catalog/skills.json +0 -8
- package/dist/baseline/scaffold-baseline/data/hooks/format-edited-file.mjs +408 -309
- package/dist/baseline/scaffold-baseline/data/scripts/commit-gate-runner.d.ts +1 -0
- package/dist/baseline/scaffold-baseline/data/scripts/commit-gate-runner.mjs +206 -58
- package/dist/baseline/scaffold-baseline/data/scripts/commit-gate-runner.test.ts +496 -29
- package/dist/baseline/scaffold-baseline/data/scripts/managed-lint-runner.d.mts +55 -0
- package/dist/baseline/scaffold-baseline/data/scripts/managed-lint-runner.mjs +323 -0
- package/dist/baseline/scaffold-baseline/data/scripts/managed-lint-runner.test.ts +821 -0
- package/dist/baseline/scaffold-baseline/data/scripts/managed-lint.d.mts +97 -0
- package/dist/baseline/scaffold-baseline/data/scripts/managed-lint.mjs +658 -0
- package/dist/baseline/scaffold-baseline/data/scripts/managed-lint.test.ts +614 -0
- package/dist/baseline/scaffold-baseline/data/scripts/sync-subagents-validator.test.ts +39 -0
- package/dist/baseline/scaffold-baseline/data/scripts/sync-subagents.mjs +8 -2
- package/dist/baseline/scaffold-baseline/skills/agnostic/cli/hi-cli/SKILL.md +2 -0
- package/dist/baseline/scaffold-baseline/skills/agnostic/cli/hi-cli/references/commands.md +6 -7
- package/dist/baseline/scaffold-baseline/skills/agnostic/cli/hi-cli/references/managed-lint.md +165 -0
- package/dist/baseline/scaffold-baseline/skills/agnostic/cli/hi-cli/references/post-command-flow.md +20 -19
- package/dist/baseline/scaffold-baseline/skills/agnostic/docs/write-graph-based-skills/phases/define-handoffs.md +1 -1
- package/dist/baseline/scaffold-baseline/skills/agnostic/docs/write-graph-based-skills/phases/model-state.md +1 -1
- package/dist/baseline/scaffold-baseline/skills/agnostic/docs/write-graph-based-skills/phases/test-routes.md +1 -1
- package/dist/baseline/scaffold-baseline/skills/agnostic/docs/write-graph-based-skills/phases/write-phases.md +2 -2
- package/dist/baseline/scaffold-baseline/skills/agnostic/docs/write-graph-based-skills/phases/write-router.md +1 -1
- package/dist/baseline/scaffold-baseline/skills/agnostic/docs/write-graph-based-skills/references/authoring-contract.md +8 -8
- package/dist/baseline/scaffold-baseline/skills/agnostic/quality/autoreview/SKILL.md +1 -1
- package/dist/baseline/scaffold-baseline/skills/agnostic/quality/make-tsuite/SKILL.md +2 -2
- package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/brainstorm/SKILL.md +21 -11
- package/dist/baseline/scaffold-baseline/skills/phases/debugging-phase/SKILL.md +3 -4
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/SKILL.md +2 -2
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/debug.md +2 -2
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/human-steering.md +25 -0
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/implement.md +2 -2
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/review.md +2 -2
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/router.md +3 -2
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/references/context-continuity.md +1 -1
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/references/failure-continuity.md +1 -1
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/references/phase-handoff.md +4 -3
- package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/AUTHORING-HANDOFF.md +9 -9
- package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/SKILL.md +1 -1
- package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/ensure-fog.md +1 -1
- package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/grilling.md +1 -1
- package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/human-steering.md +25 -0
- package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/prototype.md +1 -1
- package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/reconcile.md +1 -1
- package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/research.md +1 -1
- package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/router.md +1 -1
- package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/references/state-graph.md +1 -1
- package/dist/baseline/scaffold-baseline/skills/phases/review-phase/phases/return-route.md +6 -5
- package/dist/baseline/scaffold-baseline/skills/phases/review-phase/phases/router.md +1 -1
- package/dist/baseline/scaffold-baseline/skills/phases/review-phase/phases/run-review.md +2 -1
- package/dist/baseline/scaffold-baseline/skills/phases/review-phase/references/state-graph.md +3 -3
- package/dist/baseline/scaffold-baseline.json +5 -5
- package/dist/baseline/scaffold-baseline.tgz +0 -0
- package/dist/data/AGENTS.md +22 -5
- package/dist/data/hooks/format-edited-file.mjs +237 -325
- package/dist/data/scripts/commit-gate-runner.mjs +206 -58
- package/dist/data/scripts/managed-lint-runner.d.mts +55 -0
- package/dist/data/scripts/managed-lint-runner.mjs +323 -0
- package/dist/data/scripts/managed-lint.d.mts +97 -0
- package/dist/data/scripts/managed-lint.mjs +658 -0
- package/dist/data/scripts/sync-subagents.mjs +8 -2
- package/dist/index.js +131 -153
- package/dist/skills/agnostic/cli/hi-cli/SKILL.md +2 -0
- package/dist/skills/agnostic/cli/hi-cli/references/commands.md +6 -7
- package/dist/skills/agnostic/cli/hi-cli/references/managed-lint.md +165 -0
- package/dist/skills/agnostic/cli/hi-cli/references/post-command-flow.md +6 -5
- package/dist/skills/agnostic/docs/write-graph-based-skills/phases/define-handoffs.md +1 -1
- package/dist/skills/agnostic/docs/write-graph-based-skills/phases/model-state.md +1 -1
- package/dist/skills/agnostic/docs/write-graph-based-skills/phases/test-routes.md +1 -1
- package/dist/skills/agnostic/docs/write-graph-based-skills/phases/write-phases.md +2 -2
- package/dist/skills/agnostic/docs/write-graph-based-skills/phases/write-router.md +1 -1
- package/dist/skills/agnostic/docs/write-graph-based-skills/references/authoring-contract.md +8 -8
- package/dist/skills/agnostic/quality/autoreview/SKILL.md +1 -1
- package/dist/skills/agnostic/quality/make-tsuite/SKILL.md +2 -2
- package/dist/skills/agnostic/requirements/brainstorm/SKILL.md +21 -11
- package/dist/skills/phases/debugging-phase/SKILL.md +3 -4
- package/dist/skills/phases/delivery-phase/SKILL.md +2 -2
- package/dist/skills/phases/delivery-phase/phases/debug.md +2 -2
- package/dist/skills/phases/delivery-phase/phases/human-steering.md +25 -0
- package/dist/skills/phases/delivery-phase/phases/implement.md +2 -2
- package/dist/skills/phases/delivery-phase/phases/review.md +2 -2
- package/dist/skills/phases/delivery-phase/phases/router.md +3 -2
- package/dist/skills/phases/delivery-phase/references/context-continuity.md +1 -1
- package/dist/skills/phases/delivery-phase/references/failure-continuity.md +1 -1
- package/dist/skills/phases/delivery-phase/references/phase-handoff.md +4 -3
- package/dist/skills/phases/finder-phase/AUTHORING-HANDOFF.md +6 -6
- package/dist/skills/phases/finder-phase/SKILL.md +1 -1
- package/dist/skills/phases/finder-phase/phases/ensure-fog.md +1 -1
- package/dist/skills/phases/finder-phase/phases/grilling.md +1 -1
- package/dist/skills/phases/finder-phase/phases/human-steering.md +25 -0
- package/dist/skills/phases/finder-phase/phases/prototype.md +1 -1
- package/dist/skills/phases/finder-phase/phases/reconcile.md +1 -1
- package/dist/skills/phases/finder-phase/phases/research.md +1 -1
- package/dist/skills/phases/finder-phase/phases/router.md +1 -1
- package/dist/skills/phases/finder-phase/references/state-graph.md +1 -1
- package/dist/skills/phases/review-phase/phases/return-route.md +6 -5
- package/dist/skills/phases/review-phase/phases/router.md +1 -1
- package/dist/skills/phases/review-phase/phases/run-review.md +2 -1
- package/dist/skills/phases/review-phase/references/state-graph.md +3 -3
- package/package.json +12 -6
- package/dist/baseline/scaffold-baseline/skills/agnostic/generic/handback/SKILL.md +0 -27
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/handback.md +0 -27
- package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/handback.md +0 -29
- package/dist/skills/agnostic/generic/handback/SKILL.md +0 -27
- package/dist/skills/phases/delivery-phase/phases/handback.md +0 -27
- package/dist/skills/phases/finder-phase/phases/handback.md +0 -29
|
@@ -0,0 +1,821 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import {
|
|
3
|
+
mkdtempSync,
|
|
4
|
+
mkdirSync,
|
|
5
|
+
writeFileSync,
|
|
6
|
+
rmSync,
|
|
7
|
+
symlinkSync,
|
|
8
|
+
readFileSync,
|
|
9
|
+
existsSync,
|
|
10
|
+
} from "node:fs";
|
|
11
|
+
import os from "node:os";
|
|
12
|
+
import path from "node:path";
|
|
13
|
+
import { describe, it, expect } from "vitest";
|
|
14
|
+
import * as Schema from "effect/Schema";
|
|
15
|
+
import { runManagedLint } from "./managed-lint-runner.mjs";
|
|
16
|
+
|
|
17
|
+
const decoded = (source: string) => Schema.decodeUnknownSync(Schema.UnknownFromJsonString)(source);
|
|
18
|
+
const semantic = (source: string) => {
|
|
19
|
+
const value = decoded(source);
|
|
20
|
+
if (
|
|
21
|
+
typeof value !== "object" ||
|
|
22
|
+
value === null ||
|
|
23
|
+
!("results" in value) ||
|
|
24
|
+
!Array.isArray(value.results)
|
|
25
|
+
) {
|
|
26
|
+
throw new Error("Expected owner results");
|
|
27
|
+
}
|
|
28
|
+
return value.results.map((owner: unknown) => {
|
|
29
|
+
if (
|
|
30
|
+
typeof owner !== "object" ||
|
|
31
|
+
owner === null ||
|
|
32
|
+
!("command" in owner) ||
|
|
33
|
+
!("diagnostics" in owner)
|
|
34
|
+
) {
|
|
35
|
+
throw new Error("Expected owner result");
|
|
36
|
+
}
|
|
37
|
+
return { command: owner.command, diagnostics: owner.diagnostics };
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
const runner = path.join(import.meta.dirname, "managed-lint-runner.mjs");
|
|
41
|
+
const noFilesNotice = "No files found to lint. Please check your paths and ignore patterns.\n";
|
|
42
|
+
const emptyOutput = `${noFilesNotice}${JSON.stringify({ diagnostics: [], number_of_files: 0 })}`;
|
|
43
|
+
const withEmptyOwner = (run: (root: string, version: string) => void) => {
|
|
44
|
+
const root = mkdtempSync(path.join(os.tmpdir(), "managed-runner-empty-"));
|
|
45
|
+
try {
|
|
46
|
+
mkdirSync(path.join(root, ".devpunks/specs/lint"), { recursive: true });
|
|
47
|
+
symlinkSync(
|
|
48
|
+
path.resolve(import.meta.dirname, "../../../../../node_modules"),
|
|
49
|
+
path.join(root, "node_modules"),
|
|
50
|
+
"dir",
|
|
51
|
+
);
|
|
52
|
+
const tool = Schema.decodeUnknownSync(Schema.Struct({ version: Schema.String }))(
|
|
53
|
+
decoded(readFileSync(path.join(root, "node_modules/oxlint/package.json"), "utf-8")),
|
|
54
|
+
);
|
|
55
|
+
writeFileSync(path.join(root, "package.json"), '{"type":"module"}\n');
|
|
56
|
+
writeFileSync(
|
|
57
|
+
path.join(root, "oxlint.config.ts"),
|
|
58
|
+
'export default {ignorePatterns: ["oxlint.config.ts"]};\n',
|
|
59
|
+
);
|
|
60
|
+
writeFileSync(
|
|
61
|
+
path.join(root, ".devpunks/settings.json"),
|
|
62
|
+
JSON.stringify({ lint: { scopes: ["."] } }),
|
|
63
|
+
);
|
|
64
|
+
writeFileSync(
|
|
65
|
+
path.join(root, ".devpunks/specs/lint/selection.json"),
|
|
66
|
+
JSON.stringify({
|
|
67
|
+
managedLint: {
|
|
68
|
+
exclude: [],
|
|
69
|
+
routes: [
|
|
70
|
+
{
|
|
71
|
+
config: "oxlint.config.ts",
|
|
72
|
+
inputs: [],
|
|
73
|
+
maxWarnings: 0,
|
|
74
|
+
scope: ".",
|
|
75
|
+
tool: { package: "oxlint", version: tool.version },
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
scopes: ["."],
|
|
79
|
+
version: 1,
|
|
80
|
+
},
|
|
81
|
+
}),
|
|
82
|
+
);
|
|
83
|
+
run(root, tool.version);
|
|
84
|
+
} finally {
|
|
85
|
+
rmSync(root, { force: true, recursive: true });
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
describe("managed lint execution", () => {
|
|
89
|
+
it.each(["missing", "conflict", "stale", "no-scopes"])(
|
|
90
|
+
"skips excluded-only work with %s selection",
|
|
91
|
+
(state) => {
|
|
92
|
+
withEmptyOwner((root) => {
|
|
93
|
+
const exclude = ["examples/**"];
|
|
94
|
+
writeFileSync(
|
|
95
|
+
path.join(root, ".devpunks/settings.json"),
|
|
96
|
+
JSON.stringify({
|
|
97
|
+
lint: state === "no-scopes" ? { exclude } : { exclude, scopes: ["."] },
|
|
98
|
+
}),
|
|
99
|
+
);
|
|
100
|
+
const artifact = path.join(root, ".devpunks/specs/lint/selection.json");
|
|
101
|
+
if (state === "missing" || state === "no-scopes") {
|
|
102
|
+
rmSync(artifact);
|
|
103
|
+
}
|
|
104
|
+
if (state === "conflict") {
|
|
105
|
+
writeFileSync(artifact, JSON.stringify({ lintEvidence: { status: "conflict" } }));
|
|
106
|
+
}
|
|
107
|
+
// The stale artifact retains its original exclude list and tool identity.
|
|
108
|
+
const invoke = (args: string[]) =>
|
|
109
|
+
spawnSync(process.execPath, [runner, "--root", root, "--format", "json", ...args], {
|
|
110
|
+
cwd: root,
|
|
111
|
+
encoding: "utf-8",
|
|
112
|
+
});
|
|
113
|
+
for (const file of ["apps/wiki/page.tsx", "examples/fixture/source.ts"]) {
|
|
114
|
+
const result = invoke(["--", file]);
|
|
115
|
+
expect({ output: decoded(result.stdout), status: result.status }).toMatchObject({
|
|
116
|
+
output: { code: 0, results: [], status: "clean" },
|
|
117
|
+
status: 0,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
for (const args of [
|
|
121
|
+
[],
|
|
122
|
+
["--", "source.ts"],
|
|
123
|
+
["--", "apps/wiki/page.tsx", "source.ts"],
|
|
124
|
+
["--scope", "not-selected", "--", "apps/wiki/page.tsx"],
|
|
125
|
+
["--", ".devpunks/settings.json"],
|
|
126
|
+
["--", ".devpunks/specs/lint/selection.json"],
|
|
127
|
+
]) {
|
|
128
|
+
expect(invoke(args).status).toBe(2);
|
|
129
|
+
}
|
|
130
|
+
expect(invoke(["--scope", ".", "--", "apps/wiki/page.tsx"]).status).toBe(
|
|
131
|
+
state === "no-scopes" ? 2 : 0,
|
|
132
|
+
);
|
|
133
|
+
});
|
|
134
|
+
},
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
it.each([
|
|
138
|
+
{ evidence: "oxlint.config.ts", file: "oxlint.config.ts" },
|
|
139
|
+
{ evidence: "shared/renamed-policy.json", file: "shared/renamed-policy.json" },
|
|
140
|
+
{ evidence: "package.json#scripts.lint", file: "package.json" },
|
|
141
|
+
])(
|
|
142
|
+
"preserves migration authority for $evidence before no-work detection",
|
|
143
|
+
({ evidence, file }) => {
|
|
144
|
+
withEmptyOwner((root) => {
|
|
145
|
+
mkdirSync(path.join(root, "owner"));
|
|
146
|
+
writeFileSync(path.join(root, "owner/package.json"), "{}");
|
|
147
|
+
writeFileSync(
|
|
148
|
+
path.join(root, ".devpunks/settings.json"),
|
|
149
|
+
JSON.stringify({ lint: { exclude: ["examples/**"], scopes: ["owner"] } }),
|
|
150
|
+
);
|
|
151
|
+
writeFileSync(
|
|
152
|
+
path.join(root, ".devpunks/specs/lint/selection.json"),
|
|
153
|
+
JSON.stringify({
|
|
154
|
+
lintEvidence: {
|
|
155
|
+
conflicts: [{ path: evidence, reason: "Unresolved authored lint authority" }],
|
|
156
|
+
status: "conflict",
|
|
157
|
+
},
|
|
158
|
+
managedLint: { exclude: ["examples/**"], routes: [], scopes: ["owner"], version: 1 },
|
|
159
|
+
}),
|
|
160
|
+
);
|
|
161
|
+
for (const requested of [file, "apps/wiki/page.tsx", "examples/demo.ts"]) {
|
|
162
|
+
const isAuthority = requested === file;
|
|
163
|
+
const result = spawnSync(
|
|
164
|
+
process.execPath,
|
|
165
|
+
[runner, "--root", root, "--format", "json", "--", requested],
|
|
166
|
+
{ cwd: root, encoding: "utf-8" },
|
|
167
|
+
);
|
|
168
|
+
expect(result.status).toBe(isAuthority ? 2 : 0);
|
|
169
|
+
expect(decoded(result.stdout)).toMatchObject({
|
|
170
|
+
status: isAuthority ? "conflict" : "clean",
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
spawnSync("git", ["init", "-q"], { cwd: root });
|
|
174
|
+
writeFileSync(
|
|
175
|
+
path.join(root, ".devpunks/scaffold-manifest.json"),
|
|
176
|
+
JSON.stringify({ managedFiles: [] }),
|
|
177
|
+
);
|
|
178
|
+
const preview = spawnSync(
|
|
179
|
+
process.execPath,
|
|
180
|
+
[path.resolve(import.meta.dirname, "../hooks/format-edited-file.mjs"), "preview", file],
|
|
181
|
+
{ cwd: root, encoding: "utf-8" },
|
|
182
|
+
);
|
|
183
|
+
expect(decoded(preview.stdout)).toMatchObject({
|
|
184
|
+
failures: [expect.objectContaining({ command: "managed lint selection" })],
|
|
185
|
+
result: "operational_failure",
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
},
|
|
189
|
+
);
|
|
190
|
+
|
|
191
|
+
it("retains excluded dependency failures while skipping unrelated package boundaries", () => {
|
|
192
|
+
withEmptyOwner((root, version) => {
|
|
193
|
+
mkdirSync(path.join(root, "nested"));
|
|
194
|
+
writeFileSync(path.join(root, "nested/package.json"), "{}");
|
|
195
|
+
writeFileSync(
|
|
196
|
+
path.join(root, ".devpunks/settings.json"),
|
|
197
|
+
JSON.stringify({ lint: { exclude: ["oxlint.config.ts", "wiki/**"], scopes: ["."] } }),
|
|
198
|
+
);
|
|
199
|
+
writeFileSync(
|
|
200
|
+
path.join(root, ".devpunks/specs/lint/selection.json"),
|
|
201
|
+
JSON.stringify({
|
|
202
|
+
managedLint: {
|
|
203
|
+
exclude: [],
|
|
204
|
+
routes: [
|
|
205
|
+
{
|
|
206
|
+
config: "oxlint.config.ts",
|
|
207
|
+
inputs: ["wiki/policy.json"],
|
|
208
|
+
maxWarnings: 0,
|
|
209
|
+
scope: ".",
|
|
210
|
+
tool: { package: "oxlint", version },
|
|
211
|
+
},
|
|
212
|
+
],
|
|
213
|
+
scopes: ["."],
|
|
214
|
+
version: 1,
|
|
215
|
+
},
|
|
216
|
+
}),
|
|
217
|
+
);
|
|
218
|
+
const invoke = (file: string) =>
|
|
219
|
+
spawnSync(process.execPath, [runner, "--root", root, "--format", "json", "--", file], {
|
|
220
|
+
cwd: root,
|
|
221
|
+
encoding: "utf-8",
|
|
222
|
+
});
|
|
223
|
+
expect(invoke("nested/source.ts").status).toBe(0);
|
|
224
|
+
for (const file of [
|
|
225
|
+
"wiki/policy.json",
|
|
226
|
+
"oxlint.config.ts",
|
|
227
|
+
".devpunks/settings.json",
|
|
228
|
+
".devpunks/specs/lint/selection.json",
|
|
229
|
+
]) {
|
|
230
|
+
expect(invoke(file).status).toBe(2);
|
|
231
|
+
}
|
|
232
|
+
writeFileSync(
|
|
233
|
+
path.join(root, ".devpunks/settings.json"),
|
|
234
|
+
JSON.stringify({ lint: { scopes: ["nested"] } }),
|
|
235
|
+
);
|
|
236
|
+
rmSync(path.join(root, ".devpunks/specs/lint/selection.json"));
|
|
237
|
+
expect(invoke("unrelated/source.ts").status).toBe(0);
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
it("requires software scope selection when the settings file is absent without running lint", () => {
|
|
242
|
+
withEmptyOwner((root) => {
|
|
243
|
+
rmSync(path.join(root, ".devpunks/settings.json"));
|
|
244
|
+
const marker = path.join(root, "lint-ran");
|
|
245
|
+
writeFileSync(path.join(root, "source.ts"), "export const value = 1;\n");
|
|
246
|
+
writeFileSync(
|
|
247
|
+
path.join(root, "oxlint.config.ts"),
|
|
248
|
+
`import { writeFileSync } from "node:fs";\nwriteFileSync(${JSON.stringify(marker)}, "executed");\nexport default {};\n`,
|
|
249
|
+
);
|
|
250
|
+
const result = spawnSync(process.execPath, [runner, "--root", root, "--format", "json"], {
|
|
251
|
+
cwd: root,
|
|
252
|
+
encoding: "utf-8",
|
|
253
|
+
});
|
|
254
|
+
expect(result.status).toBe(2);
|
|
255
|
+
expect(decoded(result.stdout)).toStrictEqual({
|
|
256
|
+
code: 2,
|
|
257
|
+
diagnostics: [expect.stringContaining(".devpunks/settings.json lint.scopes")],
|
|
258
|
+
status: "selection-needed",
|
|
259
|
+
});
|
|
260
|
+
expect(result.stderr).toContain(".devpunks/settings.json lint.scopes");
|
|
261
|
+
expect(existsSync(marker)).toBeFalsy();
|
|
262
|
+
});
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
it.each([null, [], { lint: [] }, { lint: null }])(
|
|
266
|
+
"rejects malformed settings before exclusion proof: %j",
|
|
267
|
+
(settings) => {
|
|
268
|
+
withEmptyOwner((root) => {
|
|
269
|
+
writeFileSync(path.join(root, ".devpunks/settings.json"), JSON.stringify(settings));
|
|
270
|
+
const result = spawnSync(
|
|
271
|
+
process.execPath,
|
|
272
|
+
[runner, "--root", root, "--format", "json", "--", "wiki/page.ts"],
|
|
273
|
+
{ cwd: root, encoding: "utf-8" },
|
|
274
|
+
);
|
|
275
|
+
expect(result.status).toBe(2);
|
|
276
|
+
expect(decoded(result.stdout)).toMatchObject({ code: 2, status: "conflict" });
|
|
277
|
+
});
|
|
278
|
+
},
|
|
279
|
+
);
|
|
280
|
+
|
|
281
|
+
it("rejects invalid explicit paths before empty-work proof", async () => {
|
|
282
|
+
const root = mkdtempSync(path.join(os.tmpdir(), "managed-runner-invalid-"));
|
|
283
|
+
try {
|
|
284
|
+
mkdirSync(path.join(root, ".devpunks"));
|
|
285
|
+
writeFileSync(
|
|
286
|
+
path.join(root, ".devpunks/settings.json"),
|
|
287
|
+
JSON.stringify({ lint: { exclude: ["**"], scopes: ["."] } }),
|
|
288
|
+
);
|
|
289
|
+
await Promise.all(
|
|
290
|
+
["../source.ts", "/source.ts", "wiki/../source.ts"].map(async (file) => {
|
|
291
|
+
await expect(runManagedLint({ paths: [file], root })).resolves.toMatchObject({
|
|
292
|
+
code: 2,
|
|
293
|
+
status: "conflict",
|
|
294
|
+
});
|
|
295
|
+
}),
|
|
296
|
+
);
|
|
297
|
+
} finally {
|
|
298
|
+
rmSync(root, { force: true, recursive: true });
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
it("leaves bundled host command arguments to the host", () => {
|
|
303
|
+
const root = mkdtempSync(path.join(os.tmpdir(), "managed-runner-host-"));
|
|
304
|
+
try {
|
|
305
|
+
const entry = path.join(root, "entry.mjs");
|
|
306
|
+
const bundle = path.join(root, "host.mjs");
|
|
307
|
+
writeFileSync(
|
|
308
|
+
entry,
|
|
309
|
+
`import { runManagedLint } from ${JSON.stringify(runner)};\nconsole.log(typeof runManagedLint);\n`,
|
|
310
|
+
);
|
|
311
|
+
const built = spawnSync(
|
|
312
|
+
process.env.HI_TEST_BUN_PATH ?? "bun",
|
|
313
|
+
["build", entry, "--target=node", "--format=esm", "--outfile", bundle],
|
|
314
|
+
{ encoding: "utf-8" },
|
|
315
|
+
);
|
|
316
|
+
expect({ status: built.status, stderr: built.stderr }).toStrictEqual({
|
|
317
|
+
status: 0,
|
|
318
|
+
stderr: "",
|
|
319
|
+
});
|
|
320
|
+
for (const host of [entry, bundle]) {
|
|
321
|
+
const result = spawnSync(process.execPath, [host, "--help"], {
|
|
322
|
+
cwd: root,
|
|
323
|
+
encoding: "utf-8",
|
|
324
|
+
});
|
|
325
|
+
expect({
|
|
326
|
+
status: result.status,
|
|
327
|
+
stderr: result.stderr,
|
|
328
|
+
stdout: result.stdout,
|
|
329
|
+
}).toStrictEqual({ status: 0, stderr: "", stdout: "function\n" });
|
|
330
|
+
}
|
|
331
|
+
} finally {
|
|
332
|
+
rmSync(root, { force: true, recursive: true });
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
const nativeLaunchError: unknown = expect.objectContaining({ code: "EACCES" });
|
|
337
|
+
|
|
338
|
+
it.each([
|
|
339
|
+
{
|
|
340
|
+
error: undefined,
|
|
341
|
+
executable: true,
|
|
342
|
+
kind: "malformed-output",
|
|
343
|
+
name: "native exit",
|
|
344
|
+
signal: null,
|
|
345
|
+
source: "process.exitCode = 7;",
|
|
346
|
+
status: 7,
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
error: undefined,
|
|
350
|
+
executable: true,
|
|
351
|
+
kind: "process",
|
|
352
|
+
name: "interruption",
|
|
353
|
+
signal: "SIGTERM",
|
|
354
|
+
source: 'process.kill(process.pid, "SIGTERM");',
|
|
355
|
+
status: null,
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
error: nativeLaunchError,
|
|
359
|
+
executable: false,
|
|
360
|
+
kind: "process",
|
|
361
|
+
name: "launch failure",
|
|
362
|
+
signal: null,
|
|
363
|
+
source: "",
|
|
364
|
+
status: null,
|
|
365
|
+
},
|
|
366
|
+
])(
|
|
367
|
+
"preserves $name evidence beside normalized failure",
|
|
368
|
+
async ({ source, executable, status, signal, error, kind }) => {
|
|
369
|
+
const root = mkdtempSync(path.join(os.tmpdir(), "managed-runner-witness-"));
|
|
370
|
+
try {
|
|
371
|
+
mkdirSync(path.join(root, ".devpunks/specs/lint"), { recursive: true });
|
|
372
|
+
mkdirSync(path.join(root, "node_modules/oxlint/bin"), { recursive: true });
|
|
373
|
+
writeFileSync(path.join(root, "package.json"), "{}");
|
|
374
|
+
writeFileSync(path.join(root, "source.ts"), "console.log(1);");
|
|
375
|
+
writeFileSync(path.join(root, "oxlint.config.ts"), "export default {};");
|
|
376
|
+
writeFileSync(
|
|
377
|
+
path.join(root, ".devpunks/settings.json"),
|
|
378
|
+
JSON.stringify({ lint: { scopes: ["."] } }),
|
|
379
|
+
);
|
|
380
|
+
writeFileSync(
|
|
381
|
+
path.join(root, ".devpunks/specs/lint/selection.json"),
|
|
382
|
+
JSON.stringify({
|
|
383
|
+
managedLint: {
|
|
384
|
+
exclude: [],
|
|
385
|
+
routes: [
|
|
386
|
+
{
|
|
387
|
+
config: "oxlint.config.ts",
|
|
388
|
+
inputs: [],
|
|
389
|
+
maxWarnings: 0,
|
|
390
|
+
scope: ".",
|
|
391
|
+
tool: { package: "oxlint", version: "1.80.0" },
|
|
392
|
+
},
|
|
393
|
+
],
|
|
394
|
+
scopes: ["."],
|
|
395
|
+
version: 1,
|
|
396
|
+
},
|
|
397
|
+
}),
|
|
398
|
+
);
|
|
399
|
+
writeFileSync(
|
|
400
|
+
path.join(root, "node_modules/oxlint/package.json"),
|
|
401
|
+
JSON.stringify({ bin: "bin/oxlint", name: "oxlint", version: "1.80.0" }),
|
|
402
|
+
);
|
|
403
|
+
writeFileSync(
|
|
404
|
+
path.join(root, "node_modules/oxlint/bin/oxlint"),
|
|
405
|
+
`#!/usr/bin/env node\n${source}\n`,
|
|
406
|
+
{ mode: executable ? 0o755 : 0o644 },
|
|
407
|
+
);
|
|
408
|
+
const result = await runManagedLint({ root });
|
|
409
|
+
expect(result).toMatchObject({
|
|
410
|
+
code: 2,
|
|
411
|
+
results: [{ code: 2, error, failure: { kind, phase: "lint" }, signal, status }],
|
|
412
|
+
status: "operational-failure",
|
|
413
|
+
});
|
|
414
|
+
} finally {
|
|
415
|
+
rmSync(root, { force: true, recursive: true });
|
|
416
|
+
}
|
|
417
|
+
},
|
|
418
|
+
);
|
|
419
|
+
|
|
420
|
+
it.each([true, false])(
|
|
421
|
+
"succeeds without lint source and retains context (module type: %s)",
|
|
422
|
+
(moduleType) => {
|
|
423
|
+
withEmptyOwner((root, version) => {
|
|
424
|
+
if (!moduleType) {
|
|
425
|
+
writeFileSync(path.join(root, "package.json"), "{}\n");
|
|
426
|
+
}
|
|
427
|
+
const result = spawnSync(process.execPath, [runner, "--root", root, "--format", "json"], {
|
|
428
|
+
cwd: root,
|
|
429
|
+
encoding: "utf-8",
|
|
430
|
+
});
|
|
431
|
+
expect(result.status).toBe(0);
|
|
432
|
+
expect(decoded(result.stdout)).toMatchObject({
|
|
433
|
+
code: 0,
|
|
434
|
+
results: [
|
|
435
|
+
{
|
|
436
|
+
code: 0,
|
|
437
|
+
command: {
|
|
438
|
+
args: [
|
|
439
|
+
"--config",
|
|
440
|
+
path.join(root, "oxlint.config.ts"),
|
|
441
|
+
"--disable-nested-config",
|
|
442
|
+
"--max-warnings",
|
|
443
|
+
"0",
|
|
444
|
+
"--format",
|
|
445
|
+
"json",
|
|
446
|
+
"--",
|
|
447
|
+
"oxlint.config.ts",
|
|
448
|
+
"package.json",
|
|
449
|
+
],
|
|
450
|
+
config: path.join(root, "oxlint.config.ts"),
|
|
451
|
+
cwd: root,
|
|
452
|
+
executable: path.join(root, "node_modules/oxlint/bin/oxlint"),
|
|
453
|
+
scope: ".",
|
|
454
|
+
toolVersion: version,
|
|
455
|
+
},
|
|
456
|
+
diagnostics: [],
|
|
457
|
+
},
|
|
458
|
+
],
|
|
459
|
+
status: "clean",
|
|
460
|
+
});
|
|
461
|
+
expect(result.stdout).toContain("No files found to lint.");
|
|
462
|
+
});
|
|
463
|
+
},
|
|
464
|
+
);
|
|
465
|
+
|
|
466
|
+
it.each([true, false])(
|
|
467
|
+
"classifies ordinary clean and finding reports (module type: %s)",
|
|
468
|
+
(moduleType) => {
|
|
469
|
+
withEmptyOwner((root) => {
|
|
470
|
+
if (!moduleType) {
|
|
471
|
+
writeFileSync(path.join(root, "package.json"), "{}\n");
|
|
472
|
+
}
|
|
473
|
+
writeFileSync(path.join(root, "source.ts"), "console.log(1);\n");
|
|
474
|
+
const invoke = () =>
|
|
475
|
+
spawnSync(
|
|
476
|
+
process.execPath,
|
|
477
|
+
[runner, "--root", root, "--format", "json", "--", "source.ts"],
|
|
478
|
+
{ cwd: root, encoding: "utf-8" },
|
|
479
|
+
);
|
|
480
|
+
writeFileSync(
|
|
481
|
+
path.join(root, "oxlint.config.ts"),
|
|
482
|
+
'export default {rules: {"no-console": "off"}};\n',
|
|
483
|
+
);
|
|
484
|
+
const clean = invoke();
|
|
485
|
+
expect(clean.status).toBe(0);
|
|
486
|
+
expect(decoded(clean.stdout)).toMatchObject({
|
|
487
|
+
results: [{ code: 0, diagnostics: [], signal: null, status: 0 }],
|
|
488
|
+
status: "clean",
|
|
489
|
+
});
|
|
490
|
+
writeFileSync(
|
|
491
|
+
path.join(root, "oxlint.config.ts"),
|
|
492
|
+
'export default {rules: {"no-console": "error"}};\n',
|
|
493
|
+
);
|
|
494
|
+
const findings = invoke();
|
|
495
|
+
expect(findings.status).toBe(1);
|
|
496
|
+
expect(decoded(findings.stdout)).toMatchObject({
|
|
497
|
+
results: [
|
|
498
|
+
{
|
|
499
|
+
code: 1,
|
|
500
|
+
diagnostics: [expect.objectContaining({ filename: "source.ts" })],
|
|
501
|
+
signal: null,
|
|
502
|
+
status: 1,
|
|
503
|
+
},
|
|
504
|
+
],
|
|
505
|
+
status: "findings",
|
|
506
|
+
});
|
|
507
|
+
});
|
|
508
|
+
},
|
|
509
|
+
);
|
|
510
|
+
|
|
511
|
+
it("honors ignored source without removing lint coverage when the policy changes", () => {
|
|
512
|
+
withEmptyOwner((root) => {
|
|
513
|
+
writeFileSync(path.join(root, "source.ts"), "console.log(1);\n");
|
|
514
|
+
writeFileSync(
|
|
515
|
+
path.join(root, "oxlint.config.ts"),
|
|
516
|
+
'export default {ignorePatterns: ["oxlint.config.ts", "source.ts"], rules: {"no-console": "error"}};\n',
|
|
517
|
+
);
|
|
518
|
+
const invoke = () =>
|
|
519
|
+
spawnSync(process.execPath, [runner, "--format", "json", "--", "source.ts"], {
|
|
520
|
+
cwd: root,
|
|
521
|
+
encoding: "utf-8",
|
|
522
|
+
});
|
|
523
|
+
const ignored = invoke();
|
|
524
|
+
expect(ignored.status).toBe(0);
|
|
525
|
+
expect(decoded(ignored.stdout)).toMatchObject({
|
|
526
|
+
results: [{ diagnostics: [] }],
|
|
527
|
+
status: "clean",
|
|
528
|
+
});
|
|
529
|
+
writeFileSync(
|
|
530
|
+
path.join(root, "oxlint.config.ts"),
|
|
531
|
+
'export default {ignorePatterns: ["oxlint.config.ts"], rules: {"no-console": "error"}};\n',
|
|
532
|
+
);
|
|
533
|
+
const included = invoke();
|
|
534
|
+
expect(included.status).toBe(1);
|
|
535
|
+
expect(decoded(included.stdout)).toMatchObject({
|
|
536
|
+
results: [{ diagnostics: [expect.objectContaining({ filename: "source.ts" })] }],
|
|
537
|
+
status: "findings",
|
|
538
|
+
});
|
|
539
|
+
});
|
|
540
|
+
});
|
|
541
|
+
|
|
542
|
+
it("keeps staged non-source formatting checks active when lint has no work", () => {
|
|
543
|
+
withEmptyOwner((root) => {
|
|
544
|
+
for (const args of [
|
|
545
|
+
["init", "-q"],
|
|
546
|
+
["add", "--", "package.json"],
|
|
547
|
+
]) {
|
|
548
|
+
const result = spawnSync("git", args, { cwd: root, encoding: "utf-8" });
|
|
549
|
+
if (result.status !== 0) {
|
|
550
|
+
throw new Error(`Git fixture failed: ${result.stderr}`);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
writeFileSync(
|
|
554
|
+
path.join(root, ".devpunks/contracts.json"),
|
|
555
|
+
JSON.stringify([
|
|
556
|
+
{
|
|
557
|
+
execution: { formatCheck: "files", lint: "files" },
|
|
558
|
+
formatCheck: "oxfmt --check {files}",
|
|
559
|
+
lint: `node '${runner}' --format json -- {files}`,
|
|
560
|
+
path: ".",
|
|
561
|
+
},
|
|
562
|
+
]),
|
|
563
|
+
);
|
|
564
|
+
const before = readFileSync(path.join(root, "package.json"), "utf-8");
|
|
565
|
+
const gate = path.join(import.meta.dirname, "commit-gate-runner.mjs");
|
|
566
|
+
const invoke = () =>
|
|
567
|
+
spawnSync(process.execPath, [gate, "--contracts", ".devpunks/contracts.json"], {
|
|
568
|
+
cwd: root,
|
|
569
|
+
encoding: "utf-8",
|
|
570
|
+
});
|
|
571
|
+
const unformatted = invoke();
|
|
572
|
+
expect(unformatted.status).toBe(1);
|
|
573
|
+
expect(decoded(unformatted.stdout)).toMatchObject({ code: 0, status: "clean" });
|
|
574
|
+
expect(unformatted.stderr).toContain("Commit Gate formatCheck failed");
|
|
575
|
+
expect(readFileSync(path.join(root, "package.json"), "utf-8")).toBe(before);
|
|
576
|
+
const formatted = spawnSync(path.join(root, "node_modules/.bin/oxfmt"), ["package.json"], {
|
|
577
|
+
cwd: root,
|
|
578
|
+
encoding: "utf-8",
|
|
579
|
+
});
|
|
580
|
+
expect({ formatter: formatted.status, gate: invoke().status }).toStrictEqual({
|
|
581
|
+
formatter: 0,
|
|
582
|
+
gate: 0,
|
|
583
|
+
});
|
|
584
|
+
});
|
|
585
|
+
});
|
|
586
|
+
|
|
587
|
+
it.each([
|
|
588
|
+
{
|
|
589
|
+
kind: "config-load",
|
|
590
|
+
name: "clean JSON with configuration stderr",
|
|
591
|
+
status: 0,
|
|
592
|
+
stderr: "Failed to load configuration\n",
|
|
593
|
+
stdout: '{"diagnostics":[]}',
|
|
594
|
+
},
|
|
595
|
+
{
|
|
596
|
+
kind: "config-load",
|
|
597
|
+
name: "findings JSON with configuration stderr",
|
|
598
|
+
status: 1,
|
|
599
|
+
stderr: "Failed to load configuration\n",
|
|
600
|
+
stdout: '{"diagnostics":[{"message":"Failure"}]}',
|
|
601
|
+
},
|
|
602
|
+
{
|
|
603
|
+
kind: "config-load",
|
|
604
|
+
name: "forged module warning suffix",
|
|
605
|
+
status: 0,
|
|
606
|
+
stderr:
|
|
607
|
+
"(node:123) [MODULE_TYPELESS_PACKAGE_JSON] Warning: Module type of file:///tmp/config.ts is not specified and it doesn't parse as CommonJS. Configuration failed\n",
|
|
608
|
+
stdout: '{"diagnostics":[]}',
|
|
609
|
+
},
|
|
610
|
+
{
|
|
611
|
+
kind: "config-load",
|
|
612
|
+
name: "module warning followed by error",
|
|
613
|
+
status: 1,
|
|
614
|
+
stderr:
|
|
615
|
+
"(node:123) [MODULE_TYPELESS_PACKAGE_JSON] Warning: Module type of file:///tmp/config.ts is not specified and it doesn't parse as CommonJS.\nConfiguration failed\n",
|
|
616
|
+
stdout: '{"diagnostics":[{"message":"Failure"}]}',
|
|
617
|
+
},
|
|
618
|
+
{
|
|
619
|
+
kind: "process",
|
|
620
|
+
name: "ordinary stderr",
|
|
621
|
+
status: 0,
|
|
622
|
+
stderr: "Unexpected internal error\n",
|
|
623
|
+
stdout: '{"diagnostics":[]}',
|
|
624
|
+
},
|
|
625
|
+
{
|
|
626
|
+
kind: "config-load",
|
|
627
|
+
name: "native config parse output",
|
|
628
|
+
phase: "config",
|
|
629
|
+
status: 2,
|
|
630
|
+
stdout: "Failed to parse oxlint configuration file.\nInvalid property",
|
|
631
|
+
},
|
|
632
|
+
{
|
|
633
|
+
kind: "config-load",
|
|
634
|
+
name: "malformed output with configuration stderr",
|
|
635
|
+
status: 1,
|
|
636
|
+
stderr: "Failed to load configuration\n",
|
|
637
|
+
stdout: "not json",
|
|
638
|
+
},
|
|
639
|
+
{ kind: "process", name: "unproven empty diagnostics", stdout: '{"diagnostics":[]}' },
|
|
640
|
+
{
|
|
641
|
+
kind: "process",
|
|
642
|
+
name: "zero files without the notice",
|
|
643
|
+
stdout: '{"diagnostics":[],"number_of_files":0}',
|
|
644
|
+
},
|
|
645
|
+
{ name: "missing file count", stdout: `${noFilesNotice}{"diagnostics":[]}` },
|
|
646
|
+
{
|
|
647
|
+
name: "nonzero file count",
|
|
648
|
+
stdout: `${noFilesNotice}{"diagnostics":[],"number_of_files":1}`,
|
|
649
|
+
},
|
|
650
|
+
{
|
|
651
|
+
name: "invalid file count",
|
|
652
|
+
stdout: `${noFilesNotice}{"diagnostics":[],"number_of_files":"0"}`,
|
|
653
|
+
},
|
|
654
|
+
{ name: "malformed JSON", stdout: `${noFilesNotice}{ malformed` },
|
|
655
|
+
{ name: "trailing error output", stdout: `${emptyOutput}\nConfiguration error` },
|
|
656
|
+
{
|
|
657
|
+
name: "contradictory diagnostics",
|
|
658
|
+
stdout: `${noFilesNotice}{"diagnostics":[{"message":"Failure"}],"number_of_files":0}`,
|
|
659
|
+
},
|
|
660
|
+
{ name: "unexpected notice", stdout: `Configuration failed\n${emptyOutput}` },
|
|
661
|
+
{ kind: "process", name: "tool error status", status: 2, stdout: emptyOutput },
|
|
662
|
+
{
|
|
663
|
+
kind: "config-load",
|
|
664
|
+
name: "stderr error",
|
|
665
|
+
stderr: "Failed to load configuration\n",
|
|
666
|
+
stdout: emptyOutput,
|
|
667
|
+
},
|
|
668
|
+
{ executable: false, kind: "process", name: "tool launch failure", stdout: "" },
|
|
669
|
+
])(
|
|
670
|
+
"keeps $name operational and preserves the tool output",
|
|
671
|
+
({
|
|
672
|
+
stdout,
|
|
673
|
+
status = 1,
|
|
674
|
+
stderr = "",
|
|
675
|
+
executable = true,
|
|
676
|
+
kind = "malformed-output",
|
|
677
|
+
phase = "lint",
|
|
678
|
+
}) => {
|
|
679
|
+
withEmptyOwner((root, version) => {
|
|
680
|
+
rmSync(path.join(root, "node_modules"));
|
|
681
|
+
mkdirSync(path.join(root, "node_modules/oxlint/bin"), { recursive: true });
|
|
682
|
+
writeFileSync(
|
|
683
|
+
path.join(root, "node_modules/oxlint/package.json"),
|
|
684
|
+
JSON.stringify({ bin: "bin/oxlint", name: "oxlint", type: "module", version }),
|
|
685
|
+
);
|
|
686
|
+
writeFileSync(
|
|
687
|
+
path.join(root, "node_modules/oxlint/bin/oxlint"),
|
|
688
|
+
`#!/usr/bin/env node\nprocess.stdout.write(${JSON.stringify(stdout)});\nprocess.stderr.write(${JSON.stringify(stderr)});\nprocess.exitCode = ${status};\n`,
|
|
689
|
+
{ mode: executable ? 0o755 : 0o644 },
|
|
690
|
+
);
|
|
691
|
+
const result = spawnSync(process.execPath, [runner, "--root", root, "--format", "json"], {
|
|
692
|
+
cwd: root,
|
|
693
|
+
encoding: "utf-8",
|
|
694
|
+
});
|
|
695
|
+
const launchError: unknown = expect.stringContaining("EACCES");
|
|
696
|
+
expect(result.status).toBe(2);
|
|
697
|
+
expect(decoded(result.stdout)).toMatchObject({
|
|
698
|
+
code: 2,
|
|
699
|
+
results: [
|
|
700
|
+
{
|
|
701
|
+
code: 2,
|
|
702
|
+
command: {
|
|
703
|
+
config: path.join(root, "oxlint.config.ts"),
|
|
704
|
+
cwd: root,
|
|
705
|
+
executable: path.join(root, "node_modules/oxlint/bin/oxlint"),
|
|
706
|
+
toolVersion: version,
|
|
707
|
+
},
|
|
708
|
+
failure: { kind, phase },
|
|
709
|
+
stderr: executable ? stderr : launchError,
|
|
710
|
+
stdout,
|
|
711
|
+
},
|
|
712
|
+
],
|
|
713
|
+
status: "operational-failure",
|
|
714
|
+
});
|
|
715
|
+
});
|
|
716
|
+
},
|
|
717
|
+
);
|
|
718
|
+
|
|
719
|
+
it("uses identical explicit policy from root and owner cwd and excludes nested projects", () => {
|
|
720
|
+
const root = mkdtempSync(path.join(os.tmpdir(), "managed-runner-parity-"));
|
|
721
|
+
try {
|
|
722
|
+
const scope = "apps/web";
|
|
723
|
+
const owner = path.join(root, scope);
|
|
724
|
+
mkdirSync(path.join(owner, "test/fixture"), { recursive: true });
|
|
725
|
+
mkdirSync(path.join(root, ".devpunks/specs/lint"), { recursive: true });
|
|
726
|
+
symlinkSync(
|
|
727
|
+
path.resolve(import.meta.dirname, "../../../../../node_modules"),
|
|
728
|
+
path.join(root, "node_modules"),
|
|
729
|
+
"dir",
|
|
730
|
+
);
|
|
731
|
+
const tool: unknown = JSON.parse(
|
|
732
|
+
readFileSync(path.join(root, "node_modules/oxlint/package.json"), "utf-8"),
|
|
733
|
+
);
|
|
734
|
+
if (typeof tool !== "object" || tool === null || !("version" in tool)) {
|
|
735
|
+
throw new Error("Missing installed Oxlint identity");
|
|
736
|
+
}
|
|
737
|
+
writeFileSync(path.join(owner, "package.json"), "{}");
|
|
738
|
+
writeFileSync(path.join(owner, "test/fixture/package.json"), "{}");
|
|
739
|
+
writeFileSync(path.join(owner, "test/fixture/bad.ts"), "console.log(2)");
|
|
740
|
+
writeFileSync(path.join(owner, "source.ts"), "console.log(1)");
|
|
741
|
+
writeFileSync(
|
|
742
|
+
path.join(owner, "oxlint.config.ts"),
|
|
743
|
+
'export default {rules: {"no-console": "error"}};',
|
|
744
|
+
);
|
|
745
|
+
writeFileSync(
|
|
746
|
+
path.join(root, ".devpunks/settings.json"),
|
|
747
|
+
JSON.stringify({ lint: { scopes: [scope] } }),
|
|
748
|
+
);
|
|
749
|
+
writeFileSync(
|
|
750
|
+
path.join(root, ".devpunks/specs/lint/selection.json"),
|
|
751
|
+
JSON.stringify({
|
|
752
|
+
managedLint: {
|
|
753
|
+
exclude: [],
|
|
754
|
+
routes: [
|
|
755
|
+
{
|
|
756
|
+
config: `${scope}/oxlint.config.ts`,
|
|
757
|
+
inputs: ["policy.json"],
|
|
758
|
+
maxWarnings: 0,
|
|
759
|
+
scope,
|
|
760
|
+
tool: { package: "oxlint", version: tool.version },
|
|
761
|
+
},
|
|
762
|
+
],
|
|
763
|
+
scopes: [scope],
|
|
764
|
+
version: 1,
|
|
765
|
+
},
|
|
766
|
+
}),
|
|
767
|
+
);
|
|
768
|
+
const invoke = (cwd: string, files: string[]) =>
|
|
769
|
+
spawnSync(process.execPath, [runner, "--format", "json", ...files], {
|
|
770
|
+
cwd,
|
|
771
|
+
encoding: "utf-8",
|
|
772
|
+
});
|
|
773
|
+
const rootResult = invoke(root, ["--", "apps/web/source.ts"]);
|
|
774
|
+
const ownerResult = invoke(owner, ["--", "source.ts"]);
|
|
775
|
+
expect(semantic(ownerResult.stdout)).toStrictEqual(semantic(rootResult.stdout));
|
|
776
|
+
expect(rootResult.stdout).toContain("no-console");
|
|
777
|
+
const excluded = invoke(root, ["--", "apps/web/test/fixture/bad.ts"]);
|
|
778
|
+
const dependency = invoke(root, ["--", "policy.json"]);
|
|
779
|
+
writeFileSync(path.join(owner, "oxlint.config.ts"), "export default {invalid: true};");
|
|
780
|
+
const failure = spawnSync(process.execPath, [runner], { cwd: root, encoding: "utf-8" });
|
|
781
|
+
expect({
|
|
782
|
+
dependency: dependency.status,
|
|
783
|
+
excluded: excluded.status,
|
|
784
|
+
excludedDiagnostics: excluded.stdout.includes("no-console"),
|
|
785
|
+
failure: failure.status,
|
|
786
|
+
fixtureDiagnostics: dependency.stdout.includes("test/fixture/bad.ts"),
|
|
787
|
+
owner: ownerResult.status,
|
|
788
|
+
root: rootResult.status,
|
|
789
|
+
}).toStrictEqual({
|
|
790
|
+
dependency: 1,
|
|
791
|
+
excluded: 0,
|
|
792
|
+
excludedDiagnostics: false,
|
|
793
|
+
failure: 2,
|
|
794
|
+
fixtureDiagnostics: false,
|
|
795
|
+
owner: 1,
|
|
796
|
+
root: 1,
|
|
797
|
+
});
|
|
798
|
+
} finally {
|
|
799
|
+
rmSync(root, { force: true, recursive: true });
|
|
800
|
+
}
|
|
801
|
+
});
|
|
802
|
+
|
|
803
|
+
it("requires authored selection and accepts an intentionally empty selection", () => {
|
|
804
|
+
const root = mkdtempSync(path.join(os.tmpdir(), "managed-runner-"));
|
|
805
|
+
try {
|
|
806
|
+
mkdirSync(path.join(root, ".devpunks"));
|
|
807
|
+
writeFileSync(path.join(root, ".devpunks/settings.json"), "{}");
|
|
808
|
+
const missing = spawnSync(process.execPath, [runner, "--root", root], { encoding: "utf-8" });
|
|
809
|
+
expect(missing.status).toBe(2);
|
|
810
|
+
expect(missing.stderr).toContain("lint.scopes");
|
|
811
|
+
writeFileSync(
|
|
812
|
+
path.join(root, ".devpunks/settings.json"),
|
|
813
|
+
JSON.stringify({ lint: { scopes: [] } }),
|
|
814
|
+
);
|
|
815
|
+
const disabled = spawnSync(process.execPath, [runner, "--root", root], { encoding: "utf-8" });
|
|
816
|
+
expect(disabled.status).toBe(0);
|
|
817
|
+
} finally {
|
|
818
|
+
rmSync(root, { force: true, recursive: true });
|
|
819
|
+
}
|
|
820
|
+
});
|
|
821
|
+
});
|