@opendesignai/harness 0.3.0-alpha.0 → 0.5.0-alpha.0

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/dist/cli.mjs CHANGED
@@ -4,13 +4,15 @@ import { isDeepStrictEqual, parseArgs } from "node:util";
4
4
  import { execFile, execFileSync, spawn, spawnSync } from "node:child_process";
5
5
  import path from "node:path";
6
6
  import { Visitor, parseSync } from "oxc-parser";
7
- import { closeSync, constants, copyFileSync, existsSync, lstatSync, mkdirSync, mkdtempSync, openSync, readFileSync, readSync, readdirSync, realpathSync, renameSync, rmSync, statSync, symlinkSync, unlinkSync, writeFileSync } from "node:fs";
7
+ import { closeSync, constants, copyFileSync, existsSync, fstatSync, lstatSync, mkdirSync, mkdtempSync, openSync, readFileSync, readSync, readdirSync, realpathSync, renameSync, rmSync, rmdirSync, statSync, symlinkSync, unlinkSync, writeFileSync } from "node:fs";
8
8
  import { createHash, randomUUID } from "node:crypto";
9
- import { LineCounter, isMap, isScalar, parseAllDocuments, parseDocument } from "yaml";
10
- import { tmpdir } from "node:os";
9
+ import { LineCounter, isMap, isScalar, parse, parseAllDocuments, parseDocument } from "yaml";
10
+ import { availableParallelism, tmpdir } from "node:os";
11
11
  import { runJscpd } from "jscpd";
12
12
  import { createInterface } from "node:readline";
13
13
  import { createRequire } from "node:module";
14
+ import semver from "semver";
15
+ import { setTimeout as setTimeout$1 } from "node:timers/promises";
14
16
  // src/plugin/meta.ts
15
17
  const DOCS_BASE = "https://github.com/nexu-io/od-harness/blob/main/docs/rules";
16
18
  function docsUrl(rule) {
@@ -220,6 +222,122 @@ function compileRegExp(pattern, flags, option) {
220
222
  // src/plugin/rules/no-api-path-literal.ts
221
223
  const RULE$12 = "no-api-path-literal";
222
224
  const DEFAULT_PREFIXES = ["/api/", "/motion-api/"];
225
+ const ROUTE_METHODS = /* @__PURE__ */ new Set([
226
+ "get",
227
+ "post",
228
+ "put",
229
+ "patch",
230
+ "delete",
231
+ "head",
232
+ "options",
233
+ "connect",
234
+ "trace",
235
+ "all",
236
+ "use",
237
+ "route",
238
+ "on"
239
+ ]);
240
+ const ROUTER_NAMES = /* @__PURE__ */ new Set([
241
+ "app",
242
+ "router",
243
+ "routes",
244
+ "server",
245
+ "hono",
246
+ "fastify"
247
+ ]);
248
+ const ROUTER_CONSTRUCTORS = /* @__PURE__ */ new Set([
249
+ "Hono",
250
+ "Router",
251
+ "KoaRouter"
252
+ ]);
253
+ const ROUTER_FACTORIES = /* @__PURE__ */ new Set([
254
+ "express",
255
+ "Router",
256
+ "fastify"
257
+ ]);
258
+ const CLIENT_NAMES = /* @__PURE__ */ new Set([
259
+ "axios",
260
+ "ky",
261
+ "client"
262
+ ]);
263
+ const HANDLER_REFERENCES = /* @__PURE__ */ new Set([
264
+ "Identifier",
265
+ "MemberExpression",
266
+ "CallExpression",
267
+ "ArrayExpression",
268
+ "SpreadElement"
269
+ ]);
270
+ const HTTP_METHOD = /^(?:GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS|CONNECT|TRACE)$/i;
271
+ const EQUALITY_OPERATORS = /* @__PURE__ */ new Set([
272
+ "==",
273
+ "===",
274
+ "!=",
275
+ "!=="
276
+ ]);
277
+ function isHttpMethod(node) {
278
+ const method = staticString(node);
279
+ return method !== null && HTTP_METHOD.test(method);
280
+ }
281
+ function routeMethod(callee) {
282
+ const method = callee && propertyName(callee);
283
+ return method !== null && ROUTE_METHODS.has(method) ? method : null;
284
+ }
285
+ function routeRoot(node) {
286
+ let root = unwrap(node) ?? node;
287
+ while (root.type === "CallExpression") {
288
+ const callee = unwrap(root.callee);
289
+ if (callee?.type !== "MemberExpression" || routeMethod(callee) === null) break;
290
+ root = unwrap(callee.object) ?? callee.object;
291
+ }
292
+ return root;
293
+ }
294
+ function followedByRouteCall(call) {
295
+ const member = call.parent;
296
+ if (member?.type !== "MemberExpression" || member.object !== call) return false;
297
+ const next = member.parent;
298
+ return next?.type === "CallExpression" && next.callee === member && routeMethod(member) !== null;
299
+ }
300
+ function isRouteRegistration(node, call, callee) {
301
+ const method = routeMethod(callee);
302
+ if (method === null) return false;
303
+ const pathIndex = method === "on" ? 1 : 0;
304
+ const path = call.arguments[pathIndex];
305
+ const isOnPathElement = method === "on" && path?.type === "ArrayExpression" && node.parent === path;
306
+ if (path !== node && !isOnPathElement) return false;
307
+ if (method === "on") {
308
+ const verbs = unwrap(call.arguments[0]);
309
+ if (!(verbs?.type === "ArrayExpression" ? verbs.elements.length > 0 && verbs.elements.every(isHttpMethod) : isHttpMethod(verbs))) return false;
310
+ }
311
+ const root = routeRoot(callee.object);
312
+ const receiver = calleeName(root.type === "CallExpression" || root.type === "NewExpression" ? root.callee : root);
313
+ if (receiver !== null && CLIENT_NAMES.has(receiver)) return false;
314
+ let routerNames = ROUTER_NAMES;
315
+ if (root.type === "CallExpression") routerNames = ROUTER_FACTORIES;
316
+ if (root.type === "NewExpression") routerNames = ROUTER_CONSTRUCTORS;
317
+ const namedRouter = receiver !== null && routerNames.has(receiver);
318
+ if (method === "route") return namedRouter && (call.arguments.length >= 2 || followedByRouteCall(call));
319
+ return call.arguments.slice(pathIndex + 1).some((argument) => {
320
+ const handler = unwrap(argument);
321
+ return handler !== null && (handler.type === "ArrowFunctionExpression" || handler.type === "FunctionExpression" || namedRouter && HANDLER_REFERENCES.has(handler.type));
322
+ });
323
+ }
324
+ function isPathname(node) {
325
+ const value = unwrap(node);
326
+ if (!value) return false;
327
+ return value.type === "Identifier" ? value.name === "pathname" : propertyName(value) === "pathname";
328
+ }
329
+ function isRouteDefinition(node) {
330
+ const parent = node.parent;
331
+ if (!parent) return false;
332
+ if (parent.type === "BinaryExpression" && EQUALITY_OPERATORS.has(parent.operator)) return parent.left === node && isPathname(parent.right) || parent.right === node && isPathname(parent.left);
333
+ if (parent.type === "SwitchCase" && parent.test === node) return parent.parent?.type === "SwitchStatement" && isPathname(parent.parent.discriminant);
334
+ const call = parent.type === "ArrayExpression" ? parent.parent : parent;
335
+ if (call?.type !== "CallExpression") return false;
336
+ const callee = unwrap(call.callee);
337
+ if (callee?.type !== "MemberExpression") return false;
338
+ if (propertyName(callee) === "startsWith") return call.arguments[0] === node && isPathname(callee.object);
339
+ return isRouteRegistration(node, call, callee);
340
+ }
223
341
  const noApiPathLiteral = {
224
342
  meta: {
225
343
  type: "problem",
@@ -258,7 +376,9 @@ const noApiPathLiteral = {
258
376
  function check(node, text) {
259
377
  if (isModuleSource(node) || isInTypePosition(node)) return;
260
378
  const prefix = matchPrefix(text);
261
- if (prefix !== null) context.report({
379
+ if (prefix === null) return;
380
+ if (staticString(node) !== null && isRouteDefinition(node)) return;
381
+ context.report({
262
382
  node,
263
383
  messageId: "apiPath",
264
384
  data: {
@@ -1650,7 +1770,7 @@ const noWindowBus = {
1650
1770
  };
1651
1771
  // src/plugin/version.ts
1652
1772
  /** Kept in sync with package.json by test/plugin.test.ts. */
1653
- const VERSION = "0.3.0-alpha.0";
1773
+ const VERSION = "0.5.0-alpha.0";
1654
1774
  // src/plugin/index.ts
1655
1775
  const plugin = {
1656
1776
  meta: {
@@ -1820,32 +1940,36 @@ function resolveRef(cwd, ref) {
1820
1940
  if (result.status !== 0) throw new EnvironmentError(`cannot resolve base ref ${JSON.stringify(ref)}. In CI, check out with full history (fetch-depth: 0) or fetch the base commit first.`);
1821
1941
  return result.stdout.trim();
1822
1942
  }
1823
- /**
1824
- * The commit `git merge-base HEAD <ref>` names, or why there is none: `ref` does not resolve (not
1825
- * fetched), or HEAD and `ref` share no history (unrelated, or cut off by a shallow clone).
1826
- */
1827
- function mergeBase(cwd, ref) {
1828
- const resolved = spawnSync("git", [
1943
+ function readGitRef(cwd, args, absent) {
1944
+ const result = spawnSync("git", args, {
1945
+ cwd,
1946
+ encoding: "utf8"
1947
+ });
1948
+ if (result.status === absent) return null;
1949
+ if (result.status !== 0) throw new EnvironmentError(gitFailure(args, result.error ?? result));
1950
+ return result.stdout;
1951
+ }
1952
+ /** Local checks need the commit where HEAD diverged from the selected base. */
1953
+ function mergeBase(cwd, ref, read = readGitRef) {
1954
+ const sha = read(cwd, [
1829
1955
  "rev-parse",
1830
1956
  "--verify",
1831
1957
  "--quiet",
1958
+ "--end-of-options",
1832
1959
  `${ref}^{commit}`
1833
- ], {
1834
- cwd,
1835
- encoding: "utf8"
1836
- });
1837
- if (resolved.status !== 0) return { skip: `cannot resolve ${ref} (fetch it to enable the check)` };
1838
- const result = spawnSync("git", [
1960
+ ], 1);
1961
+ if (!sha) {
1962
+ const branch = /^origin\/([a-z0-9_./][a-z0-9_./-]*)$/i.exec(ref)?.[1];
1963
+ const fetch = branch ? `git fetch origin ${branch}:refs/remotes/origin/${branch}` : "git fetch";
1964
+ throw new EnvironmentError(`cannot resolve ${JSON.stringify(ref)}. Run \`${fetch}\` or select an available base commit from this branch's history.`);
1965
+ }
1966
+ const commit = read(cwd, [
1839
1967
  "merge-base",
1840
1968
  "HEAD",
1841
- resolved.stdout.trim()
1842
- ], {
1843
- cwd,
1844
- encoding: "utf8"
1845
- });
1846
- const commit = result.status === 0 ? result.stdout.trim() : "";
1847
- if (commit === "") return { skip: `no merge base with ${ref} (fetch more history to enable the check)` };
1848
- return { commit };
1969
+ sha.trim()
1970
+ ], 1)?.trim();
1971
+ if (!commit) throw new EnvironmentError(`no merge base with ${JSON.stringify(ref)}. In a shallow clone, run \`git fetch --unshallow\`. For unrelated histories, select the intended base from this branch's history.`);
1972
+ return commit;
1849
1973
  }
1850
1974
  /** `<commit>:<path>` with the path read relative to the working directory, like the working tree. */
1851
1975
  function revPath(commit, file) {
@@ -3637,6 +3761,30 @@ function childEnv(extra) {
3637
3761
  function isGitHubActions() {
3638
3762
  return process.env.GITHUB_ACTIONS === "true";
3639
3763
  }
3764
+ function enabled$1(value) {
3765
+ return !/^(?:|0|false|no|off)$/i.test(value?.trim() ?? "");
3766
+ }
3767
+ function verifySlotEnv() {
3768
+ return {
3769
+ bypass: enabled$1(process.env.CI) || enabled$1(process.env.GITHUB_ACTIONS) || process.env["OD_HARNESS_NO_SLOT"] === "1",
3770
+ capacity: process.env["OD_HARNESS_VERIFY_SLOTS"],
3771
+ directory: process.env["OD_HARNESS_SLOT_DIR"]
3772
+ };
3773
+ }
3774
+ function verifyThrottleEnv(activeSlots, ncpu = availableParallelism()) {
3775
+ if (activeSlots <= 1) return {};
3776
+ const perSlot = Math.max(2, Math.floor(ncpu / activeSlots));
3777
+ return Object.fromEntries(Object.entries({
3778
+ GOMAXPROCS: String(perSlot),
3779
+ RAYON_NUM_THREADS: String(perSlot),
3780
+ UV_THREADPOOL_SIZE: String(perSlot),
3781
+ VITEST_MAX_WORKERS: String(Math.max(2, Math.min(4, perSlot))),
3782
+ PNPM_WORKSPACE_CONCURRENCY: String(Math.min(3, perSlot))
3783
+ }).filter(([name]) => process.env[name] === void 0));
3784
+ }
3785
+ function hookLogMode() {
3786
+ return process.env["OD_HARNESS_HOOK_LOG"];
3787
+ }
3640
3788
  // src/cli/diagnostic.ts
3641
3789
  function diagnosticMessage({ message, fix, exemption, docs, severity }) {
3642
3790
  return [
@@ -3691,10 +3839,8 @@ function printReport(report) {
3691
3839
  }
3692
3840
  function printGate(command, outcome, summary, format, relativeTo) {
3693
3841
  const status = outcome.ok ? 0 : 1;
3694
- const skipped = outcome.skipped === void 0 ? "" : `skipped: ${outcome.skipped}.`;
3695
3842
  if (format === "text") {
3696
- if (skipped) console.warn(`od-harness ${command}: ${skipped}`);
3697
- else print(command, outcome, summary);
3843
+ print(command, outcome, summary);
3698
3844
  if (!isGitHubActions()) return status;
3699
3845
  }
3700
3846
  const prefix = relativeTo && outcome.diagnostics.length > 0 ? repositoryPrefix(relativeTo) : "";
@@ -3709,20 +3855,16 @@ function printGate(command, outcome, summary, format, relativeTo) {
3709
3855
  diagnostics
3710
3856
  };
3711
3857
  if (summary) report.summary = summary;
3712
- if (skipped) report.notes = [skipped];
3713
- else if (outcome.notes.length > 0) report.notes = outcome.notes;
3858
+ if (outcome.notes.length > 0) report.notes = outcome.notes;
3714
3859
  printReport(report);
3715
3860
  return status;
3716
3861
  }
3717
3862
  for (const diagnostic of diagnostics) reportDiagnostic(diagnostic, { format: "github" });
3718
- if (format === "github") {
3719
- if (skipped) console.warn(`od-harness ${command}: ${skipped}`);
3720
- else print(command, {
3721
- ok: outcome.ok,
3722
- errors: [],
3723
- notes: []
3724
- }, summary);
3725
- }
3863
+ if (format === "github") print(command, {
3864
+ ok: outcome.ok,
3865
+ errors: [],
3866
+ notes: []
3867
+ }, summary);
3726
3868
  return status;
3727
3869
  }
3728
3870
  // src/cli/comments.ts
@@ -3911,7 +4053,7 @@ function runComments(cwd, ref, format) {
3911
4053
  }
3912
4054
  // src/cli/agent-project.ts
3913
4055
  const CODEX_HOOKS = ".codex/hooks.json";
3914
- const HARNESS_PACKAGE$1 = "@opendesignai/harness";
4056
+ const HARNESS_PACKAGE = "@opendesignai/harness";
3915
4057
  function record$2(value) {
3916
4058
  return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
3917
4059
  }
@@ -4084,8 +4226,8 @@ const DEPENDENCY_SECTIONS = [
4084
4226
  "optionalDependencies"
4085
4227
  ];
4086
4228
  const EXACT_VERSION = /^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;
4087
- const ALIAS = `npm:${HARNESS_PACKAGE$1}@`;
4088
- const REGISTRY = `https://registry.npmjs.org/${HARNESS_PACKAGE$1}/-/`;
4229
+ const ALIAS = `npm:${HARNESS_PACKAGE}@`;
4230
+ const REGISTRY = `https://registry.npmjs.org/${HARNESS_PACKAGE}/-/`;
4089
4231
  const LOCAL_DEPENDENCY = /^(?:link|file|portal):/;
4090
4232
  function yamlDocuments(root, file) {
4091
4233
  const content = readProjectFile(root, file);
@@ -4126,7 +4268,7 @@ function readManifest(root) {
4126
4268
  }
4127
4269
  function declaredHarnessVersions(root) {
4128
4270
  const [workspace] = yamlDocuments(root, "pnpm-workspace.yaml");
4129
- return dependencyEntries(readManifest(root)).filter(([name]) => name === HARNESS_PACKAGE$1).map(([name, value]) => pin(resolveSpecifier(record$2(workspace), name, value)));
4271
+ return dependencyEntries(readManifest(root)).filter(([name]) => name === HARNESS_PACKAGE).map(([name, value]) => pin(resolveSpecifier(record$2(workspace), name, value)));
4130
4272
  }
4131
4273
  function overrideEntries(value) {
4132
4274
  const overrides = [];
@@ -4173,7 +4315,7 @@ function checkNpmLock(content, pins) {
4173
4315
  }
4174
4316
  function namesLocalHarness(value) {
4175
4317
  if (typeof value !== "string" || !LOCAL_DEPENDENCY.test(value)) return false;
4176
- return `/${value.slice(value.indexOf(":") + 1).replaceAll("\\", "/")}/`.includes(`/${HARNESS_PACKAGE$1}/`);
4318
+ return `/${value.slice(value.indexOf(":") + 1).replaceAll("\\", "/")}/`.includes(`/${HARNESS_PACKAGE}/`);
4177
4319
  }
4178
4320
  function checkPnpmLock(documents, pins, workspace) {
4179
4321
  const lock = documents.map(record$2).findLast((doc) => record$2(doc?.["importers"])?.["."] !== void 0 && record$2(doc?.["packages"]) !== void 0);
@@ -4193,7 +4335,7 @@ function checkPnpmLock(documents, pins, workspace) {
4193
4335
  versions.add(version);
4194
4336
  }
4195
4337
  const matched = /* @__PURE__ */ new Set();
4196
- const prefix = `${HARNESS_PACKAGE$1}@`;
4338
+ const prefix = `${HARNESS_PACKAGE}@`;
4197
4339
  for (const [directory, importer] of Object.entries(importers)) for (const [name, value] of dependencyEntries(record$2(importer) ?? {})) {
4198
4340
  const entry = record$2(value);
4199
4341
  const locked = entry?.["version"];
@@ -4218,7 +4360,7 @@ function checkHarnessSource(root) {
4218
4360
  const resolved = resolveSpecifier(workspace, name, specifier);
4219
4361
  if (name !== "@opendesignai/harness" && !isAlias(resolved)) continue;
4220
4362
  const version = pin(resolved);
4221
- if (!version || pins.has(name) && pins.get(name) !== version) errors.push(`package.json must pin ${HARNESS_PACKAGE$1} to one exact npm version or catalog entry.`);
4363
+ if (!version || pins.has(name) && pins.get(name) !== version) errors.push(`package.json must pin ${HARNESS_PACKAGE} to one exact npm version or catalog entry.`);
4222
4364
  else pins.set(name, version);
4223
4365
  }
4224
4366
  for (const overrides of [
@@ -4229,32 +4371,84 @@ function checkHarnessSource(root) {
4229
4371
  ]) for (const [selector, specifier] of overrideEntries(overrides)) {
4230
4372
  const name = overridePackage(selector);
4231
4373
  const resolved = resolveSpecifier(workspace, name, specifier);
4232
- if ((name === "@opendesignai/harness" || pins.has(name) || isAlias(resolved)) && !pin(resolved)) errors.push(`package.json overrides and resolutions for ${HARNESS_PACKAGE$1} must use an exact npm version.`);
4374
+ if ((name === "@opendesignai/harness" || pins.has(name) || isAlias(resolved)) && !pin(resolved)) errors.push(`package.json overrides and resolutions for ${HARNESS_PACKAGE} must use an exact npm version.`);
4233
4375
  }
4234
4376
  if (errors.length > 0) return errors;
4235
- if (!pins.has("@opendesignai/harness")) return [`Declare ${HARNESS_PACKAGE$1} under its original name in package.json and pin it to an exact npm version or catalog entry.`];
4377
+ if (!pins.has("@opendesignai/harness")) return [`Declare ${HARNESS_PACKAGE} under its original name in package.json and pin it to an exact npm version or catalog entry.`];
4236
4378
  const npmLock = readProjectFile(root, "package-lock.json");
4237
4379
  const pnpmLock = yamlDocuments(root, "pnpm-lock.yaml");
4238
- if (npmLock === void 0 && pnpmLock.length === 0) return [`Commit package-lock.json or pnpm-lock.yaml with the registry resolution for ${HARNESS_PACKAGE$1}.`];
4239
- if (npmLock !== void 0 && !checkNpmLock(npmLock, pins)) errors.push(`package-lock.json must resolve ${HARNESS_PACKAGE$1} from registry.npmjs.org at the pinned version with integrity.`);
4240
- if (pnpmLock.length > 0 && !checkPnpmLock(pnpmLock, pins, workspace)) errors.push(`pnpm-lock.yaml must resolve ${HARNESS_PACKAGE$1} from the npm registry at the pinned version with integrity.`);
4380
+ if (npmLock === void 0 && pnpmLock.length === 0) return [`Commit package-lock.json or pnpm-lock.yaml with the registry resolution for ${HARNESS_PACKAGE}.`];
4381
+ if (npmLock !== void 0 && !checkNpmLock(npmLock, pins)) errors.push(`package-lock.json must resolve ${HARNESS_PACKAGE} from registry.npmjs.org at the pinned version with integrity.`);
4382
+ if (pnpmLock.length > 0 && !checkPnpmLock(pnpmLock, pins, workspace)) errors.push(`pnpm-lock.yaml must resolve ${HARNESS_PACKAGE} from the npm registry at the pinned version with integrity.`);
4241
4383
  return errors;
4242
4384
  }
4385
+ // src/cli/verify-process.ts
4386
+ function vitestBin(cwd, config) {
4387
+ const project = config ? path.dirname(path.resolve(cwd, config)) : cwd;
4388
+ for (const directory of /* @__PURE__ */ new Set([project, cwd])) try {
4389
+ const manifest = createRequire(path.join(directory, "package.json")).resolve("vitest/package.json");
4390
+ return path.join(path.dirname(manifest), "vitest.mjs");
4391
+ } catch (error) {
4392
+ const code = error.code;
4393
+ if (code !== "MODULE_NOT_FOUND" && code !== "ERR_PACKAGE_PATH_NOT_EXPORTED") throw error;
4394
+ }
4395
+ }
4396
+ function invoke(cwd, base, bin, args, extraEnv) {
4397
+ const env = childEnv({
4398
+ ...extraEnv,
4399
+ HARNESS_BASE_REF: base
4400
+ });
4401
+ env.PATH = [path.join(cwd, "node_modules", ".bin"), env.PATH].filter(Boolean).join(path.delimiter);
4402
+ return new Promise((resolve) => {
4403
+ execFile(bin, args, {
4404
+ cwd,
4405
+ env,
4406
+ encoding: "utf8",
4407
+ maxBuffer: 67108864
4408
+ }, (error, stdout, stderr) => {
4409
+ const code = error ? typeof error.code === "number" ? error.code : null : 0;
4410
+ resolve({
4411
+ code,
4412
+ stdout,
4413
+ stderr,
4414
+ problem: code === null ? error?.message ?? "Process aborted" : null
4415
+ });
4416
+ });
4417
+ });
4418
+ }
4419
+ function commandOutput(result) {
4420
+ return [result.stderr.trim(), result.stdout.trim()].filter(Boolean).join("\n");
4421
+ }
4422
+ function shellCommand(bin, args) {
4423
+ return [bin, ...args].map((arg) => /^[\w+./=@:-]+$/.test(arg) ? arg : `'${arg.replaceAll("'", "'\\''")}'`).join(" ");
4424
+ }
4243
4425
  // src/cli/doctor.ts
4244
4426
  function checkInstallation(root) {
4245
- const file = `node_modules/${HARNESS_PACKAGE$1}/package.json`;
4427
+ const file = `node_modules/${HARNESS_PACKAGE}/package.json`;
4246
4428
  const content = readProjectFile(root, file);
4247
- if (content === void 0) return [`${HARNESS_PACKAGE$1} is missing. Run npm ci or pnpm install --frozen-lockfile.`];
4429
+ if (content === void 0) return [`${HARNESS_PACKAGE} is missing. Run npm ci or pnpm install --frozen-lockfile.`];
4248
4430
  const manifest = parseProjectJson(content, file);
4249
4431
  const versions = declaredHarnessVersions(root);
4250
- if (versions.length === 0 || versions.some((version) => !version)) return [`Pin ${HARNESS_PACKAGE$1} to an exact npm version in package.json or the pnpm catalog.`];
4251
- if (manifest["name"] !== "@opendesignai/harness" || versions.some((version) => version !== manifest["version"])) return [`Installed ${HARNESS_PACKAGE$1} does not match the declared version (${[...new Set(versions)].join(", ")}). Reinstall from the lockfile.`];
4432
+ if (versions.length === 0 || versions.some((version) => !version)) return [`Pin ${HARNESS_PACKAGE} to an exact npm version in package.json or the pnpm catalog.`];
4433
+ if (manifest["name"] !== "@opendesignai/harness" || versions.some((version) => version !== manifest["version"])) return [`Installed ${HARNESS_PACKAGE} does not match the declared version (${[...new Set(versions)].join(", ")}). Reinstall from the lockfile.`];
4252
4434
  return [];
4253
4435
  }
4254
- async function runDoctor(cwd) {
4436
+ function spotlightNote(root, platform) {
4437
+ if (platform !== "darwin") return void 0;
4438
+ try {
4439
+ if (!lstatSync(path.join(root, ".git"), { throwIfNoEntry: false })?.isFile()) return void 0;
4440
+ const marker = ".metadata_never_index";
4441
+ const parentMarker = path.join(path.dirname(root), marker);
4442
+ if (existsSync(path.join(root, marker)) || existsSync(parentMarker)) return void 0;
4443
+ return `Reduce Spotlight indexing during parallel worktree runs with \`${shellCommand("touch", [parentMarker])}\`.`;
4444
+ } catch {
4445
+ return;
4446
+ }
4447
+ }
4448
+ async function runDoctor(cwd, platform = process.platform) {
4255
4449
  const root = projectRoot(cwd);
4256
4450
  const errors = checkInstallation(root);
4257
- const notes = errors.length === 0 ? [`${HARNESS_PACKAGE$1} is installed at the declared version.`] : [];
4451
+ const notes = errors.length === 0 ? [`${HARNESS_PACKAGE} is installed at the declared version.`] : [];
4258
4452
  try {
4259
4453
  const trustErrors = await checkCodexTrust(root);
4260
4454
  errors.push(...trustErrors);
@@ -4262,12 +4456,254 @@ async function runDoctor(cwd) {
4262
4456
  } catch (error) {
4263
4457
  errors.push(`Could not inspect Codex trust (${error.message}). Check that Codex CLI with hooks/list is on PATH.`);
4264
4458
  }
4459
+ const advisory = spotlightNote(root, platform);
4460
+ if (advisory) notes.push(advisory);
4265
4461
  return {
4266
4462
  ok: errors.length === 0,
4267
4463
  errors,
4268
4464
  notes
4269
4465
  };
4270
4466
  }
4467
+ // src/hook/runtime/io.ts
4468
+ function missing(error) {
4469
+ return error?.code === "ENOENT";
4470
+ }
4471
+ // src/hook/runtime/state.ts
4472
+ var UnsafeTempDirectoryError = class extends Error {
4473
+ constructor(options) {
4474
+ super("Set TMPDIR to a directory you own or one protected by the sticky bit.", options);
4475
+ }
4476
+ };
4477
+ function checkedTempDirectory(dir, uid) {
4478
+ let parent;
4479
+ let stat;
4480
+ try {
4481
+ parent = realpathSync.native(dir);
4482
+ stat = lstatSync(parent);
4483
+ } catch (cause) {
4484
+ throw new UnsafeTempDirectoryError({ cause });
4485
+ }
4486
+ if (!stat.isDirectory() || stat.uid !== uid && (stat.mode & 512) === 0) throw new UnsafeTempDirectoryError();
4487
+ return parent;
4488
+ }
4489
+ function stateDirectory(create = true) {
4490
+ const uid = process.getuid?.();
4491
+ const parent = uid === void 0 ? tmpdir() : checkedTempDirectory(tmpdir(), uid);
4492
+ const dir = path.join(parent, uid === void 0 ? "od-harness" : `od-harness-${uid}`);
4493
+ if (create) mkdirSync(dir, {
4494
+ recursive: true,
4495
+ mode: 448
4496
+ });
4497
+ const stat = lstatSync(dir);
4498
+ if (!stat.isDirectory() || uid !== void 0 && (stat.uid !== uid || (stat.mode & 63) !== 0)) throw new Error("Hook state directory must be owned by the current user and private");
4499
+ return dir;
4500
+ }
4501
+ function stopMarker(dir, root) {
4502
+ const key = createHash("sha256").update(root).digest("hex");
4503
+ return path.join(dir, `stop-${key}.unverified`);
4504
+ }
4505
+ function hasUnverifiedStop(cwd) {
4506
+ try {
4507
+ const dir = stateDirectory(false);
4508
+ const root = realpathSync.native(repositoryRoot$1(cwd));
4509
+ return existsSync(stopMarker(dir, root));
4510
+ } catch {
4511
+ return false;
4512
+ }
4513
+ }
4514
+ // src/hook/runtime/decision-log.ts
4515
+ function decisionLogName(now, daysAgo = 0) {
4516
+ return `decisions-${(/* @__PURE__ */ new Date(now - daysAgo * 864e5)).toISOString().slice(0, 10)}.jsonl`;
4517
+ }
4518
+ function openLogFile(file, access) {
4519
+ const fd = openSync(file, access | constants.O_NOFOLLOW | constants.O_NONBLOCK, 384);
4520
+ try {
4521
+ const stat = fstatSync(fd);
4522
+ if (!stat.isFile() || stat.nlink !== 1 || process.getuid && (stat.uid !== process.getuid() || (stat.mode & 63) !== 0)) throw new Error("Hook decision log must be a private regular file owned by the current user");
4523
+ return {
4524
+ fd,
4525
+ size: stat.size
4526
+ };
4527
+ } catch (error) {
4528
+ closeSync(fd);
4529
+ throw error;
4530
+ }
4531
+ }
4532
+ function openDecisionLog(file, append = false) {
4533
+ if (!append) return {
4534
+ ...openLogFile(file, constants.O_RDONLY),
4535
+ created: false
4536
+ };
4537
+ const access = constants.O_WRONLY | constants.O_APPEND;
4538
+ try {
4539
+ return {
4540
+ ...openLogFile(file, access),
4541
+ created: false
4542
+ };
4543
+ } catch (error) {
4544
+ if (!missing(error)) throw error;
4545
+ }
4546
+ try {
4547
+ return {
4548
+ ...openLogFile(file, access | constants.O_CREAT | constants.O_EXCL),
4549
+ created: true
4550
+ };
4551
+ } catch (error) {
4552
+ if (error.code !== "EEXIST") throw error;
4553
+ return {
4554
+ ...openLogFile(file, access),
4555
+ created: false
4556
+ };
4557
+ }
4558
+ }
4559
+ // src/hook/types.ts
4560
+ function isAgentKind(value) {
4561
+ return value === "cc" || value === "codex" || value === "agy";
4562
+ }
4563
+ function isHookEventKind(value) {
4564
+ return value === "pre-bash" || value === "pre-edit" || value === "post-tool" || value === "stop" || value === "session-start" || value === "pre-invocation";
4565
+ }
4566
+ // src/cli/hooks-report.ts
4567
+ const HOOKS_REPORT_USAGE = "Usage: od-harness hooks report [--days N] [--format text|json]";
4568
+ function parseRow(line) {
4569
+ try {
4570
+ const row = JSON.parse(line);
4571
+ if (row && typeof row.agent === "string" && isAgentKind(row.agent) && (row.decision === "allow" || row.decision === "allow-with-notice" || row.decision === "ask" || row.decision === "deny") && typeof row.ruleId === "string" && /^[a-z0-9-]+$/.test(row.ruleId) && typeof row.reason === "string" && (row.command === void 0 || typeof row.command === "string")) return row;
4572
+ } catch {
4573
+ return;
4574
+ }
4575
+ }
4576
+ function readDay(dir, name) {
4577
+ try {
4578
+ const { fd } = openDecisionLog(path.join(dir, name));
4579
+ try {
4580
+ return readFileSync(fd, "utf8");
4581
+ } finally {
4582
+ closeSync(fd);
4583
+ }
4584
+ } catch (error) {
4585
+ if (missing(error)) return "";
4586
+ throw error;
4587
+ }
4588
+ }
4589
+ function* decisionLines(days) {
4590
+ try {
4591
+ const dir = stateDirectory(false);
4592
+ const now = Date.now();
4593
+ for (let i = 0; i < days; i++) for (const line of readDay(dir, decisionLogName(now, i)).split("\n")) if (line !== "") yield line;
4594
+ } catch (error) {
4595
+ if (missing(error)) return;
4596
+ throw new EnvironmentError("Cannot read hook decision logs. Set TMPDIR (TEMP on Windows) to a directory you own, or ensure the hook state directory and log files are private, owned by you, and free of links.", { cause: error });
4597
+ }
4598
+ }
4599
+ function summarize(days, full) {
4600
+ const grouped = /* @__PURE__ */ new Map();
4601
+ const agents = {
4602
+ cc: 0,
4603
+ codex: 0,
4604
+ agy: 0
4605
+ };
4606
+ const interventions = /* @__PURE__ */ new Map();
4607
+ const commandSamples = [];
4608
+ let total = 0;
4609
+ let skipped = 0;
4610
+ for (const line of decisionLines(days)) {
4611
+ const row = parseRow(line);
4612
+ if (!row) {
4613
+ skipped++;
4614
+ continue;
4615
+ }
4616
+ const { agent, decision, ruleId, reason, command } = row;
4617
+ total++;
4618
+ agents[agent]++;
4619
+ const key = `${agent}/${decision}/${ruleId}`;
4620
+ const group = grouped.get(key) ?? {
4621
+ agent,
4622
+ decision,
4623
+ ruleId,
4624
+ count: 0
4625
+ };
4626
+ group.count++;
4627
+ grouped.set(key, group);
4628
+ if (decision !== "allow") {
4629
+ const rule = interventions.get(ruleId) ?? {
4630
+ ruleId,
4631
+ count: 0,
4632
+ exampleReason: reason
4633
+ };
4634
+ rule.count++;
4635
+ interventions.set(ruleId, rule);
4636
+ if (full && command !== void 0 && commandSamples.length < 5) commandSamples.push({
4637
+ agent,
4638
+ decision,
4639
+ ruleId,
4640
+ command
4641
+ });
4642
+ }
4643
+ }
4644
+ const groups = [...grouped.values()].toSorted((a, b) => a.agent.localeCompare(b.agent) || a.decision.localeCompare(b.decision) || a.ruleId.localeCompare(b.ruleId)).map((group) => ({
4645
+ ...group,
4646
+ ratio: group.count / total,
4647
+ agentRatio: group.count / agents[group.agent]
4648
+ }));
4649
+ const topRules = [...interventions.values()].toSorted((a, b) => b.count - a.count || a.ruleId.localeCompare(b.ruleId)).map((rule) => ({
4650
+ ...rule,
4651
+ ratio: rule.count / total
4652
+ }));
4653
+ const notes = skipped > 0 ? [`Skipped ${skipped} invalid decision log rows.`] : [];
4654
+ return {
4655
+ days,
4656
+ total,
4657
+ groups,
4658
+ topRules,
4659
+ notes,
4660
+ ...full ? { commandSamples } : {}
4661
+ };
4662
+ }
4663
+ function percentage(ratio) {
4664
+ return `${(ratio * 100).toFixed(2)}%`;
4665
+ }
4666
+ function runHooksReport(args) {
4667
+ const { values } = parseArgs({
4668
+ args,
4669
+ options: {
4670
+ days: { type: "string" },
4671
+ format: formatOption,
4672
+ help: { type: "boolean" }
4673
+ }
4674
+ });
4675
+ if (values.help) {
4676
+ console.log(HOOKS_REPORT_USAGE);
4677
+ return 0;
4678
+ }
4679
+ if (values.format !== void 0 && values.format !== "text" && values.format !== "json") throw new UsageError("--format accepts text or json");
4680
+ const format = outputFormat(values.format);
4681
+ const rawDays = values.days ?? String(14);
4682
+ const days = Number(rawDays);
4683
+ if (!/^[0-9]+$/.test(rawDays) || days < 1 || days > 14) throw new UsageError(`--days must be a decimal integer from 1 to 14`);
4684
+ const stats = summarize(days, hookLogMode() === "full");
4685
+ const summary = `${stats.total} recorded decisions over ${days} UTC ${days === 1 ? "day" : "days"}`;
4686
+ if (format === "json") {
4687
+ printReport({
4688
+ ok: true,
4689
+ diagnostics: [],
4690
+ summary,
4691
+ ...stats
4692
+ });
4693
+ return 0;
4694
+ }
4695
+ print("hooks report", {
4696
+ ok: true,
4697
+ errors: [],
4698
+ notes: stats.notes
4699
+ }, summary);
4700
+ for (const { agent, decision, ruleId, count, ratio, agentRatio } of stats.groups) console.log(` ${agent} ${decision} ${ruleId}: ${count} (${percentage(ratio)} overall, ${percentage(agentRatio)} of ${agent})`);
4701
+ if (stats.topRules.length > 0) console.log("Rules with the most interventions:");
4702
+ for (const { ruleId, count, exampleReason } of stats.topRules) console.log(` ${ruleId}: ${count} (${JSON.stringify(exampleReason)})`);
4703
+ if (stats.commandSamples?.length) console.log("Command samples:");
4704
+ for (const { agent, decision, ruleId, command } of stats.commandSamples ?? []) console.log(` ${agent} ${decision} ${ruleId}: ${JSON.stringify(command)}`);
4705
+ return 0;
4706
+ }
4271
4707
  // src/hook/paths.ts
4272
4708
  const D_CLASS_PATTERNS = [
4273
4709
  "oxlint-suppressions.json",
@@ -4291,13 +4727,6 @@ const D_CLASS_PATTERNS = [
4291
4727
  "**/node_modules/.pnpm/@opendesignai+harness@*/**",
4292
4728
  "**/node_modules/.pnpm/@opendesignai+harness@*"
4293
4729
  ];
4294
- // src/hook/types.ts
4295
- function isAgentKind(value) {
4296
- return value === "cc" || value === "codex" || value === "agy";
4297
- }
4298
- function isHookEventKind(value) {
4299
- return value === "pre-bash" || value === "pre-edit" || value === "post-tool" || value === "stop" || value === "session-start" || value === "pre-invocation";
4300
- }
4301
4730
  // src/hook/runtime/launcher.ts
4302
4731
  const LAUNCHER = [
4303
4732
  "const fs=require('node:fs'),p=require('node:path'),m=require('node:module'),u=require('node:url')",
@@ -4887,14 +5316,13 @@ function ruleChanges(cwd, commit, lintConfig) {
4887
5316
  }
4888
5317
  // src/cli/ratchet.ts
4889
5318
  const RATCHET_DOCS = "https://github.com/nexu-io/od-harness/blob/main/docs/ratchet.md";
4890
- const HARNESS_PACKAGE = "@opendesignai/harness";
4891
5319
  /** How an accepted move was recognised, in notes and messages. */
4892
5320
  const RENAMED = "git sees the rename";
4893
5321
  /** The one condition under which baseline entries follow a file to a new path. */
4894
5322
  function seesRename(base) {
4895
5323
  return `git sees the rename at 30% similarity or more (\`git diff -M30% -l0 ${base}\`)`;
4896
5324
  }
4897
- /** The commit to compare with, how messages name it, or why there is none. */
5325
+ /** The commit to compare with and how to name it in diagnostics. */
4898
5326
  function baseCommit(options) {
4899
5327
  const { cwd, base, mergeBase: other } = options;
4900
5328
  if (base && other) throw new UsageError("use --base or --merge-base, not both");
@@ -4907,13 +5335,11 @@ function baseCommit(options) {
4907
5335
  };
4908
5336
  }
4909
5337
  if (other) {
4910
- const found = mergeBase(cwd, other);
4911
- if ("skip" in found) return found;
4912
- const ref = found.commit.slice(0, 12);
5338
+ const commit = mergeBase(cwd, other);
4913
5339
  return {
4914
- commit: found.commit,
4915
- ref,
4916
- label: `the merge base with ${other} (${found.commit.slice(0, 10)})`
5340
+ commit,
5341
+ ref: commit.slice(0, 12),
5342
+ label: `the merge base with ${other} (${commit.slice(0, 10)})`
4917
5343
  };
4918
5344
  }
4919
5345
  throw new UsageError("missing --base <ref> or --merge-base <ref>");
@@ -4935,13 +5361,14 @@ function harnessVersion(packageJson, origin) {
4935
5361
  } catch (error) {
4936
5362
  throw new EnvironmentError(`${origin} is not valid JSON: ${String(error)}`);
4937
5363
  }
4938
- return pkg.devDependencies?.[HARNESS_PACKAGE] ?? pkg.dependencies?.[HARNESS_PACKAGE] ?? null;
5364
+ return pkg.devDependencies?.["@opendesignai/harness"] ?? pkg.dependencies?.["@opendesignai/harness"] ?? null;
4939
5365
  }
4940
5366
  /** The nearest pnpm-workspace.yaml from `cwd` up to the repository root, relative to `cwd`. */
4941
- function workspaceFile(cwd) {
5367
+ function workspaceFile(cwd, commit) {
4942
5368
  for (let dir = cwd;; dir = path.dirname(dir)) {
4943
5369
  const file = path.join(dir, "pnpm-workspace.yaml");
4944
- if (existsSync(file)) return path.relative(cwd, file).split(path.sep).join("/");
5370
+ const relative = path.relative(cwd, file).split(path.sep).join("/");
5371
+ if (commit ? showFile(cwd, commit, relative) !== null : existsSync(file)) return relative;
4945
5372
  if (existsSync(path.join(dir, ".git")) || path.dirname(dir) === dir) return null;
4946
5373
  }
4947
5374
  }
@@ -4959,17 +5386,27 @@ function release(spec, workspace) {
4959
5386
  const entry = new RegExp(`^\\s*["']?${name}["']?\\s*:\\s*["']?([^"'\\s#]+)`, "gm");
4960
5387
  return `${spec} (pnpm-workspace.yaml: ${[...workspace.matchAll(entry)].map((match) => match[1]).join(", ") || "no entry"})`;
4961
5388
  }
5389
+ function parsedVersion(spec, workspace) {
5390
+ if (!spec?.startsWith("catalog:")) return semver.parse(spec);
5391
+ if (workspace === null) return null;
5392
+ try {
5393
+ const config = record$2(parse(workspace, { logLevel: "silent" }));
5394
+ const catalog = config?.["catalog"];
5395
+ const catalogs = record$2(config?.["catalogs"]);
5396
+ const defaultCatalog = catalogs?.["default"];
5397
+ if (catalog !== void 0 && defaultCatalog !== void 0) return null;
5398
+ const version = resolveSpecifier({
5399
+ catalog: catalog ?? defaultCatalog,
5400
+ catalogs
5401
+ }, HARNESS_PACKAGE, spec);
5402
+ return typeof version === "string" ? semver.parse(version) : null;
5403
+ } catch {
5404
+ return null;
5405
+ }
5406
+ }
4962
5407
  function runRatchet(options) {
4963
5408
  const { cwd } = options;
4964
- const found = baseCommit(options);
4965
- if ("skip" in found) return {
4966
- ok: true,
4967
- errors: [],
4968
- diagnostics: [],
4969
- notes: [],
4970
- skipped: found.skip
4971
- };
4972
- const { commit, ref, label: at } = found;
5409
+ const { commit, ref, label: at } = baseCommit(options);
4973
5410
  const suppressionsPath = options.suppressions ?? "oxlint-suppressions.json";
4974
5411
  const lintConfig = options.lintConfig ?? ".oxlintrc.json";
4975
5412
  const errors = [];
@@ -4989,15 +5426,20 @@ function runRatchet(options) {
4989
5426
  const harnessBefore = harnessVersion(showFile(cwd, commit, "package.json"), `package.json@${ref}`);
4990
5427
  const harnessAfter = harnessVersion(readWorking(cwd, "package.json"), "package.json");
4991
5428
  const workspace = workspaceFile(cwd);
5429
+ const workingWorkspace = workspace && readWorking(cwd, workspace);
4992
5430
  const releaseBefore = release(harnessBefore, workspace && showFile(cwd, commit, workspace));
4993
- const releaseAfter = release(harnessAfter, workspace && readWorking(cwd, workspace));
4994
- const upgrade = releaseBefore === releaseAfter ? null : `${HARNESS_PACKAGE} ${releaseBefore ?? "(none)"} → ${releaseAfter ?? "(none)"}`;
5431
+ const releaseAfter = release(harnessAfter, workingWorkspace);
5432
+ const versionChange = releaseBefore === releaseAfter ? null : `${HARNESS_PACKAGE} ${releaseBefore ?? "(none)"} → ${releaseAfter ?? "(none)"}`;
5433
+ const baseWorkspace = harnessBefore?.startsWith("catalog:") ? workspaceFile(cwd, commit) : null;
5434
+ const versionBefore = parsedVersion(harnessBefore, baseWorkspace && showFile(cwd, commit, baseWorkspace));
5435
+ const versionAfter = parsedVersion(harnessAfter, workingWorkspace);
5436
+ const upgrade = versionBefore && versionAfter && versionAfter.compare(versionBefore) > 0 ? `${HARNESS_PACKAGE} ${versionBefore.raw} → ${versionAfter.raw}` : null;
4995
5437
  const configChanged = showFile(cwd, commit, lintConfig) !== readWorking(cwd, lintConfig);
4996
5438
  let changes = null;
4997
5439
  const admits = (rule) => {
4998
- if (upgrade !== null) return {
5440
+ if (versionChange !== null) return {
4999
5441
  ok: true,
5000
- why: `${upgrade} in this change`
5442
+ why: `${versionChange} in this change`
5001
5443
  };
5002
5444
  if (!configChanged) return null;
5003
5445
  changes ??= ruleChanges(cwd, commit, lintConfig);
@@ -5100,6 +5542,10 @@ function runRatchet(options) {
5100
5542
  if (headTotal < baseTotal) notes.push(`${rule}: ${baseTotal} → ${headTotal}`);
5101
5543
  continue;
5102
5544
  }
5545
+ if (baseTotal > 0 && upgrade !== null) {
5546
+ notes.push(`${rule}: ${baseTotal} → ${headTotal} (allowed: ${upgrade} in this change, which the owner reviews).`);
5547
+ continue;
5548
+ }
5103
5549
  const admitted = baseTotal === 0 ? admits(rule) : null;
5104
5550
  if (admitted?.ok) {
5105
5551
  notes.push(`${rule}: enters the baseline with ${headTotal} (allowed: ${admitted.why}, which the owner reviews).`);
@@ -5550,49 +5996,7 @@ function readVerifyConfig(cwd) {
5550
5996
  }
5551
5997
  function verifyBase(cwd, flag, configured, env = childEnv({})) {
5552
5998
  const envBase = env.OD_HARNESS_BASE?.trim() || void 0;
5553
- const ref = flag ?? envBase ?? configured ?? "origin/main";
5554
- const result = mergeBase(cwd, ref);
5555
- if ("commit" in result) return result.commit;
5556
- const branch = /^origin\/([a-z0-9_./][a-z0-9_./-]*)$/i.exec(ref)?.[1];
5557
- const fetch = branch ? `git fetch origin ${branch}` : "git fetch";
5558
- throw new EnvironmentError(`${result.skip}. Try \`${fetch}\`.`);
5559
- }
5560
- // src/cli/verify-process.ts
5561
- function vitestBin(cwd, config) {
5562
- const project = config ? path.dirname(path.resolve(cwd, config)) : cwd;
5563
- for (const directory of /* @__PURE__ */ new Set([project, cwd])) try {
5564
- const manifest = createRequire(path.join(directory, "package.json")).resolve("vitest/package.json");
5565
- return path.join(path.dirname(manifest), "vitest.mjs");
5566
- } catch (error) {
5567
- const code = error.code;
5568
- if (code !== "MODULE_NOT_FOUND" && code !== "ERR_PACKAGE_PATH_NOT_EXPORTED") throw error;
5569
- }
5570
- }
5571
- function invoke(cwd, base, bin, args) {
5572
- const env = childEnv({ HARNESS_BASE_REF: base });
5573
- env.PATH = [path.join(cwd, "node_modules", ".bin"), env.PATH].filter(Boolean).join(path.delimiter);
5574
- return new Promise((resolve) => {
5575
- execFile(bin, args, {
5576
- cwd,
5577
- env,
5578
- encoding: "utf8",
5579
- maxBuffer: 67108864
5580
- }, (error, stdout, stderr) => {
5581
- const code = error ? typeof error.code === "number" ? error.code : null : 0;
5582
- resolve({
5583
- code,
5584
- stdout,
5585
- stderr,
5586
- problem: code === null ? error?.message ?? "Process aborted" : null
5587
- });
5588
- });
5589
- });
5590
- }
5591
- function commandOutput(result) {
5592
- return [result.stderr.trim(), result.stdout.trim()].filter(Boolean).join("\n");
5593
- }
5594
- function shellCommand(bin, args) {
5595
- return [bin, ...args].map((arg) => /^[\w+./=@:-]+$/.test(arg) ? arg : `'${arg.replaceAll("'", "'\\''")}'`).join(" ");
5999
+ return mergeBase(cwd, flag ?? envBase ?? configured ?? "origin/main");
5596
6000
  }
5597
6001
  // src/cli/verify-lint.ts
5598
6002
  const DOCS$1 = "https://github.com/nexu-io/od-harness/blob/main/docs/verify.md";
@@ -5684,7 +6088,7 @@ function batches(files) {
5684
6088
  }
5685
6089
  return groups;
5686
6090
  }
5687
- async function lintChanged(cwd, base, files, ci, annotate) {
6091
+ async function lintChanged(cwd, base, files, ci, annotate, runProcess) {
5688
6092
  const scripts = files.filter((file) => SCRIPT$1.test(file));
5689
6093
  if (!ci && scripts.length === 0) return {
5690
6094
  ok: true,
@@ -5704,7 +6108,7 @@ async function lintChanged(cwd, base, files, ci, annotate) {
5704
6108
  if (existsSync(path.join(cwd, ".oxlintrc.json"))) args.push("-c", ".oxlintrc.json");
5705
6109
  args.push("--no-error-on-unmatched-pattern", "--", ...batch);
5706
6110
  }
5707
- const output = await invoke(cwd, base, process.execPath, [bin, ...args]);
6111
+ const output = await runProcess(process.execPath, [bin, ...args]);
5708
6112
  if (output.code === 0) continue;
5709
6113
  let rows;
5710
6114
  try {
@@ -5725,7 +6129,7 @@ async function lintChanged(cwd, base, files, ci, annotate) {
5725
6129
  const diagnostics = markChangedLines(cwd, base, (rows.length ? rows : raw).map((item) => lintDiagnostic(item, cwd)));
5726
6130
  if (!diagnostics.length) throw new EnvironmentError("Oxlint failed without diagnostics. Run oxlint --deny-warnings to inspect the failure.");
5727
6131
  const prefix = repositoryPrefix(cwd);
5728
- const annotations = ci && annotate ? await nativeAnnotations(cwd, base, bin, prefix) : void 0;
6132
+ const annotations = ci && annotate ? await nativeAnnotations(runProcess, bin, prefix) : void 0;
5729
6133
  return {
5730
6134
  ok: false,
5731
6135
  diagnostics: diagnostics.map((item) => ({
@@ -5736,8 +6140,8 @@ async function lintChanged(cwd, base, files, ci, annotate) {
5736
6140
  ...annotations ? { annotations } : {}
5737
6141
  };
5738
6142
  }
5739
- async function nativeAnnotations(cwd, base, bin, prefix) {
5740
- const output = await invoke(cwd, base, process.execPath, [
6143
+ async function nativeAnnotations(runProcess, bin, prefix) {
6144
+ const output = await runProcess(process.execPath, [
5741
6145
  bin,
5742
6146
  "--deny-warnings",
5743
6147
  "--format",
@@ -5747,6 +6151,155 @@ async function nativeAnnotations(cwd, base, bin, prefix) {
5747
6151
  const annotations = output.stdout.split(/\r?\n/).filter((line) => /^::(?:error|warning|notice) (?:file|title)=/.test(line)).map((line) => line.replace(/^::(?:error|warning|notice) file=/, (start) => start + property));
5748
6152
  return annotations.length > 0 ? annotations : void 0;
5749
6153
  }
6154
+ // src/cli/verify-slot.ts
6155
+ const releases = /* @__PURE__ */ new Set();
6156
+ function verifySlotCapacity(ncpu, override) {
6157
+ const capacity = Number(override);
6158
+ return Number.isSafeInteger(capacity) && capacity > 0 ? capacity : Math.max(2, Math.floor(ncpu / 4));
6159
+ }
6160
+ function ownerIsGone(file) {
6161
+ let pid;
6162
+ try {
6163
+ pid = JSON.parse(readFileSync(file, "utf8"))?.pid;
6164
+ } catch (error) {
6165
+ if (errorCode(error) === "ENOENT") return true;
6166
+ if (error instanceof SyntaxError) return false;
6167
+ throw error;
6168
+ }
6169
+ if (typeof pid !== "number" || !Number.isInteger(pid) || pid <= 0 || pid > 0x7fffffff) return false;
6170
+ try {
6171
+ process.kill(pid, 0);
6172
+ return false;
6173
+ } catch (error) {
6174
+ return errorCode(error) === "ESRCH";
6175
+ }
6176
+ }
6177
+ function removeEmptySlot(directory) {
6178
+ try {
6179
+ rmdirSync(directory);
6180
+ } catch (error) {
6181
+ if (![
6182
+ "ENOENT",
6183
+ "ENOTEMPTY",
6184
+ "EEXIST"
6185
+ ].includes(errorCode(error) ?? "")) throw error;
6186
+ }
6187
+ }
6188
+ function removeOwner(directory, owner) {
6189
+ try {
6190
+ unlinkSync(path.join(directory, owner));
6191
+ } catch (error) {
6192
+ if (errorCode(error) !== "ENOENT") throw error;
6193
+ }
6194
+ removeEmptySlot(directory);
6195
+ }
6196
+ function slotOccupied(directory, reclaim = false) {
6197
+ let entries;
6198
+ try {
6199
+ entries = readdirSync(directory, { withFileTypes: true });
6200
+ } catch (error) {
6201
+ if (errorCode(error) === "ENOENT") return false;
6202
+ throw error;
6203
+ }
6204
+ const [entry] = entries;
6205
+ if (!entry) {
6206
+ if (reclaim) removeEmptySlot(directory);
6207
+ return false;
6208
+ }
6209
+ if (entries.length !== 1 || !entry.isFile() || !entry.name.endsWith(".json")) return true;
6210
+ if (!ownerIsGone(path.join(directory, entry.name))) return true;
6211
+ if (reclaim) removeOwner(directory, entry.name);
6212
+ return false;
6213
+ }
6214
+ function publishSlot(root, directory, owner) {
6215
+ const pending = mkdtempSync(path.join(root, "pending-"));
6216
+ let published = false;
6217
+ try {
6218
+ const fd = openSync(path.join(pending, owner), "wx", 384);
6219
+ try {
6220
+ writeFileSync(fd, JSON.stringify({
6221
+ pid: process.pid,
6222
+ startedAt: Date.now()
6223
+ }));
6224
+ } finally {
6225
+ closeSync(fd);
6226
+ }
6227
+ try {
6228
+ renameSync(pending, directory);
6229
+ published = true;
6230
+ return true;
6231
+ } catch (error) {
6232
+ const code = errorCode(error);
6233
+ if (code === "EEXIST" || code === "ENOTEMPTY") return false;
6234
+ if (process.platform === "win32" && code === "EPERM" && existsSync(directory)) return false;
6235
+ throw error;
6236
+ }
6237
+ } finally {
6238
+ if (!published) rmSync(pending, {
6239
+ recursive: true,
6240
+ force: true
6241
+ });
6242
+ }
6243
+ }
6244
+ function releaseOnSignal(signal) {
6245
+ for (const release of releases) try {
6246
+ release();
6247
+ } catch {}
6248
+ if (process.listenerCount(signal) === 0) process.kill(process.pid, signal);
6249
+ }
6250
+ function registerRelease(directory, owner) {
6251
+ const release = () => {
6252
+ if (!releases.delete(release)) return;
6253
+ if (releases.size === 0) {
6254
+ process.off("SIGINT", releaseOnSignal);
6255
+ process.off("SIGTERM", releaseOnSignal);
6256
+ }
6257
+ removeOwner(directory, owner);
6258
+ };
6259
+ if (releases.size === 0) {
6260
+ process.on("SIGINT", releaseOnSignal);
6261
+ process.on("SIGTERM", releaseOnSignal);
6262
+ }
6263
+ releases.add(release);
6264
+ return release;
6265
+ }
6266
+ async function acquireVerifySlot({ mode, noSlot }) {
6267
+ if (mode === "quick" || noSlot) return void 0;
6268
+ const env = verifySlotEnv();
6269
+ if (env.bypass) return void 0;
6270
+ const defaultDirectory = typeof process.getuid === "function" ? `od-harness-verify-slots-${process.getuid()}` : "od-harness-verify-slots";
6271
+ const root = path.resolve(env.directory?.trim() || path.join(tmpdir(), defaultDirectory));
6272
+ const maxSlots = verifySlotCapacity(availableParallelism(), env.capacity);
6273
+ mkdirSync(root, {
6274
+ recursive: true,
6275
+ mode: 448
6276
+ });
6277
+ const owner = `${randomUUID()}.json`;
6278
+ for (;;) {
6279
+ for (let slotIndex = 0; slotIndex < maxSlots; slotIndex++) {
6280
+ const directory = path.join(root, `slot-${slotIndex}`);
6281
+ if (slotOccupied(directory, true) || !publishSlot(root, directory, owner)) continue;
6282
+ return {
6283
+ slotIndex,
6284
+ maxSlots,
6285
+ get activeSlots() {
6286
+ let entries;
6287
+ try {
6288
+ entries = readdirSync(root, { withFileTypes: true });
6289
+ } catch (error) {
6290
+ if (errorCode(error) === "ENOENT") return 1;
6291
+ throw error;
6292
+ }
6293
+ const slots = entries.filter((entry) => entry.isDirectory() && /^slot-\d+$/.test(entry.name));
6294
+ if (slots.length === 1) return 1;
6295
+ return slots.filter((entry) => slotOccupied(path.join(root, entry.name))).length;
6296
+ },
6297
+ release: registerRelease(directory, owner)
6298
+ };
6299
+ }
6300
+ await setTimeout$1(200 + Math.floor(Math.random() * 301));
6301
+ }
6302
+ }
5750
6303
  // src/cli/verify-tests.ts
5751
6304
  const TEST_FILE = /\.test\.[^/]+$/;
5752
6305
  const SCRIPT = new RegExp(`\\.(?:${SCRIPT_EXTENSIONS.join("|")})$`);
@@ -5853,9 +6406,9 @@ function checkCommand(id, run, output) {
5853
6406
  const status = output.problem || output.code === 126 || output.code === 127 ? "error" : "failed";
5854
6407
  return failedCheck(id, `${run} ${reason}.${detail ? `\n${detail}` : ""}`, `Run \`${run}\`, address the reported errors, then rerun od-harness verify.`, status);
5855
6408
  }
5856
- async function harnessGate(cwd, cli, base, gate, ref) {
6409
+ async function harnessGate(runProcess, cli, gate, ref) {
5857
6410
  const args = gate === "size" ? [] : ["--base", ref];
5858
- const output = await invoke(cwd, base, process.execPath, [
6411
+ const output = await runProcess(process.execPath, [
5859
6412
  cli,
5860
6413
  gate,
5861
6414
  ...args,
@@ -5873,10 +6426,10 @@ async function harnessGate(cwd, cli, base, gate, ref) {
5873
6426
  function noTests(id, detail) {
5874
6427
  return failedCheck(id, detail, "Add or restore a matching <stem>*.test.* file, or correct the runner configuration and verify.tests paths or roots.");
5875
6428
  }
5876
- async function runTests(cwd, base, ci, project, id, files) {
6429
+ async function runTests(cwd, runProcess, ci, project, id, files) {
5877
6430
  if (!ci && files.length === 0) return noTests(id, "No test files matched the changed files.");
5878
6431
  if (ci && project.run) {
5879
- const output = await invoke(cwd, base, "bash", [
6432
+ const output = await runProcess("bash", [
5880
6433
  "-eo",
5881
6434
  "pipefail",
5882
6435
  "-c",
@@ -5891,7 +6444,7 @@ async function runTests(cwd, base, ci, project, id, files) {
5891
6444
  "--test-reporter=tap",
5892
6445
  ...ci ? project.glob ? [project.glob] : [] : files
5893
6446
  ];
5894
- const output = await invoke(cwd, base, process.execPath, args);
6447
+ const output = await runProcess(process.execPath, args);
5895
6448
  if (NO_TESTS.test(commandOutput(output))) return noTests(id, "Node ran zero tests.");
5896
6449
  return checkCommand(id, shellCommand("node", args), output);
5897
6450
  }
@@ -5907,7 +6460,7 @@ async function runTests(cwd, base, ci, project, id, files) {
5907
6460
  if (project.config) args.push("--config", project.config);
5908
6461
  args.push(...files);
5909
6462
  const bin = vitestBin(cwd, project.config);
5910
- const output = bin ? await invoke(cwd, base, process.execPath, [bin, ...args]) : await invoke(cwd, base, "vitest", args);
6463
+ const output = bin ? await runProcess(process.execPath, [bin, ...args]) : await runProcess("vitest", args);
5911
6464
  const rerunArgs = ["run", ...project.config ? ["--config", project.config] : []];
5912
6465
  const rerun = shellCommand("vitest", rerunArgs);
5913
6466
  try {
@@ -5942,11 +6495,11 @@ async function runTests(cwd, base, ci, project, id, files) {
5942
6495
  });
5943
6496
  }
5944
6497
  }
5945
- function commandTask(cwd, base, id, run) {
6498
+ function commandTask(runProcess, id, run) {
5946
6499
  return {
5947
6500
  id,
5948
6501
  async run() {
5949
- return checkCommand(id, run, await invoke(cwd, base, "bash", [
6502
+ return checkCommand(id, run, await runProcess("bash", [
5950
6503
  "-eo",
5951
6504
  "pipefail",
5952
6505
  "-c",
@@ -5955,7 +6508,7 @@ function commandTask(cwd, base, id, run) {
5955
6508
  }
5956
6509
  };
5957
6510
  }
5958
- function checkRegistry(options, config, base, changed, present, annotate) {
6511
+ function checkRegistry(options, config, base, changed, present, annotate, runProcess) {
5959
6512
  const { cwd, cli, mode } = options;
5960
6513
  const ci = mode === "ci";
5961
6514
  const quick = mode === "quick";
@@ -5976,7 +6529,7 @@ function checkRegistry(options, config, base, changed, present, annotate) {
5976
6529
  });
5977
6530
  if (config.lint && (ci || present.length > 0)) tasks.push({
5978
6531
  id: "lint",
5979
- run: () => lintChanged(cwd, base, present, ci, annotate)
6532
+ run: () => lintChanged(cwd, base, present, ci, annotate, runProcess)
5980
6533
  });
5981
6534
  for (const gate of [
5982
6535
  "size",
@@ -5987,10 +6540,10 @@ function checkRegistry(options, config, base, changed, present, annotate) {
5987
6540
  const ref = gate === "ratchet" && options.mode === "ci" ? options.base : base;
5988
6541
  tasks.push({
5989
6542
  id: gate,
5990
- run: () => harnessGate(cwd, cli, base, gate, ref)
6543
+ run: () => harnessGate(runProcess, cli, gate, ref)
5991
6544
  });
5992
6545
  }
5993
- const typecheck = config.typecheck.filter((project) => ci || touches(project.paths)).map((project) => commandTask(cwd, base, `typecheck/${project.id}`, project.run));
6546
+ const typecheck = config.typecheck.filter((project) => ci || touches(project.paths)).map((project) => commandTask(runProcess, `typecheck/${project.id}`, project.run));
5994
6547
  const tests = [];
5995
6548
  const presentFiles = new Set(present);
5996
6549
  let files;
@@ -6002,16 +6555,16 @@ function checkRegistry(options, config, base, changed, present, annotate) {
6002
6555
  const id = `tests/${project.id}`;
6003
6556
  tests.push({
6004
6557
  id,
6005
- run: () => runTests(cwd, base, ci, project, id, selected)
6558
+ run: () => runTests(cwd, runProcess, ci, project, id, selected)
6006
6559
  });
6007
6560
  }
6008
- const prepare = config.prepare.filter(({ when }) => ci || when.includes("typecheck") && typecheck.length > 0 || when.includes("tests") && tests.length > 0).map(({ run }, i) => commandTask(cwd, base, `prepare/${i + 1}`, run));
6561
+ const prepare = config.prepare.filter(({ when }) => ci || when.includes("typecheck") && typecheck.length > 0 || when.includes("tests") && tests.length > 0).map(({ run }, i) => commandTask(runProcess, `prepare/${i + 1}`, run));
6009
6562
  for (const [i, task] of prepare.entries()) {
6010
6563
  const previous = prepare[i - 1];
6011
6564
  if (previous) task.needs = [previous];
6012
6565
  }
6013
6566
  for (const task of [...typecheck, ...tests]) task.needs = prepare;
6014
- const extra = config.extra.filter(({ when, quick: fast }) => ci || (!quick || fast) && (when === "always" || touches(when))).map(({ id, run }) => commandTask(cwd, base, `extra/${id}`, run));
6567
+ const extra = config.extra.filter(({ when, quick: fast }) => ci || (!quick || fast) && (when === "always" || touches(when))).map(({ id, run }) => commandTask(runProcess, `extra/${id}`, run));
6015
6568
  for (const [i, task] of extra.entries()) {
6016
6569
  const previous = extra[i - 1];
6017
6570
  task.after = [...ci ? prepare : [], ...previous ? [previous] : []];
@@ -6036,14 +6589,28 @@ function checkRegistry(options, config, base, changed, present, annotate) {
6036
6589
  ];
6037
6590
  }
6038
6591
  async function runVerify(options) {
6039
- const { cwd, mode, format } = options;
6592
+ const { cwd } = options;
6040
6593
  const start = performance.now();
6594
+ if (options.mode !== "ci" && hasUnverifiedStop(cwd)) console.error("NOT VERIFIED: the previous Stop check could not verify changes in this worktree.");
6041
6595
  const config = readVerifyConfig(cwd);
6042
6596
  const base = options.mode === "ci" ? resolveRef(cwd, options.base) : verifyBase(cwd, options.base, config.base);
6597
+ const slot = await acquireVerifySlot(options);
6598
+ try {
6599
+ const runProcess = (bin, args) => invoke(cwd, base, bin, args, slot && {
6600
+ ...verifyThrottleEnv(slot.activeSlots),
6601
+ OD_HARNESS_NO_SLOT: "1"
6602
+ });
6603
+ return await verifyChecks(options, config, base, start, runProcess);
6604
+ } finally {
6605
+ slot?.release();
6606
+ }
6607
+ }
6608
+ async function verifyChecks(options, config, base, start, runProcess) {
6609
+ const { cwd, mode, format } = options;
6043
6610
  const changed = [...new Set(changedFiles(cwd, base, true))].toSorted();
6044
6611
  const present = changed.filter((file) => statSync(path.join(cwd, file), { throwIfNoEntry: false })?.isFile());
6045
6612
  const annotate = format === "github" || format === "text" && isGitHubActions();
6046
- const tasks = checkRegistry(options, config, base, changed, present, annotate);
6613
+ const tasks = checkRegistry(options, config, base, changed, present, annotate, runProcess);
6047
6614
  if (mode === "ci" && tasks.length === 0) tasks.push({
6048
6615
  id: "setup",
6049
6616
  run: async () => failedCheck("verify/no-checks", "No CI checks are enabled.", "Enable a gate or add a command to verify in .harness/config.json.")
@@ -6097,8 +6664,7 @@ Commands:
6097
6664
  adoption change.
6098
6665
  --merge-base <ref> instead of --base, for local runs: compare
6099
6666
  with \`git merge-base HEAD <ref>\` (for
6100
- example origin/main); skipped with a warning
6101
- when there is none
6667
+ example origin/main); requires common history
6102
6668
  --suppressions <path> default: oxlint-suppressions.json
6103
6669
  --lint-config <path> default: .oxlintrc.json
6104
6670
  clones --base <ref> Fail on duplicated code (jscpd) that <ref> does not have.
@@ -6109,7 +6675,7 @@ Commands:
6109
6675
  --check report drift without writing files
6110
6676
  agents docs [--json] Check references in agent instruction files.
6111
6677
  agents size [--json] Check expanded agent instruction sizes and AGENTS.md chains.
6112
- ${includeVerify ? " verify [--quick | --ci] Run the repository checks together. CI requires --base <ref>.\n" : ""} baseline move <from> <to> After moving files (git mv, staged), move their entries in both
6678
+ ${includeVerify ? " verify [--quick | --ci] Run the repository checks together. CI requires --base <ref>.\n --no-slot bypass host verification slots\n" : ""} baseline move <from> <to> After moving files (git mv, staged), move their entries in both
6113
6679
  baselines to the new paths. Each new file must be a rename git
6114
6680
  sees (git diff -M30% -l0), as ratchet requires.
6115
6681
  --suppressions <path> default: oxlint-suppressions.json
@@ -6117,6 +6683,7 @@ ${includeVerify ? " verify [--quick | --ci] Run the repository checks togeth
6117
6683
  (a pre-check: ratchet decides)
6118
6684
  init [--check] Generate repository agent configuration or check it without writing.
6119
6685
  doctor Check the installed harness version and Codex hook trust.
6686
+ hooks report [--days N] Summarize local hook decisions (--format text|json).
6120
6687
 
6121
6688
  Options:
6122
6689
  --format text|json|github Diagnostic output for lint-scope, size, ratchet, clones, unused, comments,
@@ -6128,7 +6695,7 @@ Options:
6128
6695
 
6129
6696
  Run from the repository root.`;
6130
6697
  }
6131
- const VERIFY_USAGE = "Usage: od-harness verify [--quick | --ci] [--base <ref>] [--skip lint-scope] [--json | --format text|json|github]";
6698
+ const VERIFY_USAGE = "Usage: od-harness verify [--quick | --ci] [--base <ref>] [--skip lint-scope] [--no-slot] [--json | --format text|json|github]";
6132
6699
  /** An option's value, which must not be empty. */
6133
6700
  function nonEmpty(option, value) {
6134
6701
  if (value.trim() === "") throw new UsageError(`${option} needs a value`);
@@ -6151,6 +6718,11 @@ function run(command, rest, cwd) {
6151
6718
  console.log(VERSION);
6152
6719
  return 0;
6153
6720
  }
6721
+ if (command === "hooks") {
6722
+ const [sub, ...args] = rest;
6723
+ if (sub !== "report") throw new UsageError(`unknown hooks command "${sub ?? ""}"`);
6724
+ return runHooksReport(args);
6725
+ }
6154
6726
  if (REPOSITORY_COMMANDS.some((candidate) => candidate === command)) requireWorkTree(cwd);
6155
6727
  if (command === "lint-scope") {
6156
6728
  const { values } = parseArgs({
@@ -6332,6 +6904,7 @@ function verify(rest, cwd, cli) {
6332
6904
  ci: { type: "boolean" },
6333
6905
  base: { type: "string" },
6334
6906
  skip: { type: "string" },
6907
+ "no-slot": { type: "boolean" },
6335
6908
  json: { type: "boolean" },
6336
6909
  format: formatOption,
6337
6910
  help: { type: "boolean" }
@@ -6348,35 +6921,35 @@ function verify(rest, cwd, cli) {
6348
6921
  const base = values.base === void 0 ? void 0 : nonEmpty("--base", values.base);
6349
6922
  const requested = outputFormat(values.format);
6350
6923
  if (values.json && values.format !== void 0 && requested !== "json") throw new UsageError(`--json conflicts with --format ${requested}`);
6351
- const format = values.json ? "json" : requested;
6924
+ const options = {
6925
+ cwd,
6926
+ cli,
6927
+ format: values.json ? "json" : requested,
6928
+ skipLintScope,
6929
+ noSlot: values["no-slot"] ?? false
6930
+ };
6352
6931
  if (values.ci) {
6353
6932
  if (base === void 0) throw new UsageError("verify --ci requires --base <ref>");
6354
6933
  return runVerify({
6355
- cwd,
6356
- cli,
6934
+ ...options,
6357
6935
  mode: "ci",
6358
- base,
6359
- format,
6360
- skipLintScope
6936
+ base
6361
6937
  });
6362
6938
  }
6363
6939
  return runVerify({
6364
- cwd,
6365
- cli,
6940
+ ...options,
6366
6941
  mode: values.quick ? "quick" : "default",
6367
- base,
6368
- format,
6369
- skipLintScope
6942
+ base
6370
6943
  });
6371
6944
  }
6372
6945
  function main(argv, cwd = process.cwd(), cli = fileURLToPath(new URL("./index.ts", import.meta.url))) {
6373
6946
  const [command, ...rest] = argv;
6374
6947
  const onError = (error) => {
6375
6948
  if (error instanceof UsageError || error.code?.startsWith("ERR_PARSE_ARGS")) {
6376
- console.error(`od-harness: ${error.message}\n\n${command === "verify" ? VERIFY_USAGE : help(false)}`);
6949
+ console.error(`od-harness: ${error.message}\n\n${command === "verify" ? VERIFY_USAGE : command === "hooks" ? HOOKS_REPORT_USAGE : help(false)}`);
6377
6950
  return 2;
6378
6951
  }
6379
- const name = command === "baseline" ? "baseline move" : command;
6952
+ const name = command === "baseline" ? "baseline move" : command === "hooks" ? "hooks report" : command;
6380
6953
  if (error instanceof EnvironmentError) {
6381
6954
  const prefix = error instanceof HarnessConfigError ? "od-harness" : `od-harness ${name}`;
6382
6955
  console.error(`${prefix}: ${error.message}`);