ccsini 0.1.65 → 0.1.67
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/dist/index.js +81 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -28058,7 +28058,7 @@ var {
|
|
|
28058
28058
|
} = import__.default;
|
|
28059
28059
|
|
|
28060
28060
|
// src/version.ts
|
|
28061
|
-
var VERSION = "0.1.
|
|
28061
|
+
var VERSION = "0.1.67";
|
|
28062
28062
|
|
|
28063
28063
|
// src/commands/init.ts
|
|
28064
28064
|
init_source();
|
|
@@ -28807,12 +28807,86 @@ init_schema();
|
|
|
28807
28807
|
// src/hooks/installer.ts
|
|
28808
28808
|
import { readFile as readFile3, writeFile as writeFile3 } from "fs/promises";
|
|
28809
28809
|
import { join as join3 } from "path";
|
|
28810
|
+
|
|
28811
|
+
// src/hooks/ipc-push-script.ts
|
|
28812
|
+
function generateIpcPushScript(configDir) {
|
|
28813
|
+
const escaped = configDir.replace(/\\/g, "\\\\");
|
|
28814
|
+
return `#!/usr/bin/env node
|
|
28815
|
+
// ccsini-ipc-push.mjs \u2014 lightweight daemon push trigger (auto-generated, do not edit)
|
|
28816
|
+
// Connects to ccsini daemon socket and requests a push. Exits 0 on success, 1 on failure.
|
|
28817
|
+
// On failure, the hook falls back to "ccsini auto-push" (full CLI).
|
|
28818
|
+
|
|
28819
|
+
import { createConnection } from "node:net";
|
|
28820
|
+
import { platform } from "node:os";
|
|
28821
|
+
import { join } from "node:path";
|
|
28822
|
+
|
|
28823
|
+
const CONFIG_DIR = "${escaped}";
|
|
28824
|
+
const PIPE_NAME = "ccsini-daemon";
|
|
28825
|
+
const SOCKET_NAME = "daemon.sock";
|
|
28826
|
+
const CONNECT_TIMEOUT_MS = 5000;
|
|
28827
|
+
const RESPONSE_TIMEOUT_MS = 60000;
|
|
28828
|
+
|
|
28829
|
+
const socketPath = platform() === "win32"
|
|
28830
|
+
? "\\\\\\\\.\\\\pipe\\\\" + PIPE_NAME
|
|
28831
|
+
: join(CONFIG_DIR, SOCKET_NAME);
|
|
28832
|
+
|
|
28833
|
+
let buffer = "";
|
|
28834
|
+
let done = false;
|
|
28835
|
+
|
|
28836
|
+
const conn = createConnection(socketPath);
|
|
28837
|
+
|
|
28838
|
+
const connectTimer = setTimeout(() => {
|
|
28839
|
+
if (!done) { done = true; conn.destroy(); process.exit(1); }
|
|
28840
|
+
}, CONNECT_TIMEOUT_MS);
|
|
28841
|
+
|
|
28842
|
+
conn.on("connect", () => {
|
|
28843
|
+
clearTimeout(connectTimer);
|
|
28844
|
+
conn.write(JSON.stringify({ cmd: "push-now" }) + "\\n");
|
|
28845
|
+
|
|
28846
|
+
// Response timeout \u2014 push with many files may take a while
|
|
28847
|
+
setTimeout(() => {
|
|
28848
|
+
if (!done) { done = true; conn.destroy(); process.exit(1); }
|
|
28849
|
+
}, RESPONSE_TIMEOUT_MS);
|
|
28850
|
+
});
|
|
28851
|
+
|
|
28852
|
+
conn.on("data", (chunk) => {
|
|
28853
|
+
buffer += chunk.toString();
|
|
28854
|
+
const idx = buffer.indexOf("\\n");
|
|
28855
|
+
if (idx === -1) return;
|
|
28856
|
+
|
|
28857
|
+
done = true;
|
|
28858
|
+
const line = buffer.slice(0, idx).trim();
|
|
28859
|
+
conn.destroy();
|
|
28860
|
+
|
|
28861
|
+
try {
|
|
28862
|
+
const res = JSON.parse(line);
|
|
28863
|
+
if (res.ok) {
|
|
28864
|
+
if (res.filesChanged > 0) {
|
|
28865
|
+
console.log("[ccsini] Pushed " + res.filesChanged + " files (" + res.durationMs + "ms) [daemon]");
|
|
28866
|
+
}
|
|
28867
|
+
process.exit(0);
|
|
28868
|
+
}
|
|
28869
|
+
console.error("[ccsini] Daemon push failed: " + (res.error || "unknown"));
|
|
28870
|
+
process.exit(1);
|
|
28871
|
+
} catch {
|
|
28872
|
+
process.exit(1);
|
|
28873
|
+
}
|
|
28874
|
+
});
|
|
28875
|
+
|
|
28876
|
+
conn.on("error", () => {
|
|
28877
|
+
if (!done) { done = true; clearTimeout(connectTimer); process.exit(1); }
|
|
28878
|
+
});
|
|
28879
|
+
`;
|
|
28880
|
+
}
|
|
28881
|
+
|
|
28882
|
+
// src/hooks/installer.ts
|
|
28810
28883
|
var HOOK_MARKER = "ccsini auto-";
|
|
28811
28884
|
var OLD_HOOK_MARKER = "ccsini-auto-sync";
|
|
28885
|
+
var IPC_SCRIPT_MARKER = "ccsini-ipc-push";
|
|
28812
28886
|
var OLD_COMMAND_SUFFIX = /\s*#\s*ccsini-auto-sync$/;
|
|
28813
28887
|
function isCcsiniHook(hookEntry) {
|
|
28814
28888
|
const s = JSON.stringify(hookEntry);
|
|
28815
|
-
return s.includes(HOOK_MARKER) || s.includes(OLD_HOOK_MARKER);
|
|
28889
|
+
return s.includes(HOOK_MARKER) || s.includes(OLD_HOOK_MARKER) || s.includes(IPC_SCRIPT_MARKER);
|
|
28816
28890
|
}
|
|
28817
28891
|
async function installHooks(claudeDir) {
|
|
28818
28892
|
const settingsPath = join3(claudeDir, "settings.json");
|
|
@@ -28821,6 +28895,10 @@ async function installHooks(claudeDir) {
|
|
|
28821
28895
|
const raw = await readFile3(settingsPath, "utf-8");
|
|
28822
28896
|
settings = JSON.parse(raw);
|
|
28823
28897
|
} catch {}
|
|
28898
|
+
const scriptPath = join3(claudeDir, "ccsini-ipc-push.mjs");
|
|
28899
|
+
await writeFile3(scriptPath, generateIpcPushScript(claudeDir));
|
|
28900
|
+
const quotedScript = `"${scriptPath.replace(/\\/g, "/")}"`;
|
|
28901
|
+
const stopCommand = `node ${quotedScript} || ccsini auto-push`;
|
|
28824
28902
|
settings.hooks = settings.hooks ?? {};
|
|
28825
28903
|
settings.hooks.PreToolUse = [
|
|
28826
28904
|
...(settings.hooks.PreToolUse ?? []).filter((h) => !isCcsiniHook(h))
|
|
@@ -28831,7 +28909,7 @@ async function installHooks(claudeDir) {
|
|
|
28831
28909
|
hooks: [
|
|
28832
28910
|
{
|
|
28833
28911
|
type: "command",
|
|
28834
|
-
command:
|
|
28912
|
+
command: stopCommand
|
|
28835
28913
|
}
|
|
28836
28914
|
]
|
|
28837
28915
|
}
|