@hasna/hooks 0.12.18 → 0.12.20

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/bin/index.js CHANGED
@@ -39039,9 +39039,9 @@ function executable2(command) {
39039
39039
  const fd = openSync18(path, constants18.O_RDONLY | constants18.O_NOFOLLOW | constants18.O_NONBLOCK);
39040
39040
  try {
39041
39041
  const stat2 = fstatSync17(fd);
39042
- need11(stat2.isFile() && [0, process.getuid?.()].includes(stat2.uid) && !(stat2.mode & 18) && !!(stat2.mode & 64) && stat2.size <= 256000000, "native_unsafe_executable");
39042
+ need11(stat2.isFile() && [0, process.getuid?.()].includes(stat2.uid) && !(stat2.mode & 18) && !!(stat2.mode & 64) && stat2.size <= CODEX_EXECUTABLE_MAX_BYTES, "native_unsafe_executable");
39043
39043
  const bytes = readFileSync16(fd);
39044
- need11(bytes.length <= 256000000, "native_unavailable");
39044
+ need11(bytes.length <= CODEX_EXECUTABLE_MAX_BYTES, "native_unavailable");
39045
39045
  need11(nativeHeader(bytes), "native_executable_required");
39046
39046
  return { path, sha256: digest3(bytes) };
39047
39047
  } finally {
@@ -39274,7 +39274,7 @@ async function verifyCodexNativeSafety(options = {}, dependencies = {}) {
39274
39274
  await rpc.close();
39275
39275
  }
39276
39276
  }
39277
- var SUPPORTED_CODEX_SAFETY_VERSIONS, versions, CodexSafetyError, digest3 = (bytes) => createHash19("sha256").update(bytes).digest("hex");
39277
+ var SUPPORTED_CODEX_SAFETY_VERSIONS, versions, CODEX_EXECUTABLE_MAX_BYTES = 512000000, CodexSafetyError, digest3 = (bytes) => createHash19("sha256").update(bytes).digest("hex");
39278
39278
  var init_codex_safety_check = __esm(() => {
39279
39279
  init_native_safety();
39280
39280
  init_registry();
@@ -45237,6 +45237,33 @@ function parentStopReviewPins(options, harness, maxTimeoutMs = 45000) {
45237
45237
  timeoutMs
45238
45238
  };
45239
45239
  }
45240
+ function createSumiStopReviewPlugin(options, dependencies = {}) {
45241
+ const pins = parentStopReviewPins(options, "sumi");
45242
+ const timeoutMs = pins.timeoutMs;
45243
+ const { hooksCommand: command, hooksCommandSha256: commandHash } = pins;
45244
+ const { runtimeCommand: runtime, runtimeCommandSha256: runtimeHash } = pins;
45245
+ const registered = new WeakSet;
45246
+ const run = dependencies.run ?? runSumiStopReviewCommand;
45247
+ return {
45248
+ id: "local.hasna-hooks-stop-review",
45249
+ async setup(ctx) {
45250
+ const capability = ctx?.session?.stopReview;
45251
+ if (!record4(capability) || capability.schema !== "hooks.stop-review.v1" || capability.admission !== "parent_final_cas" || capability.harness !== "sumi" || typeof ctx.session.hook !== "function")
45252
+ throw new Error("sumi_stop_review_native_capability_unavailable");
45253
+ if (registered.has(ctx.session))
45254
+ return;
45255
+ await ctx.session.hook("stop", async (event) => {
45256
+ if (!record4(event) || event.result !== undefined || !isSumiStopReviewEnvelope(event.envelope))
45257
+ return;
45258
+ const envelope = structuredClone(event.envelope);
45259
+ const result = await requestParentStopReview(envelope, "sumi", { hooksCommand: command, hooksCommandSha256: commandHash, runtimeCommand: runtime, runtimeCommandSha256: runtimeHash, timeoutMs }, { ...dependencies, run });
45260
+ if (event.result === undefined && JSON.stringify(event.envelope) === JSON.stringify(envelope))
45261
+ event.result = result;
45262
+ });
45263
+ registered.add(ctx.session);
45264
+ }
45265
+ };
45266
+ }
45240
45267
  var MAX_OUTPUT = 16384, CLASSES, FLAGS, GOAL_STATUSES, STOP_REASONS, CONFIG_ENV, record4 = (v) => !!v && typeof v === "object" && !Array.isArray(v), keys2 = (v, required2, optional2 = []) => required2.every((key) => Object.hasOwn(v, key)) && Object.keys(v).every((key) => required2.includes(key) || optional2.includes(key)), identifier = (v) => typeof v === "string" && /^[A-Za-z0-9][A-Za-z0-9._:-]{0,255}$/.test(v), text3 = (v, max = Infinity) => typeof v === "string" && v.trim().length > 0 && Buffer.byteLength(v) <= max, probability = (v) => typeof v === "number" && Number.isFinite(v) && v >= 0 && v <= 1, count = (v) => Number.isSafeInteger(v) && v >= 0, className = (v) => CLASSES.includes(v), digest4 = (v) => typeof v === "string" && /^[a-f0-9]{64}$/.test(v), pathForm = (v) => typeof v === "string" && isAbsolute31(v) && normalize4(v) === v && Buffer.byteLength(v) <= 4096 && !/[\u0000-\u001f\u007f]/.test(v), runSumiStopReviewCommand = (invocation) => new Promise((resolve28) => {
45241
45268
  let done = false, exited = false, stdoutBytes = 0, stderrBytes = 0;
45242
45269
  const chunks = [];
@@ -45688,6 +45715,328 @@ var init_opencode_stop_install = __esm(() => {
45688
45715
  SIBLINGS = ["config.json", "opencode.jsonc"];
45689
45716
  });
45690
45717
 
45718
+ // src/lib/sumi-stop-install.ts
45719
+ var exports_sumi_stop_install = {};
45720
+ __export(exports_sumi_stop_install, {
45721
+ verifySumiStopInstall: () => verifySumiStopInstall,
45722
+ sumiStopWrapper: () => sumiStopWrapper,
45723
+ sumiStopPluginPath: () => sumiStopPluginPath,
45724
+ planSumiStopInstall: () => planSumiStopInstall,
45725
+ installedSumiStopPins: () => installedSumiStopPins,
45726
+ applySumiStopInstall: () => applySumiStopInstall,
45727
+ SumiStopInstallError: () => SumiStopInstallError
45728
+ });
45729
+ import { createHash as createHash33, randomUUID as randomUUID10 } from "crypto";
45730
+ import { closeSync as closeSync27, constants as constants25, existsSync as existsSync18, fstatSync as fstatSync26, fsyncSync as fsyncSync10, linkSync as linkSync6, lstatSync as lstatSync33, mkdirSync as mkdirSync16, openSync as openSync27, readFileSync as readFileSync25, realpathSync as realpathSync23, renameSync as renameSync7, unlinkSync as unlinkSync9, writeFileSync as writeFileSync15 } from "fs";
45731
+ import { homedir as homedir18 } from "os";
45732
+ import { basename as basename15, dirname as dirname33, isAbsolute as isAbsolute35, join as join38, resolve as resolve29 } from "path";
45733
+ function sumiConfigRoot(options) {
45734
+ const env = options.env ?? process.env;
45735
+ const home = options.home ?? env.SUMI_TEST_HOME ?? homedir18();
45736
+ const selected = (value) => value?.trim() ? value : undefined;
45737
+ const expand = (value) => resolve29(value === "~" ? home : value.startsWith("~/") || value.startsWith("~\\") ? resolve29(home, value.slice(2)) : value);
45738
+ if (env.SUMI_CONFIG_DIR !== undefined) {
45739
+ if (!selected(env.SUMI_CONFIG_DIR) || !isAbsolute35(env.SUMI_CONFIG_DIR))
45740
+ throw new SumiStopInstallError("input_invalid", "SUMI_CONFIG_DIR must be an absolute directory");
45741
+ return env.SUMI_CONFIG_DIR;
45742
+ }
45743
+ const xdg = selected(env.XDG_CONFIG_HOME);
45744
+ if (xdg)
45745
+ return join38(expand(xdg), "sumi");
45746
+ const custom2 = selected(env.SUMI_HOME);
45747
+ if (custom2)
45748
+ return join38(expand(custom2), "config");
45749
+ const canonical9 = resolve29(home, ".hasna-internal/sumi", "config");
45750
+ const legacy = resolve29(home, ".config/sumi");
45751
+ const current2 = lstatSync33(canonical9, { throwIfNoEntry: false });
45752
+ const previous = lstatSync33(legacy, { throwIfNoEntry: false });
45753
+ if (current2 && previous && realpathSync23(canonical9) !== realpathSync23(legacy)) {
45754
+ throw new SumiStopInstallError("config_conflict", "Sumi must reconcile its independent canonical and legacy config homes first");
45755
+ }
45756
+ return current2 || !previous ? canonical9 : legacy;
45757
+ }
45758
+ function sumiStopPluginPath(options) {
45759
+ const env = options.env ?? process.env;
45760
+ if (options.scope === "project") {
45761
+ const disabled = env.SUMI_CONFIG_PROJECT_DISABLE ?? env.SUMI_DISABLE_PROJECT_CONFIG;
45762
+ if (disabled === "1" || disabled?.toLowerCase() === "true")
45763
+ throw new SumiStopInstallError("project_config_disabled");
45764
+ const globalRoot = dirname33(dirname33(sumiStopPluginPath({ ...options, scope: "global" })));
45765
+ const cwd = options.cwd ?? process.cwd();
45766
+ if (existsSync18(cwd) && realpathSync23(cwd) === globalRoot)
45767
+ throw new SumiStopInstallError("project_config_disabled", "Sumi does not discover project config from its global config directory");
45768
+ }
45769
+ const directory2 = options.scope === "project" ? join38(options.cwd ?? process.cwd(), ".sumi") : sumiConfigRoot(options);
45770
+ if (!isAbsolute35(directory2))
45771
+ throw new SumiStopInstallError("input_invalid", "Sumi config paths must be absolute");
45772
+ let ancestor = resolve29(directory2);
45773
+ const missing2 = [];
45774
+ while (!existsSync18(ancestor)) {
45775
+ missing2.unshift(basename15(ancestor));
45776
+ ancestor = dirname33(ancestor);
45777
+ }
45778
+ return join38(realpathSync23(ancestor), ...missing2, "plugins", `${NAME2}.js`);
45779
+ }
45780
+ function installedSumiStopPins(options = {}) {
45781
+ const candidate = options.plugin ?? [join38(import.meta.dir, "../../dist/sumi-stop-plugin.js"), join38(import.meta.dir, "../dist/sumi-stop-plugin.js")].find(existsSync18);
45782
+ if (!candidate)
45783
+ throw new SumiStopInstallError("plugin_missing", "build or reinstall @hasna/hooks");
45784
+ try {
45785
+ return installedOpenCodeStopPins({ ...options, plugin: options.plugin ?? realpathSync23(candidate) });
45786
+ } catch (error61) {
45787
+ if (error61 instanceof OpenCodeStopInstallError)
45788
+ throw new SumiStopInstallError(error61.code, error61.reason);
45789
+ throw error61;
45790
+ }
45791
+ }
45792
+ function pinsVerified(pins) {
45793
+ try {
45794
+ createSumiStopReviewPlugin(pins);
45795
+ return pinEligibleFile(pins.plugin, 16777216) === pins.pluginSha256 && verifySumiStopReviewCommand(pins.hooksCommand, pins.hooksCommandSha256) && verifySumiStopReviewCommand(pins.runtimeCommand, pins.runtimeCommandSha256);
45796
+ } catch {
45797
+ return false;
45798
+ }
45799
+ }
45800
+ function sumiStopWrapper(pins) {
45801
+ createSumiStopReviewPlugin(pins);
45802
+ return HEADER + `const pins = ${JSON.stringify(pins)};
45803
+ ` + `import { createHash } from "node:crypto";
45804
+ import { constants, openSync, closeSync, fstatSync, lstatSync, readFileSync, realpathSync } from "node:fs";
45805
+ import { dirname } from "node:path";
45806
+ import { pathToFileURL } from "node:url";
45807
+ if (realpathSync(pins.plugin) !== pins.plugin) throw new Error("Sumi Stop transport path changed");
45808
+ for (let path = dirname(pins.plugin); ; path = dirname(path)) {
45809
+ const stat = lstatSync(path);
45810
+ if (!stat.isDirectory() || ![0, process.getuid()].includes(stat.uid) || (stat.mode & 0o022)) throw new Error("Sumi Stop transport ancestry is unsafe");
45811
+ if (path === dirname(path)) break;
45812
+ }
45813
+ const fd = openSync(pins.plugin, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
45814
+ let bytes;
45815
+ try {
45816
+ const stat = fstatSync(fd);
45817
+ if (!stat.isFile() || ![0, process.getuid()].includes(stat.uid) || (stat.mode & 0o022) || stat.size > 16777216) throw new Error("Sumi Stop transport is unsafe");
45818
+ bytes = readFileSync(fd);
45819
+ if (bytes.length > 16777216 || createHash("sha256").update(bytes).digest("hex") !== pins.pluginSha256) throw new Error("Sumi Stop transport bytes changed");
45820
+ } finally { closeSync(fd); }
45821
+ const { createSumiStopReviewPlugin } = await import(pathToFileURL(pins.plugin).href + "?sha256=" + pins.pluginSha256);
45822
+ if (realpathSync(pins.plugin) !== pins.plugin || createHash("sha256").update(readFileSync(pins.plugin)).digest("hex") !== pins.pluginSha256) throw new Error("Sumi Stop transport changed during import");
45823
+ export default createSumiStopReviewPlugin(pins);
45824
+ `;
45825
+ }
45826
+ function safeAncestry2(path) {
45827
+ for (let cursor = path;; cursor = dirname33(cursor)) {
45828
+ const stat2 = lstatSync33(cursor, { throwIfNoEntry: false });
45829
+ if (stat2 && (!stat2.isDirectory() || !owner4(stat2.uid) || stat2.mode & 18))
45830
+ throw new SumiStopInstallError("config_unsafe");
45831
+ if (dirname33(cursor) === cursor)
45832
+ return;
45833
+ }
45834
+ }
45835
+ function readState(path) {
45836
+ if (!isAbsolute35(path) || !path.endsWith(`/plugins/${NAME2}.js`))
45837
+ throw new SumiStopInstallError("input_invalid");
45838
+ safeAncestry2(dirname33(path));
45839
+ let fd;
45840
+ try {
45841
+ fd = openSync27(path, constants25.O_RDONLY | constants25.O_NOFOLLOW | constants25.O_NONBLOCK);
45842
+ } catch (error61) {
45843
+ if (error61.code === "ENOENT")
45844
+ return { path, sha256: "absent", mode: 384 };
45845
+ throw new SumiStopInstallError("config_unsafe");
45846
+ }
45847
+ try {
45848
+ const stat2 = fstatSync26(fd);
45849
+ if (!stat2.isFile() || !owner4(stat2.uid) || stat2.mode & 18 || stat2.size > MAX_BYTES)
45850
+ throw new SumiStopInstallError("config_unsafe");
45851
+ const text4 = readFileSync25(fd, "utf8");
45852
+ if (Buffer.byteLength(text4) > MAX_BYTES)
45853
+ throw new SumiStopInstallError("config_unsafe");
45854
+ return { path, text: text4, sha256: hash6(text4), mode: stat2.mode & 511 };
45855
+ } finally {
45856
+ closeSync27(fd);
45857
+ }
45858
+ }
45859
+ function storedPins(state) {
45860
+ if (state.text === undefined)
45861
+ return;
45862
+ try {
45863
+ if (!state.text.startsWith(HEADER))
45864
+ throw new Error;
45865
+ const line = state.text.split(`
45866
+ `)[1];
45867
+ const pins = JSON.parse(line.slice("const pins = ".length, -1));
45868
+ if (sumiStopWrapper(pins) !== state.text)
45869
+ throw new Error;
45870
+ return pins;
45871
+ } catch {
45872
+ throw new SumiStopInstallError("config_conflict", "existing wrapper is not an unchanged managed registration");
45873
+ }
45874
+ }
45875
+ function conflicts(path) {
45876
+ const root = dirname33(dirname33(path));
45877
+ for (const dir of ["plugin", "plugins"]) {
45878
+ safeAncestry2(join38(root, dir));
45879
+ for (const suffix of ["", ".js", ".ts"]) {
45880
+ const other = join38(root, dir, NAME2 + suffix);
45881
+ if (other !== path && lstatSync33(other, { throwIfNoEntry: false }))
45882
+ throw new SumiStopInstallError("config_conflict", "a second native wrapper path exists");
45883
+ }
45884
+ }
45885
+ }
45886
+ function plan2(state, pins) {
45887
+ conflicts(state.path);
45888
+ const previous = storedPins(state);
45889
+ if (!pinsVerified(pins))
45890
+ throw new SumiStopInstallError("pins_drifted");
45891
+ const text4 = sumiStopWrapper(pins);
45892
+ return { text: text4, plan: {
45893
+ ok: true,
45894
+ target: "sumi",
45895
+ path: state.path,
45896
+ currentSha256: state.sha256,
45897
+ desiredSha256: hash6(text4),
45898
+ action: state.text === text4 ? "unchanged" : previous ? "update" : "add",
45899
+ ...previous ? { previousEntryVerified: pinsVerified(previous) } : {},
45900
+ nativeAdoptionVerified: false,
45901
+ mayAffectRunningSessions: true
45902
+ } };
45903
+ }
45904
+ function planSumiStopInstall(options) {
45905
+ return plan2(readState(options.path), options.pins).plan;
45906
+ }
45907
+ function syncDirectory5(path) {
45908
+ const fd = openSync27(path, constants25.O_RDONLY | constants25.O_DIRECTORY | constants25.O_NOFOLLOW);
45909
+ try {
45910
+ fsyncSync10(fd);
45911
+ } finally {
45912
+ closeSync27(fd);
45913
+ }
45914
+ }
45915
+ function applySumiStopInstall(options) {
45916
+ const first = plan2(readState(options.path), options.pins);
45917
+ if (first.plan.action === "unchanged")
45918
+ return { ...first.plan, changed: false };
45919
+ if (options.expectedSha256 === undefined)
45920
+ throw new SumiStopInstallError("config_precondition_required", `pass --expected-config-sha256 ${first.plan.currentSha256}`);
45921
+ if (options.expectedSha256 !== first.plan.currentSha256)
45922
+ throw new SumiStopInstallError("config_changed");
45923
+ const directory2 = dirname33(options.path);
45924
+ if (!existsSync18(directory2))
45925
+ mkdirSync16(directory2, { recursive: true, mode: 448 });
45926
+ safeAncestry2(directory2);
45927
+ const lock = options.path + ".hasna-hooks.lock";
45928
+ let lockFD;
45929
+ try {
45930
+ lockFD = openSync27(lock, constants25.O_CREAT | constants25.O_EXCL | constants25.O_WRONLY, 384);
45931
+ } catch {
45932
+ throw new SumiStopInstallError("config_busy");
45933
+ }
45934
+ const lockIdentity = fstatSync26(lockFD);
45935
+ const temporary = join38(directory2, `.hasna-hooks-stop-review.${randomUUID10()}.tmp`);
45936
+ let temporaryIdentity;
45937
+ try {
45938
+ writeFileSync15(lockFD, JSON.stringify({ pid: process.pid, expectedSha256: options.expectedSha256 }));
45939
+ fsyncSync10(lockFD);
45940
+ const state = readState(options.path);
45941
+ if (state.sha256 !== options.expectedSha256)
45942
+ throw new SumiStopInstallError("config_changed");
45943
+ const next = plan2(state, options.pins);
45944
+ if (state.text !== undefined) {
45945
+ const backup = `${options.path}.before-${state.sha256}`;
45946
+ if (existsSync18(backup)) {
45947
+ if (pinEligibleFile(backup, MAX_BYTES) !== state.sha256)
45948
+ throw new SumiStopInstallError("config_changed", "a different preserved original already exists");
45949
+ } else {
45950
+ const fd2 = openSync27(backup, constants25.O_CREAT | constants25.O_EXCL | constants25.O_WRONLY, 384);
45951
+ try {
45952
+ writeFileSync15(fd2, state.text);
45953
+ fsyncSync10(fd2);
45954
+ } finally {
45955
+ closeSync27(fd2);
45956
+ }
45957
+ if (pinEligibleFile(backup, MAX_BYTES) !== state.sha256)
45958
+ throw new SumiStopInstallError("config_changed", "preserved original did not read back");
45959
+ }
45960
+ }
45961
+ const fd = openSync27(temporary, constants25.O_CREAT | constants25.O_EXCL | constants25.O_WRONLY, state.mode);
45962
+ try {
45963
+ temporaryIdentity = fstatSync26(fd);
45964
+ writeFileSync15(fd, next.text);
45965
+ fsyncSync10(fd);
45966
+ } finally {
45967
+ closeSync27(fd);
45968
+ }
45969
+ if (readState(options.path).sha256 !== state.sha256)
45970
+ throw new SumiStopInstallError("config_changed");
45971
+ conflicts(options.path);
45972
+ if (!pinsVerified(options.pins))
45973
+ throw new SumiStopInstallError("pins_drifted");
45974
+ if (state.text !== undefined)
45975
+ renameSync7(temporary, options.path);
45976
+ else {
45977
+ linkSync6(temporary, options.path);
45978
+ unlinkSync9(temporary);
45979
+ }
45980
+ syncDirectory5(directory2);
45981
+ const after = readState(options.path);
45982
+ if (after.sha256 !== next.plan.desiredSha256)
45983
+ throw new SumiStopInstallError("config_changed", "written config did not read back");
45984
+ return {
45985
+ ...next.plan,
45986
+ currentSha256: after.sha256,
45987
+ previousSha256: state.sha256,
45988
+ changed: true,
45989
+ ...state.text !== undefined ? { backup: `${options.path}.before-${state.sha256}` } : {}
45990
+ };
45991
+ } finally {
45992
+ closeSync27(lockFD);
45993
+ const currentTemporary = lstatSync33(temporary, { throwIfNoEntry: false });
45994
+ if (temporaryIdentity && currentTemporary?.dev === temporaryIdentity.dev && currentTemporary.ino === temporaryIdentity.ino)
45995
+ unlinkSync9(temporary);
45996
+ const currentLock = lstatSync33(lock, { throwIfNoEntry: false });
45997
+ if (currentLock?.dev === lockIdentity.dev && currentLock.ino === lockIdentity.ino)
45998
+ unlinkSync9(lock);
45999
+ }
46000
+ }
46001
+ function verifySumiStopInstall(options) {
46002
+ const state = readState(options.path);
46003
+ conflicts(state.path);
46004
+ const pins = storedPins(state);
46005
+ if (!pins)
46006
+ throw new SumiStopInstallError("entry_missing");
46007
+ if (!pinsVerified(pins))
46008
+ throw new SumiStopInstallError("pins_drifted");
46009
+ const home = realpathSync23(options.home ?? homedir18());
46010
+ return {
46011
+ ok: true,
46012
+ target: "sumi",
46013
+ path: state.path,
46014
+ sha256: state.sha256,
46015
+ pinsVerified: true,
46016
+ durable: nativeSafetyBindingDurable(pins.plugin, home) && nativeSafetyBindingDurable(pins.hooksCommand, home),
46017
+ nativeAdoptionVerified: false,
46018
+ mayAffectRunningSessions: true
46019
+ };
46020
+ }
46021
+ var SumiStopInstallError, HEADER = `// @hasna/hooks managed Sumi stop-review v1
46022
+ `, NAME2 = "hasna-hooks-stop-review", MAX_BYTES = 1048576, hash6 = (value) => createHash33("sha256").update(value).digest("hex"), owner4 = (uid2) => uid2 === 0 || uid2 === process.getuid?.();
46023
+ var init_sumi_stop_install = __esm(() => {
46024
+ init_opencode_stop_install();
46025
+ init_native_safety();
46026
+ init_sumi_binding();
46027
+ init_sumi_stop_plugin();
46028
+ SumiStopInstallError = class SumiStopInstallError extends Error {
46029
+ code;
46030
+ reason;
46031
+ constructor(code2, reason2) {
46032
+ super(`Sumi stop-review registration refused (${code2})`);
46033
+ this.code = code2;
46034
+ this.reason = reason2;
46035
+ this.name = "SumiStopInstallError";
46036
+ }
46037
+ };
46038
+ });
46039
+
45691
46040
  // src/lib/custom-install.ts
45692
46041
  var exports_custom_install = {};
45693
46042
  __export(exports_custom_install, {
@@ -45695,15 +46044,15 @@ __export(exports_custom_install, {
45695
46044
  installCustomSource: () => installCustomSource,
45696
46045
  ensureCustomDir: () => ensureCustomDir
45697
46046
  });
45698
- import { existsSync as existsSync18, mkdirSync as mkdirSync16, mkdtempSync, readFileSync as readFileSync25, rmSync as rmSync4 } from "fs";
45699
- import { join as join38 } from "path";
46047
+ import { existsSync as existsSync19, mkdirSync as mkdirSync17, mkdtempSync, readFileSync as readFileSync26, rmSync as rmSync4 } from "fs";
46048
+ import { join as join39 } from "path";
45700
46049
  import { tmpdir as tmpdir2 } from "os";
45701
46050
  function manifestAt(dir) {
45702
- const path = join38(dir, "manifest.json");
45703
- if (!existsSync18(path))
46051
+ const path = join39(dir, "manifest.json");
46052
+ if (!existsSync19(path))
45704
46053
  return;
45705
46054
  try {
45706
- return parseManifest(readFileSync25(path, "utf-8"));
46055
+ return parseManifest(readFileSync26(path, "utf-8"));
45707
46056
  } catch {
45708
46057
  return;
45709
46058
  }
@@ -45722,8 +46071,8 @@ function writeFromManifest(manifest, srcDir, source, kind) {
45722
46071
  return { name, version: manifest.version, kind, source, dir, scriptPath };
45723
46072
  }
45724
46073
  async function cloneToTemp(gitUrl) {
45725
- const tmp = mkdtempSync(join38(tmpdir2(), "hooks-install-"));
45726
- const proc = Bun.spawn(["git", "clone", "--depth", "1", "--quiet", gitUrl, join38(tmp, "repo")], {
46074
+ const tmp = mkdtempSync(join39(tmpdir2(), "hooks-install-"));
46075
+ const proc = Bun.spawn(["git", "clone", "--depth", "1", "--quiet", gitUrl, join39(tmp, "repo")], {
45727
46076
  stdout: "pipe",
45728
46077
  stderr: "pipe"
45729
46078
  });
@@ -45736,7 +46085,7 @@ async function cloneToTemp(gitUrl) {
45736
46085
  rmSync4(tmp, { recursive: true, force: true });
45737
46086
  throw new Error(`git clone failed (${exitCode}): ${stderr.trim()}`);
45738
46087
  }
45739
- return join38(tmp, "repo");
46088
+ return join39(tmp, "repo");
45740
46089
  }
45741
46090
  function isGitUrl(value) {
45742
46091
  return value.startsWith("git@") || value.startsWith("ssh://") || value.startsWith("file://") || value.endsWith(".git");
@@ -45746,7 +46095,7 @@ function isCustomSource(value) {
45746
46095
  return true;
45747
46096
  if (value.startsWith("http://") || value.startsWith("https://"))
45748
46097
  return true;
45749
- return existsSync18(value);
46098
+ return existsSync19(value);
45750
46099
  }
45751
46100
  async function installCustomSource(source) {
45752
46101
  if (isGitUrl(source)) {
@@ -45760,11 +46109,11 @@ async function installCustomSource(source) {
45760
46109
  if (source.startsWith("http://") || source.startsWith("https://")) {
45761
46110
  return installManifestUrl(source);
45762
46111
  }
45763
- if (!existsSync18(source)) {
46112
+ if (!existsSync19(source)) {
45764
46113
  throw new Error(`No such local path: ${source}`);
45765
46114
  }
45766
46115
  if (source.endsWith("manifest.json")) {
45767
- const manifest = parseManifest(readFileSync25(source, "utf-8"));
46116
+ const manifest = parseManifest(readFileSync26(source, "utf-8"));
45768
46117
  return writeFromManifest(manifest, source.substring(0, source.lastIndexOf("/")), source, "local");
45769
46118
  }
45770
46119
  return copyManifestDir(source, source, "local");
@@ -45795,7 +46144,7 @@ async function installManifestUrl(url2) {
45795
46144
  }
45796
46145
  function ensureCustomDir() {
45797
46146
  const dir = getCustomHooksDir();
45798
- mkdirSync16(dir, { recursive: true });
46147
+ mkdirSync17(dir, { recursive: true });
45799
46148
  return dir;
45800
46149
  }
45801
46150
  var init_custom_install = __esm(() => {
@@ -45813,14 +46162,14 @@ __export(exports_sync, {
45813
46162
  fetchPinnedHook: () => fetchPinnedHook,
45814
46163
  commitSyncArtifacts: () => commitSyncArtifacts
45815
46164
  });
45816
- import { createHash as createHash33, randomUUID as randomUUID10 } from "crypto";
45817
- import { readFileSync as readFileSync26, lstatSync as lstatSync33, mkdirSync as mkdirSync17, writeFileSync as writeFileSync15, accessSync as accessSync3, constants as constants25, existsSync as existsSync19 } from "fs";
45818
- import { dirname as dirname33, join as join39, resolve as resolve29, sep as sep11 } from "path";
46165
+ import { createHash as createHash35, randomUUID as randomUUID11 } from "crypto";
46166
+ import { readFileSync as readFileSync27, lstatSync as lstatSync35, mkdirSync as mkdirSync18, writeFileSync as writeFileSync16, accessSync as accessSync3, constants as constants26, existsSync as existsSync20 } from "fs";
46167
+ import { dirname as dirname35, join as join40, resolve as resolve30, sep as sep11 } from "path";
45819
46168
  function sha256OfText(text4) {
45820
- return createHash33("sha256").update(text4).digest("hex");
46169
+ return createHash35("sha256").update(text4).digest("hex");
45821
46170
  }
45822
46171
  function sha256OfPath(path) {
45823
- return createHash33("sha256").update(readFileSync26(path)).digest("hex");
46172
+ return createHash35("sha256").update(readFileSync27(path)).digest("hex");
45824
46173
  }
45825
46174
  function collectBundledCatalog() {
45826
46175
  const out = [];
@@ -45940,9 +46289,9 @@ async function syncHooks(options = {}) {
45940
46289
  const transport = resolveHooksTransport(options.env ?? process.env, {
45941
46290
  credentials: options.credentials
45942
46291
  });
45943
- const plan2 = await planSync(options);
46292
+ const plan3 = await planSync(options);
45944
46293
  if (options.dryRun)
45945
- return { ...plan2, dryRun: true };
46294
+ return { ...plan3, dryRun: true };
45946
46295
  if (transport.mode !== "remote" || !transport.authority) {
45947
46296
  const db = getDb();
45948
46297
  for (const entry of collectBundledCatalog()) {
@@ -45956,10 +46305,10 @@ async function syncHooks(options = {}) {
45956
46305
  last_verified_at: new Date().toISOString()
45957
46306
  });
45958
46307
  }
45959
- return plan2;
46308
+ return plan3;
45960
46309
  }
45961
46310
  const { origin } = transport.authority;
45962
- const guardedOptions = { ...options, ...plan2.selection ? { selectionProfile: plan2.selection.profile, expectedRevision: plan2.selection.revision } : {} };
46311
+ const guardedOptions = { ...options, ...plan3.selection ? { selectionProfile: plan3.selection.profile, expectedRevision: plan3.selection.revision } : {} };
45963
46312
  const { catalog, remoteLock } = await fetchRemoteState(origin, transport.authority, guardedOptions);
45964
46313
  const diff = computeDiff(catalog, remoteLock);
45965
46314
  const staged = await stageSyncArtifacts(origin, transport.authority, [...diff.added, ...diff.updated], remoteLock);
@@ -45977,28 +46326,28 @@ function prepareRegistryCommit(staged) {
45977
46326
  const originals = new Map;
45978
46327
  const inspectFile = (path) => {
45979
46328
  try {
45980
- if (!lstatSync33(path).isFile())
46329
+ if (!lstatSync35(path).isFile())
45981
46330
  throw new Error("REGISTRY_SYNC_DESTINATION_INVALID");
45982
- accessSync3(path, constants25.W_OK);
45983
- originals.set(path, readFileSync26(path));
46331
+ accessSync3(path, constants26.W_OK);
46332
+ originals.set(path, readFileSync27(path));
45984
46333
  } catch (error61) {
45985
46334
  if (error61.code !== "ENOENT")
45986
46335
  throw error61;
45987
46336
  }
45988
46337
  };
45989
46338
  for (const item of staged) {
45990
- const root = resolve29(customHookDir(item.name));
45991
- const script = resolve29(root, item.scriptRel);
46339
+ const root = resolve30(customHookDir(item.name));
46340
+ const script = resolve30(root, item.scriptRel);
45992
46341
  if (script !== root && !script.startsWith(root + sep11))
45993
46342
  throw new ScriptContainmentError(script, root, item.scriptRel);
45994
- const manifest = join39(root, "manifest.json");
46343
+ const manifest = join40(root, "manifest.json");
45995
46344
  if (script === manifest || script === root)
45996
46345
  throw new Error("REGISTRY_SYNC_DESTINATION_INVALID");
45997
- for (let path = dirname33(script);; path = dirname33(path)) {
46346
+ for (let path = dirname35(script);; path = dirname35(path)) {
45998
46347
  try {
45999
- if (!lstatSync33(path).isDirectory())
46348
+ if (!lstatSync35(path).isDirectory())
46000
46349
  throw new Error("REGISTRY_SYNC_DESTINATION_INVALID");
46001
- accessSync3(path, constants25.W_OK);
46350
+ accessSync3(path, constants26.W_OK);
46002
46351
  } catch (error61) {
46003
46352
  if (error61.code !== "ENOENT")
46004
46353
  throw error61;
@@ -46006,24 +46355,24 @@ function prepareRegistryCommit(staged) {
46006
46355
  if (path === root)
46007
46356
  break;
46008
46357
  }
46009
- if (existsSync19(root))
46358
+ if (existsSync20(root))
46010
46359
  assertContained(script, root, item.scriptRel);
46011
46360
  inspectFile(script);
46012
46361
  inspectFile(manifest);
46013
46362
  }
46014
46363
  inspectFile(getLockPath());
46015
46364
  if (originals.size) {
46016
- const recovery = join39(getHooksDataDir(), "registry-preservation", randomUUID10());
46017
- mkdirSync17(recovery, { recursive: true, mode: 448 });
46365
+ const recovery = join40(getHooksDataDir(), "registry-preservation", randomUUID11());
46366
+ mkdirSync18(recovery, { recursive: true, mode: 448 });
46018
46367
  const receipt = [];
46019
46368
  for (const [target, bytes] of originals) {
46020
- const path = join39(recovery, `${receipt.length}.original`);
46021
- writeFileSync15(path, bytes, { flag: "wx", mode: 384 });
46022
- if (!readFileSync26(path).equals(bytes))
46369
+ const path = join40(recovery, `${receipt.length}.original`);
46370
+ writeFileSync16(path, bytes, { flag: "wx", mode: 384 });
46371
+ if (!readFileSync27(path).equals(bytes))
46023
46372
  throw new Error("REGISTRY_PRESERVATION_READBACK_FAILED");
46024
- receipt.push({ target, preserved: path, sha256: createHash33("sha256").update(bytes).digest("hex"), readback: true });
46373
+ receipt.push({ target, preserved: path, sha256: createHash35("sha256").update(bytes).digest("hex"), readback: true });
46025
46374
  }
46026
- writeFileSync15(join39(recovery, "receipt.json"), JSON.stringify(receipt, null, 2) + `
46375
+ writeFileSync16(join40(recovery, "receipt.json"), JSON.stringify(receipt, null, 2) + `
46027
46376
  `, { flag: "wx", mode: 384 });
46028
46377
  }
46029
46378
  for (const item of staged)
@@ -47340,7 +47689,7 @@ var init_hosted_registry = __esm(() => {
47340
47689
  });
47341
47690
 
47342
47691
  // node_modules/@hasna/contracts/dist/auth/index.js
47343
- import { createHash as createHash35, createHmac as createHmac2, randomBytes as randomBytes3, timingSafeEqual as timingSafeEqual2 } from "crypto";
47692
+ import { createHash as createHash36, createHmac as createHmac2, randomBytes as randomBytes3, timingSafeEqual as timingSafeEqual2 } from "crypto";
47344
47693
  function isValidTenantId(value) {
47345
47694
  return typeof value === "string" && TENANT_ID_PATTERN.test(value);
47346
47695
  }
@@ -48076,25 +48425,25 @@ async function handleRegistryRequest(request, key, registry2) {
48076
48425
  throw new RegistryError(401, "REGISTRY_UNAUTHORIZED");
48077
48426
  }
48078
48427
  const url2 = new URL(request.url), path = url2.pathname.replace(/^\/api\/v1(?=\/|$)/, "/v1");
48079
- const owner4 = registry2 ?? configuredRegistry();
48428
+ const owner5 = registry2 ?? configuredRegistry();
48080
48429
  if (path === "/v1/catalog" && request.method === "GET")
48081
- return json2(await owner4.catalog());
48430
+ return json2(await owner5.catalog());
48082
48431
  if (path === "/v1/lock" && request.method === "GET")
48083
- return json2(await owner4.selection(url2.searchParams.get("profile") ?? "fleet"));
48432
+ return json2(await owner5.selection(url2.searchParams.get("profile") ?? "fleet"));
48084
48433
  if (path === "/v1/hooks" && request.method === "PUT")
48085
- return json2(await owner4.publish(await boundedJson2(request)));
48434
+ return json2(await owner5.publish(await boundedJson2(request)));
48086
48435
  const artifact = /^\/v1\/hooks\/([^/]+)\/([^/]+)$/.exec(path);
48087
48436
  if (artifact && request.method === "GET") {
48088
- const { body, row, format, portable } = await owner4.artifactWire(decodeURIComponent(artifact[1]), decodeURIComponent(artifact[2]));
48437
+ const { body, row, format, portable } = await owner5.artifactWire(decodeURIComponent(artifact[1]), decodeURIComponent(artifact[2]));
48089
48438
  return new Response(body, { status: 200, headers: { "content-type": "application/json", "cache-control": "no-store", "x-hook-sha256": row.script_sha256, "x-hook-bundle-sha256": row.bundle_sha256, "x-hook-artifact-format": format, "x-hook-portable": String(portable) } });
48090
48439
  }
48091
48440
  const selection = /^\/v1\/selections\/([^/]+)$/.exec(path);
48092
48441
  if (selection) {
48093
48442
  const profile = decodeURIComponent(selection[1]);
48094
48443
  if (request.method === "GET")
48095
- return json2(await owner4.selection(profile));
48444
+ return json2(await owner5.selection(profile));
48096
48445
  if (request.method === "PUT")
48097
- return json2(await owner4.select(profile, await boundedJson2(request)));
48446
+ return json2(await owner5.select(profile, await boundedJson2(request)));
48098
48447
  }
48099
48448
  return json2({ error: "REGISTRY_ROUTE_NOT_FOUND" }, 404);
48100
48449
  } catch (error61) {
@@ -48125,13 +48474,13 @@ __export(exports_serve, {
48125
48474
  SERVE_HOST: () => SERVE_HOST,
48126
48475
  DEFAULT_SERVE_PORT: () => DEFAULT_SERVE_PORT
48127
48476
  });
48128
- import { readFileSync as readFileSync27 } from "fs";
48129
- import { dirname as dirname35, join as join40 } from "path";
48477
+ import { readFileSync as readFileSync28 } from "fs";
48478
+ import { dirname as dirname36, join as join41 } from "path";
48130
48479
  import { fileURLToPath as fileURLToPath6 } from "url";
48131
48480
  function packageVersion() {
48132
48481
  try {
48133
- const pkgPath = join40(dirname35(fileURLToPath6(import.meta.url)), "..", "package.json");
48134
- return JSON.parse(readFileSync27(pkgPath, "utf-8")).version || "0.0.0";
48482
+ const pkgPath = join41(dirname36(fileURLToPath6(import.meta.url)), "..", "package.json");
48483
+ return JSON.parse(readFileSync28(pkgPath, "utf-8")).version || "0.0.0";
48135
48484
  } catch {
48136
48485
  return "0.0.0";
48137
48486
  }
@@ -48332,17 +48681,17 @@ var exports_publish = {};
48332
48681
  __export(exports_publish, {
48333
48682
  prepareRegistryPublication: () => prepareRegistryPublication
48334
48683
  });
48335
- import { readFileSync as readFileSync28 } from "fs";
48336
- import { dirname as dirname36, resolve as resolve30 } from "path";
48684
+ import { readFileSync as readFileSync29 } from "fs";
48685
+ import { dirname as dirname37, resolve as resolve31 } from "path";
48337
48686
  async function prepareRegistryPublication(manifestPath) {
48338
- const path = resolve30(manifestPath), manifest = parseManifest(readFileSync28(path, "utf8"));
48687
+ const path = resolve31(manifestPath), manifest = parseManifest(readFileSync29(path, "utf8"));
48339
48688
  if (manifest.env && Object.keys(manifest.env).length)
48340
48689
  throw new Error("REGISTRY_MANIFEST_ENV_REFUSED: use the installed credential resolver, not artifact environment values");
48341
48690
  if (manifest.script_kind === "inline" || manifest.script.includes(`
48342
48691
  `))
48343
48692
  throw new Error("REGISTRY_PUBLICATION_FILE_REQUIRED: provide a source file to bundle");
48344
- const source = resolveScript(manifest, dirname36(path));
48345
- const result = await Bun.build({ entrypoints: [resolve30(dirname36(path), source.path)], target: "bun", format: "esm", packages: "bundle", sourcemap: "none" });
48693
+ const source = resolveScript(manifest, dirname37(path));
48694
+ const result = await Bun.build({ entrypoints: [resolve31(dirname37(path), source.path)], target: "bun", format: "esm", packages: "bundle", sourcemap: "none" });
48346
48695
  if (!result.success || result.outputs.length !== 1)
48347
48696
  throw new Error("REGISTRY_BUNDLE_FAILED");
48348
48697
  const script = await result.outputs[0].text();
@@ -48745,8 +49094,8 @@ __export(exports_legacy_registry_import, {
48745
49094
  readLegacyRegistryExport: () => readLegacyRegistryExport,
48746
49095
  importLegacyRegistryExport: () => importLegacyRegistryExport
48747
49096
  });
48748
- import { constants as constants26, closeSync as closeSync27, fstatSync as fstatSync26, lstatSync as lstatSync35, openSync as openSync27, readSync as readSync4, realpathSync as realpathSync23 } from "fs";
48749
- import { dirname as dirname37, isAbsolute as isAbsolute35, join as join41, resolve as resolve31 } from "path";
49097
+ import { constants as constants27, closeSync as closeSync28, fstatSync as fstatSync27, lstatSync as lstatSync36, openSync as openSync28, readSync as readSync4, realpathSync as realpathSync24 } from "fs";
49098
+ import { dirname as dirname38, isAbsolute as isAbsolute36, join as join42, resolve as resolve33 } from "path";
48750
49099
  function refuse4() {
48751
49100
  throw new RegistryError(400, "REGISTRY_LEGACY_EXPORT_INVALID");
48752
49101
  }
@@ -48758,17 +49107,17 @@ function decode3(bytes) {
48758
49107
  }
48759
49108
  }
48760
49109
  function fileBytes(root, relative8, expected) {
48761
- const path = join41(root, relative8);
48762
- if (resolve31(path) !== path || !path.startsWith(root + "/") || realpathSync23(path) !== path)
49110
+ const path = join42(root, relative8);
49111
+ if (resolve33(path) !== path || !path.startsWith(root + "/") || realpathSync24(path) !== path)
48763
49112
  refuse4();
48764
- for (let component = path;component !== root; component = dirname37(component))
48765
- if (lstatSync35(component).isSymbolicLink())
49113
+ for (let component = path;component !== root; component = dirname38(component))
49114
+ if (lstatSync36(component).isSymbolicLink())
48766
49115
  refuse4();
48767
49116
  if (expected && (expected.path !== relative8 || !Number.isSafeInteger(expected.bytes) || expected.bytes < 1 || expected.bytes > REGISTRY_MAX_BYTES || !SHA256.test(expected.sha256)))
48768
49117
  refuse4();
48769
- const fd = openSync27(path, constants26.O_RDONLY | constants26.O_NOFOLLOW);
49118
+ const fd = openSync28(path, constants27.O_RDONLY | constants27.O_NOFOLLOW);
48770
49119
  try {
48771
- const stat2 = fstatSync26(fd);
49120
+ const stat2 = fstatSync27(fd);
48772
49121
  if (!stat2.isFile() || stat2.size < 1 || stat2.size > REGISTRY_MAX_BYTES || expected && stat2.size !== expected.bytes)
48773
49122
  refuse4();
48774
49123
  const bytes = Buffer.alloc(stat2.size + 1);
@@ -48786,15 +49135,15 @@ function fileBytes(root, relative8, expected) {
48786
49135
  refuse4();
48787
49136
  return exact2;
48788
49137
  } finally {
48789
- closeSync27(fd);
49138
+ closeSync28(fd);
48790
49139
  }
48791
49140
  }
48792
49141
  function readLegacyRegistryExport(manifestPath, expectedSha256) {
48793
49142
  try {
48794
- if (!isAbsolute35(manifestPath) || resolve31(manifestPath) !== manifestPath || !SHA256.test(expectedSha256))
49143
+ if (!isAbsolute36(manifestPath) || resolve33(manifestPath) !== manifestPath || !SHA256.test(expectedSha256))
48795
49144
  refuse4();
48796
- const root = dirname37(manifestPath);
48797
- if (realpathSync23(root) !== root || lstatSync35(root).isSymbolicLink() || !lstatSync35(root).isDirectory())
49145
+ const root = dirname38(manifestPath);
49146
+ if (realpathSync24(root) !== root || lstatSync36(root).isSymbolicLink() || !lstatSync36(root).isDirectory())
48798
49147
  refuse4();
48799
49148
  const manifestWire = decode3(fileBytes(root, manifestPath.slice(root.length + 1)));
48800
49149
  if (scriptDigest(manifestWire) !== expectedSha256)
@@ -48997,17 +49346,17 @@ import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js";
48997
49346
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
48998
49347
  import { z as z3 } from "zod";
48999
49348
  import { createServer } from "http";
49000
- import { existsSync as existsSync20, readFileSync as readFileSync29 } from "fs";
49001
- import { join as join42, dirname as dirname38 } from "path";
49349
+ import { existsSync as existsSync21, readFileSync as readFileSync30 } from "fs";
49350
+ import { join as join43, dirname as dirname39 } from "path";
49002
49351
  import { fileURLToPath as fileURLToPath7 } from "url";
49003
49352
  async function runVerifiedHook(name, stdin, timeoutMs) {
49004
49353
  const { resolveHook: resolveHook2, resolveScriptPath: resolveScriptPath2 } = await Promise.resolve().then(() => (init_resolve(), exports_resolve));
49005
49354
  const resolved = resolveHook2(name);
49006
49355
  const hookScript = resolveScriptPath2(name);
49007
- if (!resolved || !hookScript || !existsSync20(hookScript)) {
49356
+ if (!resolved || !hookScript || !existsSync21(hookScript)) {
49008
49357
  throw new Error(`Hook '${name}' not found`);
49009
49358
  }
49010
- const content = readFileSync29(hookScript);
49359
+ const content = readFileSync30(hookScript);
49011
49360
  const sha7 = sha256Of(content);
49012
49361
  const check2 = checkScriptHash(name, sha7);
49013
49362
  if (!check2.ok) {
@@ -49218,7 +49567,7 @@ function createHooksServer() {
49218
49567
  const settingsPath = getSettingsPath(scope);
49219
49568
  const issues = [];
49220
49569
  const healthy = [];
49221
- const settingsExist = existsSync20(settingsPath);
49570
+ const settingsExist = existsSync21(settingsPath);
49222
49571
  if (!settingsExist) {
49223
49572
  issues.push({ hook: "(settings)", issue: `${settingsPath} not found`, severity: "warning" });
49224
49573
  }
@@ -49228,7 +49577,7 @@ function createHooksServer() {
49228
49577
  const meta3 = custom2 ? resolveHookMeta(name) : getHook(name);
49229
49578
  let hookHealthy = true;
49230
49579
  if (custom2) {
49231
- if (!existsSync20(custom2.scriptPath)) {
49580
+ if (!existsSync21(custom2.scriptPath)) {
49232
49581
  issues.push({ hook: name, issue: `Custom hook script missing: ${custom2.scriptPath}`, severity: "error" });
49233
49582
  hookHealthy = false;
49234
49583
  }
@@ -49238,14 +49587,14 @@ function createHooksServer() {
49238
49587
  continue;
49239
49588
  }
49240
49589
  const hookDir = getHookPath(name);
49241
- if (!existsSync20(join42(hookDir, "src", "hook.ts"))) {
49590
+ if (!existsSync21(join43(hookDir, "src", "hook.ts"))) {
49242
49591
  issues.push({ hook: name, issue: "Missing src/hook.ts in package", severity: "error" });
49243
49592
  hookHealthy = false;
49244
49593
  }
49245
49594
  }
49246
49595
  if (meta3 && settingsExist) {
49247
49596
  try {
49248
- const settings = JSON.parse(readFileSync29(settingsPath, "utf-8"));
49597
+ const settings = JSON.parse(readFileSync30(settingsPath, "utf-8"));
49249
49598
  if (!hookRegisteredInSettings(settings, name, meta3.event, matcherFor(meta3, "claude"))) {
49250
49599
  const eventName = meta3.event.split(":")[0];
49251
49600
  issues.push({ hook: name, issue: `Not registered under correct event (${eventName})`, severity: "error" });
@@ -49282,10 +49631,10 @@ function createHooksServer() {
49282
49631
  return { content: [{ type: "text", text: JSON.stringify({ error: `Hook '${name}' not found` }) }] };
49283
49632
  }
49284
49633
  const hookPath = getHookPath(name);
49285
- const readmePath = join42(hookPath, "README.md");
49634
+ const readmePath = join43(hookPath, "README.md");
49286
49635
  let readme = "";
49287
- if (existsSync20(readmePath)) {
49288
- readme = readFileSync29(readmePath, "utf-8");
49636
+ if (existsSync21(readmePath)) {
49637
+ readme = readFileSync30(readmePath, "utf-8");
49289
49638
  }
49290
49639
  if (verbose) {
49291
49640
  return { content: [{ type: "text", text: JSON.stringify({ ...meta3, readme }) }] };
@@ -49468,7 +49817,7 @@ function createHooksServer() {
49468
49817
  const ctx = {
49469
49818
  scope,
49470
49819
  settings_path: settingsPath,
49471
- settings_exists: existsSync20(settingsPath),
49820
+ settings_exists: existsSync21(settingsPath),
49472
49821
  registered_hooks: hooks,
49473
49822
  hook_count: hooks.length,
49474
49823
  healthy,
@@ -49992,13 +50341,13 @@ var init_server = __esm(() => {
49992
50341
  init_redact();
49993
50342
  init_authority2();
49994
50343
  init_storage();
49995
- __dirname3 = dirname38(fileURLToPath7(import.meta.url));
50344
+ __dirname3 = dirname39(fileURLToPath7(import.meta.url));
49996
50345
  pkg = { name: "@hasna/hooks", version: "0.0.0" };
49997
50346
  try {
49998
50347
  for (const rel of ["../../package.json", "../package.json", "../../../package.json"]) {
49999
- const p = join42(__dirname3, rel);
50000
- if (existsSync20(p)) {
50001
- pkg = JSON.parse(readFileSync29(p, "utf-8"));
50348
+ const p = join43(__dirname3, rel);
50349
+ if (existsSync21(p)) {
50350
+ pkg = JSON.parse(readFileSync30(p, "utf-8"));
50002
50351
  break;
50003
50352
  }
50004
50353
  }
@@ -50072,42 +50421,42 @@ __export(exports_native_readiness_binding, {
50072
50421
  registerTrashReadinessBinding: () => registerTrashReadinessBinding,
50073
50422
  ReadinessBindingError: () => ReadinessBindingError
50074
50423
  });
50075
- import { createHash as createHash36, randomUUID as randomUUID11 } from "crypto";
50076
- import { closeSync as closeSync28, constants as constants27, fsyncSync as fsyncSync10, lstatSync as lstatSync36, mkdirSync as mkdirSync18, openSync as openSync28, realpathSync as realpathSync24, writeFileSync as writeFileSync16 } from "fs";
50077
- import { homedir as homedir18 } from "os";
50078
- import { dirname as dirname39, join as join43 } from "path";
50424
+ import { createHash as createHash37, randomUUID as randomUUID12 } from "crypto";
50425
+ import { closeSync as closeSync29, constants as constants28, fsyncSync as fsyncSync11, lstatSync as lstatSync37, mkdirSync as mkdirSync19, openSync as openSync29, realpathSync as realpathSync25, writeFileSync as writeFileSync17 } from "fs";
50426
+ import { homedir as homedir19 } from "os";
50427
+ import { dirname as dirname40, join as join44 } from "path";
50079
50428
  function need13(value, code2) {
50080
50429
  if (!value)
50081
50430
  throw new ReadinessBindingError(code2);
50082
50431
  }
50083
50432
  function safeDirectory4(path) {
50084
- for (let p = path;; p = dirname39(p)) {
50085
- const s = lstatSync36(p);
50433
+ for (let p = path;; p = dirname40(p)) {
50434
+ const s = lstatSync37(p);
50086
50435
  need13(s.isDirectory() && [0, process.getuid?.()].includes(s.uid) && !(s.mode & 18), "binding_invalid");
50087
- if (p === dirname39(p))
50436
+ if (p === dirname40(p))
50088
50437
  break;
50089
50438
  }
50090
50439
  }
50091
- function syncDirectory5(path) {
50092
- const fd = openSync28(path, constants27.O_RDONLY | constants27.O_DIRECTORY | constants27.O_NOFOLLOW);
50440
+ function syncDirectory6(path) {
50441
+ const fd = openSync29(path, constants28.O_RDONLY | constants28.O_DIRECTORY | constants28.O_NOFOLLOW);
50093
50442
  try {
50094
- fsyncSync10(fd);
50443
+ fsyncSync11(fd);
50095
50444
  } finally {
50096
- closeSync28(fd);
50445
+ closeSync29(fd);
50097
50446
  }
50098
50447
  }
50099
50448
  function exclusive3(path, bytes) {
50100
- const fd = openSync28(path, constants27.O_WRONLY | constants27.O_CREAT | constants27.O_EXCL | constants27.O_NOFOLLOW, 384);
50449
+ const fd = openSync29(path, constants28.O_WRONLY | constants28.O_CREAT | constants28.O_EXCL | constants28.O_NOFOLLOW, 384);
50101
50450
  try {
50102
- writeFileSync16(fd, bytes);
50103
- fsyncSync10(fd);
50451
+ writeFileSync17(fd, bytes);
50452
+ fsyncSync11(fd);
50104
50453
  } finally {
50105
- closeSync28(fd);
50454
+ closeSync29(fd);
50106
50455
  }
50107
- syncDirectory5(dirname39(path));
50456
+ syncDirectory6(dirname40(path));
50108
50457
  }
50109
50458
  async function registerTrashReadinessBinding(input2, expectedSHA256) {
50110
- const home = realpathSync24(homedir18()), b = parseTrashReadinessBinding(input2, input2?.provider, home);
50459
+ const home = realpathSync25(homedir19()), b = parseTrashReadinessBinding(input2, input2?.provider, home);
50111
50460
  need13(/^(?:absent|[a-f0-9]{64})$/.test(expectedSHA256), "binding_invalid");
50112
50461
  const target = trashReadinessBindingPath(b.provider, home);
50113
50462
  const read4 = () => {
@@ -50116,7 +50465,7 @@ async function registerTrashReadinessBinding(input2, expectedSHA256) {
50116
50465
  } catch (error61) {
50117
50466
  if (error61?.code !== "ENOENT")
50118
50467
  throw new ReadinessBindingError("binding_invalid");
50119
- need13(!lstatSync36(target, { throwIfNoEntry: false }), "binding_invalid");
50468
+ need13(!lstatSync37(target, { throwIfNoEntry: false }), "binding_invalid");
50120
50469
  return null;
50121
50470
  }
50122
50471
  };
@@ -50130,25 +50479,25 @@ async function registerTrashReadinessBinding(input2, expectedSHA256) {
50130
50479
  `, digest5 = sha10(next);
50131
50480
  if (before?.sha256 === digest5)
50132
50481
  return { ok: true, changed: false, path: target, sha256: digest5, configurationReady: true, nativeAdoptionVerified: false };
50133
- const operationId = randomUUID11();
50482
+ const operationId = randomUUID12();
50134
50483
  let directory2 = home;
50135
50484
  for (const part of [".hasna", "hooks", "native", "trash-readiness"]) {
50136
- directory2 = join43(directory2, part);
50485
+ directory2 = join44(directory2, part);
50137
50486
  try {
50138
- mkdirSync18(directory2, { mode: 448 });
50139
- syncDirectory5(dirname39(directory2));
50487
+ mkdirSync19(directory2, { mode: 448 });
50488
+ syncDirectory6(dirname40(directory2));
50140
50489
  } catch (error61) {
50141
50490
  if (error61?.code !== "EEXIST")
50142
50491
  throw new ReadinessBindingError("binding_invalid");
50143
50492
  }
50144
50493
  safeDirectory4(directory2);
50145
50494
  }
50146
- const operation = join43(directory2, operationId);
50147
- mkdirSync18(operation, { mode: 448 });
50148
- syncDirectory5(directory2);
50495
+ const operation = join44(directory2, operationId);
50496
+ mkdirSync19(operation, { mode: 448 });
50497
+ syncDirectory6(directory2);
50149
50498
  if (before)
50150
- exclusive3(join43(operation, "binding.before"), before.raw);
50151
- exclusive3(join43(operation, "intent.json"), JSON.stringify({ operationId, target, expectedSHA256, desiredSHA256: digest5 }) + `
50499
+ exclusive3(join44(operation, "binding.before"), before.raw);
50500
+ exclusive3(join44(operation, "intent.json"), JSON.stringify({ operationId, target, expectedSHA256, desiredSHA256: digest5 }) + `
50152
50501
  `);
50153
50502
  let writeMayHaveStarted = false;
50154
50503
  try {
@@ -50157,16 +50506,16 @@ async function registerTrashReadinessBinding(input2, expectedSHA256) {
50157
50506
  writeMayHaveStarted = true;
50158
50507
  });
50159
50508
  writeMayHaveStarted = true;
50160
- const fd = openSync28(target, constants27.O_RDONLY | constants27.O_NOFOLLOW);
50509
+ const fd = openSync29(target, constants28.O_RDONLY | constants28.O_NOFOLLOW);
50161
50510
  try {
50162
- fsyncSync10(fd);
50511
+ fsyncSync11(fd);
50163
50512
  } finally {
50164
- closeSync28(fd);
50513
+ closeSync29(fd);
50165
50514
  }
50166
- syncDirectory5(directory2);
50515
+ syncDirectory6(directory2);
50167
50516
  need13(read4()?.sha256 === digest5, "binding_changed");
50168
50517
  const receipt = { ok: true, changed: true, operationId, path: target, sha256: digest5, configurationReady: true, nativeAdoptionVerified: false };
50169
- exclusive3(join43(operation, "receipt.json"), JSON.stringify(receipt) + `
50518
+ exclusive3(join44(operation, "receipt.json"), JSON.stringify(receipt) + `
50170
50519
  `);
50171
50520
  return receipt;
50172
50521
  } catch (error61) {
@@ -50175,7 +50524,7 @@ async function registerTrashReadinessBinding(input2, expectedSHA256) {
50175
50524
  const code2 = error61?.code;
50176
50525
  const refusal3 = { code: typeof code2 === "string" && code2 ? code2 : "writer_refused", message: error61 instanceof Error ? error61.message : String(error61) };
50177
50526
  try {
50178
- exclusive3(join43(operation, "refused.json"), JSON.stringify({ ok: false, outcome: "refused", operationId, path: target, expectedSHA256, refusal: refusal3 }) + `
50527
+ exclusive3(join44(operation, "refused.json"), JSON.stringify({ ok: false, outcome: "refused", operationId, path: target, expectedSHA256, refusal: refusal3 }) + `
50179
50528
  `);
50180
50529
  } catch {
50181
50530
  throw new ReadinessBindingError("binding_outcome_uncertain", operationId);
@@ -50183,7 +50532,7 @@ async function registerTrashReadinessBinding(input2, expectedSHA256) {
50183
50532
  throw new ReadinessBindingError("binding_refused", operationId, refusal3);
50184
50533
  }
50185
50534
  }
50186
- var ReadinessBindingError, sha10 = (bytes) => createHash36("sha256").update(bytes).digest("hex");
50535
+ var ReadinessBindingError, sha10 = (bytes) => createHash37("sha256").update(bytes).digest("hex");
50187
50536
  var init_native_readiness_binding = __esm(() => {
50188
50537
  init_native_readiness();
50189
50538
  init_codex_settings();
@@ -50202,7 +50551,7 @@ var init_native_readiness_binding = __esm(() => {
50202
50551
 
50203
50552
  // src/cli/index.tsx
50204
50553
  init_native_safety_registration();
50205
- import { resolve as resolve33 } from "path";
50554
+ import { resolve as resolve35 } from "path";
50206
50555
 
50207
50556
  // src/lib/claude-safety-check.ts
50208
50557
  init_native_safety();
@@ -51525,8 +51874,8 @@ var {
51525
51874
 
51526
51875
  // src/cli/index.tsx
51527
51876
  import chalk2 from "chalk";
51528
- import { existsSync as existsSync21, readFileSync as readFileSync30, rmSync as rmSync6 } from "fs";
51529
- import { join as join44, dirname as dirname40 } from "path";
51877
+ import { existsSync as existsSync22, readFileSync as readFileSync31, rmSync as rmSync6 } from "fs";
51878
+ import { join as join45, dirname as dirname41 } from "path";
51530
51879
  import { fileURLToPath as fileURLToPath8 } from "url";
51531
51880
 
51532
51881
  // src/cli/components/App.tsx
@@ -52719,9 +53068,9 @@ init_local_opt_in();
52719
53068
  init_transport2();
52720
53069
  init_db();
52721
53070
  import { jsxDEV as jsxDEV8 } from "react/jsx-dev-runtime";
52722
- var __dirname4 = dirname40(fileURLToPath8(import.meta.url));
52723
- var pkgPath = existsSync21(join44(__dirname4, "..", "package.json")) ? join44(__dirname4, "..", "package.json") : join44(__dirname4, "..", "..", "package.json");
52724
- var pkg2 = JSON.parse(readFileSync30(pkgPath, "utf-8"));
53071
+ var __dirname4 = dirname41(fileURLToPath8(import.meta.url));
53072
+ var pkgPath = existsSync22(join45(__dirname4, "..", "package.json")) ? join45(__dirname4, "..", "package.json") : join45(__dirname4, "..", "..", "package.json");
53073
+ var pkg2 = JSON.parse(readFileSync31(pkgPath, "utf-8"));
52725
53074
  var program3 = new Command;
52726
53075
  function resolveScope(options) {
52727
53076
  if (options.project)
@@ -52737,7 +53086,9 @@ function resolveTarget(options) {
52737
53086
  return "codewith";
52738
53087
  if (options.target === "all")
52739
53088
  return "all";
52740
- return "claude";
53089
+ if (options.target === undefined || options.target === "claude")
53090
+ return "claude";
53091
+ return program3.error("Unknown target; expected claude, gemini, codewith, codex or all", { code: "hooks.target_invalid" });
52741
53092
  }
52742
53093
  function resolveConcreteTarget(options) {
52743
53094
  if (options.target === "gemini")
@@ -52746,7 +53097,9 @@ function resolveConcreteTarget(options) {
52746
53097
  return "codex";
52747
53098
  if (options.target === "codewith")
52748
53099
  return "codewith";
52749
- return "claude";
53100
+ if (options.target === undefined || options.target === "claude")
53101
+ return "claude";
53102
+ return program3.error("Unknown target; expected claude, gemini, codewith or codex", { code: "hooks.target_invalid" });
52750
53103
  }
52751
53104
  function reportSumiBinding(result) {
52752
53105
  if (result.ok) {
@@ -52815,7 +53168,7 @@ async function openLocalStoreOrExit(json4) {
52815
53168
  function readToken(tokenFile) {
52816
53169
  if (tokenFile) {
52817
53170
  try {
52818
- return readFileSync30(tokenFile, "utf-8").trim();
53171
+ return readFileSync31(tokenFile, "utf-8").trim();
52819
53172
  } catch {
52820
53173
  return;
52821
53174
  }
@@ -52953,7 +53306,7 @@ program3.command("init").description("Register a new agent profile with a unique
52953
53306
  if (profile.name) {
52954
53307
  console.log(` ${chalk2.dim("Name:")} ${profile.name}`);
52955
53308
  }
52956
- console.log(` ${chalk2.dim("Profile:")} ${join44(getProfilesDir(), `${profile.agent_id}.json`)}`);
53309
+ console.log(` ${chalk2.dim("Profile:")} ${join45(getProfilesDir(), `${profile.agent_id}.json`)}`);
52957
53310
  console.log();
52958
53311
  console.log(chalk2.dim(" Install hooks with this profile:"));
52959
53312
  console.log(` hooks install gitguard --profile ${profile.agent_id}`);
@@ -52977,11 +53330,11 @@ program3.command("run").argument("<hook>", "Hook to run").option("--target <targ
52977
53330
  process.exit(1);
52978
53331
  }
52979
53332
  const hookScript = resolveScriptPath2(hook);
52980
- if (!hookScript || !existsSync21(hookScript)) {
53333
+ if (!hookScript || !existsSync22(hookScript)) {
52981
53334
  console.error(JSON.stringify({ error: `Hook script not found: ${hookScript ?? hook}` }));
52982
53335
  process.exit(1);
52983
53336
  }
52984
- const content = readFileSync30(hookScript);
53337
+ const content = readFileSync31(hookScript);
52985
53338
  const sha7 = sha256Of2(content);
52986
53339
  const check2 = checkScriptHash2(hook, sha7);
52987
53340
  if (!check2.ok) {
@@ -53121,7 +53474,34 @@ async function installOpenCodeStopReview(hooks, options) {
53121
53474
  process.exitCode = 1;
53122
53475
  }
53123
53476
  }
53124
- program3.command("install").alias("add").argument("[hooks...]", "Hooks to install").option("-o, --overwrite", "Overwrite existing hooks", false).option("-a, --all", "Install all available hooks", false).option("-c, --category <category>", "Install all hooks in a category").option("-g, --global", "Install globally (~/.claude/settings.json)", false).option("-p, --project", "Install for current project (.claude/settings.json)", false).option("-t, --target <target>", "Agent target: claude, gemini, codewith, codex, all, or opencode for stop-review (default: claude)", "claude").option("--profile <id>", "Agent profile ID to scope hooks to").option("--enable-mementos", "Persistently enable mementos-context (provider assistance remains separately opt-in)").option("--disable-mementos", "Persistently disable mementos-context").option("--openrouter-secret-ref <reference>", "Secrets reference for the enabled Mementos hook; never a key value").option("--dry-run", "Preview what would be installed without writing to settings", false).option("--apply-codewith", "Explicitly append Codewith TOML to a config file (prefer configs for managed configs)", false).option("--codewith-config <path>", "Explicit Codewith config path required with --apply-codewith").option("--expected-config-sha256 <sha256>", 'OpenCode: exact current opencode.json digest from --dry-run ("absent" for a new file)').option("--verify", "OpenCode: read-only drift check of the registered stop-review entry", false).option("-j, --json", "Output as JSON", false).description("Install one or more hooks (registry names, local paths, git URLs, manifest URLs, or <name>@<version> pinned installs)").action(async (hooks, options) => {
53477
+ async function installSumiStopReview(hooks, options) {
53478
+ const { SumiStopInstallError: SumiStopInstallError2, applySumiStopInstall: applySumiStopInstall2, installedSumiStopPins: installedSumiStopPins2, sumiStopPluginPath: sumiStopPluginPath2, planSumiStopInstall: planSumiStopInstall2, verifySumiStopInstall: verifySumiStopInstall2 } = await Promise.resolve().then(() => (init_sumi_stop_install(), exports_sumi_stop_install));
53479
+ try {
53480
+ if (hooks.length !== 1 || hooks[0] !== "stop-review" || options.all || options.category || options.profile || options.overwrite || options.dryRun && options.verify || options.project && options.global)
53481
+ throw new SumiStopInstallError2("input_invalid");
53482
+ const path = sumiStopPluginPath2({ scope: options.project ? "project" : "global" });
53483
+ if (options.verify) {
53484
+ console.log(JSON.stringify(verifySumiStopInstall2({ path })));
53485
+ return;
53486
+ }
53487
+ const pins = installedSumiStopPins2();
53488
+ console.log(JSON.stringify(options.dryRun ? planSumiStopInstall2({ path, pins }) : applySumiStopInstall2({ path, pins, expectedSha256: options.expectedConfigSha256 })));
53489
+ } catch (error61) {
53490
+ console.log(JSON.stringify({
53491
+ ok: false,
53492
+ target: "sumi",
53493
+ code: error61 instanceof SumiStopInstallError2 ? error61.code : "registration_failed",
53494
+ ...error61 instanceof SumiStopInstallError2 && error61.reason ? { reason: error61.reason.slice(0, 300) } : {},
53495
+ nativeAdoptionVerified: false
53496
+ }));
53497
+ process.exitCode = 1;
53498
+ }
53499
+ }
53500
+ program3.command("install").alias("add").argument("[hooks...]", "Hooks to install").option("-o, --overwrite", "Overwrite existing hooks", false).option("-a, --all", "Install all available hooks", false).option("-c, --category <category>", "Install all hooks in a category").option("-g, --global", "Install globally (~/.claude/settings.json)", false).option("-p, --project", "Install for current project (.claude/settings.json)", false).option("-t, --target <target>", "Agent target: claude, gemini, codewith, codex, all, or opencode/sumi for stop-review (default: claude)", "claude").option("--profile <id>", "Agent profile ID to scope hooks to").option("--enable-mementos", "Persistently enable mementos-context (provider assistance remains separately opt-in)").option("--disable-mementos", "Persistently disable mementos-context").option("--openrouter-secret-ref <reference>", "Secrets reference for the enabled Mementos hook; never a key value").option("--dry-run", "Preview what would be installed without writing to settings", false).option("--apply-codewith", "Explicitly append Codewith TOML to a config file (prefer configs for managed configs)", false).option("--codewith-config <path>", "Explicit Codewith config path required with --apply-codewith").option("--expected-config-sha256 <sha256>", 'OpenCode/Sumi: exact current registration digest from --dry-run ("absent" for a new file)').option("--verify", "OpenCode/Sumi: read-only drift check of the registered stop-review entry", false).option("-j, --json", "Output as JSON", false).description("Install one or more hooks (registry names, local paths, git URLs, manifest URLs, or <name>@<version> pinned installs)").action(async (hooks, options) => {
53501
+ if (options.target === "sumi") {
53502
+ await installSumiStopReview(hooks, options);
53503
+ return;
53504
+ }
53125
53505
  if (options.target === "opencode") {
53126
53506
  await installOpenCodeStopReview(hooks, options);
53127
53507
  return;
@@ -53616,7 +53996,7 @@ program3.command("doctor").option("-g, --global", "Check global settings", false
53616
53996
  });
53617
53997
  }
53618
53998
  const staleNames = new Set(stale.map((finding) => finding.hook));
53619
- const settingsExist = existsSync21(settingsPath);
53999
+ const settingsExist = existsSync22(settingsPath);
53620
54000
  if (!settingsExist) {
53621
54001
  issues.push({ hook: "(settings)", issue: `${settingsPath} not found`, severity: "warning" });
53622
54002
  }
@@ -53624,7 +54004,7 @@ program3.command("doctor").option("-g, --global", "Check global settings", false
53624
54004
  let wiringCount = 0;
53625
54005
  if (settingsExist) {
53626
54006
  try {
53627
- const settings = JSON.parse(readFileSync30(settingsPath, "utf-8"));
54007
+ const settings = JSON.parse(readFileSync31(settingsPath, "utf-8"));
53628
54008
  wiringCount = countSettingsWiring(settings);
53629
54009
  } catch {}
53630
54010
  }
@@ -53635,7 +54015,7 @@ program3.command("doctor").option("-g, --global", "Check global settings", false
53635
54015
  const meta3 = custom2 ? resolveHookMeta(name) : getHook(name);
53636
54016
  let hookHealthy = true;
53637
54017
  if (custom2) {
53638
- if (!existsSync21(custom2.scriptPath)) {
54018
+ if (!existsSync22(custom2.scriptPath)) {
53639
54019
  issues.push({ hook: name, issue: `Custom hook script missing: ${custom2.scriptPath}`, severity: "error" });
53640
54020
  hookHealthy = false;
53641
54021
  }
@@ -53646,15 +54026,15 @@ program3.command("doctor").option("-g, --global", "Check global settings", false
53646
54026
  continue;
53647
54027
  }
53648
54028
  const hookDir = getHookPath(name);
53649
- const hookScript = join44(hookDir, "src", "hook.ts");
53650
- if (!existsSync21(hookScript)) {
54029
+ const hookScript = join45(hookDir, "src", "hook.ts");
54030
+ if (!existsSync22(hookScript)) {
53651
54031
  issues.push({ hook: name, issue: "Missing src/hook.ts in package", severity: "error" });
53652
54032
  hookHealthy = false;
53653
54033
  }
53654
54034
  }
53655
54035
  if (meta3 && settingsExist) {
53656
54036
  try {
53657
- const settings = JSON.parse(readFileSync30(settingsPath, "utf-8"));
54037
+ const settings = JSON.parse(readFileSync31(settingsPath, "utf-8"));
53658
54038
  if (!hookRegisteredInSettings(settings, name, meta3.event, matcherFor(meta3, "claude"))) {
53659
54039
  const eventName = meta3.event.split(":")[0];
53660
54040
  issues.push({ hook: name, issue: `Not registered under correct event (${eventName})`, severity: "error" });
@@ -53857,10 +54237,10 @@ program3.command("docs").argument("[hook]", "Hook name (shows general docs if om
53857
54237
  return;
53858
54238
  }
53859
54239
  const hookPath = getHookPath(hook);
53860
- const readmePath = join44(hookPath, "README.md");
54240
+ const readmePath = join45(hookPath, "README.md");
53861
54241
  let readme = "";
53862
- if (existsSync21(readmePath)) {
53863
- readme = readFileSync30(readmePath, "utf-8");
54242
+ if (existsSync22(readmePath)) {
54243
+ readme = readFileSync31(readmePath, "utf-8");
53864
54244
  }
53865
54245
  if (options.json) {
53866
54246
  console.log(JSON.stringify({ ...meta3, readme }));
@@ -54059,9 +54439,9 @@ program3.command("profile-import").argument("<file>", "JSON file to import profi
54059
54439
  if (file2 === "-") {
54060
54440
  raw = await new Response(Bun.stdin.stream()).text();
54061
54441
  } else {
54062
- const { readFileSync: readFileSync31 } = await import("fs");
54442
+ const { readFileSync: readFileSync32 } = await import("fs");
54063
54443
  try {
54064
- raw = readFileSync31(file2, "utf-8");
54444
+ raw = readFileSync32(file2, "utf-8");
54065
54445
  } catch {
54066
54446
  if (options.json) {
54067
54447
  console.log(JSON.stringify({ error: `Cannot read file: ${file2}` }));
@@ -54372,8 +54752,8 @@ program3.command("selection <profile>").description("Read a hosted selection, or
54372
54752
  console.log(JSON.stringify(await client.selection(profile)));
54373
54753
  return;
54374
54754
  }
54375
- const { readFileSync: readFileSync31 } = await import("fs");
54376
- const body = JSON.parse(readFileSync31(options.file, "utf8"));
54755
+ const { readFileSync: readFileSync32 } = await import("fs");
54756
+ const body = JSON.parse(readFileSync32(options.file, "utf8"));
54377
54757
  if (!Number.isSafeInteger(body.expected_revision) || body.expected_revision < 0 || !body.hooks || Object.keys(body).some((k) => !["expected_revision", "hooks"].includes(k)))
54378
54758
  throw new Error("REGISTRY_SELECTION_INVALID");
54379
54759
  console.log(JSON.stringify(await client.select(profile, body.expected_revision, body.hooks)));
@@ -54388,15 +54768,15 @@ program3.command("sync").option("--selection-profile <name>", "Exact hosted sele
54388
54768
  const expectedRevision = options.expectedRevision === undefined ? undefined : Number(options.expectedRevision);
54389
54769
  if (expectedRevision !== undefined && (!Number.isSafeInteger(expectedRevision) || expectedRevision < 1))
54390
54770
  throw new Error("REGISTRY_REVISION_INVALID");
54391
- const plan2 = await syncHooks2({ dryRun: options.dryRun, selectionProfile: options.selectionProfile, expectedRevision });
54392
- const diff = plan2.diff;
54771
+ const plan3 = await syncHooks2({ dryRun: options.dryRun, selectionProfile: options.selectionProfile, expectedRevision });
54772
+ const diff = plan3.diff;
54393
54773
  if (options.json) {
54394
- console.log(JSON.stringify({ dry_run: plan2.dryRun, api_url: plan2.apiUrl ?? null, diff, selection: plan2.selection }));
54774
+ console.log(JSON.stringify({ dry_run: plan3.dryRun, api_url: plan3.apiUrl ?? null, diff, selection: plan3.selection }));
54395
54775
  return;
54396
54776
  }
54397
- const source = plan2.apiUrl ? plan2.apiUrl : "bundled registry";
54777
+ const source = plan3.apiUrl ? plan3.apiUrl : "bundled registry";
54398
54778
  console.log(chalk2.bold(`
54399
- Hook sync (${source})${plan2.dryRun ? " \u2014 dry run" : ""}
54779
+ Hook sync (${source})${plan3.dryRun ? " \u2014 dry run" : ""}
54400
54780
  `));
54401
54781
  if (diff.added.length > 0) {
54402
54782
  console.log(chalk2.green(` + ${diff.added.length} to add:`));
@@ -54412,7 +54792,7 @@ Hook sync (${source})${plan2.dryRun ? " \u2014 dry run" : ""}
54412
54792
  console.log(chalk2.dim(` - ${diff.skipped.length} not in remote lock (left untouched)`));
54413
54793
  }
54414
54794
  console.log(chalk2.dim(` = ${diff.unchanged.length} unchanged`));
54415
- if (plan2.dryRun)
54795
+ if (plan3.dryRun)
54416
54796
  console.log(chalk2.dim(`
54417
54797
  Dry run: nothing was written.`));
54418
54798
  else
@@ -54723,7 +55103,7 @@ safety.command("verify").requiredOption("--target <target>", "sumi, codex or cla
54723
55103
  throw new ClaudeSafetyError("settings_invalid");
54724
55104
  console.log(JSON.stringify(await verifyClaudeSafetyConfiguration({
54725
55105
  cwd: options.cwd,
54726
- ...process.env.CLAUDE_CONFIG_DIR ? { userSettingsPath: resolve33(process.env.CLAUDE_CONFIG_DIR, "settings.json") } : {}
55106
+ ...process.env.CLAUDE_CONFIG_DIR ? { userSettingsPath: resolve35(process.env.CLAUDE_CONFIG_DIR, "settings.json") } : {}
54727
55107
  })));
54728
55108
  } catch (error61) {
54729
55109
  console.log(JSON.stringify({ ok: false, target: "claude", code: error61 instanceof ClaudeSafetyError ? error61.code : "settings_invalid", nativeAdoptionVerified: false }));