arisa 2.0.6 → 2.0.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arisa",
3
- "version": "2.0.6",
3
+ "version": "2.0.7",
4
4
  "description": "Arisa - dynamic agent runtime with daemon/core architecture that evolves through user interaction",
5
5
  "preferGlobal": true,
6
6
  "bin": {
@@ -3,10 +3,51 @@
3
3
  * @role Resolve agent CLI binaries and execute them via Bun runtime.
4
4
  */
5
5
 
6
+ import { existsSync } from "fs";
7
+ import { delimiter, dirname, join } from "path";
8
+
6
9
  export type AgentCliName = "claude" | "codex";
7
10
 
11
+ function unique(paths: Array<string | null | undefined>): string[] {
12
+ const seen = new Set<string>();
13
+ const out: string[] = [];
14
+ for (const p of paths) {
15
+ if (!p) continue;
16
+ if (seen.has(p)) continue;
17
+ seen.add(p);
18
+ out.push(p);
19
+ }
20
+ return out;
21
+ }
22
+
23
+ function cliOverrideEnvVar(cli: AgentCliName): string | undefined {
24
+ return cli === "codex" ? process.env.ARISA_CODEX_BIN : process.env.ARISA_CLAUDE_BIN;
25
+ }
26
+
27
+ function candidatePaths(cli: AgentCliName): string[] {
28
+ const bunInstall = process.env.BUN_INSTALL?.trim();
29
+ const bunDir = dirname(process.execPath);
30
+ const fromPath = Bun.which(cli);
31
+ const fromEnvPath = (process.env.PATH || "")
32
+ .split(delimiter)
33
+ .map((entry) => entry.trim())
34
+ .filter(Boolean)
35
+ .map((entry) => join(entry, cli));
36
+
37
+ return unique([
38
+ cliOverrideEnvVar(cli),
39
+ bunInstall ? join(bunInstall, "bin", cli) : null,
40
+ join(bunDir, cli),
41
+ fromPath,
42
+ ...fromEnvPath,
43
+ ]);
44
+ }
45
+
8
46
  export function resolveAgentCliPath(cli: AgentCliName): string | null {
9
- return Bun.which(cli);
47
+ for (const candidate of candidatePaths(cli)) {
48
+ if (existsSync(candidate)) return candidate;
49
+ }
50
+ return null;
10
51
  }
11
52
 
12
53
  export function isAgentCliInstalled(cli: AgentCliName): boolean {
@@ -16,7 +57,7 @@ export function isAgentCliInstalled(cli: AgentCliName): boolean {
16
57
  export function buildBunWrappedAgentCliCommand(cli: AgentCliName, args: string[]): string[] {
17
58
  const cliPath = resolveAgentCliPath(cli);
18
59
  if (!cliPath) {
19
- throw new Error(`${cli} CLI not found in PATH`);
60
+ throw new Error(`${cli} CLI not found`);
20
61
  }
21
62
  return ["bun", "--bun", cliPath, ...args];
22
63
  }