@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.
Files changed (110) hide show
  1. package/AGENTS.md +28 -10
  2. package/dist/BASELINE_CHANGELOG.md +19 -1
  3. package/dist/CHANGELOG.md +49 -0
  4. package/dist/baseline/scaffold-baseline/baseline.json +5 -10
  5. package/dist/baseline/scaffold-baseline/data/catalog/packs.json +1 -1
  6. package/dist/baseline/scaffold-baseline/data/catalog/skills.json +0 -8
  7. package/dist/baseline/scaffold-baseline/data/hooks/format-edited-file.mjs +408 -309
  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 +206 -58
  10. package/dist/baseline/scaffold-baseline/data/scripts/commit-gate-runner.test.ts +496 -29
  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 +323 -0
  13. package/dist/baseline/scaffold-baseline/data/scripts/managed-lint-runner.test.ts +821 -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/data/scripts/sync-subagents-validator.test.ts +39 -0
  18. package/dist/baseline/scaffold-baseline/data/scripts/sync-subagents.mjs +8 -2
  19. package/dist/baseline/scaffold-baseline/skills/agnostic/cli/hi-cli/SKILL.md +2 -0
  20. package/dist/baseline/scaffold-baseline/skills/agnostic/cli/hi-cli/references/commands.md +6 -7
  21. package/dist/baseline/scaffold-baseline/skills/agnostic/cli/hi-cli/references/managed-lint.md +165 -0
  22. package/dist/baseline/scaffold-baseline/skills/agnostic/cli/hi-cli/references/post-command-flow.md +20 -19
  23. package/dist/baseline/scaffold-baseline/skills/agnostic/docs/write-graph-based-skills/phases/define-handoffs.md +1 -1
  24. package/dist/baseline/scaffold-baseline/skills/agnostic/docs/write-graph-based-skills/phases/model-state.md +1 -1
  25. package/dist/baseline/scaffold-baseline/skills/agnostic/docs/write-graph-based-skills/phases/test-routes.md +1 -1
  26. package/dist/baseline/scaffold-baseline/skills/agnostic/docs/write-graph-based-skills/phases/write-phases.md +2 -2
  27. package/dist/baseline/scaffold-baseline/skills/agnostic/docs/write-graph-based-skills/phases/write-router.md +1 -1
  28. package/dist/baseline/scaffold-baseline/skills/agnostic/docs/write-graph-based-skills/references/authoring-contract.md +8 -8
  29. package/dist/baseline/scaffold-baseline/skills/agnostic/quality/autoreview/SKILL.md +1 -1
  30. package/dist/baseline/scaffold-baseline/skills/agnostic/quality/make-tsuite/SKILL.md +2 -2
  31. package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/brainstorm/SKILL.md +21 -11
  32. package/dist/baseline/scaffold-baseline/skills/phases/debugging-phase/SKILL.md +3 -4
  33. package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/SKILL.md +2 -2
  34. package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/debug.md +2 -2
  35. package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/human-steering.md +25 -0
  36. package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/implement.md +2 -2
  37. package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/review.md +2 -2
  38. package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/router.md +3 -2
  39. package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/references/context-continuity.md +1 -1
  40. package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/references/failure-continuity.md +1 -1
  41. package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/references/phase-handoff.md +4 -3
  42. package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/AUTHORING-HANDOFF.md +9 -9
  43. package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/SKILL.md +1 -1
  44. package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/ensure-fog.md +1 -1
  45. package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/grilling.md +1 -1
  46. package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/human-steering.md +25 -0
  47. package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/prototype.md +1 -1
  48. package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/reconcile.md +1 -1
  49. package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/research.md +1 -1
  50. package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/router.md +1 -1
  51. package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/references/state-graph.md +1 -1
  52. package/dist/baseline/scaffold-baseline/skills/phases/review-phase/phases/return-route.md +6 -5
  53. package/dist/baseline/scaffold-baseline/skills/phases/review-phase/phases/router.md +1 -1
  54. package/dist/baseline/scaffold-baseline/skills/phases/review-phase/phases/run-review.md +2 -1
  55. package/dist/baseline/scaffold-baseline/skills/phases/review-phase/references/state-graph.md +3 -3
  56. package/dist/baseline/scaffold-baseline.json +5 -5
  57. package/dist/baseline/scaffold-baseline.tgz +0 -0
  58. package/dist/data/AGENTS.md +22 -5
  59. package/dist/data/hooks/format-edited-file.mjs +237 -325
  60. package/dist/data/scripts/commit-gate-runner.mjs +206 -58
  61. package/dist/data/scripts/managed-lint-runner.d.mts +55 -0
  62. package/dist/data/scripts/managed-lint-runner.mjs +323 -0
  63. package/dist/data/scripts/managed-lint.d.mts +97 -0
  64. package/dist/data/scripts/managed-lint.mjs +658 -0
  65. package/dist/data/scripts/sync-subagents.mjs +8 -2
  66. package/dist/index.js +131 -153
  67. package/dist/skills/agnostic/cli/hi-cli/SKILL.md +2 -0
  68. package/dist/skills/agnostic/cli/hi-cli/references/commands.md +6 -7
  69. package/dist/skills/agnostic/cli/hi-cli/references/managed-lint.md +165 -0
  70. package/dist/skills/agnostic/cli/hi-cli/references/post-command-flow.md +6 -5
  71. package/dist/skills/agnostic/docs/write-graph-based-skills/phases/define-handoffs.md +1 -1
  72. package/dist/skills/agnostic/docs/write-graph-based-skills/phases/model-state.md +1 -1
  73. package/dist/skills/agnostic/docs/write-graph-based-skills/phases/test-routes.md +1 -1
  74. package/dist/skills/agnostic/docs/write-graph-based-skills/phases/write-phases.md +2 -2
  75. package/dist/skills/agnostic/docs/write-graph-based-skills/phases/write-router.md +1 -1
  76. package/dist/skills/agnostic/docs/write-graph-based-skills/references/authoring-contract.md +8 -8
  77. package/dist/skills/agnostic/quality/autoreview/SKILL.md +1 -1
  78. package/dist/skills/agnostic/quality/make-tsuite/SKILL.md +2 -2
  79. package/dist/skills/agnostic/requirements/brainstorm/SKILL.md +21 -11
  80. package/dist/skills/phases/debugging-phase/SKILL.md +3 -4
  81. package/dist/skills/phases/delivery-phase/SKILL.md +2 -2
  82. package/dist/skills/phases/delivery-phase/phases/debug.md +2 -2
  83. package/dist/skills/phases/delivery-phase/phases/human-steering.md +25 -0
  84. package/dist/skills/phases/delivery-phase/phases/implement.md +2 -2
  85. package/dist/skills/phases/delivery-phase/phases/review.md +2 -2
  86. package/dist/skills/phases/delivery-phase/phases/router.md +3 -2
  87. package/dist/skills/phases/delivery-phase/references/context-continuity.md +1 -1
  88. package/dist/skills/phases/delivery-phase/references/failure-continuity.md +1 -1
  89. package/dist/skills/phases/delivery-phase/references/phase-handoff.md +4 -3
  90. package/dist/skills/phases/finder-phase/AUTHORING-HANDOFF.md +6 -6
  91. package/dist/skills/phases/finder-phase/SKILL.md +1 -1
  92. package/dist/skills/phases/finder-phase/phases/ensure-fog.md +1 -1
  93. package/dist/skills/phases/finder-phase/phases/grilling.md +1 -1
  94. package/dist/skills/phases/finder-phase/phases/human-steering.md +25 -0
  95. package/dist/skills/phases/finder-phase/phases/prototype.md +1 -1
  96. package/dist/skills/phases/finder-phase/phases/reconcile.md +1 -1
  97. package/dist/skills/phases/finder-phase/phases/research.md +1 -1
  98. package/dist/skills/phases/finder-phase/phases/router.md +1 -1
  99. package/dist/skills/phases/finder-phase/references/state-graph.md +1 -1
  100. package/dist/skills/phases/review-phase/phases/return-route.md +6 -5
  101. package/dist/skills/phases/review-phase/phases/router.md +1 -1
  102. package/dist/skills/phases/review-phase/phases/run-review.md +2 -1
  103. package/dist/skills/phases/review-phase/references/state-graph.md +3 -3
  104. package/package.json +12 -6
  105. package/dist/baseline/scaffold-baseline/skills/agnostic/generic/handback/SKILL.md +0 -27
  106. package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/handback.md +0 -27
  107. package/dist/baseline/scaffold-baseline/skills/phases/finder-phase/phases/handback.md +0 -29
  108. package/dist/skills/agnostic/generic/handback/SKILL.md +0 -27
  109. package/dist/skills/phases/delivery-phase/phases/handback.md +0 -27
  110. package/dist/skills/phases/finder-phase/phases/handback.md +0 -29
@@ -0,0 +1,323 @@
1
+ #!/usr/bin/env node
2
+ /// <reference types="node" />
3
+ import { readFile, access } from "node:fs/promises";
4
+ import { spawnSync } from "node:child_process";
5
+ import path from "node:path";
6
+ import { resolveManagedLint, buildManagedLintCommand } from "./managed-lint.mjs";
7
+
8
+ /** @param {unknown} error - A filesystem or subprocess boundary failure. */
9
+ const missingFile = (error) => error instanceof Error && "code" in error && error.code === "ENOENT";
10
+ /** @param {unknown} error - A filesystem or subprocess boundary failure. */
11
+ const errorMessage = (error) => (error instanceof Error ? error.message : String(error));
12
+ /** @param {unknown} value @returns {value is Record<string, unknown>} */
13
+ const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
14
+ /** @param {unknown} value @returns {value is import("./managed-lint-runner.mjs").ManagedLintDiagnostic} */
15
+ const isDiagnostic = (value) =>
16
+ isRecord(value) &&
17
+ typeof value.message === "string" &&
18
+ ["filename", "code", "severity"].every(
19
+ (key) => value[key] === undefined || typeof value[key] === "string",
20
+ );
21
+ /** @param {string} file @param {unknown} [missingValue] @returns {Promise<unknown>} */
22
+ const readJson = async (file, missingValue = null) => {
23
+ try {
24
+ /** @type {unknown} */
25
+ const value = JSON.parse(await readFile(file, "utf-8"));
26
+ return value;
27
+ } catch (error) {
28
+ if (missingFile(error)) {
29
+ return missingValue;
30
+ }
31
+ throw error;
32
+ }
33
+ };
34
+ /** @param {string} root @param {readonly string[]} [paths] @param {string} [scope] */
35
+ export const loadManagedLint = async (root, paths, scope) =>
36
+ await resolveManagedLint({
37
+ root,
38
+ selection: await readJson(path.join(root, ".devpunks/specs/lint/selection.json")),
39
+ settings: await readJson(path.join(root, ".devpunks/settings.json"), {}),
40
+ ...(paths === undefined ? {} : { paths }),
41
+ ...(scope === undefined ? {} : { scope }),
42
+ });
43
+ /** @param {string} cwd @returns {Promise<string>} */
44
+ const discoverRoot = async (cwd) => {
45
+ try {
46
+ await access(path.join(cwd, ".devpunks/settings.json"));
47
+ return cwd;
48
+ } catch (error) {
49
+ if (!missingFile(error)) {
50
+ throw error;
51
+ }
52
+ }
53
+ const parent = path.dirname(cwd);
54
+ if (parent === cwd) {
55
+ throw new Error(
56
+ "Select software scopes in .devpunks/settings.json lint.scopes, or pass --root.",
57
+ );
58
+ }
59
+ return await discoverRoot(parent);
60
+ };
61
+ /** @param {string} root @param {string} cwd @returns {NodeJS.ProcessEnv} */
62
+ export const managedLintEnvironment = (root, cwd) => {
63
+ const bins = [];
64
+ let current = cwd;
65
+ while (true) {
66
+ bins.push(path.join(current, "node_modules/.bin"));
67
+ if (current === root) {
68
+ break;
69
+ }
70
+ const parent = path.dirname(current);
71
+ if (parent === current) {
72
+ break;
73
+ }
74
+ current = parent;
75
+ }
76
+ return { ...process.env, PATH: [...bins, path.dirname(process.execPath)].join(path.delimiter) };
77
+ };
78
+ /** @param {import("./managed-lint-runner.mjs").ManagedLintRunOptions} options @returns {Promise<import("./managed-lint-runner.mjs").ManagedLintRunResult>} */
79
+ export const runManagedLint = async (options) => {
80
+ try {
81
+ return await executeManagedLint(options);
82
+ } catch (error) {
83
+ return { code: 2, diagnostics: [errorMessage(error)], status: "conflict" };
84
+ }
85
+ };
86
+ /** @param {import("./managed-lint-runner.mjs").ManagedLintRunOptions} options @returns {Promise<import("./managed-lint-runner.mjs").ManagedLintRunResult>} */
87
+ const executeManagedLint = async ({ root, scope, paths, output = "human" }) => {
88
+ let resolution = await loadManagedLint(root, paths, scope);
89
+ if (resolution.status === "disabled") {
90
+ return { code: 0, results: [], status: "clean" };
91
+ }
92
+ if (resolution.status !== "ready") {
93
+ return { ...resolution, code: 2 };
94
+ }
95
+ if (resolution.routes.some((route) => route.triggered)) {
96
+ const complete = await loadManagedLint(root);
97
+ if (complete.status !== "ready") {
98
+ return { ...complete, code: 2 };
99
+ }
100
+ resolution = {
101
+ ...resolution,
102
+ routes: resolution.routes.map((route) =>
103
+ route.triggered
104
+ ? (complete.routes.find((item) => item.scope === route.scope) ?? route)
105
+ : route,
106
+ ),
107
+ };
108
+ }
109
+ const commands = await Promise.all(
110
+ resolution.routes
111
+ .filter((item) => scope === undefined || scope === item.scope)
112
+ .map(async (route) => await buildManagedLintCommand({ output: "json", root, route })),
113
+ );
114
+ const failure = commands.find(
115
+ (command) => command.status !== "ready" && command.status !== "empty",
116
+ );
117
+ if (failure !== undefined) {
118
+ return { ...failure, code: 2, results: [] };
119
+ }
120
+ const results = commands
121
+ .filter((command) => command.status === "ready")
122
+ .map((command) => executeManagedLintCommand({ command, output, root }));
123
+ /** @type {0 | 1 | 2} */
124
+ let code = 0;
125
+ if (results.some((result) => result.code !== 0)) {
126
+ code = 1;
127
+ }
128
+ if (results.some((result) => result.code === 2)) {
129
+ code = 2;
130
+ }
131
+ /** @type {readonly ["clean", "findings", "operational-failure"]} */
132
+ const statuses = ["clean", "findings", "operational-failure"];
133
+ return { code, results, status: statuses[code] };
134
+ };
135
+ /** @param {string} stdout - Structured output from the local Oxlint subprocess.
136
+ * @returns {{ diagnostics: readonly import("./managed-lint-runner.mjs").ManagedLintDiagnostic[], empty: boolean } | null} A valid report, or null for malformed output.
137
+ */
138
+ const readLintOutput = (stdout) => {
139
+ const notice = [
140
+ "No files found matching the given patterns.",
141
+ "No files found to lint. Please check your paths and ignore patterns.",
142
+ ].find((candidate) => stdout.startsWith(`${candidate}\n`));
143
+ try {
144
+ /** @type {unknown} */
145
+ const value = JSON.parse(notice === undefined ? stdout : stdout.slice(notice.length + 1));
146
+ if (
147
+ isRecord(value) &&
148
+ Array.isArray(value.diagnostics) &&
149
+ value.diagnostics.every(isDiagnostic) &&
150
+ (notice === undefined || (value.diagnostics.length === 0 && value.number_of_files === 0))
151
+ ) {
152
+ return { diagnostics: value.diagnostics, empty: notice !== undefined };
153
+ }
154
+ } catch {
155
+ // Malformed/config output is operational, even if the subprocess exits zero.
156
+ }
157
+ return null;
158
+ };
159
+ /** @param {string} stderr - Node's benign warning for a typeless package's ESM config. */
160
+ const hasOnlyModuleTypeWarnings = (stderr) =>
161
+ stderr
162
+ .split(/\r?\n/u)
163
+ .map((line) => line.trim())
164
+ .filter((line) => line.length > 0)
165
+ .every(
166
+ (line) =>
167
+ /^\(node:\d+\) \[MODULE_TYPELESS_PACKAGE_JSON\] Warning: Module type of .+ is not specified and it doesn't parse as CommonJS\.$/u.test(
168
+ line,
169
+ ) ||
170
+ line ===
171
+ "Reparsing as ES module because module syntax was detected. This incurs a performance overhead." ||
172
+ /^To eliminate this warning, add "type": "module" to .+\.$/u.test(line) ||
173
+ line === "(Use `node --trace-warnings ...` to show where the warning was created)",
174
+ );
175
+ /** @param {import("node:child_process").SpawnSyncReturns<string>} result - The local Oxlint process result.
176
+ * @param {ReturnType<typeof readLintOutput>} report - Its validated structured output.
177
+ * @returns {0 | 1 | 2} The public clean, findings, or operational-failure exit code.
178
+ */
179
+ const lintExitCode = (result, report) => {
180
+ if (result.error !== undefined || result.signal !== null || report === null) {
181
+ return 2;
182
+ }
183
+ if (!hasOnlyModuleTypeWarnings(result.stderr ?? "")) {
184
+ return 2;
185
+ }
186
+ if (result.status === 0) {
187
+ return 0;
188
+ }
189
+ if (result.status !== 1) {
190
+ return 2;
191
+ }
192
+ if (report.empty) {
193
+ return 0;
194
+ }
195
+ return report.diagnostics.length > 0 ? 1 : 2;
196
+ };
197
+ /** @param {import("node:child_process").SpawnSyncReturns<string>} result - Original process evidence.
198
+ * @param {ReturnType<typeof readLintOutput>} report - Validated structured output.
199
+ * @returns {NonNullable<import("./managed-lint-runner.mjs").ManagedLintExecution["failure"]>} The operational failure's presentation context.
200
+ */
201
+ const lintFailure = (result, report) => {
202
+ if (result.error !== undefined || result.signal !== null || result.status === null) {
203
+ return { kind: "process", phase: "lint" };
204
+ }
205
+ if (
206
+ result.status !== 0 &&
207
+ /^Failed to parse oxlint configuration file\./mu.test(result.stdout ?? "")
208
+ ) {
209
+ return { kind: "config-load", phase: "config" };
210
+ }
211
+ const stderr = result.stderr ?? "";
212
+ if (!hasOnlyModuleTypeWarnings(stderr) && /config|load/iu.test(stderr)) {
213
+ return { kind: "config-load", phase: "lint" };
214
+ }
215
+ return { kind: report === null ? "malformed-output" : "process", phase: "lint" };
216
+ };
217
+ /** @param {import("./managed-lint-runner.mjs").ManagedLintExecutionOptions} options @returns {import("./managed-lint-runner.mjs").ManagedLintExecution} */
218
+ export const executeManagedLintCommand = ({ root, command, output = "json" }) => {
219
+ const result = spawnSync(command.executable, command.args, {
220
+ cwd: command.cwd,
221
+ encoding: "utf-8",
222
+ env: managedLintEnvironment(root, command.cwd),
223
+ maxBuffer: 10 * 1024 * 1024,
224
+ });
225
+ const report = readLintOutput(result.stdout ?? "");
226
+ const stderr = result.stderr ?? "";
227
+ const diagnostics = report?.diagnostics;
228
+ const code = lintExitCode(result, report);
229
+ const stdout =
230
+ output === "json" || code === 2 || diagnostics === undefined
231
+ ? (result.stdout ?? "")
232
+ : diagnostics
233
+ .map(
234
+ (item) =>
235
+ `${item.filename ?? command.scope}: ${item.severity ?? "error"}: ${item.message} (${item.code ?? "lint"})`,
236
+ )
237
+ .join("\n") + (diagnostics.length > 0 ? "\n" : "");
238
+ return {
239
+ code,
240
+ command,
241
+ error: result.error,
242
+ scope: command.scope,
243
+ signal: result.signal,
244
+ status: result.status,
245
+ stderr: stderr === "" ? (result.error?.message ?? "") : stderr,
246
+ stdout,
247
+ ...(code === 2 ? { failure: lintFailure(result, report) } : {}),
248
+ ...(diagnostics === undefined ? {} : { diagnostics }),
249
+ };
250
+ };
251
+
252
+ const main = async () => {
253
+ const args = process.argv.slice(2);
254
+ let root;
255
+ let scope;
256
+ /** @type {"human" | "json"} */
257
+ let output = "human";
258
+ let paths;
259
+ for (let index = 0; index < args.length; index += 1) {
260
+ const arg = args[index];
261
+ if (arg === "--") {
262
+ paths = args.slice(index + 1);
263
+ break;
264
+ }
265
+ if (!["--root", "--scope", "--format"].includes(arg) || args[index + 1] === undefined) {
266
+ throw new Error(`Unknown or incomplete argument: ${arg}`);
267
+ }
268
+ index += 1;
269
+ const value = args[index];
270
+ if (value.startsWith("--")) {
271
+ throw new Error(`Missing value for ${arg}`);
272
+ }
273
+ if (arg === "--root") {
274
+ root = path.resolve(value);
275
+ }
276
+ if (arg === "--scope") {
277
+ scope = value;
278
+ }
279
+ if (arg === "--format") {
280
+ if (value !== "human" && value !== "json") {
281
+ throw new Error("--format must be human or json");
282
+ }
283
+ output = value;
284
+ }
285
+ }
286
+ if (!["human", "json"].includes(output)) {
287
+ throw new Error("--format must be human or json");
288
+ }
289
+ const resolvedRoot = root ?? (await discoverRoot(process.cwd()));
290
+ const result = await runManagedLint({
291
+ output,
292
+ paths: paths?.map((file) =>
293
+ path.relative(resolvedRoot, path.resolve(file)).split(path.sep).join("/"),
294
+ ),
295
+ root: resolvedRoot,
296
+ scope,
297
+ });
298
+ if (output === "json") {
299
+ process.stdout.write(`${JSON.stringify(result)}\n`);
300
+ } else {
301
+ for (const owner of result.results ?? []) {
302
+ process.stdout.write(owner.stdout);
303
+ process.stderr.write(owner.stderr);
304
+ }
305
+ }
306
+ for (const diagnostic of result.diagnostics ?? []) {
307
+ process.stderr.write(`${diagnostic}\n`);
308
+ }
309
+ process.exitCode = result.code;
310
+ };
311
+ // Bundling rewrites import.meta.filename to the host CLI; retain the standalone asset identity.
312
+ if (
313
+ process.argv[1] !== undefined &&
314
+ path.basename(process.argv[1]) === "managed-lint-runner.mjs" &&
315
+ path.resolve(process.argv[1]) === import.meta.filename
316
+ ) {
317
+ try {
318
+ await main();
319
+ } catch (error) {
320
+ console.error(errorMessage(error));
321
+ process.exitCode = 2;
322
+ }
323
+ }
@@ -0,0 +1,97 @@
1
+ /** Derived member of the existing .devpunks/specs/lint/selection.json artifact. */
2
+ export interface ManagedLintSelection {
3
+ readonly version: 1;
4
+ readonly scopes: readonly string[];
5
+ readonly exclude: readonly string[];
6
+ readonly routes: readonly ManagedLintRoute[];
7
+ }
8
+ export interface ManagedQualityPathOptions {
9
+ /** Normalized repository-relative POSIX path. */
10
+ readonly path: string;
11
+ /** Repository-relative exclusions already validated at the settings boundary. */
12
+ readonly exclude: readonly string[];
13
+ }
14
+ /**
15
+ * Pure shared hard and persisted exclusions, independent of package selection.
16
+ * @throws {TypeError} If path fails the managed lint repository-relative path boundary.
17
+ */
18
+ export function isManagedQualityPathExcluded(options: ManagedQualityPathOptions): boolean;
19
+
20
+ export interface ManagedLintPolicyInput {
21
+ readonly path: string;
22
+ readonly sha256: string;
23
+ }
24
+ export interface ManagedLintRoute {
25
+ /** Exact repository-relative package root, or explicit standalone ".". */
26
+ readonly scope: string;
27
+ /** Repository-relative effective oxlint.config.ts. */
28
+ readonly config: string;
29
+ readonly tool: { readonly package: "oxlint"; readonly version: string };
30
+ /** null preserves an explicitly represented unrestricted warning threshold. */
31
+ readonly maxWarnings: number | null;
32
+ /** Repository-relative transitive policy, preset, plugin and toolchain inputs. */
33
+ readonly inputs: readonly string[];
34
+ /** Hashes of authored inputs whose semantics were compiled into the effective policy. */
35
+ readonly policyInputs?: readonly ManagedLintPolicyInput[];
36
+ }
37
+ export interface ResolvedManagedLintRoute extends ManagedLintRoute {
38
+ readonly files: readonly string[];
39
+ readonly boundaries: readonly string[];
40
+ /** A shared dependency changed: adapter should validate the complete owner. */
41
+ readonly triggered: boolean;
42
+ }
43
+ export interface ManagedLintFailure {
44
+ readonly status: "selection-needed" | "conflict";
45
+ readonly diagnostics: readonly string[];
46
+ }
47
+ export type ManagedLintResolution =
48
+ | ManagedLintFailure
49
+ | {
50
+ readonly status: "disabled";
51
+ readonly diagnostics: readonly string[];
52
+ }
53
+ | {
54
+ readonly status: "ready";
55
+ readonly routes: readonly ResolvedManagedLintRoute[];
56
+ readonly excludedPaths: readonly string[];
57
+ };
58
+ /** No execution or publication. Omitted paths enumerate existing eligible files; [] selects none. */
59
+ export interface ResolveManagedLintOptions {
60
+ /** When provided, validate this selected owner even for excluded-only requests. */
61
+ readonly scope?: string;
62
+ readonly root: string;
63
+ readonly settings: unknown;
64
+ readonly selection: unknown;
65
+ readonly paths?: readonly string[];
66
+ }
67
+ export function resolveManagedLint(
68
+ options: ResolveManagedLintOptions,
69
+ ): Promise<ManagedLintResolution>;
70
+ export type ManagedLintCommand =
71
+ | ManagedLintFailure
72
+ | {
73
+ readonly status: "empty";
74
+ readonly diagnostics: readonly string[];
75
+ }
76
+ | {
77
+ readonly status: "ready";
78
+ readonly executable: string;
79
+ readonly args: readonly string[];
80
+ readonly cwd: string;
81
+ readonly config: string;
82
+ readonly toolVersion: string;
83
+ readonly scope: string;
84
+ readonly logicalSourcePath: string | undefined;
85
+ readonly physicalInputPath: string | undefined;
86
+ };
87
+ /** A different physical path is rejected until an adapter provides a controlled mirror root. */
88
+ export interface BuildManagedLintCommandOptions {
89
+ readonly root: string;
90
+ readonly route: ResolvedManagedLintRoute;
91
+ readonly output?: "human" | "json";
92
+ readonly logicalSourcePath?: string;
93
+ readonly physicalInputPath?: string;
94
+ }
95
+ export function buildManagedLintCommand(
96
+ options: BuildManagedLintCommandOptions,
97
+ ): Promise<ManagedLintCommand>;