@node9/proxy 1.24.1 → 1.24.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/cli.js +26 -13
  2. package/dist/cli.mjs +26 -13
  3. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -6478,20 +6478,33 @@ function printDaemonTip() {
6478
6478
  }
6479
6479
  function fullPathCommand(subcommand) {
6480
6480
  if (process.env.NODE9_TESTING === "1") return `node9 ${subcommand}`;
6481
- const nodeExec = process.execPath;
6482
- const cliScript = process.argv[1];
6483
- if (!cliScript.endsWith(".js")) return `${cliScript} ${subcommand}`;
6484
- return `${nodeExec} ${cliScript} ${subcommand}`;
6481
+ const nodeExec = toForwardSlashes(process.execPath);
6482
+ const cliScript = toForwardSlashes(process.argv[1]);
6483
+ if (!cliScript.endsWith(".js")) return `"${cliScript}" ${subcommand}`;
6484
+ return `"${nodeExec}" "${cliScript}" ${subcommand}`;
6485
+ }
6486
+ function toForwardSlashes(p) {
6487
+ return p.replace(/\\/g, "/");
6485
6488
  }
6486
6489
  function isStaleHookCommand(command) {
6487
6490
  if (!command) return false;
6488
- const tokens = command.split(/\s+/);
6491
+ const tokens = [];
6492
+ const re = /"([^"]*)"|(\S+)/g;
6493
+ let m;
6494
+ while ((m = re.exec(command)) !== null) tokens.push(m[1] ?? m[2] ?? "");
6489
6495
  for (const tok of tokens) {
6490
- if (!tok.startsWith("/")) continue;
6496
+ if (!tok.startsWith("/") && !/^[A-Za-z]:\//.test(tok)) continue;
6491
6497
  if (!import_fs13.default.existsSync(tok)) return true;
6492
6498
  }
6493
6499
  return false;
6494
6500
  }
6501
+ function isLegacyHookFormat(command) {
6502
+ if (!command) return false;
6503
+ return command.includes("\\");
6504
+ }
6505
+ function needsRewrite(command) {
6506
+ return isStaleHookCommand(command) || isLegacyHookFormat(command);
6507
+ }
6495
6508
  function readJson(filePath) {
6496
6509
  try {
6497
6510
  if (import_fs13.default.existsSync(filePath)) {
@@ -6508,7 +6521,7 @@ function writeJson(filePath, data) {
6508
6521
  }
6509
6522
  function isNode9Hook(cmd) {
6510
6523
  if (!cmd) return false;
6511
- return /(?:^|[\s/\\])node9 (?:check|log)/.test(cmd) || /(?:^|[\s/\\])cli\.js (?:check|log)/.test(cmd);
6524
+ return /(?:^|[\s/\\"])node9 (?:check|log)/.test(cmd) || /(?:^|[\s/\\"])cli\.js" (?:check|log)/.test(cmd) || /(?:^|[\s/\\])cli\.js (?:check|log)/.test(cmd);
6512
6525
  }
6513
6526
  function teardownClaude() {
6514
6527
  const homeDir2 = import_os12.default.homedir();
@@ -6664,7 +6677,7 @@ async function setupClaude() {
6664
6677
  for (const h of matcher.hooks) {
6665
6678
  const cmd = h.command ?? "";
6666
6679
  const isNode9 = cmd.includes("node9 check") || cmd.includes("cli.js check");
6667
- if (isNode9 && isStaleHookCommand(cmd)) {
6680
+ if (isNode9 && needsRewrite(cmd)) {
6668
6681
  h.command = fullPathCommand("check");
6669
6682
  console.log(import_chalk.default.yellow(" \u{1F527} PreToolUse hook repaired (stale path \u2192 current binary)"));
6670
6683
  hooksChanged = true;
@@ -6690,7 +6703,7 @@ async function setupClaude() {
6690
6703
  for (const h of matcher.hooks) {
6691
6704
  const cmd = h.command ?? "";
6692
6705
  const isNode9 = cmd.includes("node9 log") || cmd.includes("cli.js log");
6693
- if (isNode9 && isStaleHookCommand(cmd)) {
6706
+ if (isNode9 && needsRewrite(cmd)) {
6694
6707
  h.command = fullPathCommand("log");
6695
6708
  console.log(import_chalk.default.yellow(" \u{1F527} PostToolUse hook repaired (stale path \u2192 current binary)"));
6696
6709
  hooksChanged = true;
@@ -6715,7 +6728,7 @@ async function setupClaude() {
6715
6728
  for (const matcher of settings.hooks.UserPromptSubmit) {
6716
6729
  for (const h of matcher.hooks) {
6717
6730
  const cmd = h.command ?? "";
6718
- if (isNode9Hook(cmd) && isStaleHookCommand(cmd)) {
6731
+ if (isNode9Hook(cmd) && needsRewrite(cmd)) {
6719
6732
  h.command = fullPathCommand("check");
6720
6733
  console.log(
6721
6734
  import_chalk.default.yellow(" \u{1F527} UserPromptSubmit hook repaired (stale path \u2192 current binary)")
@@ -7034,7 +7047,7 @@ async function setupCodex() {
7034
7047
  } else {
7035
7048
  for (const h of existing.hooks) {
7036
7049
  const cmd = h.command ?? "";
7037
- if (isNode9Hook(cmd) && isStaleHookCommand(cmd)) {
7050
+ if (isNode9Hook(cmd) && needsRewrite(cmd)) {
7038
7051
  h.command = fullPathCommand("check");
7039
7052
  hooksChanged = true;
7040
7053
  }
@@ -7054,7 +7067,7 @@ async function setupCodex() {
7054
7067
  for (const m of hooksFile.hooks.UserPromptSubmit) {
7055
7068
  for (const h of m.hooks) {
7056
7069
  const cmd = h.command ?? "";
7057
- if (isNode9Hook(cmd) && isStaleHookCommand(cmd)) {
7070
+ if (isNode9Hook(cmd) && needsRewrite(cmd)) {
7058
7071
  h.command = fullPathCommand("check");
7059
7072
  hooksChanged = true;
7060
7073
  }
@@ -7075,7 +7088,7 @@ async function setupCodex() {
7075
7088
  for (const m of hooksFile.hooks.PostToolUse) {
7076
7089
  for (const h of m.hooks) {
7077
7090
  const cmd = h.command ?? "";
7078
- if (isNode9Hook(cmd) && isStaleHookCommand(cmd)) {
7091
+ if (isNode9Hook(cmd) && needsRewrite(cmd)) {
7079
7092
  h.command = fullPathCommand("log");
7080
7093
  hooksChanged = true;
7081
7094
  }
package/dist/cli.mjs CHANGED
@@ -6459,20 +6459,33 @@ function printDaemonTip() {
6459
6459
  }
6460
6460
  function fullPathCommand(subcommand) {
6461
6461
  if (process.env.NODE9_TESTING === "1") return `node9 ${subcommand}`;
6462
- const nodeExec = process.execPath;
6463
- const cliScript = process.argv[1];
6464
- if (!cliScript.endsWith(".js")) return `${cliScript} ${subcommand}`;
6465
- return `${nodeExec} ${cliScript} ${subcommand}`;
6462
+ const nodeExec = toForwardSlashes(process.execPath);
6463
+ const cliScript = toForwardSlashes(process.argv[1]);
6464
+ if (!cliScript.endsWith(".js")) return `"${cliScript}" ${subcommand}`;
6465
+ return `"${nodeExec}" "${cliScript}" ${subcommand}`;
6466
+ }
6467
+ function toForwardSlashes(p) {
6468
+ return p.replace(/\\/g, "/");
6466
6469
  }
6467
6470
  function isStaleHookCommand(command) {
6468
6471
  if (!command) return false;
6469
- const tokens = command.split(/\s+/);
6472
+ const tokens = [];
6473
+ const re = /"([^"]*)"|(\S+)/g;
6474
+ let m;
6475
+ while ((m = re.exec(command)) !== null) tokens.push(m[1] ?? m[2] ?? "");
6470
6476
  for (const tok of tokens) {
6471
- if (!tok.startsWith("/")) continue;
6477
+ if (!tok.startsWith("/") && !/^[A-Za-z]:\//.test(tok)) continue;
6472
6478
  if (!fs13.existsSync(tok)) return true;
6473
6479
  }
6474
6480
  return false;
6475
6481
  }
6482
+ function isLegacyHookFormat(command) {
6483
+ if (!command) return false;
6484
+ return command.includes("\\");
6485
+ }
6486
+ function needsRewrite(command) {
6487
+ return isStaleHookCommand(command) || isLegacyHookFormat(command);
6488
+ }
6476
6489
  function readJson(filePath) {
6477
6490
  try {
6478
6491
  if (fs13.existsSync(filePath)) {
@@ -6489,7 +6502,7 @@ function writeJson(filePath, data) {
6489
6502
  }
6490
6503
  function isNode9Hook(cmd) {
6491
6504
  if (!cmd) return false;
6492
- return /(?:^|[\s/\\])node9 (?:check|log)/.test(cmd) || /(?:^|[\s/\\])cli\.js (?:check|log)/.test(cmd);
6505
+ return /(?:^|[\s/\\"])node9 (?:check|log)/.test(cmd) || /(?:^|[\s/\\"])cli\.js" (?:check|log)/.test(cmd) || /(?:^|[\s/\\])cli\.js (?:check|log)/.test(cmd);
6493
6506
  }
6494
6507
  function teardownClaude() {
6495
6508
  const homeDir2 = os12.homedir();
@@ -6645,7 +6658,7 @@ async function setupClaude() {
6645
6658
  for (const h of matcher.hooks) {
6646
6659
  const cmd = h.command ?? "";
6647
6660
  const isNode9 = cmd.includes("node9 check") || cmd.includes("cli.js check");
6648
- if (isNode9 && isStaleHookCommand(cmd)) {
6661
+ if (isNode9 && needsRewrite(cmd)) {
6649
6662
  h.command = fullPathCommand("check");
6650
6663
  console.log(chalk.yellow(" \u{1F527} PreToolUse hook repaired (stale path \u2192 current binary)"));
6651
6664
  hooksChanged = true;
@@ -6671,7 +6684,7 @@ async function setupClaude() {
6671
6684
  for (const h of matcher.hooks) {
6672
6685
  const cmd = h.command ?? "";
6673
6686
  const isNode9 = cmd.includes("node9 log") || cmd.includes("cli.js log");
6674
- if (isNode9 && isStaleHookCommand(cmd)) {
6687
+ if (isNode9 && needsRewrite(cmd)) {
6675
6688
  h.command = fullPathCommand("log");
6676
6689
  console.log(chalk.yellow(" \u{1F527} PostToolUse hook repaired (stale path \u2192 current binary)"));
6677
6690
  hooksChanged = true;
@@ -6696,7 +6709,7 @@ async function setupClaude() {
6696
6709
  for (const matcher of settings.hooks.UserPromptSubmit) {
6697
6710
  for (const h of matcher.hooks) {
6698
6711
  const cmd = h.command ?? "";
6699
- if (isNode9Hook(cmd) && isStaleHookCommand(cmd)) {
6712
+ if (isNode9Hook(cmd) && needsRewrite(cmd)) {
6700
6713
  h.command = fullPathCommand("check");
6701
6714
  console.log(
6702
6715
  chalk.yellow(" \u{1F527} UserPromptSubmit hook repaired (stale path \u2192 current binary)")
@@ -7015,7 +7028,7 @@ async function setupCodex() {
7015
7028
  } else {
7016
7029
  for (const h of existing.hooks) {
7017
7030
  const cmd = h.command ?? "";
7018
- if (isNode9Hook(cmd) && isStaleHookCommand(cmd)) {
7031
+ if (isNode9Hook(cmd) && needsRewrite(cmd)) {
7019
7032
  h.command = fullPathCommand("check");
7020
7033
  hooksChanged = true;
7021
7034
  }
@@ -7035,7 +7048,7 @@ async function setupCodex() {
7035
7048
  for (const m of hooksFile.hooks.UserPromptSubmit) {
7036
7049
  for (const h of m.hooks) {
7037
7050
  const cmd = h.command ?? "";
7038
- if (isNode9Hook(cmd) && isStaleHookCommand(cmd)) {
7051
+ if (isNode9Hook(cmd) && needsRewrite(cmd)) {
7039
7052
  h.command = fullPathCommand("check");
7040
7053
  hooksChanged = true;
7041
7054
  }
@@ -7056,7 +7069,7 @@ async function setupCodex() {
7056
7069
  for (const m of hooksFile.hooks.PostToolUse) {
7057
7070
  for (const h of m.hooks) {
7058
7071
  const cmd = h.command ?? "";
7059
- if (isNode9Hook(cmd) && isStaleHookCommand(cmd)) {
7072
+ if (isNode9Hook(cmd) && needsRewrite(cmd)) {
7060
7073
  h.command = fullPathCommand("log");
7061
7074
  hooksChanged = true;
7062
7075
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@node9/proxy",
3
- "version": "1.24.1",
3
+ "version": "1.24.3",
4
4
  "description": "The Sudo Command for AI Agents. Execution Security for Claude Code & MCP.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",