cozempic 1.2.2 → 1.2.4
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/install.js +68 -14
- package/package.json +31 -8
package/install.js
CHANGED
|
@@ -2,26 +2,80 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
const { spawnSync } = require("child_process");
|
|
5
|
+
const { existsSync, readFileSync, writeFileSync, mkdirSync } = require("fs");
|
|
6
|
+
const { join } = require("path");
|
|
7
|
+
const os = require("os");
|
|
8
|
+
|
|
9
|
+
// ── 1. Install Python package ─────────────────────────────────────────────────
|
|
5
10
|
|
|
6
|
-
// Skip if already installed
|
|
7
11
|
const check = spawnSync("cozempic", ["--version"], { stdio: "pipe" });
|
|
8
|
-
|
|
12
|
+
const alreadyInstalled = check.status === 0;
|
|
9
13
|
|
|
10
|
-
|
|
14
|
+
if (!alreadyInstalled) {
|
|
15
|
+
console.log("Installing cozempic Python package...");
|
|
11
16
|
|
|
12
|
-
const attempts = [
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
];
|
|
17
|
+
const attempts = [
|
|
18
|
+
["pip", ["install", "cozempic", "--quiet", "--disable-pip-version-check"]],
|
|
19
|
+
["pip3", ["install", "cozempic", "--quiet", "--disable-pip-version-check"]],
|
|
20
|
+
["python", ["-m", "pip", "install", "cozempic", "--quiet"]],
|
|
21
|
+
["python3", ["-m", "pip", "install", "cozempic", "--quiet"]],
|
|
22
|
+
];
|
|
18
23
|
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
let installed = false;
|
|
25
|
+
for (const [cmd, args] of attempts) {
|
|
26
|
+
const r = spawnSync(cmd, args, { stdio: "inherit" });
|
|
27
|
+
if (r.status === 0) { installed = true; break; }
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (!installed) {
|
|
31
|
+
console.log("\ncozempic could not be auto-installed. Run manually:\n pip install cozempic\n");
|
|
23
32
|
process.exit(0);
|
|
24
33
|
}
|
|
25
34
|
}
|
|
26
35
|
|
|
27
|
-
|
|
36
|
+
// ── 2. Wire global SessionStart hook in ~/.claude/settings.json ──────────────
|
|
37
|
+
// This ensures cozempic auto-configures on every Claude Code session the user
|
|
38
|
+
// opens — even in projects they haven't run `cozempic init` in yet.
|
|
39
|
+
|
|
40
|
+
const claudeDir = join(os.homedir(), ".claude");
|
|
41
|
+
const globalSettingsPath = join(claudeDir, "settings.json");
|
|
42
|
+
const hookCmd = "command -v cozempic >/dev/null 2>&1 || pip install cozempic --quiet; [ -d .claude ] && cozempic init --quiet 2>/dev/null; cozempic guard --daemon 2>/dev/null || true";
|
|
43
|
+
|
|
44
|
+
if (existsSync(claudeDir)) {
|
|
45
|
+
let settings = {};
|
|
46
|
+
if (existsSync(globalSettingsPath)) {
|
|
47
|
+
try { settings = JSON.parse(readFileSync(globalSettingsPath, "utf8")); } catch {}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
settings.hooks = settings.hooks || {};
|
|
51
|
+
settings.hooks.SessionStart = settings.hooks.SessionStart || [];
|
|
52
|
+
|
|
53
|
+
const alreadyWired = settings.hooks.SessionStart.some(h =>
|
|
54
|
+
(h.hooks || []).some(hh => hh.command && hh.command.includes("cozempic"))
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
if (!alreadyWired) {
|
|
58
|
+
settings.hooks.SessionStart.push({
|
|
59
|
+
hooks: [{ type: "command", command: hookCmd }]
|
|
60
|
+
});
|
|
61
|
+
writeFileSync(globalSettingsPath, JSON.stringify(settings, null, 2));
|
|
62
|
+
console.log("Global SessionStart hook wired — cozempic will auto-configure on every Claude Code session.");
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// ── 3. Auto-configure if already inside a Claude Code project ────────────────
|
|
67
|
+
|
|
68
|
+
const cwd = process.env.INIT_CWD || process.cwd();
|
|
69
|
+
const isClaudeProject = existsSync(join(cwd, ".claude"));
|
|
70
|
+
|
|
71
|
+
if (isClaudeProject) {
|
|
72
|
+
console.log("Claude Code project detected — running cozempic init...");
|
|
73
|
+
const r = spawnSync("cozempic", ["init"], { stdio: "inherit", cwd });
|
|
74
|
+
if (r.status === 0) {
|
|
75
|
+
console.log("Guard daemon and hooks wired. Auto-pruning is active.");
|
|
76
|
+
} else {
|
|
77
|
+
console.log("cozempic init failed — run manually: cozempic init");
|
|
78
|
+
}
|
|
79
|
+
} else {
|
|
80
|
+
console.log("cozempic ready. Auto-guard will activate on your next Claude Code session.");
|
|
81
|
+
}
|
package/package.json
CHANGED
|
@@ -1,15 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozempic",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
4
4
|
"description": "Context weight-loss for Claude Code — prune bloated sessions, protect Agent Teams from compaction",
|
|
5
|
-
"keywords": [
|
|
5
|
+
"keywords": [
|
|
6
|
+
"claude",
|
|
7
|
+
"claude-code",
|
|
8
|
+
"context",
|
|
9
|
+
"pruning",
|
|
10
|
+
"jsonl",
|
|
11
|
+
"agent-teams",
|
|
12
|
+
"compaction",
|
|
13
|
+
"mcp"
|
|
14
|
+
],
|
|
6
15
|
"homepage": "https://github.com/Ruya-AI/cozempic",
|
|
7
|
-
"repository": {
|
|
8
|
-
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/Ruya-AI/cozempic.git"
|
|
19
|
+
},
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/Ruya-AI/cozempic/issues"
|
|
22
|
+
},
|
|
9
23
|
"license": "MIT",
|
|
10
24
|
"author": "Ruya AI",
|
|
11
|
-
"bin": {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"
|
|
25
|
+
"bin": {
|
|
26
|
+
"cozempic": "bin/cozempic.js"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"postinstall": "node install.js"
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"bin/",
|
|
33
|
+
"install.js"
|
|
34
|
+
],
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">=16"
|
|
37
|
+
}
|
|
15
38
|
}
|