rex-claude 2.0.0 → 2.2.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.
- package/dist/index.js +17 -5
- package/dist/{init-YMRG5ZXU.js → init-NXU37FCV.js} +185 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -369,7 +369,7 @@ async function main() {
|
|
|
369
369
|
break;
|
|
370
370
|
}
|
|
371
371
|
case "init": {
|
|
372
|
-
const { init } = await import("./init-
|
|
372
|
+
const { init } = await import("./init-NXU37FCV.js");
|
|
373
373
|
await init();
|
|
374
374
|
break;
|
|
375
375
|
}
|
|
@@ -413,9 +413,19 @@ async function main() {
|
|
|
413
413
|
await optimize();
|
|
414
414
|
break;
|
|
415
415
|
}
|
|
416
|
+
case "startup": {
|
|
417
|
+
const { installStartup } = await import("./init-NXU37FCV.js");
|
|
418
|
+
installStartup();
|
|
419
|
+
break;
|
|
420
|
+
}
|
|
421
|
+
case "startup-remove": {
|
|
422
|
+
const { uninstallStartup } = await import("./init-NXU37FCV.js");
|
|
423
|
+
uninstallStartup();
|
|
424
|
+
break;
|
|
425
|
+
}
|
|
416
426
|
case "--version":
|
|
417
427
|
case "-v":
|
|
418
|
-
console.log("rex-
|
|
428
|
+
console.log("rex-claude v2.2.0");
|
|
419
429
|
break;
|
|
420
430
|
case "help":
|
|
421
431
|
default:
|
|
@@ -423,9 +433,11 @@ async function main() {
|
|
|
423
433
|
${COLORS.bold}REX${COLORS.reset} \u2014 Claude Code sous steroides
|
|
424
434
|
|
|
425
435
|
${COLORS.bold}Commands:${COLORS.reset}
|
|
426
|
-
rex init
|
|
427
|
-
rex doctor
|
|
428
|
-
rex status
|
|
436
|
+
rex init Setup REX (guards, hooks, MCP, startup)
|
|
437
|
+
rex doctor Full health check (9 categories)
|
|
438
|
+
rex status Quick one-line status
|
|
439
|
+
rex startup Install LaunchAgent (auto-start on login)
|
|
440
|
+
rex startup-remove Remove LaunchAgent
|
|
429
441
|
|
|
430
442
|
${COLORS.bold}Memory (requires Ollama):${COLORS.reset}
|
|
431
443
|
rex ingest Sync session history to vector DB
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/init.ts
|
|
4
|
-
import { existsSync, readFileSync, writeFileSync, mkdirSync } from "fs";
|
|
4
|
+
import { existsSync, readFileSync, writeFileSync, mkdirSync, unlinkSync } from "fs";
|
|
5
5
|
import { join, dirname } from "path";
|
|
6
6
|
import { homedir } from "os";
|
|
7
|
+
import { execSync } from "child_process";
|
|
7
8
|
import { fileURLToPath } from "url";
|
|
8
9
|
var COLORS = {
|
|
9
10
|
reset: "\x1B[0m",
|
|
@@ -39,6 +40,180 @@ function writeJson(path, data) {
|
|
|
39
40
|
function ensureDir(dir) {
|
|
40
41
|
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
|
|
41
42
|
}
|
|
43
|
+
var PLIST_LABEL = "com.dstudio.rex";
|
|
44
|
+
var INGEST_PLIST_LABEL = "com.dstudio.rex-ingest";
|
|
45
|
+
function installIngestAgent() {
|
|
46
|
+
if (process.platform !== "darwin") {
|
|
47
|
+
info("Auto-ingest only supported on macOS");
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const launchAgentsDir = join(homedir(), "Library", "LaunchAgents");
|
|
51
|
+
ensureDir(launchAgentsDir);
|
|
52
|
+
const plistPath = join(launchAgentsDir, `${INGEST_PLIST_LABEL}.plist`);
|
|
53
|
+
let rexBin = "";
|
|
54
|
+
try {
|
|
55
|
+
rexBin = execSync("which rex", { encoding: "utf-8" }).trim();
|
|
56
|
+
} catch {
|
|
57
|
+
}
|
|
58
|
+
if (!rexBin) {
|
|
59
|
+
info("rex binary not in PATH \u2014 skipping ingest LaunchAgent");
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (existsSync(plistPath)) {
|
|
63
|
+
skip("Ingest LaunchAgent already installed (auto-ingest every hour)");
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const plist = `<?xml version="1.0" encoding="UTF-8"?>
|
|
67
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
68
|
+
<plist version="1.0">
|
|
69
|
+
<dict>
|
|
70
|
+
<key>Label</key>
|
|
71
|
+
<string>${INGEST_PLIST_LABEL}</string>
|
|
72
|
+
<key>ProgramArguments</key>
|
|
73
|
+
<array>
|
|
74
|
+
<string>${rexBin}</string>
|
|
75
|
+
<string>ingest</string>
|
|
76
|
+
</array>
|
|
77
|
+
<key>RunAtLoad</key>
|
|
78
|
+
<true/>
|
|
79
|
+
<key>StartInterval</key>
|
|
80
|
+
<integer>3600</integer>
|
|
81
|
+
<key>StandardOutPath</key>
|
|
82
|
+
<string>${join(homedir(), ".claude", "rex-ingest.log")}</string>
|
|
83
|
+
<key>StandardErrorPath</key>
|
|
84
|
+
<string>${join(homedir(), ".claude", "rex-ingest.log")}</string>
|
|
85
|
+
<key>EnvironmentVariables</key>
|
|
86
|
+
<dict>
|
|
87
|
+
<key>PATH</key>
|
|
88
|
+
<string>/usr/local/bin:/usr/bin:/bin:${dirname(rexBin)}</string>
|
|
89
|
+
</dict>
|
|
90
|
+
</dict>
|
|
91
|
+
</plist>
|
|
92
|
+
`;
|
|
93
|
+
writeFileSync(plistPath, plist);
|
|
94
|
+
try {
|
|
95
|
+
execSync(`launchctl load ${plistPath}`, { stdio: "ignore" });
|
|
96
|
+
} catch {
|
|
97
|
+
}
|
|
98
|
+
ok("Ingest LaunchAgent installed \u2014 auto-ingest every hour");
|
|
99
|
+
}
|
|
100
|
+
function uninstallIngestAgent() {
|
|
101
|
+
if (process.platform !== "darwin") return;
|
|
102
|
+
const plistPath = join(homedir(), "Library", "LaunchAgents", `${INGEST_PLIST_LABEL}.plist`);
|
|
103
|
+
if (!existsSync(plistPath)) {
|
|
104
|
+
info("Ingest LaunchAgent not installed");
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
try {
|
|
108
|
+
execSync(`launchctl unload ${plistPath}`, { stdio: "ignore" });
|
|
109
|
+
} catch {
|
|
110
|
+
}
|
|
111
|
+
try {
|
|
112
|
+
unlinkSync(plistPath);
|
|
113
|
+
} catch {
|
|
114
|
+
}
|
|
115
|
+
ok("Ingest LaunchAgent removed");
|
|
116
|
+
}
|
|
117
|
+
function installApp() {
|
|
118
|
+
if (process.platform !== "darwin") return;
|
|
119
|
+
const thisDir = new URL(".", import.meta.url).pathname;
|
|
120
|
+
const buildApp = join(thisDir, "..", "..", "app", "src-tauri", "target", "release", "bundle", "macos", "REX.app");
|
|
121
|
+
const installedApp = "/Applications/REX.app";
|
|
122
|
+
if (existsSync(installedApp)) {
|
|
123
|
+
skip("REX.app already in /Applications");
|
|
124
|
+
} else if (existsSync(buildApp)) {
|
|
125
|
+
try {
|
|
126
|
+
execSync(`cp -R "${buildApp}" "${installedApp}"`, { stdio: "ignore" });
|
|
127
|
+
ok("REX.app installed to /Applications");
|
|
128
|
+
} catch {
|
|
129
|
+
info("Could not copy REX.app to /Applications (try manually)");
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
} else {
|
|
133
|
+
info("REX.app not built \u2014 run `pnpm tauri build` in packages/app first");
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
try {
|
|
137
|
+
execSync(`osascript -e 'tell application "System Events" to make login item at end with properties {path:"${installedApp}", hidden:false}'`, { stdio: "ignore" });
|
|
138
|
+
ok("REX.app added to Login Items (auto-start on login)");
|
|
139
|
+
} catch {
|
|
140
|
+
skip("REX.app already in Login Items");
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
function installStartup() {
|
|
144
|
+
if (process.platform !== "darwin") {
|
|
145
|
+
info("Startup auto-launch only supported on macOS");
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
const launchAgentsDir = join(homedir(), "Library", "LaunchAgents");
|
|
149
|
+
ensureDir(launchAgentsDir);
|
|
150
|
+
const plistPath = join(launchAgentsDir, `${PLIST_LABEL}.plist`);
|
|
151
|
+
let rexBin = "";
|
|
152
|
+
try {
|
|
153
|
+
rexBin = execSync("which rex", { encoding: "utf-8" }).trim();
|
|
154
|
+
} catch {
|
|
155
|
+
rexBin = "";
|
|
156
|
+
}
|
|
157
|
+
if (!rexBin) {
|
|
158
|
+
info("rex binary not in PATH \u2014 skipping LaunchAgent (install globally first)");
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
if (existsSync(plistPath)) {
|
|
162
|
+
skip("LaunchAgent already installed (auto-start on login)");
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
const plist = `<?xml version="1.0" encoding="UTF-8"?>
|
|
166
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
167
|
+
<plist version="1.0">
|
|
168
|
+
<dict>
|
|
169
|
+
<key>Label</key>
|
|
170
|
+
<string>${PLIST_LABEL}</string>
|
|
171
|
+
<key>ProgramArguments</key>
|
|
172
|
+
<array>
|
|
173
|
+
<string>${rexBin}</string>
|
|
174
|
+
<string>doctor</string>
|
|
175
|
+
</array>
|
|
176
|
+
<key>RunAtLoad</key>
|
|
177
|
+
<true/>
|
|
178
|
+
<key>StartInterval</key>
|
|
179
|
+
<integer>3600</integer>
|
|
180
|
+
<key>StandardOutPath</key>
|
|
181
|
+
<string>${join(homedir(), ".claude", "rex-doctor.log")}</string>
|
|
182
|
+
<key>StandardErrorPath</key>
|
|
183
|
+
<string>${join(homedir(), ".claude", "rex-doctor.log")}</string>
|
|
184
|
+
<key>EnvironmentVariables</key>
|
|
185
|
+
<dict>
|
|
186
|
+
<key>PATH</key>
|
|
187
|
+
<string>/usr/local/bin:/usr/bin:/bin:${dirname(rexBin)}</string>
|
|
188
|
+
</dict>
|
|
189
|
+
</dict>
|
|
190
|
+
</plist>
|
|
191
|
+
`;
|
|
192
|
+
writeFileSync(plistPath, plist);
|
|
193
|
+
try {
|
|
194
|
+
execSync(`launchctl load ${plistPath}`, { stdio: "ignore" });
|
|
195
|
+
} catch {
|
|
196
|
+
}
|
|
197
|
+
ok("LaunchAgent installed \u2014 rex runs at login + every hour");
|
|
198
|
+
}
|
|
199
|
+
function uninstallStartup() {
|
|
200
|
+
if (process.platform !== "darwin") return;
|
|
201
|
+
const plistPath = join(homedir(), "Library", "LaunchAgents", `${PLIST_LABEL}.plist`);
|
|
202
|
+
if (!existsSync(plistPath)) {
|
|
203
|
+
info("LaunchAgent not installed");
|
|
204
|
+
} else {
|
|
205
|
+
try {
|
|
206
|
+
execSync(`launchctl unload ${plistPath}`, { stdio: "ignore" });
|
|
207
|
+
} catch {
|
|
208
|
+
}
|
|
209
|
+
try {
|
|
210
|
+
unlinkSync(plistPath);
|
|
211
|
+
} catch {
|
|
212
|
+
}
|
|
213
|
+
ok("LaunchAgent removed");
|
|
214
|
+
}
|
|
215
|
+
uninstallIngestAgent();
|
|
216
|
+
}
|
|
42
217
|
async function init() {
|
|
43
218
|
const claudeDir = join(homedir(), ".claude");
|
|
44
219
|
const line = "\u2550".repeat(45);
|
|
@@ -204,6 +379,9 @@ fi
|
|
|
204
379
|
} else {
|
|
205
380
|
skip("All REX guards already installed");
|
|
206
381
|
}
|
|
382
|
+
installStartup();
|
|
383
|
+
installIngestAgent();
|
|
384
|
+
installApp();
|
|
207
385
|
let ollamaOk = false;
|
|
208
386
|
try {
|
|
209
387
|
const res = await fetch("http://localhost:11434/api/tags");
|
|
@@ -244,5 +422,10 @@ ${COLORS.bold} REX initialized!${COLORS.reset}`);
|
|
|
244
422
|
console.log();
|
|
245
423
|
}
|
|
246
424
|
export {
|
|
247
|
-
init
|
|
425
|
+
init,
|
|
426
|
+
installApp,
|
|
427
|
+
installIngestAgent,
|
|
428
|
+
installStartup,
|
|
429
|
+
uninstallIngestAgent,
|
|
430
|
+
uninstallStartup
|
|
248
431
|
};
|