claudekit-cli 4.4.0-dev.8 → 4.4.0-dev.9

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/cli-manifest.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
- "version": "4.4.0-dev.8",
3
- "generatedAt": "2026-06-09T18:06:36.611Z",
2
+ "version": "4.4.0-dev.9",
3
+ "generatedAt": "2026-06-10T04:10:27.534Z",
4
4
  "commands": {
5
5
  "agents": {
6
6
  "name": "agents",
package/dist/index.js CHANGED
@@ -54841,6 +54841,7 @@ function rewriteCommandPath(command, pathRewrite) {
54841
54841
  if (pathRewrite.commandSubstitutions && pathRewrite.commandSubstitutions.size > 0) {
54842
54842
  const home3 = homedir25();
54843
54843
  const homeForward = normalizeSlashes(home3);
54844
+ const projectDirForward = pathRewrite.projectDir ? normalizeSlashes(pathRewrite.projectDir) : null;
54844
54845
  for (const [originalAbsPath, wrapperAbsPath] of pathRewrite.commandSubstitutions) {
54845
54846
  const originalAbsForward = normalizeSlashes(originalAbsPath);
54846
54847
  let relFromHome = null;
@@ -54849,34 +54850,84 @@ function rewriteCommandPath(command, pathRewrite) {
54849
54850
  } else if (originalAbsForward === homeForward) {
54850
54851
  relFromHome = "";
54851
54852
  }
54853
+ let relFromProject = null;
54854
+ if (projectDirForward !== null) {
54855
+ if (originalAbsForward.startsWith(`${projectDirForward}/`)) {
54856
+ relFromProject = originalAbsForward.slice(projectDirForward.length + 1);
54857
+ } else if (originalAbsForward === projectDirForward) {
54858
+ relFromProject = "";
54859
+ }
54860
+ }
54861
+ const wrapperForward = normalizeSlashes(wrapperAbsPath);
54852
54862
  const candidates = [
54853
- originalAbsForward,
54854
- originalAbsPath
54863
+ { text: originalAbsForward, replacement: wrapperForward },
54864
+ { text: originalAbsPath, replacement: wrapperForward }
54855
54865
  ];
54856
54866
  if (relFromHome !== null && relFromHome !== "") {
54857
- candidates.push(`$HOME/${relFromHome}`);
54858
- candidates.push(`~/${relFromHome}`);
54859
- candidates.push(`%USERPROFILE%/${relFromHome}`);
54860
- candidates.push(`\${HOME}/${relFromHome}`);
54867
+ candidates.push({ text: `$HOME/${relFromHome}`, replacement: wrapperForward });
54868
+ candidates.push({ text: `~/${relFromHome}`, replacement: wrapperForward });
54869
+ candidates.push({ text: `%USERPROFILE%/${relFromHome}`, replacement: wrapperForward });
54870
+ candidates.push({ text: `\${HOME}/${relFromHome}`, replacement: wrapperForward });
54871
+ }
54872
+ if (relFromProject !== null && relFromProject !== "") {
54873
+ candidates.push({
54874
+ text: `"$CLAUDE_PROJECT_DIR/${relFromProject}"`,
54875
+ replacement: `"${wrapperForward}"`
54876
+ });
54877
+ candidates.push({
54878
+ text: `"$CLAUDE_PROJECT_DIR"/${relFromProject}`,
54879
+ replacement: `"${wrapperForward}"`
54880
+ });
54881
+ candidates.push({
54882
+ text: `"\${CLAUDE_PROJECT_DIR}"/${relFromProject}`,
54883
+ replacement: `"${wrapperForward}"`
54884
+ });
54885
+ candidates.push({
54886
+ text: `"%CLAUDE_PROJECT_DIR%"/${relFromProject}`,
54887
+ replacement: `"${wrapperForward}"`
54888
+ });
54889
+ candidates.push({
54890
+ text: `\${CLAUDE_PROJECT_DIR}/${relFromProject}`,
54891
+ replacement: wrapperForward
54892
+ });
54893
+ candidates.push({
54894
+ text: `$CLAUDE_PROJECT_DIR/${relFromProject}`,
54895
+ replacement: wrapperForward
54896
+ });
54897
+ candidates.push({
54898
+ text: `%CLAUDE_PROJECT_DIR%/${relFromProject}`,
54899
+ replacement: `"${wrapperForward}"`
54900
+ });
54861
54901
  }
54862
- const wrapperForward = normalizeSlashes(wrapperAbsPath);
54863
- for (const candidate of candidates) {
54864
- const candidateNorm = normalizeSlashes(candidate);
54902
+ for (const { text, replacement } of candidates) {
54903
+ const candidateNorm = normalizeSlashes(text);
54865
54904
  const rewrittenNorm = normalizeSlashes(rewritten);
54866
54905
  if (rewrittenNorm.includes(candidateNorm)) {
54867
- rewritten = replaceCommandCandidate(rewrittenNorm, candidateNorm, wrapperForward);
54906
+ rewritten = replaceCommandCandidate(rewrittenNorm, candidateNorm, replacement);
54868
54907
  }
54869
54908
  }
54870
54909
  }
54871
54910
  }
54872
54911
  const src = normalizeSlashes(pathRewrite.sourceDir.endsWith("/") || pathRewrite.sourceDir.endsWith("\\") ? pathRewrite.sourceDir : `${pathRewrite.sourceDir}/`);
54873
54912
  const tgt = normalizeSlashes(pathRewrite.targetDir.endsWith("/") || pathRewrite.targetDir.endsWith("\\") ? pathRewrite.targetDir : `${pathRewrite.targetDir}/`);
54874
- if (src === tgt)
54875
- return rewritten;
54876
- const normalizedRewritten = normalizeSlashes(rewritten);
54877
- if (!normalizedRewritten.includes(src))
54878
- return rewritten;
54879
- return normalizedRewritten.replaceAll(src, tgt);
54913
+ if (src !== tgt) {
54914
+ const normalizedRewritten = normalizeSlashes(rewritten);
54915
+ if (normalizedRewritten.includes(src)) {
54916
+ rewritten = normalizedRewritten.replaceAll(src, tgt);
54917
+ }
54918
+ }
54919
+ if (pathRewrite.projectDir) {
54920
+ const pd = normalizeSlashes(pathRewrite.projectDir);
54921
+ rewritten = rewritten.replace(/"(\$CLAUDE_PROJECT_DIR)(\/[^"]+)"/g, (_match, _varRef, suffix) => `"${pd}${suffix}"`);
54922
+ rewritten = rewritten.replace(/"(\$CLAUDE_PROJECT_DIR)"(\/[^\s"';&|()]*)?/g, (_match, _varRef, suffix) => `"${pd}${suffix ?? ""}"`);
54923
+ rewritten = rewritten.replace(/"\$\{CLAUDE_PROJECT_DIR\}"(\/[^\s"';&|()]*)?/g, (_match, suffix) => `"${pd}${suffix ?? ""}"`);
54924
+ rewritten = rewritten.replace(/\$\{CLAUDE_PROJECT_DIR\}(\/[^\s"';&|()]*)?/g, (_match, suffix) => `"${pd}${suffix ?? ""}"`);
54925
+ rewritten = rewritten.replace(/"%CLAUDE_PROJECT_DIR%(\/[^"]+)"/g, (_match, suffix) => `"${pd}${suffix}"`);
54926
+ rewritten = rewritten.replace(/"%CLAUDE_PROJECT_DIR%"(\/[^\s"';&|()]*)?/g, (_match, suffix) => `"${pd}${suffix ?? ""}"`);
54927
+ rewritten = rewritten.replace(/%CLAUDE_PROJECT_DIR%(\/[^\s"';&|()]*)?(?=[\s"']|$)/g, (_match, suffix) => `"${pd}${suffix ?? ""}"`);
54928
+ rewritten = rewritten.replace(/\$CLAUDE_PROJECT_DIR(?![A-Za-z0-9_])(\/[^\s"';&|()]*)?/g, (_match, suffix) => `"${pd}${suffix ?? ""}"`);
54929
+ }
54930
+ return rewritten;
54880
54931
  }
54881
54932
  function replaceCommandCandidate(command, candidate, replacement) {
54882
54933
  if (!isRelativeCommandCandidate(candidate)) {
@@ -54886,7 +54937,7 @@ function replaceCommandCandidate(command, candidate, replacement) {
54886
54937
  return command.replace(pattern, (_match, prefix) => `${prefix}${replacement}`);
54887
54938
  }
54888
54939
  function isRelativeCommandCandidate(candidate) {
54889
- return !candidate.startsWith("/") && !candidate.startsWith("$HOME/") && !candidate.startsWith("~/");
54940
+ return !candidate.startsWith("/") && !candidate.startsWith("$HOME/") && !candidate.startsWith("~/") && !candidate.startsWith('"') && !candidate.startsWith("$CLAUDE_PROJECT_DIR") && !candidate.startsWith("${CLAUDE_PROJECT_DIR}") && !candidate.startsWith("%CLAUDE_PROJECT_DIR%");
54890
54941
  }
54891
54942
  function escapeRegExp2(value) {
54892
54943
  return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
@@ -55115,7 +55166,8 @@ async function mergeHooksIntoSettings(targetSettingsPath, newHooks, options2 = {
55115
55166
  }
55116
55167
  const existingHooks = existingSettings.hooks ?? {};
55117
55168
  const incompatibleCleanup = pruneIncompatibleHookRegistrations(existingHooks, options2);
55118
- const pruned = pruneStaleFileHooks(incompatibleCleanup.hooks);
55169
+ const brokenCleanup = pruneVariableTokenBrokenEntries(incompatibleCleanup.hooks, options2);
55170
+ const pruned = pruneStaleFileHooks(brokenCleanup.hooks);
55119
55171
  const merged = deduplicateMerge(pruned, newHooks);
55120
55172
  existingSettings.hooks = merged;
55121
55173
  const dir = dirname16(targetSettingsPath);
@@ -55128,7 +55180,10 @@ async function mergeHooksIntoSettings(targetSettingsPath, newHooks, options2 = {
55128
55180
  await rm6(tempPath, { force: true });
55129
55181
  throw new Error(`Failed to write settings: ${err}. Backup preserved at: ${backupPath}`);
55130
55182
  }
55131
- return { backupPath, hooksPruned: incompatibleCleanup.hooksPruned };
55183
+ return {
55184
+ backupPath,
55185
+ hooksPruned: incompatibleCleanup.hooksPruned + brokenCleanup.hooksPruned
55186
+ };
55132
55187
  }
55133
55188
  function pruneIncompatibleHookRegistrations(hooks, options2) {
55134
55189
  if (options2.targetProvider !== "codex")
@@ -55157,6 +55212,32 @@ function pruneIncompatibleHookRegistrations(hooks, options2) {
55157
55212
  }
55158
55213
  return { hooks: pruned, hooksPruned };
55159
55214
  }
55215
+ function pruneVariableTokenBrokenEntries(hooks, options2) {
55216
+ if (options2.targetProvider !== "codex")
55217
+ return { hooks, hooksPruned: 0 };
55218
+ const varPattern = /\$\{?CLAUDE_PROJECT_DIR\}?|%CLAUDE_PROJECT_DIR%/;
55219
+ const ckHookDirPattern = /\.claude\/hooks\/|\.codex\/hooks\//;
55220
+ let hooksPruned = 0;
55221
+ const result = {};
55222
+ for (const [event, groups] of Object.entries(hooks)) {
55223
+ const keptGroups = [];
55224
+ for (const group of groups) {
55225
+ const keptHooks = group.hooks.filter((entry) => {
55226
+ const cmd = entry.command;
55227
+ if (varPattern.test(cmd) && ckHookDirPattern.test(cmd)) {
55228
+ hooksPruned += 1;
55229
+ return false;
55230
+ }
55231
+ return true;
55232
+ });
55233
+ if (keptHooks.length > 0)
55234
+ keptGroups.push({ ...group, hooks: keptHooks });
55235
+ }
55236
+ if (keptGroups.length > 0)
55237
+ result[event] = keptGroups;
55238
+ }
55239
+ return { hooks: result, hooksPruned };
55240
+ }
55160
55241
  function commandTargetsHookDir(command, targetHooksDir) {
55161
55242
  const normalizedCommand = command.replace(/\\/g, "/");
55162
55243
  const normalizedDir = targetHooksDir.replace(/\\/g, "/").replace(/\/+$/, "");
@@ -55423,6 +55504,7 @@ async function migrateHooksSettingsForCodex(options2) {
55423
55504
  }
55424
55505
  const resolvedSourcePath = isGlobal ? sourceSettingsPath : join44(process.cwd(), sourceSettingsPath);
55425
55506
  const resolvedTargetPath = isGlobal ? targetSettingsPath : join44(process.cwd(), targetSettingsPath);
55507
+ const projectDir = isGlobal ? undefined : process.cwd();
55426
55508
  const sourceHooksResult = await inspectHooksSettings(resolvedSourcePath);
55427
55509
  if (sourceHooksResult.status === "missing-file") {
55428
55510
  return {
@@ -55538,7 +55620,8 @@ async function migrateHooksSettingsForCodex(options2) {
55538
55620
  const converted = convertClaudeHooksToCodex(filtered, capabilities, {
55539
55621
  sourceDir: sourceHooksDir,
55540
55622
  targetDir: effectiveTargetDir,
55541
- commandSubstitutions: commandSubstitutions.size > 0 ? commandSubstitutions : undefined
55623
+ commandSubstitutions: commandSubstitutions.size > 0 ? commandSubstitutions : undefined,
55624
+ projectDir
55542
55625
  });
55543
55626
  let hooksRegistered = 0;
55544
55627
  for (const groups of Object.values(converted)) {
@@ -63859,7 +63942,7 @@ var package_default;
63859
63942
  var init_package = __esm(() => {
63860
63943
  package_default = {
63861
63944
  name: "claudekit-cli",
63862
- version: "4.4.0-dev.8",
63945
+ version: "4.4.0-dev.9",
63863
63946
  description: "CLI tool for bootstrapping and updating ClaudeKit projects",
63864
63947
  type: "module",
63865
63948
  repository: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claudekit-cli",
3
- "version": "4.4.0-dev.8",
3
+ "version": "4.4.0-dev.9",
4
4
  "description": "CLI tool for bootstrapping and updating ClaudeKit projects",
5
5
  "type": "module",
6
6
  "repository": {