@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,614 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { mkdtemp, mkdir, writeFile, rm } from "node:fs/promises";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { afterEach, assert, describe, expect, it } from "vitest";
|
|
6
|
+
import {
|
|
7
|
+
resolveManagedLint,
|
|
8
|
+
buildManagedLintCommand,
|
|
9
|
+
isManagedQualityPathExcluded,
|
|
10
|
+
} from "./managed-lint.mjs";
|
|
11
|
+
|
|
12
|
+
describe("managed quality path exclusions", () => {
|
|
13
|
+
it("rejects unnormalized or escaping paths before considering exclusions", () => {
|
|
14
|
+
for (const source of [
|
|
15
|
+
"",
|
|
16
|
+
"../source.py",
|
|
17
|
+
"src/../source.py",
|
|
18
|
+
"wiki/../source.py",
|
|
19
|
+
"/source.py",
|
|
20
|
+
"src\\source.py",
|
|
21
|
+
"./source.py",
|
|
22
|
+
"src//source.py",
|
|
23
|
+
"src/source.py/",
|
|
24
|
+
]) {
|
|
25
|
+
expect(() => isManagedQualityPathExcluded({ exclude: ["**"], path: source })).toThrow(
|
|
26
|
+
TypeError,
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("excludes hard wiki and managed directories without software scope selection", () => {
|
|
32
|
+
const exclude: readonly string[] = Object.freeze([]);
|
|
33
|
+
for (const source of [
|
|
34
|
+
"wiki",
|
|
35
|
+
"wiki/content/page.py",
|
|
36
|
+
"app/wiki",
|
|
37
|
+
"app/wiki/content/page.py",
|
|
38
|
+
"apps/wiki",
|
|
39
|
+
"apps/wiki/content/page.py",
|
|
40
|
+
"node_modules/dependency/source.py",
|
|
41
|
+
"src/node_modules/dependency/source.py",
|
|
42
|
+
".git/hooks/source.py",
|
|
43
|
+
".devpunks/generated/source.py",
|
|
44
|
+
]) {
|
|
45
|
+
expect(isManagedQualityPathExcluded({ exclude, path: source })).toBeTruthy();
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("applies saved fixture globs while keeping ordinary tests and Python source eligible", () => {
|
|
50
|
+
const exclude = Object.freeze(["**/{examples,fixtures}/**", "generated?.py", "snapshots"]);
|
|
51
|
+
for (const source of [
|
|
52
|
+
"fixtures",
|
|
53
|
+
"fixtures/source.py",
|
|
54
|
+
"apps/backend/tests/fixtures/source.py",
|
|
55
|
+
"apps/web/tests/fixtures/source.ts",
|
|
56
|
+
"apps/backend/examples/source.py",
|
|
57
|
+
"generated1.py",
|
|
58
|
+
"snapshots/source.py",
|
|
59
|
+
]) {
|
|
60
|
+
expect(isManagedQualityPathExcluded({ exclude, path: source })).toBeTruthy();
|
|
61
|
+
}
|
|
62
|
+
for (const source of [
|
|
63
|
+
"source.py",
|
|
64
|
+
"src/source.py",
|
|
65
|
+
"tests/test_source.py",
|
|
66
|
+
"apps/backend/tests/test_source.py",
|
|
67
|
+
"apps/web/tests/unit.ts",
|
|
68
|
+
"src/fixtures_helpers.py",
|
|
69
|
+
"src/generated1.py",
|
|
70
|
+
"src/snapshots/source.py",
|
|
71
|
+
]) {
|
|
72
|
+
expect(isManagedQualityPathExcluded({ exclude, path: source })).toBeFalsy();
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("keeps similarly named and nested non-wiki paths eligible", () => {
|
|
77
|
+
for (const source of [
|
|
78
|
+
"wikipedia/page.py",
|
|
79
|
+
"wiki-tools/source.py",
|
|
80
|
+
"app/wikipedia/source.py",
|
|
81
|
+
"apps/wiki-tools/source.py",
|
|
82
|
+
"apps/web/wiki/source.py",
|
|
83
|
+
"src/wiki/source.py",
|
|
84
|
+
]) {
|
|
85
|
+
expect(isManagedQualityPathExcluded({ exclude: [], path: source })).toBeFalsy();
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
describe("managed lint routes", () => {
|
|
91
|
+
const roots: string[] = [];
|
|
92
|
+
const repo = async () => {
|
|
93
|
+
const root = await mkdtemp(path.join(tmpdir(), "managed-lint-"));
|
|
94
|
+
roots.push(root);
|
|
95
|
+
await Promise.all(
|
|
96
|
+
["apps/web", "apps/web/test/fixtures/demo", "apps/web/nested", "apps/wiki"].map(
|
|
97
|
+
async (scope) => {
|
|
98
|
+
await mkdir(path.join(root, scope), { recursive: true });
|
|
99
|
+
await writeFile(path.join(root, scope, "package.json"), "{}");
|
|
100
|
+
},
|
|
101
|
+
),
|
|
102
|
+
);
|
|
103
|
+
return root;
|
|
104
|
+
};
|
|
105
|
+
afterEach(async () => {
|
|
106
|
+
await Promise.all(
|
|
107
|
+
roots.splice(0).map(async (root) => {
|
|
108
|
+
await rm(root, { force: true, recursive: true });
|
|
109
|
+
}),
|
|
110
|
+
);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it("routes ordinary tests to the most specific saved owner, excluding wiki and nested fixture packages", async () => {
|
|
114
|
+
const root = await repo();
|
|
115
|
+
const scopes = ["apps/web", "apps/web/nested"];
|
|
116
|
+
const result = await resolveManagedLint({
|
|
117
|
+
paths: [
|
|
118
|
+
"apps/web/test/unit.ts",
|
|
119
|
+
"apps/web/test/fixtures/demo/src.ts",
|
|
120
|
+
"apps/web/nested/src.ts",
|
|
121
|
+
"apps/wiki/page.ts",
|
|
122
|
+
],
|
|
123
|
+
root,
|
|
124
|
+
selection: {
|
|
125
|
+
managedLint: {
|
|
126
|
+
exclude: [],
|
|
127
|
+
routes: scopes.map((scope) => ({
|
|
128
|
+
config: `${scope}/oxlint.config.ts`,
|
|
129
|
+
inputs: [],
|
|
130
|
+
maxWarnings: 0,
|
|
131
|
+
scope,
|
|
132
|
+
tool: { package: "oxlint", version: "1.80.0" },
|
|
133
|
+
})),
|
|
134
|
+
scopes,
|
|
135
|
+
version: 1,
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
settings: { lint: { exclude: [], scopes } },
|
|
139
|
+
});
|
|
140
|
+
expect(result.status).toBe("ready");
|
|
141
|
+
assert(result.status === "ready");
|
|
142
|
+
expect(result.routes.map((route) => [route.scope, route.files])).toStrictEqual([
|
|
143
|
+
["apps/web", ["apps/web/test/unit.ts"]],
|
|
144
|
+
["apps/web/nested", ["apps/web/nested/src.ts"]],
|
|
145
|
+
]);
|
|
146
|
+
expect(result.excludedPaths).toStrictEqual([
|
|
147
|
+
"apps/web/test/fixtures/demo/src.ts",
|
|
148
|
+
"apps/wiki/page.ts",
|
|
149
|
+
]);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it("keeps ordinary tests eligible while excluding unselected pyproject-only projects from every route", async () => {
|
|
153
|
+
const root = await repo();
|
|
154
|
+
const scope = "apps/web";
|
|
155
|
+
const nested = `${scope}/test/python-example`;
|
|
156
|
+
const ordinary = `${scope}/test/unit.js`;
|
|
157
|
+
const nestedFiles = [`${nested}/source.js`, `${nested}/source.ts`];
|
|
158
|
+
await mkdir(path.join(root, nested), { recursive: true });
|
|
159
|
+
await writeFile(path.join(root, nested, "pyproject.toml"), "[project]\nname = 'example'\n");
|
|
160
|
+
await Promise.all(
|
|
161
|
+
[ordinary, ...nestedFiles].map(async (file) => {
|
|
162
|
+
await writeFile(path.join(root, file), "export const value = 1;\n");
|
|
163
|
+
}),
|
|
164
|
+
);
|
|
165
|
+
const scopes = [scope];
|
|
166
|
+
const options = {
|
|
167
|
+
root,
|
|
168
|
+
selection: {
|
|
169
|
+
managedLint: {
|
|
170
|
+
exclude: [],
|
|
171
|
+
routes: [
|
|
172
|
+
{
|
|
173
|
+
config: `${scope}/oxlint.config.ts`,
|
|
174
|
+
inputs: [],
|
|
175
|
+
maxWarnings: 0,
|
|
176
|
+
scope,
|
|
177
|
+
tool: { package: "oxlint", version: "1.80.0" },
|
|
178
|
+
},
|
|
179
|
+
],
|
|
180
|
+
scopes,
|
|
181
|
+
version: 1,
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
settings: { lint: { exclude: [], scopes } },
|
|
185
|
+
};
|
|
186
|
+
const whole = await resolveManagedLint(options);
|
|
187
|
+
assert(whole.status === "ready");
|
|
188
|
+
expect(whole.routes.map((route) => [route.scope, route.files])).toStrictEqual([
|
|
189
|
+
[scope, [`${scope}/package.json`, ordinary]],
|
|
190
|
+
]);
|
|
191
|
+
const explicit = await resolveManagedLint({ ...options, paths: [ordinary, ...nestedFiles] });
|
|
192
|
+
assert(explicit.status === "ready");
|
|
193
|
+
expect(explicit.routes.map((route) => [route.scope, route.files])).toStrictEqual([
|
|
194
|
+
[scope, [ordinary]],
|
|
195
|
+
]);
|
|
196
|
+
expect(explicit.excludedPaths).toStrictEqual(nestedFiles);
|
|
197
|
+
await Promise.all(
|
|
198
|
+
[ordinary, ...nestedFiles].map(async (file) => {
|
|
199
|
+
const isolated = await resolveManagedLint({ ...options, paths: [file] });
|
|
200
|
+
assert(isolated.status === "ready");
|
|
201
|
+
expect(isolated.routes.map((route) => [route.scope, route.files])).toStrictEqual(
|
|
202
|
+
file === ordinary ? [[scope, [ordinary]]] : [],
|
|
203
|
+
);
|
|
204
|
+
expect(isolated.excludedPaths).toStrictEqual(file === ordinary ? [] : [file]);
|
|
205
|
+
}),
|
|
206
|
+
);
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
it("fails closed for stale or malformed selection and distinguishes intentional empty scopes", async () => {
|
|
210
|
+
const root = await repo();
|
|
211
|
+
await expect(resolveManagedLint({ root, selection: {}, settings: {} })).resolves.toMatchObject({
|
|
212
|
+
status: "selection-needed",
|
|
213
|
+
});
|
|
214
|
+
await expect(
|
|
215
|
+
resolveManagedLint({ root, selection: {}, settings: { lint: { scopes: [] } } }),
|
|
216
|
+
).resolves.toMatchObject({ status: "disabled" });
|
|
217
|
+
await expect(
|
|
218
|
+
resolveManagedLint({
|
|
219
|
+
root,
|
|
220
|
+
selection: {},
|
|
221
|
+
settings: { lint: { scopes: ["apps/web"] } },
|
|
222
|
+
}),
|
|
223
|
+
).resolves.toMatchObject({ status: "conflict" });
|
|
224
|
+
await expect(
|
|
225
|
+
resolveManagedLint({
|
|
226
|
+
root,
|
|
227
|
+
selection: {},
|
|
228
|
+
settings: { lint: { scopes: ["../outside"] } },
|
|
229
|
+
}),
|
|
230
|
+
).resolves.toMatchObject({ status: "conflict" });
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
it("applies exclusions before routing, expands omitted files safely and selects owners from shared inputs", async () => {
|
|
234
|
+
const root = await repo();
|
|
235
|
+
await mkdir(path.join(root, "apps/web/example"), { recursive: true });
|
|
236
|
+
await Promise.all(
|
|
237
|
+
[
|
|
238
|
+
"apps/web/test/unit.ts",
|
|
239
|
+
"apps/web/example/sample.ts",
|
|
240
|
+
"apps/web/test/fixtures/demo/main.ts",
|
|
241
|
+
].map(async (file) => {
|
|
242
|
+
await writeFile(path.join(root, file), "");
|
|
243
|
+
}),
|
|
244
|
+
);
|
|
245
|
+
const scopes = ["apps/web"];
|
|
246
|
+
const exclude = ["apps/web/example/**"];
|
|
247
|
+
const selection = {
|
|
248
|
+
managedLint: {
|
|
249
|
+
exclude,
|
|
250
|
+
routes: [
|
|
251
|
+
{
|
|
252
|
+
config: "apps/web/oxlint.config.ts",
|
|
253
|
+
inputs: ["shared/policy.json"],
|
|
254
|
+
maxWarnings: 0,
|
|
255
|
+
scope: "apps/web",
|
|
256
|
+
tool: { package: "oxlint", version: "1.80.0" },
|
|
257
|
+
},
|
|
258
|
+
],
|
|
259
|
+
scopes,
|
|
260
|
+
version: 1,
|
|
261
|
+
},
|
|
262
|
+
};
|
|
263
|
+
const result = await resolveManagedLint({
|
|
264
|
+
root,
|
|
265
|
+
selection,
|
|
266
|
+
settings: { lint: { exclude, scopes } },
|
|
267
|
+
});
|
|
268
|
+
expect(result.status).toBe("ready");
|
|
269
|
+
assert(result.status === "ready");
|
|
270
|
+
expect(result.routes[0]?.files).toStrictEqual([
|
|
271
|
+
"apps/web/package.json",
|
|
272
|
+
"apps/web/test/unit.ts",
|
|
273
|
+
]);
|
|
274
|
+
const triggered = await resolveManagedLint({
|
|
275
|
+
paths: ["shared/policy.json"],
|
|
276
|
+
root,
|
|
277
|
+
selection,
|
|
278
|
+
settings: { lint: { exclude, scopes } },
|
|
279
|
+
});
|
|
280
|
+
expect(triggered.status).toBe("ready");
|
|
281
|
+
assert(triggered.status === "ready");
|
|
282
|
+
expect(triggered.routes[0]?.triggered).toBeTruthy();
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
it("constructs an explicit local command and rejects stale tool versions and unproven temporary paths", async () => {
|
|
286
|
+
const root = await repo();
|
|
287
|
+
const scope = "apps/web";
|
|
288
|
+
await mkdir(path.join(root, "node_modules/oxlint/bin"), { recursive: true });
|
|
289
|
+
await writeFile(
|
|
290
|
+
path.join(root, "node_modules/oxlint/package.json"),
|
|
291
|
+
JSON.stringify({ bin: { oxlint: "bin/oxlint" }, name: "oxlint", version: "1.80.0" }),
|
|
292
|
+
);
|
|
293
|
+
await writeFile(path.join(root, "node_modules/oxlint/bin/oxlint"), "");
|
|
294
|
+
await writeFile(path.join(root, scope, "oxlint.config.ts"), "export default {};");
|
|
295
|
+
await writeFile(path.join(root, scope, "source.ts"), "const x=1");
|
|
296
|
+
const route = {
|
|
297
|
+
boundaries: [],
|
|
298
|
+
config: `${scope}/oxlint.config.ts`,
|
|
299
|
+
files: [`${scope}/source.ts`],
|
|
300
|
+
inputs: [],
|
|
301
|
+
maxWarnings: 0,
|
|
302
|
+
scope,
|
|
303
|
+
tool: { package: "oxlint" as const, version: "1.80.0" },
|
|
304
|
+
triggered: false,
|
|
305
|
+
};
|
|
306
|
+
const result = await buildManagedLintCommand({ output: "json", root, route });
|
|
307
|
+
expect(result).toMatchObject({
|
|
308
|
+
args: [
|
|
309
|
+
"--config",
|
|
310
|
+
path.join(root, route.config),
|
|
311
|
+
"--disable-nested-config",
|
|
312
|
+
"--max-warnings",
|
|
313
|
+
"0",
|
|
314
|
+
"--format",
|
|
315
|
+
"json",
|
|
316
|
+
"--",
|
|
317
|
+
"source.ts",
|
|
318
|
+
],
|
|
319
|
+
cwd: path.join(root, scope),
|
|
320
|
+
executable: path.join(root, "node_modules/oxlint/bin/oxlint"),
|
|
321
|
+
status: "ready",
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
await expect(
|
|
325
|
+
buildManagedLintCommand({
|
|
326
|
+
root,
|
|
327
|
+
route: { ...route, tool: { package: "oxlint", version: "1.79.0" } },
|
|
328
|
+
}),
|
|
329
|
+
).resolves.toMatchObject({ status: "conflict" });
|
|
330
|
+
await expect(
|
|
331
|
+
buildManagedLintCommand({
|
|
332
|
+
logicalSourcePath: `${scope}/source.ts`,
|
|
333
|
+
physicalInputPath: "/tmp/edit.ts",
|
|
334
|
+
root,
|
|
335
|
+
route,
|
|
336
|
+
}),
|
|
337
|
+
).resolves.toMatchObject({ status: "conflict" });
|
|
338
|
+
await rm(path.join(root, "node_modules"), { recursive: true });
|
|
339
|
+
await expect(buildManagedLintCommand({ root, route })).resolves.toMatchObject({
|
|
340
|
+
status: "conflict",
|
|
341
|
+
});
|
|
342
|
+
});
|
|
343
|
+
|
|
344
|
+
it("returns actionable conflicts for untrusted routes and escaping symlink owners", async () => {
|
|
345
|
+
const root = await repo();
|
|
346
|
+
const options = {
|
|
347
|
+
root,
|
|
348
|
+
selection: { managedLint: { exclude: [], routes: [null], scopes: ["apps/web"], version: 1 } },
|
|
349
|
+
settings: { lint: { scopes: ["apps/web"] } },
|
|
350
|
+
};
|
|
351
|
+
await expect(resolveManagedLint(options)).resolves.toMatchObject({ status: "conflict" });
|
|
352
|
+
const { symlink } = await import("node:fs/promises");
|
|
353
|
+
const outside = await repo();
|
|
354
|
+
await symlink(path.join(outside, "apps/web"), path.join(root, "apps/linked"));
|
|
355
|
+
await expect(
|
|
356
|
+
resolveManagedLint({
|
|
357
|
+
root,
|
|
358
|
+
selection: {
|
|
359
|
+
managedLint: {
|
|
360
|
+
exclude: [],
|
|
361
|
+
routes: [
|
|
362
|
+
{
|
|
363
|
+
config: "apps/linked/oxlint.config.ts",
|
|
364
|
+
inputs: [],
|
|
365
|
+
maxWarnings: 0,
|
|
366
|
+
scope: "apps/linked",
|
|
367
|
+
tool: { package: "oxlint", version: "1.80.0" },
|
|
368
|
+
},
|
|
369
|
+
],
|
|
370
|
+
scopes: ["apps/linked"],
|
|
371
|
+
version: 1,
|
|
372
|
+
},
|
|
373
|
+
},
|
|
374
|
+
settings: { lint: { scopes: ["apps/linked"] } },
|
|
375
|
+
}),
|
|
376
|
+
).resolves.toMatchObject({ status: "conflict" });
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
it("rejects saved owners replaced by contained aliases while allowing repository root aliases", async () => {
|
|
380
|
+
const { symlink } = await import("node:fs/promises");
|
|
381
|
+
await Promise.all(
|
|
382
|
+
["apps/wiki", "apps/other"].map(async (target) => {
|
|
383
|
+
const root = await repo();
|
|
384
|
+
await mkdir(path.join(root, target), { recursive: true });
|
|
385
|
+
await writeFile(path.join(root, target, "package.json"), "{}");
|
|
386
|
+
await writeFile(path.join(root, target, "source.ts"), "export const value = 1;");
|
|
387
|
+
const scopes = target === "apps/wiki" ? ["apps/web"] : ["apps/web", target];
|
|
388
|
+
const options = {
|
|
389
|
+
root,
|
|
390
|
+
selection: {
|
|
391
|
+
managedLint: {
|
|
392
|
+
exclude: [],
|
|
393
|
+
routes: scopes.map((scope) => ({
|
|
394
|
+
config: `${scope}/oxlint.config.ts`,
|
|
395
|
+
inputs: [],
|
|
396
|
+
maxWarnings: 0,
|
|
397
|
+
scope,
|
|
398
|
+
tool: { package: "oxlint", version: "1.80.0" },
|
|
399
|
+
})),
|
|
400
|
+
scopes,
|
|
401
|
+
version: 1,
|
|
402
|
+
},
|
|
403
|
+
},
|
|
404
|
+
settings: { lint: { exclude: [], scopes } },
|
|
405
|
+
};
|
|
406
|
+
await expect(resolveManagedLint(options)).resolves.toMatchObject({ status: "ready" });
|
|
407
|
+
const aliasParent = await repo();
|
|
408
|
+
const alias = path.join(aliasParent, "repository");
|
|
409
|
+
await symlink(root, alias);
|
|
410
|
+
await expect(resolveManagedLint({ ...options, root: alias })).resolves.toMatchObject({
|
|
411
|
+
status: "ready",
|
|
412
|
+
});
|
|
413
|
+
await rm(path.join(root, "apps/web"), { recursive: true });
|
|
414
|
+
await symlink(path.join(root, target), path.join(root, "apps/web"));
|
|
415
|
+
await expect(resolveManagedLint(options)).resolves.toMatchObject({ status: "conflict" });
|
|
416
|
+
await expect(
|
|
417
|
+
resolveManagedLint({ ...options, paths: ["apps/web/source.ts"] }),
|
|
418
|
+
).resolves.toMatchObject({ status: "conflict" });
|
|
419
|
+
}),
|
|
420
|
+
);
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
it("excludes explicit source aliases into wiki or other owners just like whole-owner enumeration", async () => {
|
|
424
|
+
const { symlink } = await import("node:fs/promises");
|
|
425
|
+
const root = await repo();
|
|
426
|
+
const scopes = ["apps/web", "apps/web/nested"];
|
|
427
|
+
const ordinary = "apps/web/test/unit.ts";
|
|
428
|
+
await writeFile(path.join(root, ordinary), "export const value = 1;");
|
|
429
|
+
const aliases = ["apps/web/wiki-alias.ts", "apps/web/owner-alias.ts"];
|
|
430
|
+
await Promise.all(
|
|
431
|
+
["apps/wiki/source.ts", "apps/web/nested/source.ts"].map(async (target, index) => {
|
|
432
|
+
await writeFile(path.join(root, target), "export const value = 1;");
|
|
433
|
+
await symlink(path.join(root, target), path.join(root, aliases[index] ?? ""));
|
|
434
|
+
}),
|
|
435
|
+
);
|
|
436
|
+
const options = {
|
|
437
|
+
root,
|
|
438
|
+
selection: {
|
|
439
|
+
managedLint: {
|
|
440
|
+
exclude: [],
|
|
441
|
+
routes: scopes.map((scope) => ({
|
|
442
|
+
config: `${scope}/oxlint.config.ts`,
|
|
443
|
+
inputs: [],
|
|
444
|
+
maxWarnings: 0,
|
|
445
|
+
scope,
|
|
446
|
+
tool: { package: "oxlint", version: "1.80.0" },
|
|
447
|
+
})),
|
|
448
|
+
scopes,
|
|
449
|
+
version: 1,
|
|
450
|
+
},
|
|
451
|
+
},
|
|
452
|
+
settings: { lint: { exclude: [], scopes } },
|
|
453
|
+
};
|
|
454
|
+
const whole = await resolveManagedLint(options);
|
|
455
|
+
assert(whole.status === "ready");
|
|
456
|
+
for (const alias of aliases) {
|
|
457
|
+
expect(whole.routes.flatMap((route) => route.files)).not.toContain(alias);
|
|
458
|
+
}
|
|
459
|
+
const explicit = await resolveManagedLint({ ...options, paths: [ordinary, ...aliases] });
|
|
460
|
+
assert(explicit.status === "ready");
|
|
461
|
+
expect(explicit.excludedPaths).toStrictEqual(aliases.toSorted());
|
|
462
|
+
expect(explicit.routes.flatMap((route) => route.files)).toStrictEqual([ordinary]);
|
|
463
|
+
});
|
|
464
|
+
|
|
465
|
+
it("matches portable exclusion globs without excluding ordinary tests", async () => {
|
|
466
|
+
const root = await repo();
|
|
467
|
+
const scopes = ["apps/web"];
|
|
468
|
+
const exclude = ["**/{examples,fixtures}/**", "apps/web/generated?.ts"];
|
|
469
|
+
const result = await resolveManagedLint({
|
|
470
|
+
paths: [
|
|
471
|
+
"apps/web/examples/foo.ts",
|
|
472
|
+
"apps/web/src/fixtures/bar.ts",
|
|
473
|
+
"apps/web/generated1.ts",
|
|
474
|
+
"apps/web/tests/unit.ts",
|
|
475
|
+
],
|
|
476
|
+
root,
|
|
477
|
+
selection: {
|
|
478
|
+
managedLint: {
|
|
479
|
+
exclude,
|
|
480
|
+
routes: [
|
|
481
|
+
{
|
|
482
|
+
config: "apps/web/oxlint.config.ts",
|
|
483
|
+
inputs: [],
|
|
484
|
+
maxWarnings: 0,
|
|
485
|
+
scope: "apps/web",
|
|
486
|
+
tool: { package: "oxlint", version: "1.80.0" },
|
|
487
|
+
},
|
|
488
|
+
],
|
|
489
|
+
scopes,
|
|
490
|
+
version: 1,
|
|
491
|
+
},
|
|
492
|
+
},
|
|
493
|
+
settings: { lint: { exclude, scopes } },
|
|
494
|
+
});
|
|
495
|
+
expect(result.status).toBe("ready");
|
|
496
|
+
assert(result.status === "ready");
|
|
497
|
+
expect(result.routes[0]?.files).toStrictEqual(["apps/web/tests/unit.ts"]);
|
|
498
|
+
});
|
|
499
|
+
|
|
500
|
+
it("executes the described command with the real installed Oxlint and explicit policy", async () => {
|
|
501
|
+
const root = await repo();
|
|
502
|
+
const { symlink } = await import("node:fs/promises");
|
|
503
|
+
const { execFileSync } = await import("node:child_process");
|
|
504
|
+
await symlink(path.resolve("node_modules"), path.join(root, "node_modules"));
|
|
505
|
+
await writeFile(
|
|
506
|
+
path.join(root, "apps/web/oxlint.config.ts"),
|
|
507
|
+
'export default {rules: {"no-debugger": "error"}};',
|
|
508
|
+
);
|
|
509
|
+
await writeFile(path.join(root, "apps/web/source.ts"), "export const answer = 42;");
|
|
510
|
+
const command = await buildManagedLintCommand({
|
|
511
|
+
output: "json",
|
|
512
|
+
root,
|
|
513
|
+
route: {
|
|
514
|
+
boundaries: [],
|
|
515
|
+
config: "apps/web/oxlint.config.ts",
|
|
516
|
+
files: ["apps/web/source.ts"],
|
|
517
|
+
inputs: [],
|
|
518
|
+
maxWarnings: 0,
|
|
519
|
+
scope: "apps/web",
|
|
520
|
+
tool: { package: "oxlint", version: "1.80.0" },
|
|
521
|
+
triggered: false,
|
|
522
|
+
},
|
|
523
|
+
});
|
|
524
|
+
expect(command.status).toBe("ready");
|
|
525
|
+
assert(command.status === "ready");
|
|
526
|
+
const stdout = execFileSync(command.executable, [...command.args], {
|
|
527
|
+
cwd: command.cwd,
|
|
528
|
+
encoding: "utf-8",
|
|
529
|
+
});
|
|
530
|
+
const result: unknown = JSON.parse(stdout);
|
|
531
|
+
expect(result).toMatchObject({ diagnostics: [] });
|
|
532
|
+
});
|
|
533
|
+
|
|
534
|
+
it("selects dependent owners when a changed policy input is excluded from source lint", async () => {
|
|
535
|
+
const root = await repo();
|
|
536
|
+
const scopes = ["apps/web"];
|
|
537
|
+
const exclude = [".devpunks/**"];
|
|
538
|
+
const result = await resolveManagedLint({
|
|
539
|
+
paths: [".devpunks/policy.json"],
|
|
540
|
+
root,
|
|
541
|
+
selection: {
|
|
542
|
+
managedLint: {
|
|
543
|
+
exclude,
|
|
544
|
+
routes: [
|
|
545
|
+
{
|
|
546
|
+
config: "apps/web/oxlint.config.ts",
|
|
547
|
+
inputs: [".devpunks/policy.json"],
|
|
548
|
+
maxWarnings: 0,
|
|
549
|
+
scope: "apps/web",
|
|
550
|
+
tool: { package: "oxlint", version: "1.80.0" },
|
|
551
|
+
},
|
|
552
|
+
],
|
|
553
|
+
scopes,
|
|
554
|
+
version: 1,
|
|
555
|
+
},
|
|
556
|
+
},
|
|
557
|
+
settings: { lint: { exclude, scopes } },
|
|
558
|
+
});
|
|
559
|
+
expect(result.status).toBe("ready");
|
|
560
|
+
assert(result.status === "ready");
|
|
561
|
+
|
|
562
|
+
expect(result.routes[0]?.triggered).toBeTruthy();
|
|
563
|
+
expect(result.routes[0]?.files).toStrictEqual([]);
|
|
564
|
+
expect(result.excludedPaths).toStrictEqual([".devpunks/policy.json"]);
|
|
565
|
+
});
|
|
566
|
+
describe("compiled project policy freshness", () => {
|
|
567
|
+
it("rejects changed, missing and escaping policy inputs while saved scopes stay unchanged", async () => {
|
|
568
|
+
const root = await repo();
|
|
569
|
+
const policy = "apps/web/oxlint.project.json";
|
|
570
|
+
const content = '{"rules":{"no-debugger":"off"}}';
|
|
571
|
+
await writeFile(path.join(root, policy), content);
|
|
572
|
+
const scopes = ["apps/web"];
|
|
573
|
+
const route = {
|
|
574
|
+
config: "apps/web/oxlint.config.ts",
|
|
575
|
+
inputs: [policy],
|
|
576
|
+
maxWarnings: 0,
|
|
577
|
+
policyInputs: [
|
|
578
|
+
{ path: policy, sha256: createHash("sha256").update(content).digest("hex") },
|
|
579
|
+
],
|
|
580
|
+
scope: "apps/web",
|
|
581
|
+
tool: { package: "oxlint", version: "1.80.0" },
|
|
582
|
+
};
|
|
583
|
+
const options = {
|
|
584
|
+
paths: [],
|
|
585
|
+
root,
|
|
586
|
+
selection: { managedLint: { exclude: [], routes: [route], scopes, version: 1 } },
|
|
587
|
+
settings: { lint: { scopes } },
|
|
588
|
+
};
|
|
589
|
+
const resolution = await resolveManagedLint(options);
|
|
590
|
+
expect(resolution.status).toBe("ready");
|
|
591
|
+
if (resolution.status !== "ready") {
|
|
592
|
+
throw new Error("Expected fresh route");
|
|
593
|
+
}
|
|
594
|
+
await writeFile(path.join(root, policy), "{}");
|
|
595
|
+
await expect(resolveManagedLint(options)).resolves.toMatchObject({
|
|
596
|
+
diagnostics: [expect.stringMatching(/stale.*policy|policy.*stale/iu)],
|
|
597
|
+
status: "conflict",
|
|
598
|
+
});
|
|
599
|
+
await expect(
|
|
600
|
+
buildManagedLintCommand({ root, route: resolution.routes[0] }),
|
|
601
|
+
).resolves.toMatchObject({
|
|
602
|
+
diagnostics: [expect.stringMatching(/stale.*policy|policy.*stale/iu)],
|
|
603
|
+
status: "conflict",
|
|
604
|
+
});
|
|
605
|
+
await rm(path.join(root, policy));
|
|
606
|
+
await expect(resolveManagedLint(options)).resolves.toMatchObject({ status: "conflict" });
|
|
607
|
+
const { symlink } = await import("node:fs/promises");
|
|
608
|
+
const outside = await repo();
|
|
609
|
+
await writeFile(path.join(outside, "policy.json"), content);
|
|
610
|
+
await symlink(path.join(outside, "policy.json"), path.join(root, policy));
|
|
611
|
+
await expect(resolveManagedLint(options)).resolves.toMatchObject({ status: "conflict" });
|
|
612
|
+
});
|
|
613
|
+
});
|
|
614
|
+
});
|
|
@@ -52,6 +52,45 @@ describe("sync-subagents context-plan validator", () => {
|
|
|
52
52
|
expect(validateCanonicalContextPlan(plan())).toBeUndefined();
|
|
53
53
|
});
|
|
54
54
|
|
|
55
|
+
it.each(["files", "owner", "repository"])("accepts explicit %s execution", (mode) => {
|
|
56
|
+
const entry = {
|
|
57
|
+
...contribution,
|
|
58
|
+
contract: { ...contribution.contract, execution: { formatCheck: mode, lint: mode } },
|
|
59
|
+
};
|
|
60
|
+
expect(validateCanonicalContextPlan(plan(entry))).toBeUndefined();
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it("accepts independent execution modes for each command", () => {
|
|
64
|
+
expect(
|
|
65
|
+
validateCanonicalContextPlan(
|
|
66
|
+
plan({
|
|
67
|
+
...contribution,
|
|
68
|
+
contract: {
|
|
69
|
+
...contribution.contract,
|
|
70
|
+
execution: { formatCheck: "files", lint: "repository" },
|
|
71
|
+
},
|
|
72
|
+
}),
|
|
73
|
+
),
|
|
74
|
+
).toBeUndefined();
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it.each([
|
|
78
|
+
["missing formatCheck mode", { lint: "files" }],
|
|
79
|
+
["missing lint mode", { formatCheck: "owner" }],
|
|
80
|
+
["unknown lint mode", { formatCheck: "files", lint: "workspace" }],
|
|
81
|
+
["unknown formatCheck mode", { formatCheck: "workspace", lint: "files" }],
|
|
82
|
+
["extra execution key", { extra: "owner", formatCheck: "files", lint: "files" }],
|
|
83
|
+
["null execution", null],
|
|
84
|
+
["undefined execution", undefined],
|
|
85
|
+
["non-object execution", "repository"],
|
|
86
|
+
])("rejects %s", (_label, execution) => {
|
|
87
|
+
expect(
|
|
88
|
+
validateCanonicalContextPlan(
|
|
89
|
+
plan({ ...contribution, contract: { ...contribution.contract, execution } }),
|
|
90
|
+
),
|
|
91
|
+
).toMatch(/contract/iu);
|
|
92
|
+
});
|
|
93
|
+
|
|
55
94
|
it.each(invalidCases)("rejects %s", (_label, mutate) => {
|
|
56
95
|
const invalid = mutate(contribution);
|
|
57
96
|
expect(validateCanonicalContextPlan(plan(invalid))).toMatch(/contract|fields/iu);
|
|
@@ -2910,12 +2910,18 @@ const compatibilityIssue = (compatibility) =>
|
|
|
2910
2910
|
? undefined
|
|
2911
2911
|
: "Context contribution compatibility is invalid";
|
|
2912
2912
|
|
|
2913
|
+
const qualityCommandExecutionModes = new Set(["files", "owner", "repository"]);
|
|
2914
|
+
|
|
2913
2915
|
const commitGateContractIssue = (contract) =>
|
|
2914
|
-
exactKeys(contract, ["lint", "formatCheck"])
|
|
2916
|
+
(exactKeys(contract, ["lint", "formatCheck"]) ||
|
|
2917
|
+
(exactKeys(contract, ["lint", "formatCheck", "execution"]) &&
|
|
2918
|
+
exactKeys(contract.execution, ["lint", "formatCheck"]) &&
|
|
2919
|
+
qualityCommandExecutionModes.has(contract.execution.lint) &&
|
|
2920
|
+
qualityCommandExecutionModes.has(contract.execution.formatCheck))) &&
|
|
2915
2921
|
isNonEmptyString(contract.lint) &&
|
|
2916
2922
|
isNonEmptyString(contract.formatCheck)
|
|
2917
2923
|
? undefined
|
|
2918
|
-
: "Commit-gate contract must contain non-empty lint and formatCheck strings";
|
|
2924
|
+
: "Commit-gate contract must contain non-empty lint and formatCheck strings and optional execution with lint and formatCheck modes: files, owner, or repository";
|
|
2919
2925
|
|
|
2920
2926
|
const contributionIssue = (contribution) => {
|
|
2921
2927
|
const expectedKeys =
|
|
@@ -27,6 +27,8 @@ Read [references/commands.md](references/commands.md) when choosing or explainin
|
|
|
27
27
|
|
|
28
28
|
## Workflow
|
|
29
29
|
|
|
30
|
+
For managed lint setup, scope changes, policy migration, conflicting commands, or stale-policy findings, read [references/managed-lint.md](references/managed-lint.md). Complete explicit scope selection before dependent lint adoption; `--yes` does not supply that decision.
|
|
31
|
+
|
|
30
32
|
1. Run the bounded command requested by the user.
|
|
31
33
|
2. Classify its result as init, scaffold, check, ensure, update, tools ensure, report, upgrade, or operator.
|
|
32
34
|
3. Follow only that branch in [references/post-command-flow.md](references/post-command-flow.md).
|