@punks/cli 5.2.0 → 5.2.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.
Files changed (91) hide show
  1. package/README.md +2 -2
  2. package/dist/BASELINE_CHANGELOG.md +46 -1
  3. package/dist/CHANGELOG.md +37 -0
  4. package/dist/baseline/scaffold-baseline/baseline.json +15 -5
  5. package/dist/baseline/scaffold-baseline/data/catalog/packs.json +2 -0
  6. package/dist/baseline/scaffold-baseline/data/catalog/skills.json +16 -0
  7. package/dist/baseline/scaffold-baseline/data/hooks/format-edited-file.mjs +459 -318
  8. package/dist/baseline/scaffold-baseline/data/scripts/commit-gate-runner.d.ts +1 -0
  9. package/dist/baseline/scaffold-baseline/data/scripts/commit-gate-runner.mjs +98 -27
  10. package/dist/baseline/scaffold-baseline/data/scripts/commit-gate-runner.test.ts +156 -8
  11. package/dist/baseline/scaffold-baseline/data/scripts/managed-lint-runner.d.mts +55 -0
  12. package/dist/baseline/scaffold-baseline/data/scripts/managed-lint-runner.mjs +329 -0
  13. package/dist/baseline/scaffold-baseline/data/scripts/managed-lint-runner.test.ts +864 -0
  14. package/dist/baseline/scaffold-baseline/data/scripts/managed-lint.d.mts +97 -0
  15. package/dist/baseline/scaffold-baseline/data/scripts/managed-lint.mjs +658 -0
  16. package/dist/baseline/scaffold-baseline/data/scripts/managed-lint.test.ts +614 -0
  17. package/dist/baseline/scaffold-baseline/skills/agnostic/cli/hi-cli/SKILL.md +2 -0
  18. package/dist/baseline/scaffold-baseline/skills/agnostic/cli/hi-cli/references/commands.md +8 -9
  19. package/dist/baseline/scaffold-baseline/skills/agnostic/cli/hi-cli/references/managed-lint.md +165 -0
  20. package/dist/baseline/scaffold-baseline/skills/agnostic/cli/hi-cli/references/post-command-flow.md +28 -24
  21. package/dist/baseline/scaffold-baseline/skills/agnostic/cli/hi-cli/references/wiki-structure.md +16 -0
  22. package/dist/baseline/scaffold-baseline/skills/agnostic/docs/docs-onboarding/SKILL.md +21 -16
  23. package/dist/baseline/scaffold-baseline/skills/agnostic/docs/docs-onboarding/agents/openai.yaml +1 -1
  24. package/dist/baseline/scaffold-baseline/skills/agnostic/docs/docs-onboarding/references/artifact-contract.md +16 -4
  25. package/dist/baseline/scaffold-baseline/skills/agnostic/planning/create-architecture/SKILL.md +65 -0
  26. package/dist/baseline/scaffold-baseline/skills/agnostic/planning/create-architecture/assets/ARCHITECTURE-TEMPLATE.md +119 -0
  27. package/dist/baseline/scaffold-baseline/skills/agnostic/planning/create-architecture/references/artifact-contract.md +200 -0
  28. package/dist/baseline/scaffold-baseline/skills/agnostic/planning/create-plan/SKILL.md +11 -3
  29. package/dist/baseline/scaffold-baseline/skills/agnostic/planning/create-plan/references/architecture-convergence.md +19 -4
  30. package/dist/baseline/scaffold-baseline/skills/agnostic/planning/create-plan/references/plan-schema.md +17 -3
  31. package/dist/baseline/scaffold-baseline/skills/agnostic/planning/create-spec/SKILL.md +38 -20
  32. package/dist/baseline/scaffold-baseline/skills/agnostic/planning/create-spec/assets/SPEC-TEMPLATE.md +11 -0
  33. package/dist/baseline/scaffold-baseline/skills/agnostic/planning/create-spec/references/readiness.md +40 -0
  34. package/dist/baseline/scaffold-baseline/skills/agnostic/planning/create-spec/references/spec-quality-bar.md +8 -0
  35. package/dist/baseline/scaffold-baseline/skills/agnostic/planning/implement-spec/SKILL.md +4 -2
  36. package/dist/baseline/scaffold-baseline/skills/agnostic/planning/implement-spec/references/architecture-conformance.md +10 -6
  37. package/dist/baseline/scaffold-baseline/skills/agnostic/planning/implement-spec/references/lifecycle.md +23 -10
  38. package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/brainstorm/SKILL.md +22 -0
  39. package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/requirements-grill/SKILL.md +2 -1
  40. package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/requirements-grill/references/artifact-output.md +3 -2
  41. package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/SKILL.md +6 -3
  42. package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/plan.md +4 -2
  43. package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/review.md +5 -1
  44. package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/router.md +15 -9
  45. package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/spec.md +13 -26
  46. package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/references/artifact-state.md +39 -1
  47. package/dist/baseline/scaffold-baseline/skills/phases/requirements-phase/SKILL.md +31 -14
  48. package/dist/baseline/scaffold-baseline/skills/phases/review-phase/phases/prepare-review.md +12 -4
  49. package/dist/baseline/scaffold-baseline.json +5 -5
  50. package/dist/baseline/scaffold-baseline.tgz +0 -0
  51. package/dist/data/hooks/format-edited-file.d.mts +5 -0
  52. package/dist/data/hooks/format-edited-file.mjs +282 -333
  53. package/dist/data/scripts/commit-gate-runner.mjs +98 -27
  54. package/dist/data/scripts/managed-lint-runner.d.mts +55 -0
  55. package/dist/data/scripts/managed-lint-runner.mjs +329 -0
  56. package/dist/data/scripts/managed-lint.d.mts +97 -0
  57. package/dist/data/scripts/managed-lint.mjs +658 -0
  58. package/dist/index.js +86 -1184
  59. package/dist/skills/agnostic/cli/hi-cli/SKILL.md +2 -0
  60. package/dist/skills/agnostic/cli/hi-cli/references/commands.md +8 -9
  61. package/dist/skills/agnostic/cli/hi-cli/references/managed-lint.md +165 -0
  62. package/dist/skills/agnostic/cli/hi-cli/references/post-command-flow.md +15 -11
  63. package/dist/skills/agnostic/cli/hi-cli/references/wiki-structure.md +16 -0
  64. package/dist/skills/agnostic/docs/docs-onboarding/SKILL.md +21 -16
  65. package/dist/skills/agnostic/docs/docs-onboarding/agents/openai.yaml +1 -1
  66. package/dist/skills/agnostic/docs/docs-onboarding/references/artifact-contract.md +16 -4
  67. package/dist/skills/agnostic/planning/create-architecture/SKILL.md +65 -0
  68. package/dist/skills/agnostic/planning/create-architecture/assets/ARCHITECTURE-TEMPLATE.md +119 -0
  69. package/dist/skills/agnostic/planning/create-architecture/references/artifact-contract.md +200 -0
  70. package/dist/skills/agnostic/planning/create-plan/SKILL.md +11 -3
  71. package/dist/skills/agnostic/planning/create-plan/references/architecture-convergence.md +19 -4
  72. package/dist/skills/agnostic/planning/create-plan/references/plan-schema.md +17 -3
  73. package/dist/skills/agnostic/planning/create-spec/SKILL.md +38 -20
  74. package/dist/skills/agnostic/planning/create-spec/assets/SPEC-TEMPLATE.md +11 -0
  75. package/dist/skills/agnostic/planning/create-spec/references/readiness.md +40 -0
  76. package/dist/skills/agnostic/planning/create-spec/references/spec-quality-bar.md +8 -0
  77. package/dist/skills/agnostic/planning/implement-spec/SKILL.md +4 -2
  78. package/dist/skills/agnostic/planning/implement-spec/references/architecture-conformance.md +10 -6
  79. package/dist/skills/agnostic/planning/implement-spec/references/lifecycle.md +23 -10
  80. package/dist/skills/agnostic/requirements/brainstorm/SKILL.md +22 -0
  81. package/dist/skills/agnostic/requirements/requirements-grill/SKILL.md +2 -1
  82. package/dist/skills/agnostic/requirements/requirements-grill/references/artifact-output.md +3 -2
  83. package/dist/skills/phases/delivery-phase/SKILL.md +6 -3
  84. package/dist/skills/phases/delivery-phase/phases/plan.md +4 -2
  85. package/dist/skills/phases/delivery-phase/phases/review.md +5 -1
  86. package/dist/skills/phases/delivery-phase/phases/router.md +15 -9
  87. package/dist/skills/phases/delivery-phase/phases/spec.md +13 -26
  88. package/dist/skills/phases/delivery-phase/references/artifact-state.md +39 -1
  89. package/dist/skills/phases/requirements-phase/SKILL.md +31 -14
  90. package/dist/skills/phases/review-phase/phases/prepare-review.md +12 -4
  91. package/package.json +3 -2
@@ -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
+ });
@@ -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).
@@ -4,25 +4,25 @@ The command is `hi`; `hint` is an alias. The npm package remains `@punks/cli`.
4
4
 
5
5
  ## `hi init`
6
6
 
7
- Use before repo-aware setup. It seeds docs onboarding, requirements/backlog/spec skills, and the initial wiki structure.
7
+ Use before repo-aware setup. It seeds docs onboarding and requirements/backlog/spec skills.
8
8
 
9
- Activate `$docs-onboarding` after the command. Reconcile a generated wiki root with the real repository layout before writing durable specs or routed docs.
9
+ Activate `$docs-onboarding` after the command. Follow the [existing wiki structure check](wiki-structure.md) before writing durable specs or routed docs. Wiki structure is project-owned; CLI commands do not create or update it.
10
10
 
11
11
  ## `hi scaffold`
12
12
 
13
13
  Use for repo-aware AI setup. It detects the repository, resolves packs, and writes managed `.agents/`, `.devpunks/`, skill, prompt, lint, subagent, tool, and scaffold-manifest assets.
14
14
 
15
- The command does not finish repo-specific authoring. Reconcile its generated instructions with the real repository. Use `hi scaffold --yes` only when a non-interactive harness must accept the resolved default pack selection; it does not select optional packs or resolve policy choices.
15
+ The command does not finish repo-specific authoring. Reconcile its generated instructions with the real repository. Use `hi scaffold --yes` only when a non-interactive harness must accept the resolved default pack selection; it does not select optional packs or resolve policy choices. Managed lint requires saved `lint.scopes`; missing selection is actionable work, while `[]` deliberately selects none. Follow [managed-lint.md](managed-lint.md) for candidate inventory, settings authoring, and policy reconciliation.
16
16
 
17
17
  ## `hi check`
18
18
 
19
- Use as the preferred read-only drift command. It checks managed scaffold, baseline, and CLI drift without writing files.
19
+ Use as the preferred read-only drift command. It checks managed scaffold, baseline, CLI, and managed lint selection/route health without writing files. An installed baseline identity alone does not establish correct live lint policy.
20
20
 
21
- Report the current findings. A clean result needs no update follow-through.
21
+ Report the current findings. For missing selection, stale policy, or command/config conflicts, use the matching next action in [managed-lint.md](managed-lint.md#interpret-the-result). A clean result needs no update follow-through; basic health inspection is not a whole-repository lint run.
22
22
 
23
23
  ## `hi ensure`
24
24
 
25
- Use to reconfigure repository manager, backlog provider, asset provider, and backlog project URL settings in an existing Harness setup.
25
+ Use to reconfigure repository manager, backlog provider, asset provider, backlog project URL, and managed lint ownership in an existing Harness setup. The managed lint choice keeps saved selection or accepts JSON arrays of exact Software Scopes and Excluded Paths. Inventory candidates through [managed-lint.md](managed-lint.md#select-software-scopes) before entering those arrays; preserve unrelated settings.
26
26
 
27
27
  It does not install, repair, validate, or refresh external tools. Use `hi tools ensure` for tools.
28
28
 
@@ -30,11 +30,10 @@ It does not install, repair, validate, or refresh external tools. Use `hi tools
30
30
 
31
31
  Use to refresh scaffold-managed files recorded in `.devpunks/scaffold-manifest.json`.
32
32
 
33
- - `--write` applies accepted managed-file updates.
34
- - `--yes` applies them non-interactively.
33
+ - Normal `hi update` applies updates; `--write` and `--yes` are compatibility apply aliases.
35
34
  - `--check` remains a supported compatibility preview, but prefer `hi check` for read-only drift inspection.
36
35
 
37
- After a write, follow only the changed categories in [post-command-flow.md](post-command-flow.md).
36
+ For lint changes, follow [managed-lint.md](managed-lint.md#reconcile-lint-adoption): preview the complete dependent change, preserve project policy, and distinguish source findings from failures that block activation. After a write, follow only the changed categories in [post-command-flow.md](post-command-flow.md).
38
37
 
39
38
  ## `hi tools ensure`
40
39