@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
@@ -2,7 +2,11 @@
2
2
 
3
3
  import { createHash, randomUUID } from "node:crypto";
4
4
  import {
5
- accessSync,
5
+ cpSync,
6
+ mkdtempSync,
7
+ readdirSync,
8
+ readlinkSync,
9
+ symlinkSync,
6
10
  closeSync,
7
11
  constants,
8
12
  existsSync,
@@ -19,7 +23,7 @@ import {
19
23
  import os from "node:os";
20
24
  import path from "node:path";
21
25
  import { spawnSync } from "node:child_process";
22
- import { fileURLToPath } from "node:url";
26
+ import { pathToFileURL, fileURLToPath } from "node:url";
23
27
 
24
28
  const javascriptFormattableSuffixes = new Set([
25
29
  ".ts",
@@ -38,8 +42,8 @@ const formattableSuffixes = new Set([
38
42
  ]);
39
43
  const ignoredParts = new Set([".git", "node_modules", ".next", "dist"]);
40
44
  const scaffoldManifestPath = ".devpunks/scaffold-manifest.json";
45
+ const managedHookPathsPath = ".devpunks/managed-hook-paths.json";
41
46
  const productRoots = new Set(["apps", "packages"]);
42
- const packageManagers = new Set(["bun", "pnpm", "npm", "yarn"]);
43
47
  const backendWorkspaceSegments = new Set(["api", "backend", "server", "services"]);
44
48
 
45
49
  function readStdinJson() {
@@ -180,116 +184,33 @@ function runCommand(root, args, stdio = ["ignore", "pipe", "pipe"]) {
180
184
  };
181
185
  }
182
186
 
183
- function owningWorkspace(root, relativePath) {
184
- const absolutePath = path.join(root, relativePath);
185
- let current = path.dirname(absolutePath);
186
-
187
- while (current === root || !path.relative(root, current).startsWith("..")) {
188
- if (existsSync(path.join(current, "package.json"))) {
189
- return current;
190
- }
191
-
192
- const parent = path.dirname(current);
193
- if (parent === current) {
194
- break;
195
- }
196
- current = parent;
197
- }
198
-
199
- return root;
200
- }
201
-
202
187
  function workspaceRelativePath(workspace, root, relativePath) {
203
188
  const workspacePath = path.relative(workspace, path.join(root, relativePath));
204
189
  return workspacePath.split(path.sep).join("/");
205
190
  }
206
191
 
207
- function commandExists(command) {
208
- const pathValue = process.env.PATH ?? process.env.Path;
209
- if (!pathValue) {
210
- return false;
211
- }
212
-
213
- const isWindows = os.platform() === "win32";
214
- const pathEntries = pathValue.split(isWindows ? ";" : ":").filter(Boolean);
215
- const pathExtensions = isWindows
216
- ? (process.env.PATHEXT ?? ".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean)
217
- : [""];
218
- const commandExtensions = isWindows && path.extname(command) === "" ? pathExtensions : [""];
219
- const hasPathSegment = command.includes("/") || command.includes("\\");
220
- const candidates = (hasPathSegment ? [""] : pathEntries).flatMap((entry) =>
221
- commandExtensions.map((extension) =>
222
- hasPathSegment ? `${command}${extension}` : path.join(entry, `${command}${extension}`),
223
- ),
224
- );
225
-
226
- return candidates.some((candidate) => {
227
- try {
228
- accessSync(candidate, isWindows ? constants.F_OK : constants.X_OK);
229
- return true;
230
- } catch {
231
- return false;
192
+ function toolCommand(directory, tool, args) {
193
+ const root = repoRoot(directory);
194
+ let current = directory;
195
+ while (true) {
196
+ const manifest = path.join(current, "node_modules", tool, "package.json");
197
+ if (existsSync(manifest)) {
198
+ const value = JSON.parse(readFileSync(manifest, "utf8"));
199
+ const bin = typeof value.bin === "string" ? value.bin : value.bin?.[tool];
200
+ if (
201
+ value.name !== tool ||
202
+ typeof bin !== "string" ||
203
+ path.isAbsolute(bin) ||
204
+ bin.split(/[\\/]/u).includes("..")
205
+ )
206
+ throw new Error(`Invalid repository-local ${tool} executable`);
207
+ return [path.resolve(path.dirname(manifest), bin), ...args];
232
208
  }
233
- });
234
- }
235
-
236
- function packageManagerFromPackageJson(root) {
237
- const packageManager = loadJson(path.join(root, "package.json"))?.packageManager;
238
-
239
- if (typeof packageManager !== "string") {
240
- return null;
241
- }
242
-
243
- const name = packageManager.split("@")[0];
244
- return packageManagers.has(name) ? name : null;
245
- }
246
-
247
- function packageManagerFromLockfile(root) {
248
- if (existsSync(path.join(root, "bun.lock")) || existsSync(path.join(root, "bun.lockb"))) {
249
- return "bun";
250
- }
251
-
252
- if (
253
- existsSync(path.join(root, "pnpm-lock.yaml")) ||
254
- existsSync(path.join(root, "pnpm-workspace.yaml"))
255
- ) {
256
- return "pnpm";
257
- }
258
-
259
- if (existsSync(path.join(root, "yarn.lock"))) {
260
- return "yarn";
261
- }
262
-
263
- if (existsSync(path.join(root, "package-lock.json"))) {
264
- return "npm";
209
+ if (current === root || path.dirname(current) === current) break;
210
+ current = path.dirname(current);
265
211
  }
266
-
267
- return null;
268
- }
269
-
270
- function toolCommand(root, tool, args) {
271
- switch (packageManagerFromPackageJson(root) ?? packageManagerFromLockfile(root)) {
272
- case "bun":
273
- return ["bunx", tool, ...args];
274
- case "pnpm":
275
- return ["pnpm", "exec", tool, ...args];
276
- case "yarn":
277
- return ["yarn", "exec", tool, ...args];
278
- case "npm":
279
- return ["npm", "exec", "--", tool, ...args];
280
- default:
281
- break;
282
- }
283
-
284
- if (commandExists("bunx")) {
285
- return ["bunx", tool, ...args];
286
- }
287
-
288
- if (commandExists("pnpm")) {
289
- return ["pnpm", "exec", tool, ...args];
290
- }
291
-
292
- return ["npx", tool, ...args];
212
+ // An intentionally missing local path becomes a normal operational failure in runCommand.
213
+ return [path.join(root || directory, "node_modules/.bin", tool), ...args];
293
214
  }
294
215
 
295
216
  function nearestPythonProject(root, relativePath) {
@@ -372,23 +293,52 @@ function normalizeManagedPath(filePath) {
372
293
  }
373
294
 
374
295
  function loadManagedPaths(root, caseInsensitivePaths) {
375
- const manifest = loadJson(path.join(root, scaffoldManifestPath));
376
- if (!manifest || typeof manifest !== "object" || !Array.isArray(manifest.managedFiles)) {
377
- return null;
378
- }
379
-
380
- const managedPaths = new Set();
381
- for (const entry of manifest.managedFiles) {
382
- if (!entry || typeof entry !== "object" || Array.isArray(entry)) {
296
+ let paths;
297
+ let usesTrackedIndex = false;
298
+ try {
299
+ if (!lstatSync(path.join(root, managedHookPathsPath)).isFile()) {
300
+ return null;
301
+ }
302
+ const index = loadJson(path.join(root, managedHookPathsPath));
303
+ if (!index || index.version !== 1 || !Array.isArray(index.paths)) {
304
+ return null;
305
+ }
306
+ paths = index.paths;
307
+ usesTrackedIndex = true;
308
+ } catch (error) {
309
+ if (error?.code !== "ENOENT") {
383
310
  return null;
384
311
  }
312
+ const manifest = loadJson(path.join(root, scaffoldManifestPath));
313
+ if (!manifest || typeof manifest !== "object" || !Array.isArray(manifest.managedFiles)) {
314
+ return null;
315
+ }
316
+ paths = [];
317
+ for (const entry of manifest.managedFiles) {
318
+ if (!entry || typeof entry !== "object" || Array.isArray(entry)) {
319
+ return null;
320
+ }
321
+ paths.push(entry.path);
322
+ }
323
+ }
385
324
 
386
- const normalizedPath = normalizeManagedPath(entry.path);
325
+ const managedPaths = new Set();
326
+ for (const filePath of paths) {
327
+ const normalizedPath = normalizeManagedPath(filePath);
387
328
  if (!normalizedPath) {
388
329
  return null;
389
330
  }
390
331
  managedPaths.add(managedPathKey(normalizedPath, caseInsensitivePaths));
391
332
  }
333
+ if (
334
+ usesTrackedIndex &&
335
+ [managedHookPathsPath, scaffoldManifestPath].some(
336
+ (filePath) => !managedPaths.has(managedPathKey(filePath, caseInsensitivePaths)),
337
+ )
338
+ ) {
339
+ return null;
340
+ }
341
+ managedPaths.add(managedPathKey(managedHookPathsPath, caseInsensitivePaths));
392
342
 
393
343
  return managedPaths;
394
344
  }
@@ -518,105 +468,269 @@ function normalizeDiagnostic(diagnostic, root, fallbackPath, temporaryPath = nul
518
468
  return normalized;
519
469
  }
520
470
 
521
- function parseLintDiagnostics(stdout, root, fallbackPath, temporaryPath = null) {
522
- let parsed;
523
- try {
524
- parsed = JSON.parse(stdout || "");
525
- } catch {
526
- return { ok: false, error: "Oxlint returned malformed JSON" };
527
- }
528
-
529
- if (!parsed || typeof parsed !== "object" || !Array.isArray(parsed.diagnostics)) {
530
- return { ok: false, error: "Oxlint JSON did not contain diagnostics" };
471
+ function normalizeManagedDiagnostics(report, root, scope, fallbackPath) {
472
+ if (!Array.isArray(report))
473
+ return { ok: false, error: "Oxlint did not return validated diagnostics" };
474
+ const diagnostics = [];
475
+ for (const diagnostic of report) {
476
+ let filename = fallbackPath;
477
+ if (typeof diagnostic.filename === "string" && diagnostic.filename.length > 0) {
478
+ filename = path
479
+ .relative(root, path.resolve(root, scope, diagnostic.filename))
480
+ .split(path.sep)
481
+ .join("/");
482
+ if (filename === ".." || filename.startsWith("../") || path.isAbsolute(filename))
483
+ return { ok: false, error: "Oxlint diagnostic escaped the managed repository" };
484
+ }
485
+ diagnostics.push(normalizeDiagnostic({ ...diagnostic, filename }, root, fallbackPath));
531
486
  }
487
+ return { ok: true, diagnostics };
488
+ }
532
489
 
533
- const diagnostics = parsed.diagnostics.map((diagnostic) =>
534
- normalizeDiagnostic(diagnostic, root, fallbackPath, temporaryPath),
490
+ async function lintRuntime(root) {
491
+ const canonical = path.join(root, ".agents/scripts/managed-lint-runner.mjs");
492
+ const local = new URL("../scripts/managed-lint-runner.mjs", import.meta.url);
493
+ const runner = await import(existsSync(canonical) ? pathToFileURL(canonical).href : local.href);
494
+ const resolver = await import(
495
+ existsSync(canonical)
496
+ ? pathToFileURL(path.join(root, ".agents/scripts/managed-lint.mjs")).href
497
+ : new URL("../scripts/managed-lint.mjs", import.meta.url).href
535
498
  );
536
- if (diagnostics.some((diagnostic) => diagnostic === null)) {
537
- return { ok: false, error: "Oxlint JSON contained an invalid diagnostic" };
499
+ return { ...runner, ...resolver };
500
+ }
501
+
502
+ async function selectedLint(root, filePaths) {
503
+ try {
504
+ const runtime = await lintRuntime(root);
505
+ const paths = filePaths.map((file) =>
506
+ path.relative(root, path.resolve(root, file)).split(path.sep).join("/"),
507
+ );
508
+ const resolution = await runtime.loadManagedLint(root, paths);
509
+ if (resolution.status === "disabled") return { runtime, routes: [] };
510
+ if (resolution.status !== "ready") throw new Error(resolution.diagnostics.join("\n"));
511
+ return { runtime, routes: resolution.routes };
512
+ } catch (error) {
513
+ return {
514
+ failure: emptyLintSummary("operational_failure", [
515
+ { stage: "config-load", command: "managed lint selection", message: error.message },
516
+ ]),
517
+ };
538
518
  }
519
+ }
539
520
 
540
- return { ok: true, diagnostics };
521
+ // Python shares quality exclusions, but does not require JavaScript owner selection.
522
+ function qualityExclusions(root) {
523
+ let settings;
524
+ try {
525
+ settings = JSON.parse(readFileSync(path.join(root, ".devpunks/settings.json"), "utf8"));
526
+ } catch (error) {
527
+ if (error?.code === "ENOENT") return [];
528
+ throw error;
529
+ }
530
+ const record = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
531
+ if (!record(settings) || (settings.lint !== undefined && !record(settings.lint))) {
532
+ throw new TypeError("Managed quality settings and lint must be objects");
533
+ }
534
+ const exclude = settings.lint?.exclude;
535
+ if (exclude === undefined) return [];
536
+ if (
537
+ !Array.isArray(exclude) ||
538
+ !exclude.every(
539
+ (pattern) =>
540
+ typeof pattern === "string" &&
541
+ pattern.length > 0 &&
542
+ !pattern.startsWith("!") &&
543
+ !pattern.includes("\\") &&
544
+ !path.posix.isAbsolute(pattern) &&
545
+ pattern.split("/").every((part) => part !== ".." && part !== "") &&
546
+ path.posix.normalize(pattern) === pattern,
547
+ )
548
+ )
549
+ throw new TypeError("lint.exclude must be a list of repository-relative patterns.");
550
+ return exclude;
541
551
  }
542
552
 
543
- function runSafeJavascriptLint(workspace, root, relativePath, content) {
544
- const workspacePath = workspaceRelativePath(workspace, root, relativePath);
545
- const directory = path.dirname(path.join(workspace, workspacePath));
546
- const temporaryDirectory = path.join(directory, `.hi-lint-stage-${randomUUID()}`);
547
- const temporaryPath = path.join(temporaryDirectory, path.basename(workspacePath));
548
- const temporaryRelativePath = path.relative(workspace, temporaryPath).split(path.sep).join("/");
553
+ async function selectedQuality(root, filePaths) {
554
+ const caseSemantics = pathCaseSemantics(root);
555
+ if (caseSemantics === "unknown") {
556
+ return {
557
+ failure: emptyLintSummary("operational_failure", [
558
+ {
559
+ stage: "config-load",
560
+ command: "path case semantics",
561
+ message: "Unable to determine path case semantics",
562
+ },
563
+ ]),
564
+ };
565
+ }
566
+
567
+ const caseInsensitivePaths = caseSemantics === "case-insensitive";
568
+ const managedPaths = loadManagedPaths(root, caseInsensitivePaths);
569
+ if (managedPaths === null) {
570
+ return {
571
+ failure: emptyLintSummary("operational_failure", [
572
+ {
573
+ stage: "config-load",
574
+ command: managedHookPathsPath,
575
+ message: `Managed hook ownership metadata is missing or invalid (${managedHookPathsPath}; legacy fallback: ${scaffoldManifestPath})`,
576
+ },
577
+ ]),
578
+ };
579
+ }
549
580
 
550
581
  try {
551
- mkdirSync(temporaryDirectory, { mode: 0o700 });
552
- writeFileSync(temporaryPath, content, { flag: "wx", mode: 0o600 });
553
- const fixCommand = toolCommand(workspace, "oxlint", [
554
- "--fix",
555
- "--format",
556
- "json",
557
- temporaryRelativePath,
558
- ]);
559
- const fixResult = runCommand(workspace, fixCommand);
560
- if (fixResult.error !== undefined) {
561
- return {
562
- ok: false,
563
- stage: "lint-fix",
564
- command: commandText(fixCommand),
565
- exitCode: fixResult.status,
566
- error: `Oxlint could not start: ${fixResult.error.message}`,
567
- };
568
- }
582
+ const runtime = await lintRuntime(root);
583
+ const exclude = qualityExclusions(root);
584
+ const eligible = [
585
+ ...new Set(
586
+ filePaths
587
+ .map((file) => normalizeRelativePath(root, file, managedPaths, caseInsensitivePaths))
588
+ .filter(
589
+ (file) =>
590
+ file !== null && !runtime.isManagedQualityPathExcluded({ path: file, exclude }),
591
+ ),
592
+ ),
593
+ ];
594
+ const nonPythonPaths = filePaths.filter((file) => !isPythonPath(file));
595
+ const selection =
596
+ nonPythonPaths.length > 0
597
+ ? await selectedLint(root, nonPythonPaths)
598
+ : { runtime, routes: [] };
599
+ // Keep raw resolver-owned dependency triggers, including scaffold metadata.
600
+ // The resolver handles excluded-only source; unrelated non-JS files stay independent.
601
+ const requiresSelection = nonPythonPaths.some((file) =>
602
+ javascriptFormattableSuffixes.has(path.extname(file)),
603
+ );
604
+ const javascriptPaths = selection.failure && !requiresSelection ? [] : nonPythonPaths;
605
+ const routes = selection.routes ?? [];
606
+ const selectedFiles = new Set(routes.flatMap((route) => route.files));
607
+ return {
608
+ runtime,
609
+ routes,
610
+ javascriptPaths,
611
+ files: eligible.filter((file) => isPythonPath(file) || selectedFiles.has(file)),
612
+ failures: javascriptPaths.length > 0 ? (selection.failure?.failures ?? []) : [],
613
+ };
614
+ } catch (error) {
615
+ return {
616
+ failure: emptyLintSummary("operational_failure", [
617
+ { stage: "config-load", command: "managed quality exclusions", message: error.message },
618
+ ]),
619
+ };
620
+ }
621
+ }
569
622
 
570
- const fixedContent = readFileSync(temporaryPath);
571
- const verificationCommand = toolCommand(workspace, "oxlint", [
572
- "--format",
573
- "json",
574
- temporaryRelativePath,
575
- ]);
576
- const verificationResult = runCommand(workspace, verificationCommand);
577
- if (verificationResult.error !== undefined) {
578
- return {
579
- ok: false,
580
- stage: "lint-verify",
581
- command: commandText(verificationCommand),
582
- exitCode: verificationResult.status,
583
- error: `Oxlint could not start: ${verificationResult.error.message}`,
584
- };
623
+ function copyLintMirror(root, mirror, requiredInputs) {
624
+ const physicalRoot = realpathSync(root);
625
+ for (const input of requiredInputs) {
626
+ const source = path.join(root, input);
627
+ if (!existsSync(source)) continue;
628
+ const relativeTarget = path.relative(physicalRoot, realpathSync(source));
629
+ if (
630
+ relativeTarget === ".." ||
631
+ relativeTarget.startsWith(`..${path.sep}`) ||
632
+ path.isAbsolute(relativeTarget)
633
+ ) {
634
+ throw new Error(`Cannot prove temporary lint parity for external repository input: ${input}`);
585
635
  }
586
-
587
- const parsed = parseLintDiagnostics(
588
- verificationResult.stdout,
589
- root,
590
- relativePath,
591
- temporaryRelativePath,
592
- );
593
- if (!parsed.ok) {
594
- return {
595
- ok: false,
596
- stage: "lint-verify",
597
- command: commandText(verificationCommand),
598
- exitCode: verificationResult.status,
599
- error: parsed.error,
600
- };
636
+ }
637
+ const visit = (source, destination) => {
638
+ mkdirSync(destination, { recursive: true });
639
+ for (const entry of readdirSync(source, { withFileTypes: true })) {
640
+ const relative = path.relative(root, path.join(source, entry.name)).split(path.sep).join("/");
641
+ if (
642
+ [".git", ".turbo", ".next", "coverage", "dist", "build", "__pycache__"].includes(
643
+ entry.name,
644
+ ) ||
645
+ /^(?:\.devpunks\/(?:delivery|cache|replaced-scaffold)|\.devpunks-cache)(?:\/|$)/u.test(
646
+ relative,
647
+ )
648
+ )
649
+ continue;
650
+ const from = path.join(source, entry.name);
651
+ const to = path.join(destination, entry.name);
652
+ if (entry.name === "node_modules") {
653
+ symlinkSync(realpathSync(from), to, "dir");
654
+ continue;
655
+ }
656
+ if (entry.isSymbolicLink()) {
657
+ const resolved = realpathSync(from);
658
+ const relativeTarget = path.relative(physicalRoot, resolved);
659
+ if (
660
+ relativeTarget === ".." ||
661
+ relativeTarget.startsWith(`..${path.sep}`) ||
662
+ path.isAbsolute(relativeTarget)
663
+ )
664
+ continue;
665
+ const link = readlinkSync(from);
666
+ symlinkSync(path.isAbsolute(link) ? path.resolve(mirror, relativeTarget) : link, to);
667
+ continue;
668
+ }
669
+ if (entry.isDirectory()) visit(from, to);
670
+ else if (entry.isFile()) cpSync(from, to);
671
+ else
672
+ throw new Error(`Cannot mirror non-regular repository input: ${path.relative(root, from)}`);
601
673
  }
674
+ };
675
+ visit(root, mirror);
676
+ }
602
677
 
603
- if (verificationResult.status !== 0 && parsed.diagnostics.length === 0) {
604
- return {
605
- ok: false,
606
- stage: "lint-verify",
607
- command: commandText(verificationCommand),
608
- exitCode: verificationResult.status,
609
- error: verificationResult.stderr || "Oxlint verification failed without diagnostics",
610
- };
678
+ async function runSafeJavascriptLint(workspace, root, relativePath, content, route, runtime) {
679
+ const mirror = mkdtempSync(path.join(os.tmpdir(), "hi-lint-mirror-"));
680
+ let command;
681
+ try {
682
+ copyLintMirror(root, mirror, [relativePath, route.config, ...route.inputs]);
683
+ for (const input of [route.config, ...route.inputs]) {
684
+ if (existsSync(path.join(root, input)) && !existsSync(path.join(mirror, input)))
685
+ throw new Error(`Required lint input is excluded from safe mirror: ${input}`);
611
686
  }
612
-
613
- return { ok: true, content: fixedContent, diagnostics: parsed.diagnostics };
687
+ const target = path.join(mirror, relativePath);
688
+ if (!lstatSync(target).isFile())
689
+ throw new Error("Temporary lint target must be a copied regular file");
690
+ writeFileSync(target, content);
691
+ command = await runtime.buildManagedLintCommand({
692
+ root: mirror,
693
+ route,
694
+ output: "json",
695
+ logicalSourcePath: relativePath,
696
+ physicalInputPath: target,
697
+ });
698
+ if (command.status !== "ready") throw new Error(command.diagnostics.join("\n"));
699
+ const fixed = runtime.executeManagedLintCommand({
700
+ root: mirror,
701
+ command: { ...command, args: ["--fix", ...command.args] },
702
+ });
703
+ if (fixed.code === 2)
704
+ throw new Error(["Oxlint fix failed", fixed.stdout, fixed.stderr].filter(Boolean).join("\n"));
705
+ const fixedDiagnostics = normalizeManagedDiagnostics(
706
+ fixed.diagnostics,
707
+ mirror,
708
+ route.scope,
709
+ relativePath,
710
+ );
711
+ if (!fixedDiagnostics.ok) throw new Error(fixedDiagnostics.error);
712
+ const result = runtime.executeManagedLintCommand({ root: mirror, command });
713
+ if (result.code === 2)
714
+ throw new Error(
715
+ ["Oxlint verification failed", result.stdout, result.stderr].filter(Boolean).join("\n"),
716
+ );
717
+ const parsed = normalizeManagedDiagnostics(
718
+ result.diagnostics,
719
+ mirror,
720
+ route.scope,
721
+ relativePath,
722
+ );
723
+ if (!parsed.ok) throw new Error(parsed.error);
724
+ return { ok: true, content: readFileSync(target), diagnostics: parsed.diagnostics };
725
+ } catch (error) {
726
+ return {
727
+ ok: false,
728
+ stage: "lint-verify",
729
+ command: command ? commandText([command.executable, ...command.args]) : "managed lint mirror",
730
+ error: error.message,
731
+ };
614
732
  } finally {
615
- try {
616
- rmSync(temporaryDirectory, { force: true, recursive: true });
617
- } catch {
618
- // The temporary stage is producer-owned; an absent file is already clean.
619
- }
733
+ rmSync(mirror, { force: true, recursive: true });
620
734
  }
621
735
  }
622
736
 
@@ -857,49 +971,16 @@ function commandText(command) {
857
971
  return Array.isArray(command) ? command.join(" ") : String(command ?? "");
858
972
  }
859
973
 
860
- function formatAndLintFiles(root, filePaths, expectedFingerprints = null) {
861
- const caseSemantics = pathCaseSemantics(root);
862
- if (caseSemantics === "unknown") {
863
- return emptyLintSummary("operational_failure", [
864
- {
865
- stage: "config-load",
866
- command: "path case semantics",
867
- message: "Unable to determine path case semantics",
868
- },
869
- ]);
870
- }
871
-
872
- const caseInsensitivePaths = caseSemantics === "case-insensitive";
873
- const managedPaths = loadManagedPaths(root, caseInsensitivePaths);
874
- if (managedPaths === null) {
875
- return emptyLintSummary("operational_failure", [
876
- {
877
- stage: "config-load",
878
- command: scaffoldManifestPath,
879
- message: "Managed scaffold manifest is invalid",
880
- },
881
- ]);
882
- }
883
-
884
- const normalizedFiles = [];
885
-
886
- for (const filePath of filePaths) {
887
- const normalizedPath = normalizeRelativePath(
888
- root,
889
- filePath,
890
- managedPaths,
891
- caseInsensitivePaths,
892
- );
893
- if (normalizedPath && !normalizedFiles.includes(normalizedPath)) {
894
- normalizedFiles.push(normalizedPath);
895
- }
896
- }
974
+ async function formatAndLintFiles(root, filePaths, expectedFingerprints = null) {
975
+ const selection = await selectedQuality(root, filePaths);
976
+ if (selection.failure) return selection.failure;
977
+ const normalizedFiles = selection.files;
897
978
 
898
979
  const formatted = [];
899
980
  const formatFailed = [];
900
981
  const lintFailed = [];
901
982
  const diagnostics = [];
902
- const failures = [];
983
+ const failures = [...selection.failures];
903
984
 
904
985
  for (const relativePath of normalizedFiles) {
905
986
  const expectedFingerprint = expectedFingerprints?.[relativePath];
@@ -920,9 +1001,23 @@ function formatAndLintFiles(root, filePaths, expectedFingerprints = null) {
920
1001
  continue;
921
1002
  }
922
1003
 
923
- const workspace = owningWorkspace(root, relativePath);
1004
+ const route = selection.routes.find((item) => item.files.includes(relativePath));
1005
+ const workspace = isPythonPath(relativePath) ? root : path.resolve(root, route.scope);
924
1006
  const workspacePath = workspaceRelativePath(workspace, root, relativePath);
925
- const formatCommand = formatCommandForPath(workspace, workspacePath);
1007
+ let formatCommand;
1008
+ try {
1009
+ formatCommand = formatCommandForPath(workspace, workspacePath);
1010
+ } catch (error) {
1011
+ closeSync(target.descriptor);
1012
+ failures.push({
1013
+ kind: "format",
1014
+ stage: "format",
1015
+ file: relativePath,
1016
+ command: "local formatter",
1017
+ message: error.message,
1018
+ });
1019
+ continue;
1020
+ }
926
1021
 
927
1022
  // Keep mutating tools off the live path; stage output before claiming the validated target.
928
1023
  const formatResult = runTransformCommand(workspace, formatCommand, target.content);
@@ -941,7 +1036,11 @@ function formatAndLintFiles(root, filePaths, expectedFingerprints = null) {
941
1036
  continue;
942
1037
  }
943
1038
 
944
- const lintCommand = lintCommandForPath(workspace, workspacePath, true);
1039
+ const lintCommand = isPythonPath(relativePath)
1040
+ ? lintCommandForPath(workspace, workspacePath, true)
1041
+ : javascriptLintableSuffixes.has(path.extname(relativePath))
1042
+ ? ["managed lint"]
1043
+ : null;
945
1044
  let formattedContent = formatResult.output;
946
1045
  let lintResult = null;
947
1046
  if (lintCommand !== null && isPythonPath(relativePath)) {
@@ -950,7 +1049,14 @@ function formatAndLintFiles(root, filePaths, expectedFingerprints = null) {
950
1049
  formattedContent = lintResult.output;
951
1050
  }
952
1051
  } else if (lintCommand !== null) {
953
- lintResult = runSafeJavascriptLint(workspace, root, relativePath, formattedContent);
1052
+ lintResult = await runSafeJavascriptLint(
1053
+ workspace,
1054
+ root,
1055
+ relativePath,
1056
+ formattedContent,
1057
+ route,
1058
+ selection.runtime,
1059
+ );
954
1060
  if (lintResult.ok) {
955
1061
  formattedContent = lintResult.content;
956
1062
  diagnostics.push(...lintResult.diagnostics);
@@ -991,6 +1097,16 @@ function formatAndLintFiles(root, filePaths, expectedFingerprints = null) {
991
1097
  }
992
1098
  }
993
1099
 
1100
+ if (selection.routes.some((route) => route.triggered)) {
1101
+ const verified = await verifyLintFiles(root, filePaths);
1102
+ const known = new Set(diagnostics.map((diagnostic) => JSON.stringify(diagnostic)));
1103
+ for (const diagnostic of verified.diagnostics) {
1104
+ if (!known.has(JSON.stringify(diagnostic))) diagnostics.push(diagnostic);
1105
+ }
1106
+ failures.push(...verified.failures);
1107
+ for (const file of verified.lint_failed) if (!lintFailed.includes(file)) lintFailed.push(file);
1108
+ }
1109
+
994
1110
  const result =
995
1111
  failures.length > 0 ? "operational_failure" : diagnostics.length > 0 ? "findings" : "clean";
996
1112
  return {
@@ -1020,87 +1136,114 @@ function formatAndLintFiles(root, filePaths, expectedFingerprints = null) {
1020
1136
  };
1021
1137
  }
1022
1138
 
1023
- function verifyLintFiles(root, filePaths) {
1024
- const caseSemantics = pathCaseSemantics(root);
1025
- const managedPaths = loadManagedPaths(root, caseSemantics === "case-insensitive");
1026
- if (caseSemantics === "unknown" || managedPaths === null) {
1027
- return emptyLintSummary("operational_failure", [
1028
- {
1029
- stage: "config-load",
1030
- command: scaffoldManifestPath,
1031
- message: "Lint preview cannot validate repository state",
1032
- },
1033
- ]);
1034
- }
1035
-
1036
- const normalizedFiles = [
1037
- ...new Set(
1038
- filePaths
1039
- .map((filePath) =>
1040
- normalizeRelativePath(root, filePath, managedPaths, caseSemantics === "case-insensitive"),
1041
- )
1042
- .filter((filePath) => filePath && isLintablePath(filePath)),
1043
- ),
1139
+ function verifyPythonFile(root, relativePath) {
1140
+ const command = [
1141
+ "uv",
1142
+ "run",
1143
+ "--project",
1144
+ nearestPythonProject(root, relativePath),
1145
+ "ruff",
1146
+ "check",
1147
+ "--output-format",
1148
+ "json",
1149
+ "--stdin-filename",
1150
+ relativePath,
1151
+ "-",
1044
1152
  ];
1045
- const diagnostics = [];
1046
- const failures = [];
1047
- const lintFailed = new Set();
1048
-
1049
- for (const relativePath of normalizedFiles) {
1050
- const workspace = owningWorkspace(root, relativePath);
1051
- const workspacePath = workspaceRelativePath(workspace, root, relativePath);
1052
- const command = toolCommand(workspace, "oxlint", ["--format", "json", workspacePath]);
1053
- const result = runCommand(workspace, command);
1054
- if (result.error !== undefined) {
1055
- failures.push({
1056
- kind: "lint",
1153
+ const target = openFormattingTarget(path.join(root, relativePath));
1154
+ if (target === null)
1155
+ return {
1156
+ failure: {
1057
1157
  stage: "lint-verify",
1058
1158
  file: relativePath,
1059
1159
  command: commandText(command),
1060
- exitCode: result.status,
1061
- message: `Oxlint could not start: ${result.error.message}`,
1062
- });
1063
- continue;
1064
- }
1065
-
1066
- const parsed = parseLintDiagnostics(result.stdout, root, relativePath, workspacePath);
1067
- if (!parsed.ok) {
1068
- failures.push({
1069
- kind: "lint",
1160
+ message: "Edited file changed before verification",
1161
+ },
1162
+ };
1163
+ try {
1164
+ const result = runTransformCommand(root, command, target.content);
1165
+ if (result.error || ![0, 1].includes(result.status))
1166
+ throw new Error(result.error?.message ?? (result.stderr || "Ruff verification failed"));
1167
+ const report = JSON.parse(result.output.toString());
1168
+ if (
1169
+ !Array.isArray(report) ||
1170
+ report.some(
1171
+ (item) =>
1172
+ !item ||
1173
+ typeof item.message !== "string" ||
1174
+ typeof item.code !== "string" ||
1175
+ !Number.isInteger(item.location?.row) ||
1176
+ !Number.isInteger(item.location?.column),
1177
+ )
1178
+ )
1179
+ throw new Error("Ruff returned invalid diagnostics");
1180
+ if (result.status !== 0 && report.length === 0)
1181
+ throw new Error(result.stderr || "Ruff failed without diagnostics");
1182
+ return {
1183
+ diagnostics: report.map((item) => ({
1184
+ file: relativePath,
1185
+ rule: item.code,
1186
+ severity: "error",
1187
+ line: item.location.row,
1188
+ column: item.location.column,
1189
+ message: item.message,
1190
+ ...(typeof item.url === "string" ? { documentation: item.url } : {}),
1191
+ })),
1192
+ };
1193
+ } catch (error) {
1194
+ return {
1195
+ failure: {
1070
1196
  stage: "lint-verify",
1071
1197
  file: relativePath,
1072
1198
  command: commandText(command),
1073
- exitCode: result.status,
1074
- message: parsed.error,
1075
- });
1076
- continue;
1077
- }
1199
+ message: error.message,
1200
+ },
1201
+ };
1202
+ } finally {
1203
+ closeSync(target.descriptor);
1204
+ }
1205
+ }
1078
1206
 
1079
- if (result.status !== 0 && parsed.diagnostics.length === 0) {
1207
+ async function verifyLintFiles(root, filePaths) {
1208
+ const selection = await selectedQuality(root, filePaths);
1209
+ if (selection.failure) return selection.failure;
1210
+ const diagnostics = [];
1211
+ const failures = [...selection.failures];
1212
+ for (const file of selection.files.filter(isPythonPath)) {
1213
+ const verified = verifyPythonFile(root, file);
1214
+ if (verified.failure) failures.push(verified.failure);
1215
+ else diagnostics.push(...verified.diagnostics);
1216
+ }
1217
+ if (selection.javascriptPaths.length > 0 && selection.failures.length === 0) {
1218
+ const result = await selection.runtime.runManagedLint({
1219
+ root,
1220
+ paths: selection.javascriptPaths.map((file) =>
1221
+ path.relative(root, path.resolve(root, file)).split(path.sep).join("/"),
1222
+ ),
1223
+ output: "json",
1224
+ });
1225
+ for (const owner of result.results ?? []) {
1226
+ const parsed = normalizeManagedDiagnostics(owner.diagnostics, root, owner.scope, "");
1227
+ if (parsed.ok) diagnostics.push(...parsed.diagnostics);
1228
+ else failures.push({ stage: "lint-verify", command: "managed lint", message: parsed.error });
1229
+ }
1230
+ if (result.code === 2)
1080
1231
  failures.push({
1081
- kind: "lint",
1082
1232
  stage: "lint-verify",
1083
- file: relativePath,
1084
- command: commandText(command),
1085
- exitCode: result.status,
1086
- message: result.stderr || "Oxlint verification failed without diagnostics",
1233
+ command: "managed lint",
1234
+ message:
1235
+ result.diagnostics?.join("\n") ||
1236
+ result.results?.map((owner) => `${owner.stdout}\n${owner.stderr}`).join("\n") ||
1237
+ "Lint verification failed without diagnostics",
1087
1238
  });
1088
- continue;
1089
- }
1090
-
1091
- diagnostics.push(...parsed.diagnostics);
1092
- if (parsed.diagnostics.length > 0) {
1093
- lintFailed.add(relativePath);
1094
- }
1095
1239
  }
1096
-
1097
1240
  return {
1098
1241
  ...emptyLintSummary(
1099
- failures.length > 0 ? "operational_failure" : diagnostics.length > 0 ? "findings" : "clean",
1242
+ failures.length ? "operational_failure" : diagnostics.length ? "findings" : "clean",
1100
1243
  failures,
1101
1244
  ),
1102
1245
  diagnostics,
1103
- lint_failed: [...lintFailed],
1246
+ lint_failed: [...new Set(diagnostics.map((diagnostic) => diagnostic.file))],
1104
1247
  };
1105
1248
  }
1106
1249
 
@@ -1193,7 +1336,7 @@ function emitProviderFeedback(provider, summary) {
1193
1336
  }
1194
1337
  }
1195
1338
 
1196
- function runSingleFileMode(style) {
1339
+ async function runSingleFileMode(style) {
1197
1340
  const payload = readStdinJson();
1198
1341
  const root = repoRoot(process.cwd());
1199
1342
 
@@ -1206,7 +1349,7 @@ function runSingleFileMode(style) {
1206
1349
  return;
1207
1350
  }
1208
1351
 
1209
- const summary = formatAndLintFiles(root, [filePath]);
1352
+ const summary = await formatAndLintFiles(root, [filePath]);
1210
1353
  emitProviderFeedback(style, summary);
1211
1354
  }
1212
1355
 
@@ -1222,7 +1365,6 @@ function dirtyFiles(root) {
1222
1365
  .split("\n")
1223
1366
  .map((line) => line.trim())
1224
1367
  .filter(Boolean)
1225
- .filter((filePath) => formattableSuffixes.has(path.extname(filePath)))
1226
1368
  .filter((filePath) => !filePath.split("/").some((part) => ignoredParts.has(part))),
1227
1369
  ),
1228
1370
  ].sort();
@@ -1404,7 +1546,7 @@ function pruneProcessedFingerprints(state, current) {
1404
1546
  }
1405
1547
  }
1406
1548
 
1407
- function runCodexSnapshotMode(mode) {
1549
+ async function runCodexSnapshotMode(mode) {
1408
1550
  const payload = readStdinJson();
1409
1551
  const cwd = String(payload.cwd ?? process.cwd());
1410
1552
  const sessionId = String(payload.session_id ?? "");
@@ -1471,7 +1613,7 @@ function runCodexSnapshotMode(mode) {
1471
1613
  return;
1472
1614
  }
1473
1615
 
1474
- const summary = formatAndLintFiles(root, touched, current);
1616
+ const summary = await formatAndLintFiles(root, touched, current);
1475
1617
  if (summary.diagnostics.length > 0) {
1476
1618
  applyDiagnosticRetryLimit(state, summary);
1477
1619
  } else {
@@ -1613,32 +1755,31 @@ export const FormatAndLintPlugin = async ({ client, worktree }) => {
1613
1755
  };
1614
1756
 
1615
1757
  export const testHooks = {
1758
+ copyLintMirror,
1616
1759
  codexStateFilePath,
1617
1760
  formatCommandForPath,
1618
1761
  lintCommandForPath,
1619
- owningWorkspace,
1620
- parseLintDiagnostics,
1621
1762
  renderProviderFeedback,
1622
1763
  toolCommand,
1623
1764
  };
1624
1765
 
1625
- function main() {
1766
+ async function main() {
1626
1767
  const mode = process.argv[2] ?? "";
1627
1768
 
1628
1769
  if (mode === "session-start" || mode === "post") {
1629
- runCodexSnapshotMode(mode);
1770
+ await runCodexSnapshotMode(mode);
1630
1771
  return;
1631
1772
  }
1632
1773
 
1633
1774
  if (mode === "claude" || mode === "cursor" || mode === "opencode") {
1634
- runSingleFileMode(mode);
1775
+ await runSingleFileMode(mode);
1635
1776
  return;
1636
1777
  }
1637
1778
 
1638
1779
  if (mode === "files") {
1639
1780
  const root = repoRoot(process.cwd());
1640
1781
  const summary = root
1641
- ? formatAndLintFiles(root, process.argv.slice(3))
1782
+ ? await formatAndLintFiles(root, process.argv.slice(3))
1642
1783
  : emptyLintSummary("operational_failure", [
1643
1784
  {
1644
1785
  stage: "config-load",
@@ -1653,7 +1794,7 @@ function main() {
1653
1794
  if (mode === "preview") {
1654
1795
  const root = repoRoot(process.cwd());
1655
1796
  const summary = root
1656
- ? verifyLintFiles(root, process.argv.slice(3))
1797
+ ? await verifyLintFiles(root, process.argv.slice(3))
1657
1798
  : emptyLintSummary("operational_failure", [
1658
1799
  {
1659
1800
  stage: "config-load",
@@ -1669,5 +1810,5 @@ const invokedPath = process.argv[1] ? path.resolve(process.argv[1]) : "";
1669
1810
  const modulePath = fileURLToPath(import.meta.url);
1670
1811
 
1671
1812
  if (invokedPath && path.basename(invokedPath) === path.basename(modulePath)) {
1672
- main();
1813
+ await main();
1673
1814
  }