arisa 2.1.8 → 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/bin/arisa.js CHANGED
@@ -575,33 +575,38 @@ function isSystemdActive() {
575
575
  return result.status === 0;
576
576
  }
577
577
 
578
+ function canUseSystemdSystem() {
579
+ if (platform() !== "linux") return false;
580
+ if (!commandExists("systemctl")) return false;
581
+ const probe = runCommand("systemctl", ["is-system-running"], { stdio: "pipe" });
582
+ const state = (probe.stdout || "").trim();
583
+ return probe.status === 0 || state === "degraded" || state === "running";
584
+ }
585
+
586
+ function runArisaForeground() {
587
+ const su = spawnSync("su", ["-", "arisa", "-c", `${ARISA_BUN_ENV} && /home/arisa/.bun/bin/bun /home/arisa/arisa/src/daemon/index.ts`], {
588
+ stdio: "inherit",
589
+ });
590
+ return su.status ?? 1;
591
+ }
592
+
578
593
  // ── Root guard ──────────────────────────────────────────────────────
579
594
 
580
595
  if (isRoot()) {
581
596
  if (!isProvisioned()) {
582
597
  provisionArisaUser();
583
- writeSystemdSystemUnit();
584
- spawnSync("systemctl", ["daemon-reload"], { stdio: "inherit" });
585
- spawnSync("systemctl", ["enable", "arisa"], { stdio: "inherit" });
586
- step(true, "Systemd service enabled (auto-starts on reboot)");
598
+ if (canUseSystemdSystem()) {
599
+ writeSystemdSystemUnit();
600
+ spawnSync("systemctl", ["daemon-reload"], { stdio: "inherit" });
601
+ spawnSync("systemctl", ["enable", "arisa"], { stdio: "inherit" });
602
+ step(true, "Systemd service enabled (auto-starts on reboot)");
603
+ }
587
604
 
588
605
  process.stdout.write("\nStarting interactive setup as user arisa...\n\n");
589
- const su = spawnSync("su", ["-", "arisa", "-c", `${ARISA_BUN_ENV} && /home/arisa/.bun/bin/bun /home/arisa/arisa/src/daemon/index.ts`], {
590
- stdio: "inherit",
591
- });
592
-
593
- process.stdout.write(`
594
- Arisa management:
595
- Start: systemctl start arisa
596
- Status: systemctl status arisa
597
- Logs: journalctl -u arisa -f
598
- Restart: systemctl restart arisa
599
- Stop: systemctl stop arisa
600
- `);
601
- process.exit(su.status ?? 0);
602
- }
603
-
604
- // Already provisioned — route commands to system-level systemd
606
+ process.exit(runArisaForeground());
607
+ }
608
+
609
+ // Already provisioned — route commands
605
610
  if (command === "help" || command === "--help" || command === "-h") {
606
611
  printHelp();
607
612
  process.exit(0);
@@ -611,51 +616,48 @@ Arisa management:
611
616
  process.exit(0);
612
617
  }
613
618
 
614
- // No args → interactive setup if not configured, otherwise systemd
619
+ const hasSystemd = canUseSystemdSystem();
620
+
621
+ // No args → setup if needed, then systemd or foreground
615
622
  if (isDefaultInvocation) {
616
623
  if (!isArisaConfigured()) {
617
624
  process.stdout.write("Arisa is not configured yet. Starting interactive setup...\n\n");
618
- const su = spawnSync("su", ["-", "arisa", "-c", `${ARISA_BUN_ENV} && /home/arisa/.bun/bin/bun /home/arisa/arisa/src/daemon/index.ts`], {
619
- stdio: "inherit",
620
- });
621
- process.stdout.write(`
622
- Arisa management:
623
- Start: systemctl start arisa
624
- Status: systemctl status arisa
625
- Logs: journalctl -u arisa -f
626
- Restart: systemctl restart arisa
627
- Stop: systemctl stop arisa
628
- `);
629
- process.exit(su.status ?? 0);
625
+ process.exit(runArisaForeground());
630
626
  }
631
- if (isSystemdActive()) {
632
- process.exit(statusSystemdSystem());
633
- } else {
634
- process.exit(startSystemdSystem());
627
+ if (hasSystemd) {
628
+ if (isSystemdActive()) {
629
+ process.exit(statusSystemdSystem());
630
+ } else {
631
+ process.exit(startSystemdSystem());
632
+ }
635
633
  }
634
+ // No systemd → foreground
635
+ process.exit(runArisaForeground());
636
636
  }
637
637
 
638
638
  switch (command) {
639
639
  case "start":
640
- process.exit(startSystemdSystem());
640
+ if (hasSystemd) process.exit(startSystemdSystem());
641
+ process.exit(runArisaForeground());
641
642
  break;
642
643
  case "stop":
643
- process.exit(stopSystemdSystem());
644
+ if (hasSystemd) process.exit(stopSystemdSystem());
645
+ process.stderr.write("No systemd available. Stop the foreground process with Ctrl+C.\n");
646
+ process.exit(1);
644
647
  break;
645
648
  case "restart":
646
- process.exit(restartSystemdSystem());
649
+ if (hasSystemd) process.exit(restartSystemdSystem());
650
+ process.stderr.write("No systemd available. Restart the foreground process manually.\n");
651
+ process.exit(1);
647
652
  break;
648
653
  case "status":
649
- process.exit(statusSystemdSystem());
654
+ if (hasSystemd) process.exit(statusSystemdSystem());
655
+ process.stderr.write("No systemd available.\n");
656
+ process.exit(1);
650
657
  break;
651
658
  case "daemon":
652
- case "run": {
653
- // Explicit "arisa daemon/run" → foreground as arisa user
654
- const su = spawnSync("su", ["-", "arisa", "-c", `${ARISA_BUN_ENV} && /home/arisa/.bun/bin/bun /home/arisa/arisa/src/daemon/index.ts`], {
655
- stdio: "inherit",
656
- });
657
- process.exit(su.status ?? 1);
658
- }
659
+ case "run":
660
+ process.exit(runArisaForeground());
659
661
  default:
660
662
  process.stderr.write(`Unknown command: ${command}\n\n`);
661
663
  printHelp();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arisa",
3
- "version": "2.1.8",
3
+ "version": "2.2.0",
4
4
  "description": "Arisa - dynamic agent runtime with daemon/core architecture that evolves through user interaction",
5
5
  "preferGlobal": true,
6
6
  "bin": {
@@ -147,9 +147,12 @@ async function runClaude(message: string, chatId: string): Promise<string> {
147
147
 
148
148
  const proc = Bun.spawn(buildBunWrappedAgentCliCommand("claude", args), {
149
149
  cwd: config.projectDir,
150
+ stdin: "pipe",
150
151
  stdout: "pipe",
151
152
  stderr: "pipe",
153
+ env: { ...process.env, CI: "1" },
152
154
  });
155
+ proc.stdin.end();
153
156
 
154
157
  const timeout = setTimeout(() => {
155
158
  log.warn(`Claude timed out after ${model.timeout}ms, killing process`);