rex-claude 2.0.0 → 2.1.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 CHANGED
@@ -369,7 +369,7 @@ async function main() {
369
369
  break;
370
370
  }
371
371
  case "init": {
372
- const { init } = await import("./init-YMRG5ZXU.js");
372
+ const { init } = await import("./init-S7BKM2N2.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-S7BKM2N2.js");
418
+ installStartup();
419
+ break;
420
+ }
421
+ case "startup-remove": {
422
+ const { uninstallStartup } = await import("./init-S7BKM2N2.js");
423
+ uninstallStartup();
424
+ break;
425
+ }
416
426
  case "--version":
417
427
  case "-v":
418
- console.log("rex-cli v0.1.0");
428
+ console.log("rex-claude v2.1.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 Setup REX (guards, hooks, MCP)
427
- rex doctor Full health check (9 categories)
428
- rex status Quick one-line 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,80 @@ 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
+ function installStartup() {
45
+ if (process.platform !== "darwin") {
46
+ info("Startup auto-launch only supported on macOS");
47
+ return;
48
+ }
49
+ const launchAgentsDir = join(homedir(), "Library", "LaunchAgents");
50
+ ensureDir(launchAgentsDir);
51
+ const plistPath = join(launchAgentsDir, `${PLIST_LABEL}.plist`);
52
+ let rexBin = "";
53
+ try {
54
+ rexBin = execSync("which rex", { encoding: "utf-8" }).trim();
55
+ } catch {
56
+ rexBin = "";
57
+ }
58
+ if (!rexBin) {
59
+ info("rex binary not in PATH \u2014 skipping LaunchAgent (install globally first)");
60
+ return;
61
+ }
62
+ if (existsSync(plistPath)) {
63
+ skip("LaunchAgent already installed (auto-start on login)");
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>${PLIST_LABEL}</string>
72
+ <key>ProgramArguments</key>
73
+ <array>
74
+ <string>${rexBin}</string>
75
+ <string>doctor</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-doctor.log")}</string>
83
+ <key>StandardErrorPath</key>
84
+ <string>${join(homedir(), ".claude", "rex-doctor.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("LaunchAgent installed \u2014 rex runs at login + every hour");
99
+ }
100
+ function uninstallStartup() {
101
+ if (process.platform !== "darwin") return;
102
+ const plistPath = join(homedir(), "Library", "LaunchAgents", `${PLIST_LABEL}.plist`);
103
+ if (!existsSync(plistPath)) {
104
+ info("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("LaunchAgent removed");
116
+ }
42
117
  async function init() {
43
118
  const claudeDir = join(homedir(), ".claude");
44
119
  const line = "\u2550".repeat(45);
@@ -204,6 +279,7 @@ fi
204
279
  } else {
205
280
  skip("All REX guards already installed");
206
281
  }
282
+ installStartup();
207
283
  let ollamaOk = false;
208
284
  try {
209
285
  const res = await fetch("http://localhost:11434/api/tags");
@@ -244,5 +320,7 @@ ${COLORS.bold} REX initialized!${COLORS.reset}`);
244
320
  console.log();
245
321
  }
246
322
  export {
247
- init
323
+ init,
324
+ installStartup,
325
+ uninstallStartup
248
326
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rex-claude",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "Claude Code sous steroides — guards, health checks, memory RAG",
5
5
  "type": "module",
6
6
  "bin": {