claude-auto 0.15.0 → 0.16.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.
Files changed (35) hide show
  1. package/dist/bundle/scripts/auto-continue.js +52 -71
  2. package/dist/bundle/scripts/pre-tool-use.js +58 -77
  3. package/dist/bundle/scripts/session-start.js +45 -42
  4. package/dist/bundle/scripts/user-prompt-submit.js +45 -42
  5. package/dist/scripts/auto-continue.js +1 -2
  6. package/dist/scripts/auto-continue.js.map +1 -1
  7. package/dist/scripts/pre-tool-use.js +1 -2
  8. package/dist/scripts/pre-tool-use.js.map +1 -1
  9. package/dist/scripts/session-start.js +1 -2
  10. package/dist/scripts/session-start.js.map +1 -1
  11. package/dist/scripts/user-prompt-submit.js +1 -2
  12. package/dist/scripts/user-prompt-submit.js.map +1 -1
  13. package/dist/src/gitignore-manager.js +1 -1
  14. package/dist/src/gitignore-manager.js.map +1 -1
  15. package/dist/src/gitignore-manager.test.js +1 -1
  16. package/dist/src/gitignore-manager.test.js.map +1 -1
  17. package/dist/src/hook-state.d.ts +1 -6
  18. package/dist/src/hook-state.d.ts.map +1 -1
  19. package/dist/src/hook-state.js +3 -25
  20. package/dist/src/hook-state.js.map +1 -1
  21. package/dist/src/hook-state.test.js +24 -46
  22. package/dist/src/hook-state.test.js.map +1 -1
  23. package/dist/src/path-resolver.d.ts +1 -0
  24. package/dist/src/path-resolver.d.ts.map +1 -1
  25. package/dist/src/path-resolver.js +5 -0
  26. package/dist/src/path-resolver.js.map +1 -1
  27. package/dist/src/path-resolver.test.d.ts +2 -0
  28. package/dist/src/path-resolver.test.d.ts.map +1 -0
  29. package/dist/src/path-resolver.test.js +22 -0
  30. package/dist/src/path-resolver.test.js.map +1 -0
  31. package/package.json +1 -1
  32. package/scripts/auto-continue.ts +2 -3
  33. package/scripts/pre-tool-use.ts +2 -3
  34. package/scripts/session-start.ts +2 -3
  35. package/scripts/user-prompt-submit.ts +2 -3
@@ -30,7 +30,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
30
30
  var require_resolve_from = __commonJS({
31
31
  "node_modules/.pnpm/resolve-from@4.0.0/node_modules/resolve-from/index.js"(exports2, module2) {
32
32
  "use strict";
33
- var path6 = require("path");
33
+ var path5 = require("path");
34
34
  var Module = require("module");
35
35
  var fs5 = require("fs");
36
36
  var resolveFrom = (fromDir, moduleId, silent) => {
@@ -44,14 +44,14 @@ var require_resolve_from = __commonJS({
44
44
  fromDir = fs5.realpathSync(fromDir);
45
45
  } catch (err) {
46
46
  if (err.code === "ENOENT") {
47
- fromDir = path6.resolve(fromDir);
47
+ fromDir = path5.resolve(fromDir);
48
48
  } else if (silent) {
49
49
  return null;
50
50
  } else {
51
51
  throw err;
52
52
  }
53
53
  }
54
- const fromFile = path6.join(fromDir, "noop.js");
54
+ const fromFile = path5.join(fromDir, "noop.js");
55
55
  const resolveFileName = () => Module._resolveFilename(moduleId, {
56
56
  id: fromFile,
57
57
  filename: fromFile,
@@ -123,7 +123,7 @@ var require_parent_module = __commonJS({
123
123
  var require_import_fresh = __commonJS({
124
124
  "node_modules/.pnpm/import-fresh@3.3.1/node_modules/import-fresh/index.js"(exports2, module2) {
125
125
  "use strict";
126
- var path6 = require("path");
126
+ var path5 = require("path");
127
127
  var resolveFrom = require_resolve_from();
128
128
  var parentModule = require_parent_module();
129
129
  module2.exports = (moduleId) => {
@@ -131,7 +131,7 @@ var require_import_fresh = __commonJS({
131
131
  throw new TypeError("Expected a string");
132
132
  }
133
133
  const parentPath = parentModule(__filename);
134
- const cwd = parentPath ? path6.dirname(parentPath) : __dirname;
134
+ const cwd = parentPath ? path5.dirname(parentPath) : __dirname;
135
135
  const filePath = resolveFrom(cwd, moduleId);
136
136
  const oldModule = require.cache[filePath];
137
137
  if (oldModule && oldModule.parent) {
@@ -3889,7 +3889,7 @@ ${error.message}`;
3889
3889
  return typescript.sys.fileExists(fileName);
3890
3890
  });
3891
3891
  if (filePath !== void 0) {
3892
- const { config, error } = typescript.readConfigFile(filePath, (path6) => typescript.sys.readFile(path6));
3892
+ const { config, error } = typescript.readConfigFile(filePath, (path5) => typescript.sys.readFile(path5));
3893
3893
  if (error) {
3894
3894
  throw new Error(`Error in ${filePath}: ${error.messageText.toString()}`);
3895
3895
  }
@@ -4012,42 +4012,42 @@ var require_defaults = __commonJS({
4012
4012
  var require_env_paths = __commonJS({
4013
4013
  "node_modules/.pnpm/env-paths@2.2.1/node_modules/env-paths/index.js"(exports2, module2) {
4014
4014
  "use strict";
4015
- var path6 = require("path");
4015
+ var path5 = require("path");
4016
4016
  var os = require("os");
4017
4017
  var homedir = os.homedir();
4018
4018
  var tmpdir = os.tmpdir();
4019
4019
  var { env } = process;
4020
4020
  var macos = (name) => {
4021
- const library = path6.join(homedir, "Library");
4021
+ const library = path5.join(homedir, "Library");
4022
4022
  return {
4023
- data: path6.join(library, "Application Support", name),
4024
- config: path6.join(library, "Preferences", name),
4025
- cache: path6.join(library, "Caches", name),
4026
- log: path6.join(library, "Logs", name),
4027
- temp: path6.join(tmpdir, name)
4023
+ data: path5.join(library, "Application Support", name),
4024
+ config: path5.join(library, "Preferences", name),
4025
+ cache: path5.join(library, "Caches", name),
4026
+ log: path5.join(library, "Logs", name),
4027
+ temp: path5.join(tmpdir, name)
4028
4028
  };
4029
4029
  };
4030
4030
  var windows = (name) => {
4031
- const appData = env.APPDATA || path6.join(homedir, "AppData", "Roaming");
4032
- const localAppData = env.LOCALAPPDATA || path6.join(homedir, "AppData", "Local");
4031
+ const appData = env.APPDATA || path5.join(homedir, "AppData", "Roaming");
4032
+ const localAppData = env.LOCALAPPDATA || path5.join(homedir, "AppData", "Local");
4033
4033
  return {
4034
4034
  // Data/config/cache/log are invented by me as Windows isn't opinionated about this
4035
- data: path6.join(localAppData, name, "Data"),
4036
- config: path6.join(appData, name, "Config"),
4037
- cache: path6.join(localAppData, name, "Cache"),
4038
- log: path6.join(localAppData, name, "Log"),
4039
- temp: path6.join(tmpdir, name)
4035
+ data: path5.join(localAppData, name, "Data"),
4036
+ config: path5.join(appData, name, "Config"),
4037
+ cache: path5.join(localAppData, name, "Cache"),
4038
+ log: path5.join(localAppData, name, "Log"),
4039
+ temp: path5.join(tmpdir, name)
4040
4040
  };
4041
4041
  };
4042
4042
  var linux = (name) => {
4043
- const username = path6.basename(homedir);
4043
+ const username = path5.basename(homedir);
4044
4044
  return {
4045
- data: path6.join(env.XDG_DATA_HOME || path6.join(homedir, ".local", "share"), name),
4046
- config: path6.join(env.XDG_CONFIG_HOME || path6.join(homedir, ".config"), name),
4047
- cache: path6.join(env.XDG_CACHE_HOME || path6.join(homedir, ".cache"), name),
4045
+ data: path5.join(env.XDG_DATA_HOME || path5.join(homedir, ".local", "share"), name),
4046
+ config: path5.join(env.XDG_CONFIG_HOME || path5.join(homedir, ".config"), name),
4047
+ cache: path5.join(env.XDG_CACHE_HOME || path5.join(homedir, ".cache"), name),
4048
4048
  // https://wiki.debian.org/XDGBaseDirectorySpecification#state
4049
- log: path6.join(env.XDG_STATE_HOME || path6.join(homedir, ".local", "state"), name),
4050
- temp: path6.join(tmpdir, username, name)
4049
+ log: path5.join(env.XDG_STATE_HOME || path5.join(homedir, ".local", "state"), name),
4050
+ temp: path5.join(tmpdir, username, name)
4051
4051
  };
4052
4052
  };
4053
4053
  var envPaths = (name, options) => {
@@ -4115,11 +4115,11 @@ var require_util = __commonJS({
4115
4115
  return result;
4116
4116
  }
4117
4117
  exports2.emplace = emplace;
4118
- function getPropertyByPath(source, path6) {
4119
- if (typeof path6 === "string" && Object.prototype.hasOwnProperty.call(source, path6)) {
4120
- return source[path6];
4118
+ function getPropertyByPath(source, path5) {
4119
+ if (typeof path5 === "string" && Object.prototype.hasOwnProperty.call(source, path5)) {
4120
+ return source[path5];
4121
4121
  }
4122
- const parsedPath = typeof path6 === "string" ? path6.split(".") : path6;
4122
+ const parsedPath = typeof path5 === "string" ? path5.split(".") : path5;
4123
4123
  return parsedPath.reduce((previous, key) => {
4124
4124
  if (previous === void 0) {
4125
4125
  return previous;
@@ -4132,9 +4132,9 @@ var require_util = __commonJS({
4132
4132
  return Object.fromEntries(Object.entries(options).filter(([, value]) => value !== void 0));
4133
4133
  }
4134
4134
  exports2.removeUndefinedValuesFromObject = removeUndefinedValuesFromObject;
4135
- async function isDirectory(path6) {
4135
+ async function isDirectory(path5) {
4136
4136
  try {
4137
- const stat = await fs_1.promises.stat(path6);
4137
+ const stat = await fs_1.promises.stat(path5);
4138
4138
  return stat.isDirectory();
4139
4139
  } catch (e) {
4140
4140
  if (e.code === "ENOENT") {
@@ -4144,9 +4144,9 @@ var require_util = __commonJS({
4144
4144
  }
4145
4145
  }
4146
4146
  exports2.isDirectory = isDirectory;
4147
- function isDirectorySync(path6) {
4147
+ function isDirectorySync(path5) {
4148
4148
  try {
4149
- const stat = fs_1.default.statSync(path6);
4149
+ const stat = fs_1.default.statSync(path5);
4150
4150
  return stat.isDirectory();
4151
4151
  } catch (e) {
4152
4152
  if (e.code === "ENOENT") {
@@ -4244,7 +4244,7 @@ var require_ExplorerBase = __commonJS({
4244
4244
  const idx = importStack.indexOf(fullPath);
4245
4245
  if (idx !== -1) {
4246
4246
  throw new Error(`Circular import detected:
4247
- ${[...importStack, fullPath].map((path6, i) => `${i + 1}. ${path6}`).join("\n")} (same as ${idx + 1}.)`);
4247
+ ${[...importStack, fullPath].map((path5, i) => `${i + 1}. ${path5}`).join("\n")} (same as ${idx + 1}.)`);
4248
4248
  }
4249
4249
  }
4250
4250
  }
@@ -4429,9 +4429,9 @@ var require_Explorer = __commonJS({
4429
4429
  throw error;
4430
4430
  }
4431
4431
  }
4432
- async #fileExists(path6) {
4432
+ async #fileExists(path5) {
4433
4433
  try {
4434
- await promises_1.default.stat(path6);
4434
+ await promises_1.default.stat(path5);
4435
4435
  return true;
4436
4436
  } catch (e) {
4437
4437
  return false;
@@ -4587,9 +4587,9 @@ var require_ExplorerSync = __commonJS({
4587
4587
  throw error;
4588
4588
  }
4589
4589
  }
4590
- #fileExists(path6) {
4590
+ #fileExists(path5) {
4591
4591
  try {
4592
- fs_1.default.statSync(path6);
4592
+ fs_1.default.statSync(path5);
4593
4593
  return true;
4594
4594
  } catch (e) {
4595
4595
  return false;
@@ -4709,7 +4709,7 @@ var require_dist = __commonJS({
4709
4709
  };
4710
4710
  }
4711
4711
  function getResolvedSearchPlaces(moduleName, toolDefinedSearchPlaces, userConfiguredOptions) {
4712
- const userConfiguredSearchPlaces = userConfiguredOptions.searchPlaces?.map((path6) => path6.replace("{name}", moduleName));
4712
+ const userConfiguredSearchPlaces = userConfiguredOptions.searchPlaces?.map((path5) => path5.replace("{name}", moduleName));
4713
4713
  if (userConfiguredOptions.mergeSearchPlaces) {
4714
4714
  return [...userConfiguredSearchPlaces ?? [], ...toolDefinedSearchPlaces];
4715
4715
  }
@@ -4808,7 +4808,6 @@ var require_dist = __commonJS({
4808
4808
 
4809
4809
  // scripts/auto-continue.ts
4810
4810
  var fs4 = __toESM(require("node:fs"));
4811
- var path5 = __toESM(require("node:path"));
4812
4811
 
4813
4812
  // src/activity-logger.ts
4814
4813
  var import_node_fs = __toESM(require("node:fs"));
@@ -4916,7 +4915,6 @@ var DEFAULT_HOOK_STATE = {
4916
4915
  autoContinue: {
4917
4916
  mode: "smart",
4918
4917
  maxIterations: 0,
4919
- iteration: 0,
4920
4918
  skipModes: ["plan"]
4921
4919
  },
4922
4920
  validateCommit: {
@@ -4934,9 +4932,7 @@ var DEFAULT_HOOK_STATE = {
4934
4932
  validateCommitOnExplore: false,
4935
4933
  validateCommitOnWork: true,
4936
4934
  validateCommitOnUnknown: true
4937
- },
4938
- updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
4939
- updatedBy: "default"
4935
+ }
4940
4936
  };
4941
4937
  function createHookState(autoDir) {
4942
4938
  if (!fs3.existsSync(autoDir)) {
@@ -4945,10 +4941,9 @@ function createHookState(autoDir) {
4945
4941
  const stateFile = path3.join(autoDir, ".claude.hooks.json");
4946
4942
  function read() {
4947
4943
  if (!fs3.existsSync(stateFile)) {
4948
- const state = { ...DEFAULT_HOOK_STATE, updatedAt: (/* @__PURE__ */ new Date()).toISOString(), updatedBy: "init" };
4949
- fs3.writeFileSync(stateFile, `${JSON.stringify(state, null, 2)}
4944
+ fs3.writeFileSync(stateFile, `${JSON.stringify(DEFAULT_HOOK_STATE, null, 2)}
4950
4945
  `);
4951
- return state;
4946
+ return { ...DEFAULT_HOOK_STATE };
4952
4947
  }
4953
4948
  const content = fs3.readFileSync(stateFile, "utf-8");
4954
4949
  const partial = JSON.parse(content);
@@ -4957,17 +4952,14 @@ function createHookState(autoDir) {
4957
4952
  validateCommit: { ...DEFAULT_HOOK_STATE.validateCommit, ...partial.validateCommit },
4958
4953
  denyList: { ...DEFAULT_HOOK_STATE.denyList, ...partial.denyList },
4959
4954
  promptReminder: { ...DEFAULT_HOOK_STATE.promptReminder, ...partial.promptReminder },
4960
- subagentHooks: { ...DEFAULT_HOOK_STATE.subagentHooks, ...partial.subagentHooks },
4961
- updatedAt: partial.updatedAt ?? DEFAULT_HOOK_STATE.updatedAt,
4962
- updatedBy: partial.updatedBy
4955
+ subagentHooks: { ...DEFAULT_HOOK_STATE.subagentHooks, ...partial.subagentHooks }
4963
4956
  };
4964
4957
  }
4965
4958
  function write(state) {
4966
- state.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
4967
4959
  fs3.writeFileSync(stateFile, `${JSON.stringify(state, null, 2)}
4968
4960
  `);
4969
4961
  }
4970
- function update(updates, updatedBy) {
4962
+ function update(updates) {
4971
4963
  const current = read();
4972
4964
  const newState = {
4973
4965
  ...current,
@@ -4976,30 +4968,15 @@ function createHookState(autoDir) {
4976
4968
  validateCommit: { ...current.validateCommit, ...updates.validateCommit },
4977
4969
  denyList: { ...current.denyList, ...updates.denyList },
4978
4970
  promptReminder: { ...current.promptReminder, ...updates.promptReminder },
4979
- subagentHooks: { ...current.subagentHooks, ...updates.subagentHooks },
4980
- updatedBy: updatedBy ?? "unknown",
4981
- updatedAt: current.updatedAt
4971
+ subagentHooks: { ...current.subagentHooks, ...updates.subagentHooks }
4982
4972
  };
4983
4973
  write(newState);
4984
4974
  return newState;
4985
4975
  }
4986
- function incrementIteration() {
4987
- const state = read();
4988
- state.autoContinue.iteration = state.autoContinue.iteration + 1;
4989
- write(state);
4990
- return state.autoContinue.iteration;
4991
- }
4992
- function resetIteration() {
4993
- const state = read();
4994
- state.autoContinue.iteration = 0;
4995
- write(state);
4996
- }
4997
4976
  return {
4998
4977
  read,
4999
4978
  write,
5000
- update,
5001
- incrementIteration,
5002
- resetIteration
4979
+ update
5003
4980
  };
5004
4981
  }
5005
4982
 
@@ -5034,6 +5011,10 @@ async function loadConfig(searchFrom) {
5034
5011
  }
5035
5012
 
5036
5013
  // src/path-resolver.ts
5014
+ function resolveClaudeDirFromScript(scriptDir) {
5015
+ const projectRoot = path4.resolve(scriptDir, "..", "..");
5016
+ return path4.join(projectRoot, ".claude");
5017
+ }
5037
5018
  async function resolvePaths(claudeDir2) {
5038
5019
  const projectRoot = path4.dirname(claudeDir2);
5039
5020
  const config = await loadConfig(projectRoot);
@@ -5049,7 +5030,7 @@ async function resolvePaths(claudeDir2) {
5049
5030
  }
5050
5031
 
5051
5032
  // scripts/auto-continue.ts
5052
- var claudeDir = path5.resolve(process.cwd(), ".claude");
5033
+ var claudeDir = resolveClaudeDirFromScript(__dirname);
5053
5034
  var stdin = fs4.readFileSync(0, "utf8").trim();
5054
5035
  if (!stdin) {
5055
5036
  process.exit(0);
@@ -1112,7 +1112,7 @@ var require_braces = __commonJS({
1112
1112
  var require_constants2 = __commonJS({
1113
1113
  "node_modules/.pnpm/picomatch@2.3.1/node_modules/picomatch/lib/constants.js"(exports2, module2) {
1114
1114
  "use strict";
1115
- var path10 = require("path");
1115
+ var path9 = require("path");
1116
1116
  var WIN_SLASH = "\\\\/";
1117
1117
  var WIN_NO_SLASH = `[^${WIN_SLASH}]`;
1118
1118
  var DOT_LITERAL = "\\.";
@@ -1282,7 +1282,7 @@ var require_constants2 = __commonJS({
1282
1282
  /* | */
1283
1283
  CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
1284
1284
  /* \uFEFF */
1285
- SEP: path10.sep,
1285
+ SEP: path9.sep,
1286
1286
  /**
1287
1287
  * Create EXTGLOB_CHARS
1288
1288
  */
@@ -1309,7 +1309,7 @@ var require_constants2 = __commonJS({
1309
1309
  var require_utils2 = __commonJS({
1310
1310
  "node_modules/.pnpm/picomatch@2.3.1/node_modules/picomatch/lib/utils.js"(exports2) {
1311
1311
  "use strict";
1312
- var path10 = require("path");
1312
+ var path9 = require("path");
1313
1313
  var win32 = process.platform === "win32";
1314
1314
  var {
1315
1315
  REGEX_BACKSLASH,
@@ -1338,7 +1338,7 @@ var require_utils2 = __commonJS({
1338
1338
  if (options2 && typeof options2.windows === "boolean") {
1339
1339
  return options2.windows;
1340
1340
  }
1341
- return win32 === true || path10.sep === "\\";
1341
+ return win32 === true || path9.sep === "\\";
1342
1342
  };
1343
1343
  exports2.escapeLast = (input2, char, lastIdx) => {
1344
1344
  const idx = input2.lastIndexOf(char, lastIdx);
@@ -2473,7 +2473,7 @@ var require_parse2 = __commonJS({
2473
2473
  var require_picomatch = __commonJS({
2474
2474
  "node_modules/.pnpm/picomatch@2.3.1/node_modules/picomatch/lib/picomatch.js"(exports2, module2) {
2475
2475
  "use strict";
2476
- var path10 = require("path");
2476
+ var path9 = require("path");
2477
2477
  var scan = require_scan();
2478
2478
  var parse2 = require_parse2();
2479
2479
  var utils = require_utils2();
@@ -2558,7 +2558,7 @@ var require_picomatch = __commonJS({
2558
2558
  };
2559
2559
  picomatch.matchBase = (input2, glob, options2, posix = utils.isWindows(options2)) => {
2560
2560
  const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options2);
2561
- return regex.test(path10.basename(input2));
2561
+ return regex.test(path9.basename(input2));
2562
2562
  };
2563
2563
  picomatch.isMatch = (str2, patterns, options2) => picomatch(patterns, options2)(str2);
2564
2564
  picomatch.parse = (pattern, options2) => {
@@ -2783,7 +2783,7 @@ var require_micromatch = __commonJS({
2783
2783
  var require_resolve_from = __commonJS({
2784
2784
  "node_modules/.pnpm/resolve-from@4.0.0/node_modules/resolve-from/index.js"(exports2, module2) {
2785
2785
  "use strict";
2786
- var path10 = require("path");
2786
+ var path9 = require("path");
2787
2787
  var Module = require("module");
2788
2788
  var fs9 = require("fs");
2789
2789
  var resolveFrom = (fromDir, moduleId, silent) => {
@@ -2797,14 +2797,14 @@ var require_resolve_from = __commonJS({
2797
2797
  fromDir = fs9.realpathSync(fromDir);
2798
2798
  } catch (err) {
2799
2799
  if (err.code === "ENOENT") {
2800
- fromDir = path10.resolve(fromDir);
2800
+ fromDir = path9.resolve(fromDir);
2801
2801
  } else if (silent) {
2802
2802
  return null;
2803
2803
  } else {
2804
2804
  throw err;
2805
2805
  }
2806
2806
  }
2807
- const fromFile = path10.join(fromDir, "noop.js");
2807
+ const fromFile = path9.join(fromDir, "noop.js");
2808
2808
  const resolveFileName = () => Module._resolveFilename(moduleId, {
2809
2809
  id: fromFile,
2810
2810
  filename: fromFile,
@@ -2876,7 +2876,7 @@ var require_parent_module = __commonJS({
2876
2876
  var require_import_fresh = __commonJS({
2877
2877
  "node_modules/.pnpm/import-fresh@3.3.1/node_modules/import-fresh/index.js"(exports2, module2) {
2878
2878
  "use strict";
2879
- var path10 = require("path");
2879
+ var path9 = require("path");
2880
2880
  var resolveFrom = require_resolve_from();
2881
2881
  var parentModule = require_parent_module();
2882
2882
  module2.exports = (moduleId) => {
@@ -2884,7 +2884,7 @@ var require_import_fresh = __commonJS({
2884
2884
  throw new TypeError("Expected a string");
2885
2885
  }
2886
2886
  const parentPath = parentModule(__filename);
2887
- const cwd = parentPath ? path10.dirname(parentPath) : __dirname;
2887
+ const cwd = parentPath ? path9.dirname(parentPath) : __dirname;
2888
2888
  const filePath = resolveFrom(cwd, moduleId);
2889
2889
  const oldModule = require.cache[filePath];
2890
2890
  if (oldModule && oldModule.parent) {
@@ -6642,7 +6642,7 @@ ${error.message}`;
6642
6642
  return typescript.sys.fileExists(fileName);
6643
6643
  });
6644
6644
  if (filePath !== void 0) {
6645
- const { config, error } = typescript.readConfigFile(filePath, (path10) => typescript.sys.readFile(path10));
6645
+ const { config, error } = typescript.readConfigFile(filePath, (path9) => typescript.sys.readFile(path9));
6646
6646
  if (error) {
6647
6647
  throw new Error(`Error in ${filePath}: ${error.messageText.toString()}`);
6648
6648
  }
@@ -6765,42 +6765,42 @@ var require_defaults = __commonJS({
6765
6765
  var require_env_paths = __commonJS({
6766
6766
  "node_modules/.pnpm/env-paths@2.2.1/node_modules/env-paths/index.js"(exports2, module2) {
6767
6767
  "use strict";
6768
- var path10 = require("path");
6768
+ var path9 = require("path");
6769
6769
  var os = require("os");
6770
6770
  var homedir = os.homedir();
6771
6771
  var tmpdir = os.tmpdir();
6772
6772
  var { env } = process;
6773
6773
  var macos = (name) => {
6774
- const library = path10.join(homedir, "Library");
6774
+ const library = path9.join(homedir, "Library");
6775
6775
  return {
6776
- data: path10.join(library, "Application Support", name),
6777
- config: path10.join(library, "Preferences", name),
6778
- cache: path10.join(library, "Caches", name),
6779
- log: path10.join(library, "Logs", name),
6780
- temp: path10.join(tmpdir, name)
6776
+ data: path9.join(library, "Application Support", name),
6777
+ config: path9.join(library, "Preferences", name),
6778
+ cache: path9.join(library, "Caches", name),
6779
+ log: path9.join(library, "Logs", name),
6780
+ temp: path9.join(tmpdir, name)
6781
6781
  };
6782
6782
  };
6783
6783
  var windows = (name) => {
6784
- const appData = env.APPDATA || path10.join(homedir, "AppData", "Roaming");
6785
- const localAppData = env.LOCALAPPDATA || path10.join(homedir, "AppData", "Local");
6784
+ const appData = env.APPDATA || path9.join(homedir, "AppData", "Roaming");
6785
+ const localAppData = env.LOCALAPPDATA || path9.join(homedir, "AppData", "Local");
6786
6786
  return {
6787
6787
  // Data/config/cache/log are invented by me as Windows isn't opinionated about this
6788
- data: path10.join(localAppData, name, "Data"),
6789
- config: path10.join(appData, name, "Config"),
6790
- cache: path10.join(localAppData, name, "Cache"),
6791
- log: path10.join(localAppData, name, "Log"),
6792
- temp: path10.join(tmpdir, name)
6788
+ data: path9.join(localAppData, name, "Data"),
6789
+ config: path9.join(appData, name, "Config"),
6790
+ cache: path9.join(localAppData, name, "Cache"),
6791
+ log: path9.join(localAppData, name, "Log"),
6792
+ temp: path9.join(tmpdir, name)
6793
6793
  };
6794
6794
  };
6795
6795
  var linux = (name) => {
6796
- const username = path10.basename(homedir);
6796
+ const username = path9.basename(homedir);
6797
6797
  return {
6798
- data: path10.join(env.XDG_DATA_HOME || path10.join(homedir, ".local", "share"), name),
6799
- config: path10.join(env.XDG_CONFIG_HOME || path10.join(homedir, ".config"), name),
6800
- cache: path10.join(env.XDG_CACHE_HOME || path10.join(homedir, ".cache"), name),
6798
+ data: path9.join(env.XDG_DATA_HOME || path9.join(homedir, ".local", "share"), name),
6799
+ config: path9.join(env.XDG_CONFIG_HOME || path9.join(homedir, ".config"), name),
6800
+ cache: path9.join(env.XDG_CACHE_HOME || path9.join(homedir, ".cache"), name),
6801
6801
  // https://wiki.debian.org/XDGBaseDirectorySpecification#state
6802
- log: path10.join(env.XDG_STATE_HOME || path10.join(homedir, ".local", "state"), name),
6803
- temp: path10.join(tmpdir, username, name)
6802
+ log: path9.join(env.XDG_STATE_HOME || path9.join(homedir, ".local", "state"), name),
6803
+ temp: path9.join(tmpdir, username, name)
6804
6804
  };
6805
6805
  };
6806
6806
  var envPaths = (name, options2) => {
@@ -6868,11 +6868,11 @@ var require_util = __commonJS({
6868
6868
  return result;
6869
6869
  }
6870
6870
  exports2.emplace = emplace;
6871
- function getPropertyByPath(source, path10) {
6872
- if (typeof path10 === "string" && Object.prototype.hasOwnProperty.call(source, path10)) {
6873
- return source[path10];
6871
+ function getPropertyByPath(source, path9) {
6872
+ if (typeof path9 === "string" && Object.prototype.hasOwnProperty.call(source, path9)) {
6873
+ return source[path9];
6874
6874
  }
6875
- const parsedPath = typeof path10 === "string" ? path10.split(".") : path10;
6875
+ const parsedPath = typeof path9 === "string" ? path9.split(".") : path9;
6876
6876
  return parsedPath.reduce((previous, key) => {
6877
6877
  if (previous === void 0) {
6878
6878
  return previous;
@@ -6885,9 +6885,9 @@ var require_util = __commonJS({
6885
6885
  return Object.fromEntries(Object.entries(options2).filter(([, value]) => value !== void 0));
6886
6886
  }
6887
6887
  exports2.removeUndefinedValuesFromObject = removeUndefinedValuesFromObject;
6888
- async function isDirectory(path10) {
6888
+ async function isDirectory(path9) {
6889
6889
  try {
6890
- const stat = await fs_1.promises.stat(path10);
6890
+ const stat = await fs_1.promises.stat(path9);
6891
6891
  return stat.isDirectory();
6892
6892
  } catch (e) {
6893
6893
  if (e.code === "ENOENT") {
@@ -6897,9 +6897,9 @@ var require_util = __commonJS({
6897
6897
  }
6898
6898
  }
6899
6899
  exports2.isDirectory = isDirectory;
6900
- function isDirectorySync(path10) {
6900
+ function isDirectorySync(path9) {
6901
6901
  try {
6902
- const stat = fs_1.default.statSync(path10);
6902
+ const stat = fs_1.default.statSync(path9);
6903
6903
  return stat.isDirectory();
6904
6904
  } catch (e) {
6905
6905
  if (e.code === "ENOENT") {
@@ -6997,7 +6997,7 @@ var require_ExplorerBase = __commonJS({
6997
6997
  const idx = importStack.indexOf(fullPath);
6998
6998
  if (idx !== -1) {
6999
6999
  throw new Error(`Circular import detected:
7000
- ${[...importStack, fullPath].map((path10, i) => `${i + 1}. ${path10}`).join("\n")} (same as ${idx + 1}.)`);
7000
+ ${[...importStack, fullPath].map((path9, i) => `${i + 1}. ${path9}`).join("\n")} (same as ${idx + 1}.)`);
7001
7001
  }
7002
7002
  }
7003
7003
  }
@@ -7182,9 +7182,9 @@ var require_Explorer = __commonJS({
7182
7182
  throw error;
7183
7183
  }
7184
7184
  }
7185
- async #fileExists(path10) {
7185
+ async #fileExists(path9) {
7186
7186
  try {
7187
- await promises_1.default.stat(path10);
7187
+ await promises_1.default.stat(path9);
7188
7188
  return true;
7189
7189
  } catch (e) {
7190
7190
  return false;
@@ -7340,9 +7340,9 @@ var require_ExplorerSync = __commonJS({
7340
7340
  throw error;
7341
7341
  }
7342
7342
  }
7343
- #fileExists(path10) {
7343
+ #fileExists(path9) {
7344
7344
  try {
7345
- fs_1.default.statSync(path10);
7345
+ fs_1.default.statSync(path9);
7346
7346
  return true;
7347
7347
  } catch (e) {
7348
7348
  return false;
@@ -7462,7 +7462,7 @@ var require_dist = __commonJS({
7462
7462
  };
7463
7463
  }
7464
7464
  function getResolvedSearchPlaces(moduleName, toolDefinedSearchPlaces, userConfiguredOptions) {
7465
- const userConfiguredSearchPlaces = userConfiguredOptions.searchPlaces?.map((path10) => path10.replace("{name}", moduleName));
7465
+ const userConfiguredSearchPlaces = userConfiguredOptions.searchPlaces?.map((path9) => path9.replace("{name}", moduleName));
7466
7466
  if (userConfiguredOptions.mergeSearchPlaces) {
7467
7467
  return [...userConfiguredSearchPlaces ?? [], ...toolDefinedSearchPlaces];
7468
7468
  }
@@ -11044,7 +11044,6 @@ var require_gray_matter = __commonJS({
11044
11044
 
11045
11045
  // scripts/pre-tool-use.ts
11046
11046
  var fs8 = __toESM(require("node:fs"));
11047
- var path9 = __toESM(require("node:path"));
11048
11047
 
11049
11048
  // src/activity-logger.ts
11050
11049
  var import_node_fs = __toESM(require("node:fs"));
@@ -11385,7 +11384,6 @@ var DEFAULT_HOOK_STATE = {
11385
11384
  autoContinue: {
11386
11385
  mode: "smart",
11387
11386
  maxIterations: 0,
11388
- iteration: 0,
11389
11387
  skipModes: ["plan"]
11390
11388
  },
11391
11389
  validateCommit: {
@@ -11403,9 +11401,7 @@ var DEFAULT_HOOK_STATE = {
11403
11401
  validateCommitOnExplore: false,
11404
11402
  validateCommitOnWork: true,
11405
11403
  validateCommitOnUnknown: true
11406
- },
11407
- updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
11408
- updatedBy: "default"
11404
+ }
11409
11405
  };
11410
11406
  function createHookState(autoDir) {
11411
11407
  if (!fs5.existsSync(autoDir)) {
@@ -11414,10 +11410,9 @@ function createHookState(autoDir) {
11414
11410
  const stateFile = path5.join(autoDir, ".claude.hooks.json");
11415
11411
  function read() {
11416
11412
  if (!fs5.existsSync(stateFile)) {
11417
- const state = { ...DEFAULT_HOOK_STATE, updatedAt: (/* @__PURE__ */ new Date()).toISOString(), updatedBy: "init" };
11418
- fs5.writeFileSync(stateFile, `${JSON.stringify(state, null, 2)}
11413
+ fs5.writeFileSync(stateFile, `${JSON.stringify(DEFAULT_HOOK_STATE, null, 2)}
11419
11414
  `);
11420
- return state;
11415
+ return { ...DEFAULT_HOOK_STATE };
11421
11416
  }
11422
11417
  const content = fs5.readFileSync(stateFile, "utf-8");
11423
11418
  const partial = JSON.parse(content);
@@ -11426,17 +11421,14 @@ function createHookState(autoDir) {
11426
11421
  validateCommit: { ...DEFAULT_HOOK_STATE.validateCommit, ...partial.validateCommit },
11427
11422
  denyList: { ...DEFAULT_HOOK_STATE.denyList, ...partial.denyList },
11428
11423
  promptReminder: { ...DEFAULT_HOOK_STATE.promptReminder, ...partial.promptReminder },
11429
- subagentHooks: { ...DEFAULT_HOOK_STATE.subagentHooks, ...partial.subagentHooks },
11430
- updatedAt: partial.updatedAt ?? DEFAULT_HOOK_STATE.updatedAt,
11431
- updatedBy: partial.updatedBy
11424
+ subagentHooks: { ...DEFAULT_HOOK_STATE.subagentHooks, ...partial.subagentHooks }
11432
11425
  };
11433
11426
  }
11434
11427
  function write(state) {
11435
- state.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
11436
11428
  fs5.writeFileSync(stateFile, `${JSON.stringify(state, null, 2)}
11437
11429
  `);
11438
11430
  }
11439
- function update(updates, updatedBy) {
11431
+ function update(updates) {
11440
11432
  const current = read();
11441
11433
  const newState = {
11442
11434
  ...current,
@@ -11445,30 +11437,15 @@ function createHookState(autoDir) {
11445
11437
  validateCommit: { ...current.validateCommit, ...updates.validateCommit },
11446
11438
  denyList: { ...current.denyList, ...updates.denyList },
11447
11439
  promptReminder: { ...current.promptReminder, ...updates.promptReminder },
11448
- subagentHooks: { ...current.subagentHooks, ...updates.subagentHooks },
11449
- updatedBy: updatedBy ?? "unknown",
11450
- updatedAt: current.updatedAt
11440
+ subagentHooks: { ...current.subagentHooks, ...updates.subagentHooks }
11451
11441
  };
11452
11442
  write(newState);
11453
11443
  return newState;
11454
11444
  }
11455
- function incrementIteration() {
11456
- const state = read();
11457
- state.autoContinue.iteration = state.autoContinue.iteration + 1;
11458
- write(state);
11459
- return state.autoContinue.iteration;
11460
- }
11461
- function resetIteration() {
11462
- const state = read();
11463
- state.autoContinue.iteration = 0;
11464
- write(state);
11465
- }
11466
11445
  return {
11467
11446
  read,
11468
11447
  write,
11469
- update,
11470
- incrementIteration,
11471
- resetIteration
11448
+ update
11472
11449
  };
11473
11450
  }
11474
11451
 
@@ -11485,6 +11462,10 @@ async function loadConfig(searchFrom) {
11485
11462
  }
11486
11463
 
11487
11464
  // src/path-resolver.ts
11465
+ function resolveClaudeDirFromScript(scriptDir) {
11466
+ const projectRoot = path6.resolve(scriptDir, "..", "..");
11467
+ return path6.join(projectRoot, ".claude");
11468
+ }
11488
11469
  async function resolvePaths(claudeDir2) {
11489
11470
  const projectRoot = path6.dirname(claudeDir2);
11490
11471
  const config = await loadConfig(projectRoot);
@@ -11660,7 +11641,7 @@ async function handleCommitValidation(claudeDir2, sessionId, command, options2,
11660
11641
 
11661
11642
  // scripts/pre-tool-use.ts
11662
11643
  var input = parseHookInput(fs8.readFileSync(0, "utf-8"));
11663
- var claudeDir = path9.resolve(process.cwd(), ".claude");
11644
+ var claudeDir = resolveClaudeDirFromScript(__dirname);
11664
11645
  var startTime = Date.now();
11665
11646
  (async () => {
11666
11647
  const { autoDir } = await resolvePaths(claudeDir);