@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.
- package/README.md +2 -2
- package/dist/BASELINE_CHANGELOG.md +46 -1
- package/dist/CHANGELOG.md +37 -0
- package/dist/baseline/scaffold-baseline/baseline.json +15 -5
- package/dist/baseline/scaffold-baseline/data/catalog/packs.json +2 -0
- package/dist/baseline/scaffold-baseline/data/catalog/skills.json +16 -0
- package/dist/baseline/scaffold-baseline/data/hooks/format-edited-file.mjs +459 -318
- package/dist/baseline/scaffold-baseline/data/scripts/commit-gate-runner.d.ts +1 -0
- package/dist/baseline/scaffold-baseline/data/scripts/commit-gate-runner.mjs +98 -27
- package/dist/baseline/scaffold-baseline/data/scripts/commit-gate-runner.test.ts +156 -8
- package/dist/baseline/scaffold-baseline/data/scripts/managed-lint-runner.d.mts +55 -0
- package/dist/baseline/scaffold-baseline/data/scripts/managed-lint-runner.mjs +329 -0
- package/dist/baseline/scaffold-baseline/data/scripts/managed-lint-runner.test.ts +864 -0
- package/dist/baseline/scaffold-baseline/data/scripts/managed-lint.d.mts +97 -0
- package/dist/baseline/scaffold-baseline/data/scripts/managed-lint.mjs +658 -0
- package/dist/baseline/scaffold-baseline/data/scripts/managed-lint.test.ts +614 -0
- package/dist/baseline/scaffold-baseline/skills/agnostic/cli/hi-cli/SKILL.md +2 -0
- package/dist/baseline/scaffold-baseline/skills/agnostic/cli/hi-cli/references/commands.md +8 -9
- package/dist/baseline/scaffold-baseline/skills/agnostic/cli/hi-cli/references/managed-lint.md +165 -0
- package/dist/baseline/scaffold-baseline/skills/agnostic/cli/hi-cli/references/post-command-flow.md +28 -24
- package/dist/baseline/scaffold-baseline/skills/agnostic/cli/hi-cli/references/wiki-structure.md +16 -0
- package/dist/baseline/scaffold-baseline/skills/agnostic/docs/docs-onboarding/SKILL.md +21 -16
- package/dist/baseline/scaffold-baseline/skills/agnostic/docs/docs-onboarding/agents/openai.yaml +1 -1
- package/dist/baseline/scaffold-baseline/skills/agnostic/docs/docs-onboarding/references/artifact-contract.md +16 -4
- package/dist/baseline/scaffold-baseline/skills/agnostic/planning/create-architecture/SKILL.md +65 -0
- package/dist/baseline/scaffold-baseline/skills/agnostic/planning/create-architecture/assets/ARCHITECTURE-TEMPLATE.md +119 -0
- package/dist/baseline/scaffold-baseline/skills/agnostic/planning/create-architecture/references/artifact-contract.md +200 -0
- package/dist/baseline/scaffold-baseline/skills/agnostic/planning/create-plan/SKILL.md +11 -3
- package/dist/baseline/scaffold-baseline/skills/agnostic/planning/create-plan/references/architecture-convergence.md +19 -4
- package/dist/baseline/scaffold-baseline/skills/agnostic/planning/create-plan/references/plan-schema.md +17 -3
- package/dist/baseline/scaffold-baseline/skills/agnostic/planning/create-spec/SKILL.md +38 -20
- package/dist/baseline/scaffold-baseline/skills/agnostic/planning/create-spec/assets/SPEC-TEMPLATE.md +11 -0
- package/dist/baseline/scaffold-baseline/skills/agnostic/planning/create-spec/references/readiness.md +40 -0
- package/dist/baseline/scaffold-baseline/skills/agnostic/planning/create-spec/references/spec-quality-bar.md +8 -0
- package/dist/baseline/scaffold-baseline/skills/agnostic/planning/implement-spec/SKILL.md +4 -2
- package/dist/baseline/scaffold-baseline/skills/agnostic/planning/implement-spec/references/architecture-conformance.md +10 -6
- package/dist/baseline/scaffold-baseline/skills/agnostic/planning/implement-spec/references/lifecycle.md +23 -10
- package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/brainstorm/SKILL.md +22 -0
- package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/requirements-grill/SKILL.md +2 -1
- package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/requirements-grill/references/artifact-output.md +3 -2
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/SKILL.md +6 -3
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/plan.md +4 -2
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/review.md +5 -1
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/router.md +15 -9
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/spec.md +13 -26
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/references/artifact-state.md +39 -1
- package/dist/baseline/scaffold-baseline/skills/phases/requirements-phase/SKILL.md +31 -14
- package/dist/baseline/scaffold-baseline/skills/phases/review-phase/phases/prepare-review.md +12 -4
- package/dist/baseline/scaffold-baseline.json +5 -5
- package/dist/baseline/scaffold-baseline.tgz +0 -0
- package/dist/data/hooks/format-edited-file.d.mts +5 -0
- package/dist/data/hooks/format-edited-file.mjs +282 -333
- package/dist/data/scripts/commit-gate-runner.mjs +98 -27
- package/dist/data/scripts/managed-lint-runner.d.mts +55 -0
- package/dist/data/scripts/managed-lint-runner.mjs +329 -0
- package/dist/data/scripts/managed-lint.d.mts +97 -0
- package/dist/data/scripts/managed-lint.mjs +658 -0
- package/dist/index.js +86 -1184
- package/dist/skills/agnostic/cli/hi-cli/SKILL.md +2 -0
- package/dist/skills/agnostic/cli/hi-cli/references/commands.md +8 -9
- package/dist/skills/agnostic/cli/hi-cli/references/managed-lint.md +165 -0
- package/dist/skills/agnostic/cli/hi-cli/references/post-command-flow.md +15 -11
- package/dist/skills/agnostic/cli/hi-cli/references/wiki-structure.md +16 -0
- package/dist/skills/agnostic/docs/docs-onboarding/SKILL.md +21 -16
- package/dist/skills/agnostic/docs/docs-onboarding/agents/openai.yaml +1 -1
- package/dist/skills/agnostic/docs/docs-onboarding/references/artifact-contract.md +16 -4
- package/dist/skills/agnostic/planning/create-architecture/SKILL.md +65 -0
- package/dist/skills/agnostic/planning/create-architecture/assets/ARCHITECTURE-TEMPLATE.md +119 -0
- package/dist/skills/agnostic/planning/create-architecture/references/artifact-contract.md +200 -0
- package/dist/skills/agnostic/planning/create-plan/SKILL.md +11 -3
- package/dist/skills/agnostic/planning/create-plan/references/architecture-convergence.md +19 -4
- package/dist/skills/agnostic/planning/create-plan/references/plan-schema.md +17 -3
- package/dist/skills/agnostic/planning/create-spec/SKILL.md +38 -20
- package/dist/skills/agnostic/planning/create-spec/assets/SPEC-TEMPLATE.md +11 -0
- package/dist/skills/agnostic/planning/create-spec/references/readiness.md +40 -0
- package/dist/skills/agnostic/planning/create-spec/references/spec-quality-bar.md +8 -0
- package/dist/skills/agnostic/planning/implement-spec/SKILL.md +4 -2
- package/dist/skills/agnostic/planning/implement-spec/references/architecture-conformance.md +10 -6
- package/dist/skills/agnostic/planning/implement-spec/references/lifecycle.md +23 -10
- package/dist/skills/agnostic/requirements/brainstorm/SKILL.md +22 -0
- package/dist/skills/agnostic/requirements/requirements-grill/SKILL.md +2 -1
- package/dist/skills/agnostic/requirements/requirements-grill/references/artifact-output.md +3 -2
- package/dist/skills/phases/delivery-phase/SKILL.md +6 -3
- package/dist/skills/phases/delivery-phase/phases/plan.md +4 -2
- package/dist/skills/phases/delivery-phase/phases/review.md +5 -1
- package/dist/skills/phases/delivery-phase/phases/router.md +15 -9
- package/dist/skills/phases/delivery-phase/phases/spec.md +13 -26
- package/dist/skills/phases/delivery-phase/references/artifact-state.md +39 -1
- package/dist/skills/phases/requirements-phase/SKILL.md +31 -14
- package/dist/skills/phases/review-phase/phases/prepare-review.md +12 -4
- package/package.json +3 -2
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
import { createHash, randomUUID } from "node:crypto";
|
|
4
4
|
import {
|
|
5
|
-
|
|
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,27 @@ 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
|
|
208
|
-
const
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
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 (value.name !== tool || typeof bin !== "string" || path.isAbsolute(bin) || bin.split(/[\\/]/u).includes("..")) throw new Error(`Invalid repository-local ${tool} executable`);
|
|
201
|
+
return [path.resolve(path.dirname(manifest), bin), ...args];
|
|
232
202
|
}
|
|
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";
|
|
265
|
-
}
|
|
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];
|
|
203
|
+
if (current === root || path.dirname(current) === current) break;
|
|
204
|
+
current = path.dirname(current);
|
|
290
205
|
}
|
|
291
|
-
|
|
292
|
-
return ["
|
|
206
|
+
// An intentionally missing local path becomes a normal operational failure in runCommand.
|
|
207
|
+
return [path.join(root || directory, "node_modules/.bin", tool), ...args];
|
|
293
208
|
}
|
|
294
209
|
|
|
295
210
|
function nearestPythonProject(root, relativePath) {
|
|
@@ -372,23 +287,49 @@ function normalizeManagedPath(filePath) {
|
|
|
372
287
|
}
|
|
373
288
|
|
|
374
289
|
function loadManagedPaths(root, caseInsensitivePaths) {
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
const managedPaths = new Set();
|
|
381
|
-
for (const entry of manifest.managedFiles) {
|
|
382
|
-
if (!entry || typeof entry !== "object" || Array.isArray(entry)) {
|
|
290
|
+
let paths;
|
|
291
|
+
let usesTrackedIndex = false;
|
|
292
|
+
try {
|
|
293
|
+
if (!lstatSync(path.join(root, managedHookPathsPath)).isFile()) {
|
|
383
294
|
return null;
|
|
384
295
|
}
|
|
296
|
+
const index = loadJson(path.join(root, managedHookPathsPath));
|
|
297
|
+
if (!index || index.version !== 1 || !Array.isArray(index.paths)) {
|
|
298
|
+
return null;
|
|
299
|
+
}
|
|
300
|
+
paths = index.paths;
|
|
301
|
+
usesTrackedIndex = true;
|
|
302
|
+
} catch (error) {
|
|
303
|
+
if (error?.code !== "ENOENT") {
|
|
304
|
+
return null;
|
|
305
|
+
}
|
|
306
|
+
const manifest = loadJson(path.join(root, scaffoldManifestPath));
|
|
307
|
+
if (!manifest || typeof manifest !== "object" || !Array.isArray(manifest.managedFiles)) {
|
|
308
|
+
return null;
|
|
309
|
+
}
|
|
310
|
+
paths = [];
|
|
311
|
+
for (const entry of manifest.managedFiles) {
|
|
312
|
+
if (!entry || typeof entry !== "object" || Array.isArray(entry)) {
|
|
313
|
+
return null;
|
|
314
|
+
}
|
|
315
|
+
paths.push(entry.path);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
385
318
|
|
|
386
|
-
|
|
319
|
+
const managedPaths = new Set();
|
|
320
|
+
for (const filePath of paths) {
|
|
321
|
+
const normalizedPath = normalizeManagedPath(filePath);
|
|
387
322
|
if (!normalizedPath) {
|
|
388
323
|
return null;
|
|
389
324
|
}
|
|
390
325
|
managedPaths.add(managedPathKey(normalizedPath, caseInsensitivePaths));
|
|
391
326
|
}
|
|
327
|
+
if (usesTrackedIndex && [managedHookPathsPath, scaffoldManifestPath].some((filePath) =>
|
|
328
|
+
!managedPaths.has(managedPathKey(filePath, caseInsensitivePaths))
|
|
329
|
+
)) {
|
|
330
|
+
return null;
|
|
331
|
+
}
|
|
332
|
+
managedPaths.add(managedPathKey(managedHookPathsPath, caseInsensitivePaths));
|
|
392
333
|
|
|
393
334
|
return managedPaths;
|
|
394
335
|
}
|
|
@@ -518,106 +459,178 @@ function normalizeDiagnostic(diagnostic, root, fallbackPath, temporaryPath = nul
|
|
|
518
459
|
return normalized;
|
|
519
460
|
}
|
|
520
461
|
|
|
521
|
-
function
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
462
|
+
function normalizeManagedDiagnostics(report, root, scope, fallbackPath) {
|
|
463
|
+
if (!Array.isArray(report)) return {ok: false, error: "Oxlint did not return validated diagnostics"};
|
|
464
|
+
const diagnostics = [];
|
|
465
|
+
for (const diagnostic of report) {
|
|
466
|
+
let filename = fallbackPath;
|
|
467
|
+
if (typeof diagnostic.filename === "string" && diagnostic.filename.length > 0) {
|
|
468
|
+
filename = path.relative(root, path.resolve(root, scope, diagnostic.filename)).split(path.sep).join("/");
|
|
469
|
+
if (filename === ".." || filename.startsWith("../") || path.isAbsolute(filename)) return {ok: false, error: "Oxlint diagnostic escaped the managed repository"};
|
|
470
|
+
}
|
|
471
|
+
diagnostics.push(normalizeDiagnostic({...diagnostic, filename}, root, fallbackPath));
|
|
527
472
|
}
|
|
473
|
+
return {ok: true, diagnostics};
|
|
474
|
+
}
|
|
528
475
|
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
476
|
+
async function lintRuntime(root) {
|
|
477
|
+
const canonical = path.join(root, ".agents/scripts/managed-lint-runner.mjs");
|
|
478
|
+
const local = new URL("../scripts/managed-lint-runner.mjs", import.meta.url);
|
|
479
|
+
const runner = await import(existsSync(canonical) ? pathToFileURL(canonical).href : local.href);
|
|
480
|
+
const resolver = await import(existsSync(canonical) ? pathToFileURL(path.join(root, ".agents/scripts/managed-lint.mjs")).href : new URL("../scripts/managed-lint.mjs", import.meta.url).href);
|
|
481
|
+
return { ...runner, ...resolver };
|
|
482
|
+
}
|
|
532
483
|
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
484
|
+
async function selectedLint(root, filePaths) {
|
|
485
|
+
try {
|
|
486
|
+
const runtime = await lintRuntime(root);
|
|
487
|
+
const paths = filePaths.map((file) => path.relative(root, path.resolve(root, file)).split(path.sep).join("/"));
|
|
488
|
+
const resolution = await runtime.loadManagedLint(root, paths);
|
|
489
|
+
if (resolution.status === "disabled") return { runtime, routes: [] };
|
|
490
|
+
if (resolution.status !== "ready") throw new Error(resolution.diagnostics.join("\n"));
|
|
491
|
+
return { runtime, routes: resolution.routes };
|
|
492
|
+
} catch (error) {
|
|
493
|
+
return { failure: emptyLintSummary("operational_failure", [{ stage: "config-load", command: "managed lint selection", message: error.message }]) };
|
|
538
494
|
}
|
|
495
|
+
}
|
|
539
496
|
|
|
540
|
-
|
|
497
|
+
// Python shares quality exclusions, but does not require JavaScript owner selection.
|
|
498
|
+
function qualityExclusions(root) {
|
|
499
|
+
let settings;
|
|
500
|
+
try {
|
|
501
|
+
settings = JSON.parse(readFileSync(path.join(root, ".devpunks/settings.json"), "utf8"));
|
|
502
|
+
} catch (error) {
|
|
503
|
+
if (error?.code === "ENOENT") return [];
|
|
504
|
+
throw error;
|
|
505
|
+
}
|
|
506
|
+
const record = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
507
|
+
if (!record(settings) || (settings.lint !== undefined && !record(settings.lint))) {
|
|
508
|
+
throw new TypeError("Managed quality settings and lint must be objects");
|
|
509
|
+
}
|
|
510
|
+
const exclude = settings.lint?.exclude;
|
|
511
|
+
if (exclude === undefined) return [];
|
|
512
|
+
if (!Array.isArray(exclude) || !exclude.every((pattern) =>
|
|
513
|
+
typeof pattern === "string" && pattern.length > 0 && !pattern.startsWith("!") &&
|
|
514
|
+
!pattern.includes("\\") && !path.posix.isAbsolute(pattern) &&
|
|
515
|
+
pattern.split("/").every((part) => part !== ".." && part !== "") &&
|
|
516
|
+
path.posix.normalize(pattern) === pattern
|
|
517
|
+
)) throw new TypeError("lint.exclude must be a list of repository-relative patterns.");
|
|
518
|
+
return exclude;
|
|
541
519
|
}
|
|
542
520
|
|
|
543
|
-
function
|
|
544
|
-
const
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
521
|
+
async function selectedQuality(root, filePaths) {
|
|
522
|
+
const caseSemantics = pathCaseSemantics(root);
|
|
523
|
+
if (caseSemantics === "unknown") {
|
|
524
|
+
return {failure: emptyLintSummary("operational_failure", [
|
|
525
|
+
{
|
|
526
|
+
stage: "config-load",
|
|
527
|
+
command: "path case semantics",
|
|
528
|
+
message: "Unable to determine path case semantics",
|
|
529
|
+
},
|
|
530
|
+
])};
|
|
531
|
+
}
|
|
549
532
|
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
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
|
-
}
|
|
533
|
+
const caseInsensitivePaths = caseSemantics === "case-insensitive";
|
|
534
|
+
const managedPaths = loadManagedPaths(root, caseInsensitivePaths);
|
|
535
|
+
if (managedPaths === null) {
|
|
536
|
+
return {failure: emptyLintSummary("operational_failure", [
|
|
537
|
+
{
|
|
538
|
+
stage: "config-load",
|
|
539
|
+
command: managedHookPathsPath,
|
|
540
|
+
message: `Managed hook ownership metadata is missing or invalid (${managedHookPathsPath}; legacy fallback: ${scaffoldManifestPath})`,
|
|
541
|
+
},
|
|
542
|
+
])};
|
|
543
|
+
}
|
|
569
544
|
|
|
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
|
-
};
|
|
585
|
-
}
|
|
586
545
|
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
546
|
+
try {
|
|
547
|
+
const runtime = await lintRuntime(root);
|
|
548
|
+
const exclude = qualityExclusions(root);
|
|
549
|
+
const eligible = [...new Set(filePaths.map((file) =>
|
|
550
|
+
normalizeRelativePath(root, file, managedPaths, caseInsensitivePaths)
|
|
551
|
+
).filter((file) => file !== null && !runtime.isManagedQualityPathExcluded({path: file, exclude})))];
|
|
552
|
+
const nonPythonPaths = filePaths.filter((file) => !isPythonPath(file));
|
|
553
|
+
const selection = nonPythonPaths.length > 0
|
|
554
|
+
? await selectedLint(root, nonPythonPaths)
|
|
555
|
+
: {runtime, routes: []};
|
|
556
|
+
// Keep raw resolver-owned dependency triggers, including scaffold metadata.
|
|
557
|
+
// The resolver handles excluded-only source; unrelated non-JS files stay independent.
|
|
558
|
+
const requiresSelection = nonPythonPaths.some((file) =>
|
|
559
|
+
javascriptFormattableSuffixes.has(path.extname(file))
|
|
592
560
|
);
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
}
|
|
561
|
+
const javascriptPaths = selection.failure && !requiresSelection
|
|
562
|
+
? [] : nonPythonPaths;
|
|
563
|
+
const routes = selection.routes ?? [];
|
|
564
|
+
const selectedFiles = new Set(routes.flatMap((route) => route.files));
|
|
565
|
+
return {
|
|
566
|
+
runtime, routes, javascriptPaths,
|
|
567
|
+
files: eligible.filter((file) => isPythonPath(file) || selectedFiles.has(file)),
|
|
568
|
+
failures: javascriptPaths.length > 0 ? selection.failure?.failures ?? [] : [],
|
|
569
|
+
};
|
|
570
|
+
} catch (error) {
|
|
571
|
+
return {failure: emptyLintSummary("operational_failure", [{stage: "config-load", command: "managed quality exclusions", message: error.message}])};
|
|
572
|
+
}
|
|
573
|
+
}
|
|
602
574
|
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
};
|
|
575
|
+
function copyLintMirror(root, mirror, requiredInputs) {
|
|
576
|
+
const physicalRoot = realpathSync(root);
|
|
577
|
+
for (const input of requiredInputs) {
|
|
578
|
+
const source = path.join(root, input);
|
|
579
|
+
if (!existsSync(source)) continue;
|
|
580
|
+
const relativeTarget = path.relative(physicalRoot, realpathSync(source));
|
|
581
|
+
if (relativeTarget === ".." || relativeTarget.startsWith(`..${path.sep}`) || path.isAbsolute(relativeTarget)) {
|
|
582
|
+
throw new Error(`Cannot prove temporary lint parity for external repository input: ${input}`);
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
const visit = (source, destination) => {
|
|
586
|
+
mkdirSync(destination, {recursive: true});
|
|
587
|
+
for (const entry of readdirSync(source, {withFileTypes: true})) {
|
|
588
|
+
const relative = path.relative(root, path.join(source, entry.name)).split(path.sep).join("/");
|
|
589
|
+
if ([".git", ".turbo", ".next", "coverage", "dist", "build", "__pycache__"].includes(entry.name) || /^(?:\.devpunks\/(?:delivery|cache|replaced-scaffold)|\.devpunks-cache)(?:\/|$)/u.test(relative)) continue;
|
|
590
|
+
const from = path.join(source, entry.name);
|
|
591
|
+
const to = path.join(destination, entry.name);
|
|
592
|
+
if (entry.name === "node_modules") { symlinkSync(realpathSync(from), to, "dir"); continue; }
|
|
593
|
+
if (entry.isSymbolicLink()) {
|
|
594
|
+
const resolved = realpathSync(from);
|
|
595
|
+
const relativeTarget = path.relative(physicalRoot, resolved);
|
|
596
|
+
if (relativeTarget === ".." || relativeTarget.startsWith(`..${path.sep}`) || path.isAbsolute(relativeTarget)) continue;
|
|
597
|
+
const link = readlinkSync(from);
|
|
598
|
+
symlinkSync(path.isAbsolute(link) ? path.resolve(mirror, relativeTarget) : link, to);
|
|
599
|
+
continue;
|
|
600
|
+
}
|
|
601
|
+
if (entry.isDirectory()) visit(from, to);
|
|
602
|
+
else if (entry.isFile()) cpSync(from, to);
|
|
603
|
+
else throw new Error(`Cannot mirror non-regular repository input: ${path.relative(root, from)}`);
|
|
611
604
|
}
|
|
605
|
+
};
|
|
606
|
+
visit(root, mirror);
|
|
607
|
+
}
|
|
612
608
|
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
609
|
+
async function runSafeJavascriptLint(workspace, root, relativePath, content, route, runtime) {
|
|
610
|
+
const mirror = mkdtempSync(path.join(os.tmpdir(), "hi-lint-mirror-"));
|
|
611
|
+
let command;
|
|
612
|
+
try {
|
|
613
|
+
copyLintMirror(root, mirror, [relativePath, route.config, ...route.inputs]);
|
|
614
|
+
for (const input of [route.config, ...route.inputs]) {
|
|
615
|
+
if (existsSync(path.join(root, input)) && !existsSync(path.join(mirror, input))) throw new Error(`Required lint input is excluded from safe mirror: ${input}`);
|
|
619
616
|
}
|
|
620
|
-
|
|
617
|
+
const target = path.join(mirror, relativePath);
|
|
618
|
+
if (!lstatSync(target).isFile()) throw new Error("Temporary lint target must be a copied regular file");
|
|
619
|
+
writeFileSync(target, content);
|
|
620
|
+
command = await runtime.buildManagedLintCommand({root: mirror, route, output: "json", logicalSourcePath: relativePath, physicalInputPath: target});
|
|
621
|
+
if (command.status !== "ready") throw new Error(command.diagnostics.join("\n"));
|
|
622
|
+
const fixed = runtime.executeManagedLintCommand({root: mirror, command: {...command, args: ["--fix", ...command.args]}});
|
|
623
|
+
if (fixed.code === 2) throw new Error(["Oxlint fix failed", fixed.stdout, fixed.stderr].filter(Boolean).join("\n"));
|
|
624
|
+
const fixedDiagnostics = normalizeManagedDiagnostics(fixed.diagnostics, mirror, route.scope, relativePath);
|
|
625
|
+
if (!fixedDiagnostics.ok) throw new Error(fixedDiagnostics.error);
|
|
626
|
+
const result = runtime.executeManagedLintCommand({root: mirror, command});
|
|
627
|
+
if (result.code === 2) throw new Error(["Oxlint verification failed", result.stdout, result.stderr].filter(Boolean).join("\n"));
|
|
628
|
+
const parsed = normalizeManagedDiagnostics(result.diagnostics, mirror, route.scope, relativePath);
|
|
629
|
+
if (!parsed.ok) throw new Error(parsed.error);
|
|
630
|
+
return {ok: true, content: readFileSync(target), diagnostics: parsed.diagnostics};
|
|
631
|
+
} catch (error) {
|
|
632
|
+
return {ok: false, stage: "lint-verify", command: command ? commandText([command.executable, ...command.args]) : "managed lint mirror", error: error.message};
|
|
633
|
+
} finally { rmSync(mirror, {force: true, recursive: true}); }
|
|
621
634
|
}
|
|
622
635
|
|
|
623
636
|
const publicationWorkerScript = `
|
|
@@ -857,49 +870,16 @@ function commandText(command) {
|
|
|
857
870
|
return Array.isArray(command) ? command.join(" ") : String(command ?? "");
|
|
858
871
|
}
|
|
859
872
|
|
|
860
|
-
function formatAndLintFiles(root, filePaths, expectedFingerprints = null) {
|
|
861
|
-
const
|
|
862
|
-
if (
|
|
863
|
-
|
|
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
|
-
}
|
|
873
|
+
async function formatAndLintFiles(root, filePaths, expectedFingerprints = null) {
|
|
874
|
+
const selection = await selectedQuality(root, filePaths);
|
|
875
|
+
if (selection.failure) return selection.failure;
|
|
876
|
+
const normalizedFiles = selection.files;
|
|
897
877
|
|
|
898
878
|
const formatted = [];
|
|
899
879
|
const formatFailed = [];
|
|
900
880
|
const lintFailed = [];
|
|
901
881
|
const diagnostics = [];
|
|
902
|
-
const failures = [];
|
|
882
|
+
const failures = [...selection.failures];
|
|
903
883
|
|
|
904
884
|
for (const relativePath of normalizedFiles) {
|
|
905
885
|
const expectedFingerprint = expectedFingerprints?.[relativePath];
|
|
@@ -920,9 +900,16 @@ function formatAndLintFiles(root, filePaths, expectedFingerprints = null) {
|
|
|
920
900
|
continue;
|
|
921
901
|
}
|
|
922
902
|
|
|
923
|
-
const
|
|
903
|
+
const route = selection.routes.find((item) => item.files.includes(relativePath));
|
|
904
|
+
const workspace = isPythonPath(relativePath) ? root : path.resolve(root, route.scope);
|
|
924
905
|
const workspacePath = workspaceRelativePath(workspace, root, relativePath);
|
|
925
|
-
|
|
906
|
+
let formatCommand;
|
|
907
|
+
try { formatCommand = formatCommandForPath(workspace, workspacePath); }
|
|
908
|
+
catch (error) {
|
|
909
|
+
closeSync(target.descriptor);
|
|
910
|
+
failures.push({kind: "format", stage: "format", file: relativePath, command: "local formatter", message: error.message});
|
|
911
|
+
continue;
|
|
912
|
+
}
|
|
926
913
|
|
|
927
914
|
// Keep mutating tools off the live path; stage output before claiming the validated target.
|
|
928
915
|
const formatResult = runTransformCommand(
|
|
@@ -945,7 +932,7 @@ function formatAndLintFiles(root, filePaths, expectedFingerprints = null) {
|
|
|
945
932
|
continue;
|
|
946
933
|
}
|
|
947
934
|
|
|
948
|
-
const lintCommand = lintCommandForPath(workspace, workspacePath, true);
|
|
935
|
+
const lintCommand = isPythonPath(relativePath) ? lintCommandForPath(workspace, workspacePath, true) : javascriptLintableSuffixes.has(path.extname(relativePath)) ? ["managed lint"] : null;
|
|
949
936
|
let formattedContent = formatResult.output;
|
|
950
937
|
let lintResult = null;
|
|
951
938
|
if (lintCommand !== null && isPythonPath(relativePath)) {
|
|
@@ -954,7 +941,7 @@ function formatAndLintFiles(root, filePaths, expectedFingerprints = null) {
|
|
|
954
941
|
formattedContent = lintResult.output;
|
|
955
942
|
}
|
|
956
943
|
} else if (lintCommand !== null) {
|
|
957
|
-
lintResult = runSafeJavascriptLint(workspace, root, relativePath, formattedContent);
|
|
944
|
+
lintResult = await runSafeJavascriptLint(workspace, root, relativePath, formattedContent, route, selection.runtime);
|
|
958
945
|
if (lintResult.ok) {
|
|
959
946
|
formattedContent = lintResult.content;
|
|
960
947
|
diagnostics.push(...lintResult.diagnostics);
|
|
@@ -994,6 +981,16 @@ function formatAndLintFiles(root, filePaths, expectedFingerprints = null) {
|
|
|
994
981
|
}
|
|
995
982
|
}
|
|
996
983
|
|
|
984
|
+
if (selection.routes.some((route) => route.triggered)) {
|
|
985
|
+
const verified = await verifyLintFiles(root, filePaths);
|
|
986
|
+
const known = new Set(diagnostics.map((diagnostic) => JSON.stringify(diagnostic)));
|
|
987
|
+
for (const diagnostic of verified.diagnostics) {
|
|
988
|
+
if (!known.has(JSON.stringify(diagnostic))) diagnostics.push(diagnostic);
|
|
989
|
+
}
|
|
990
|
+
failures.push(...verified.failures);
|
|
991
|
+
for (const file of verified.lint_failed) if (!lintFailed.includes(file)) lintFailed.push(file);
|
|
992
|
+
}
|
|
993
|
+
|
|
997
994
|
const result =
|
|
998
995
|
failures.length > 0 ? "operational_failure" : diagnostics.length > 0 ? "findings" : "clean";
|
|
999
996
|
return {
|
|
@@ -1018,88 +1015,42 @@ function formatAndLintFiles(root, filePaths, expectedFingerprints = null) {
|
|
|
1018
1015
|
};
|
|
1019
1016
|
}
|
|
1020
1017
|
|
|
1021
|
-
function
|
|
1022
|
-
const
|
|
1023
|
-
const
|
|
1024
|
-
if (
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
}
|
|
1018
|
+
function verifyPythonFile(root, relativePath) {
|
|
1019
|
+
const command = ["uv", "run", "--project", nearestPythonProject(root, relativePath), "ruff", "check", "--output-format", "json", "--stdin-filename", relativePath, "-"];
|
|
1020
|
+
const target = openFormattingTarget(path.join(root, relativePath));
|
|
1021
|
+
if (target === null) return {failure: {stage: "lint-verify", file: relativePath, command: commandText(command), message: "Edited file changed before verification"}};
|
|
1022
|
+
try {
|
|
1023
|
+
const result = runTransformCommand(root, command, target.content);
|
|
1024
|
+
if (result.error || ![0, 1].includes(result.status)) throw new Error(result.error?.message ?? (result.stderr || "Ruff verification failed"));
|
|
1025
|
+
const report = JSON.parse(result.output.toString());
|
|
1026
|
+
if (!Array.isArray(report) || report.some((item) => !item || typeof item.message !== "string" || typeof item.code !== "string" || !Number.isInteger(item.location?.row) || !Number.isInteger(item.location?.column))) throw new Error("Ruff returned invalid diagnostics");
|
|
1027
|
+
if (result.status !== 0 && report.length === 0) throw new Error(result.stderr || "Ruff failed without diagnostics");
|
|
1028
|
+
return {diagnostics: report.map((item) => ({file: relativePath, rule: item.code, severity: "error", line: item.location.row, column: item.location.column, message: item.message, ...(typeof item.url === "string" ? {documentation: item.url} : {})}))};
|
|
1029
|
+
} catch (error) {
|
|
1030
|
+
return {failure: {stage: "lint-verify", file: relativePath, command: commandText(command), message: error.message}};
|
|
1031
|
+
} finally { closeSync(target.descriptor); }
|
|
1032
|
+
}
|
|
1033
1033
|
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
.map((filePath) =>
|
|
1038
|
-
normalizeRelativePath(root, filePath, managedPaths, caseSemantics === "case-insensitive"),
|
|
1039
|
-
)
|
|
1040
|
-
.filter((filePath) => filePath && isLintablePath(filePath)),
|
|
1041
|
-
),
|
|
1042
|
-
];
|
|
1034
|
+
async function verifyLintFiles(root, filePaths) {
|
|
1035
|
+
const selection = await selectedQuality(root, filePaths);
|
|
1036
|
+
if (selection.failure) return selection.failure;
|
|
1043
1037
|
const diagnostics = [];
|
|
1044
|
-
const failures = [];
|
|
1045
|
-
const
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
const result =
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
file: relativePath,
|
|
1057
|
-
command: commandText(command),
|
|
1058
|
-
exitCode: result.status,
|
|
1059
|
-
message: `Oxlint could not start: ${result.error.message}`,
|
|
1060
|
-
});
|
|
1061
|
-
continue;
|
|
1062
|
-
}
|
|
1063
|
-
|
|
1064
|
-
const parsed = parseLintDiagnostics(result.stdout, root, relativePath, workspacePath);
|
|
1065
|
-
if (!parsed.ok) {
|
|
1066
|
-
failures.push({
|
|
1067
|
-
kind: "lint",
|
|
1068
|
-
stage: "lint-verify",
|
|
1069
|
-
file: relativePath,
|
|
1070
|
-
command: commandText(command),
|
|
1071
|
-
exitCode: result.status,
|
|
1072
|
-
message: parsed.error,
|
|
1073
|
-
});
|
|
1074
|
-
continue;
|
|
1075
|
-
}
|
|
1076
|
-
|
|
1077
|
-
if (result.status !== 0 && parsed.diagnostics.length === 0) {
|
|
1078
|
-
failures.push({
|
|
1079
|
-
kind: "lint",
|
|
1080
|
-
stage: "lint-verify",
|
|
1081
|
-
file: relativePath,
|
|
1082
|
-
command: commandText(command),
|
|
1083
|
-
exitCode: result.status,
|
|
1084
|
-
message: result.stderr || "Oxlint verification failed without diagnostics",
|
|
1085
|
-
});
|
|
1086
|
-
continue;
|
|
1087
|
-
}
|
|
1088
|
-
|
|
1089
|
-
diagnostics.push(...parsed.diagnostics);
|
|
1090
|
-
if (parsed.diagnostics.length > 0) {
|
|
1091
|
-
lintFailed.add(relativePath);
|
|
1038
|
+
const failures = [...selection.failures];
|
|
1039
|
+
for (const file of selection.files.filter(isPythonPath)) {
|
|
1040
|
+
const verified = verifyPythonFile(root, file);
|
|
1041
|
+
if (verified.failure) failures.push(verified.failure);
|
|
1042
|
+
else diagnostics.push(...verified.diagnostics);
|
|
1043
|
+
}
|
|
1044
|
+
if (selection.javascriptPaths.length > 0 && selection.failures.length === 0) {
|
|
1045
|
+
const result = await selection.runtime.runManagedLint({root, paths: selection.javascriptPaths.map((file) => path.relative(root, path.resolve(root, file)).split(path.sep).join("/")), output: "json"});
|
|
1046
|
+
for (const owner of result.results ?? []) {
|
|
1047
|
+
const parsed = normalizeManagedDiagnostics(owner.diagnostics, root, owner.scope, "");
|
|
1048
|
+
if (parsed.ok) diagnostics.push(...parsed.diagnostics);
|
|
1049
|
+
else failures.push({stage: "lint-verify", command: "managed lint", message: parsed.error});
|
|
1092
1050
|
}
|
|
1051
|
+
if (result.code === 2) failures.push({stage: "lint-verify", command: "managed lint", message: result.diagnostics?.join("\n") || result.results?.map((owner) => `${owner.stdout}\n${owner.stderr}`).join("\n") || "Lint verification failed without diagnostics"});
|
|
1093
1052
|
}
|
|
1094
|
-
|
|
1095
|
-
return {
|
|
1096
|
-
...emptyLintSummary(
|
|
1097
|
-
failures.length > 0 ? "operational_failure" : diagnostics.length > 0 ? "findings" : "clean",
|
|
1098
|
-
failures,
|
|
1099
|
-
),
|
|
1100
|
-
diagnostics,
|
|
1101
|
-
lint_failed: [...lintFailed],
|
|
1102
|
-
};
|
|
1053
|
+
return {...emptyLintSummary(failures.length ? "operational_failure" : diagnostics.length ? "findings" : "clean", failures), diagnostics, lint_failed: [...new Set(diagnostics.map((diagnostic) => diagnostic.file))]};
|
|
1103
1054
|
}
|
|
1104
1055
|
|
|
1105
1056
|
function extractSingleFilePath(payload) {
|
|
@@ -1191,7 +1142,7 @@ function emitProviderFeedback(provider, summary) {
|
|
|
1191
1142
|
}
|
|
1192
1143
|
}
|
|
1193
1144
|
|
|
1194
|
-
function runSingleFileMode(style) {
|
|
1145
|
+
async function runSingleFileMode(style) {
|
|
1195
1146
|
const payload = readStdinJson();
|
|
1196
1147
|
const root = repoRoot(process.cwd());
|
|
1197
1148
|
|
|
@@ -1204,7 +1155,7 @@ function runSingleFileMode(style) {
|
|
|
1204
1155
|
return;
|
|
1205
1156
|
}
|
|
1206
1157
|
|
|
1207
|
-
const summary = formatAndLintFiles(root, [filePath]);
|
|
1158
|
+
const summary = await formatAndLintFiles(root, [filePath]);
|
|
1208
1159
|
emitProviderFeedback(style, summary);
|
|
1209
1160
|
}
|
|
1210
1161
|
|
|
@@ -1220,7 +1171,6 @@ function dirtyFiles(root) {
|
|
|
1220
1171
|
.split("\n")
|
|
1221
1172
|
.map((line) => line.trim())
|
|
1222
1173
|
.filter(Boolean)
|
|
1223
|
-
.filter((filePath) => formattableSuffixes.has(path.extname(filePath)))
|
|
1224
1174
|
.filter((filePath) => !filePath.split("/").some((part) => ignoredParts.has(part))),
|
|
1225
1175
|
),
|
|
1226
1176
|
].sort();
|
|
@@ -1404,7 +1354,7 @@ function pruneProcessedFingerprints(state, current) {
|
|
|
1404
1354
|
}
|
|
1405
1355
|
}
|
|
1406
1356
|
|
|
1407
|
-
function runCodexSnapshotMode(mode) {
|
|
1357
|
+
async function runCodexSnapshotMode(mode) {
|
|
1408
1358
|
const payload = readStdinJson();
|
|
1409
1359
|
const cwd = String(payload.cwd ?? process.cwd());
|
|
1410
1360
|
const sessionId = String(payload.session_id ?? "");
|
|
@@ -1471,7 +1421,7 @@ function runCodexSnapshotMode(mode) {
|
|
|
1471
1421
|
return;
|
|
1472
1422
|
}
|
|
1473
1423
|
|
|
1474
|
-
const summary = formatAndLintFiles(root, touched, current);
|
|
1424
|
+
const summary = await formatAndLintFiles(root, touched, current);
|
|
1475
1425
|
if (summary.diagnostics.length > 0) {
|
|
1476
1426
|
applyDiagnosticRetryLimit(state, summary);
|
|
1477
1427
|
} else {
|
|
@@ -1610,32 +1560,31 @@ export const FormatAndLintPlugin = async ({ client, worktree }) => {
|
|
|
1610
1560
|
};
|
|
1611
1561
|
|
|
1612
1562
|
export const testHooks = {
|
|
1563
|
+
copyLintMirror,
|
|
1613
1564
|
codexStateFilePath,
|
|
1614
1565
|
formatCommandForPath,
|
|
1615
1566
|
lintCommandForPath,
|
|
1616
|
-
owningWorkspace,
|
|
1617
|
-
parseLintDiagnostics,
|
|
1618
1567
|
renderProviderFeedback,
|
|
1619
1568
|
toolCommand,
|
|
1620
1569
|
};
|
|
1621
1570
|
|
|
1622
|
-
function main() {
|
|
1571
|
+
async function main() {
|
|
1623
1572
|
const mode = process.argv[2] ?? "";
|
|
1624
1573
|
|
|
1625
1574
|
if (mode === "session-start" || mode === "post") {
|
|
1626
|
-
runCodexSnapshotMode(mode);
|
|
1575
|
+
await runCodexSnapshotMode(mode);
|
|
1627
1576
|
return;
|
|
1628
1577
|
}
|
|
1629
1578
|
|
|
1630
1579
|
if (mode === "claude" || mode === "cursor" || mode === "opencode") {
|
|
1631
|
-
runSingleFileMode(mode);
|
|
1580
|
+
await runSingleFileMode(mode);
|
|
1632
1581
|
return;
|
|
1633
1582
|
}
|
|
1634
1583
|
|
|
1635
1584
|
if (mode === "files") {
|
|
1636
1585
|
const root = repoRoot(process.cwd());
|
|
1637
1586
|
const summary = root
|
|
1638
|
-
? formatAndLintFiles(root, process.argv.slice(3))
|
|
1587
|
+
? await formatAndLintFiles(root, process.argv.slice(3))
|
|
1639
1588
|
: emptyLintSummary("operational_failure", [
|
|
1640
1589
|
{ stage: "config-load", command: "git rev-parse --show-toplevel", message: "Not inside a Git repository" },
|
|
1641
1590
|
]);
|
|
@@ -1646,7 +1595,7 @@ function main() {
|
|
|
1646
1595
|
if (mode === "preview") {
|
|
1647
1596
|
const root = repoRoot(process.cwd());
|
|
1648
1597
|
const summary = root
|
|
1649
|
-
? verifyLintFiles(root, process.argv.slice(3))
|
|
1598
|
+
? await verifyLintFiles(root, process.argv.slice(3))
|
|
1650
1599
|
: emptyLintSummary("operational_failure", [
|
|
1651
1600
|
{ stage: "config-load", command: "git rev-parse --show-toplevel", message: "Not inside a Git repository" },
|
|
1652
1601
|
]);
|
|
@@ -1658,5 +1607,5 @@ const invokedPath = process.argv[1] ? path.resolve(process.argv[1]) : "";
|
|
|
1658
1607
|
const modulePath = fileURLToPath(import.meta.url);
|
|
1659
1608
|
|
|
1660
1609
|
if (invokedPath && path.basename(invokedPath) === path.basename(modulePath)) {
|
|
1661
|
-
main();
|
|
1610
|
+
await main();
|
|
1662
1611
|
}
|