ccsini 0.1.24 → 0.1.25

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 (2) hide show
  1. package/dist/index.js +32 -10
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -27996,7 +27996,7 @@ var {
27996
27996
  } = import__.default;
27997
27997
 
27998
27998
  // src/version.ts
27999
- var VERSION = "0.1.24";
27999
+ var VERSION = "0.1.25";
28000
28000
 
28001
28001
  // src/commands/init.ts
28002
28002
  init_source();
@@ -28737,7 +28737,13 @@ function buildDefaultSchema() {
28737
28737
  // src/hooks/installer.ts
28738
28738
  import { readFile as readFile3, writeFile as writeFile3 } from "fs/promises";
28739
28739
  import { join as join3 } from "path";
28740
- var HOOK_MARKER = "ccsini-auto-sync";
28740
+ var HOOK_MARKER = "ccsini auto-";
28741
+ var OLD_HOOK_MARKER = "ccsini-auto-sync";
28742
+ var OLD_COMMAND_SUFFIX = /\s*#\s*ccsini-auto-sync$/;
28743
+ function isCcsiniHook(hookEntry) {
28744
+ const s = JSON.stringify(hookEntry);
28745
+ return s.includes(HOOK_MARKER) || s.includes(OLD_HOOK_MARKER);
28746
+ }
28741
28747
  async function installHooks(claudeDir) {
28742
28748
  const settingsPath = join3(claudeDir, "settings.json");
28743
28749
  let settings = {};
@@ -28747,26 +28753,26 @@ async function installHooks(claudeDir) {
28747
28753
  } catch {}
28748
28754
  settings.hooks = settings.hooks ?? {};
28749
28755
  settings.hooks.PreToolUse = [
28750
- ...(settings.hooks.PreToolUse ?? []).filter((h) => !h.command?.includes(HOOK_MARKER))
28756
+ ...(settings.hooks.PreToolUse ?? []).filter((h) => !isCcsiniHook(h))
28751
28757
  ];
28752
28758
  settings.hooks.Stop = [
28753
- ...(settings.hooks.Stop ?? []).filter((h) => !JSON.stringify(h).includes(HOOK_MARKER)),
28759
+ ...(settings.hooks.Stop ?? []).filter((h) => !isCcsiniHook(h)),
28754
28760
  {
28755
28761
  hooks: [
28756
28762
  {
28757
28763
  type: "command",
28758
- command: `ccsini auto-push # ${HOOK_MARKER}`
28764
+ command: "ccsini auto-push"
28759
28765
  }
28760
28766
  ]
28761
28767
  }
28762
28768
  ];
28763
28769
  settings.hooks.Notification = [
28764
- ...(settings.hooks.Notification ?? []).filter((h) => !JSON.stringify(h).includes(HOOK_MARKER)),
28770
+ ...(settings.hooks.Notification ?? []).filter((h) => !isCcsiniHook(h)),
28765
28771
  {
28766
28772
  hooks: [
28767
28773
  {
28768
28774
  type: "command",
28769
- command: `ccsini auto-pull # ${HOOK_MARKER}`
28775
+ command: "ccsini auto-pull"
28770
28776
  }
28771
28777
  ]
28772
28778
  }
@@ -28778,7 +28784,7 @@ async function hooksInstalled(claudeDir) {
28778
28784
  const raw = await readFile3(join3(claudeDir, "settings.json"), "utf-8");
28779
28785
  const settings = JSON.parse(raw);
28780
28786
  const allHooks = JSON.stringify(settings.hooks ?? {});
28781
- return allHooks.includes(HOOK_MARKER);
28787
+ return allHooks.includes(HOOK_MARKER) || allHooks.includes(OLD_HOOK_MARKER);
28782
28788
  } catch {
28783
28789
  return false;
28784
28790
  }
@@ -28805,13 +28811,18 @@ async function fixHooks(claudeDir) {
28805
28811
  if (!Array.isArray(settings.hooks[hookType]))
28806
28812
  continue;
28807
28813
  for (const hookEntry of settings.hooks[hookType]) {
28808
- if (!JSON.stringify(hookEntry).includes(HOOK_MARKER))
28814
+ if (!isCcsiniHook(hookEntry))
28809
28815
  continue;
28810
28816
  if ("matcher" in hookEntry && typeof hookEntry.matcher !== "string") {
28811
28817
  delete hookEntry.matcher;
28812
28818
  details.push(`Removed invalid matcher from ${hookType} hook`);
28813
28819
  fixed++;
28814
28820
  }
28821
+ if (typeof hookEntry.command === "string" && OLD_COMMAND_SUFFIX.test(hookEntry.command)) {
28822
+ hookEntry.command = hookEntry.command.replace(OLD_COMMAND_SUFFIX, "");
28823
+ details.push(`Stripped old marker suffix from ${hookType} command`);
28824
+ fixed++;
28825
+ }
28815
28826
  if (Array.isArray(hookEntry.hooks)) {
28816
28827
  for (const innerHook of hookEntry.hooks) {
28817
28828
  if ("matcher" in innerHook && typeof innerHook.matcher !== "string") {
@@ -28819,6 +28830,11 @@ async function fixHooks(claudeDir) {
28819
28830
  details.push(`Removed invalid matcher from ${hookType} inner hook`);
28820
28831
  fixed++;
28821
28832
  }
28833
+ if (typeof innerHook.command === "string" && OLD_COMMAND_SUFFIX.test(innerHook.command)) {
28834
+ innerHook.command = innerHook.command.replace(OLD_COMMAND_SUFFIX, "");
28835
+ details.push(`Stripped old marker suffix from ${hookType} inner command`);
28836
+ fixed++;
28837
+ }
28822
28838
  }
28823
28839
  }
28824
28840
  }
@@ -28850,16 +28866,22 @@ async function checkHooksHealth(claudeDir) {
28850
28866
  if (!Array.isArray(settings.hooks[hookType]))
28851
28867
  continue;
28852
28868
  for (const hookEntry of settings.hooks[hookType]) {
28853
- if (!JSON.stringify(hookEntry).includes(HOOK_MARKER))
28869
+ if (!isCcsiniHook(hookEntry))
28854
28870
  continue;
28855
28871
  if ("matcher" in hookEntry && typeof hookEntry.matcher !== "string") {
28856
28872
  issues.push(`${hookType}: matcher is ${typeof hookEntry.matcher}, expected string`);
28857
28873
  }
28874
+ if (typeof hookEntry.command === "string" && OLD_COMMAND_SUFFIX.test(hookEntry.command)) {
28875
+ issues.push(`${hookType}: command has old marker suffix that causes argument errors`);
28876
+ }
28858
28877
  if (Array.isArray(hookEntry.hooks)) {
28859
28878
  for (const innerHook of hookEntry.hooks) {
28860
28879
  if ("matcher" in innerHook && typeof innerHook.matcher !== "string") {
28861
28880
  issues.push(`${hookType} inner hook: matcher is ${typeof innerHook.matcher}, expected string`);
28862
28881
  }
28882
+ if (typeof innerHook.command === "string" && OLD_COMMAND_SUFFIX.test(innerHook.command)) {
28883
+ issues.push(`${hookType} inner hook: command has old marker suffix that causes argument errors`);
28884
+ }
28863
28885
  }
28864
28886
  }
28865
28887
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccsini",
3
- "version": "0.1.24",
3
+ "version": "0.1.25",
4
4
  "description": "Claude Code seamless sync across devices",
5
5
  "type": "module",
6
6
  "bin": {