@rse/claudex 1.0.16 → 1.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/CHANGELOG.md +13 -0
- package/README.md +12 -0
- package/ansi-recolor.conf +3 -0
- package/claudex.js +106 -28
- package/claudex.ts +108 -28
- package/lazygit.yaml +3 -3
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,19 @@
|
|
|
2
2
|
ChangeLog
|
|
3
3
|
=========
|
|
4
4
|
|
|
5
|
+
1.0.17 (2026-09-28)
|
|
6
|
+
-------------------
|
|
7
|
+
|
|
8
|
+
- IMPROVEMENT: add more color mappings to ansi-recolor configuration
|
|
9
|
+
- BUGFIX: fix coloring under latest Claude Code
|
|
10
|
+
- BUGFIX: do not break on non-interactive TTYs when determining color depth
|
|
11
|
+
- UPDATE: upgrade NPM dependencies
|
|
12
|
+
|
|
13
|
+
1.0.16 (2026-08-25)
|
|
14
|
+
-------------------
|
|
15
|
+
|
|
16
|
+
- UPDATE: upgrade to newer LazyGit configuration (diff renderers, hunk mode in staging view)
|
|
17
|
+
|
|
5
18
|
1.0.15 (2026-08-08)
|
|
6
19
|
-------------------
|
|
7
20
|
|
package/README.md
CHANGED
|
@@ -90,6 +90,18 @@ $ CLAUDE_MODEL="ollama:/gemma4:31b-coding-mtp-bf16?context=262K" claudex -T -R -
|
|
|
90
90
|
$ CLAUDE_MODEL="openrouter:google/gemini-3.5-flash?context=1000000" claudex -T -R -A
|
|
91
91
|
```
|
|
92
92
|
|
|
93
|
+
```sh
|
|
94
|
+
# example: run Claude Code with a Codex model via a local proxy
|
|
95
|
+
$ CLAUDE_MODEL="codex:gpt-6.1-sol[1m]" claudex -T -R -A
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Codex mode requires `claude-code-proxy` in `$PATH` with its Codex
|
|
99
|
+
authentication configured. claudeX reuses a healthy proxy at
|
|
100
|
+
`http://127.0.0.1:18765`, or automatically starts
|
|
101
|
+
`claude-code-proxy serve --port 18765 --no-monitor` and waits for readiness.
|
|
102
|
+
The proxy stays running after Claude Code exits so other sessions can reuse it.
|
|
103
|
+
With `-C`, the proxy and its authentication must be available inside the container.
|
|
104
|
+
|
|
93
105
|
See Also
|
|
94
106
|
--------
|
|
95
107
|
|
package/ansi-recolor.conf
CHANGED
|
@@ -88,6 +88,7 @@ claude:
|
|
|
88
88
|
|
|
89
89
|
default/255 -> rse-white/rse-blue-1
|
|
90
90
|
16/255 -> rse-white/rse-blue-1
|
|
91
|
+
241/255 -> rse-white/rse-blue-1
|
|
91
92
|
248/255 -> rse-blue-4/rse-blue-1
|
|
92
93
|
145/255 -> rse-blue-4/rse-blue-1
|
|
93
94
|
|
|
@@ -121,6 +122,8 @@ claude:
|
|
|
121
122
|
|
|
122
123
|
*/189 -> */rse-blue-4
|
|
123
124
|
|
|
125
|
+
168/* -> red/*
|
|
126
|
+
|
|
124
127
|
magenta/* -> red/*
|
|
125
128
|
yellow/* -> red/*
|
|
126
129
|
cyan/* -> blue/*
|
package/claudex.js
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import * as fs from "node:fs";
|
|
8
8
|
import * as path from "node:path";
|
|
9
9
|
import * as os from "node:os";
|
|
10
|
+
import { spawn } from "node:child_process";
|
|
10
11
|
import { execa, execaSync } from "execa";
|
|
11
12
|
import which from "which";
|
|
12
13
|
import chalk from "chalk";
|
|
@@ -160,7 +161,7 @@ const execInherit = (file, args, opts = {}) => {
|
|
|
160
161
|
reject: false,
|
|
161
162
|
windowsHide: false
|
|
162
163
|
});
|
|
163
|
-
process.exit(r.exitCode ??
|
|
164
|
+
process.exit(r.exitCode ?? 1);
|
|
164
165
|
};
|
|
165
166
|
/* helper to execute a platform-specific command */
|
|
166
167
|
const executeCommand = (config, platformOverride) => {
|
|
@@ -177,7 +178,7 @@ const executeCommand = (config, platformOverride) => {
|
|
|
177
178
|
reject: false,
|
|
178
179
|
windowsHide: false
|
|
179
180
|
});
|
|
180
|
-
return result.exitCode;
|
|
181
|
+
return result.exitCode ?? 1;
|
|
181
182
|
};
|
|
182
183
|
/* helper to update an externally managed tool with exactly the package
|
|
183
184
|
manager which actually provides it, instead of just the preferred one */
|
|
@@ -253,7 +254,7 @@ const self = async (...args) => {
|
|
|
253
254
|
stdio: "inherit",
|
|
254
255
|
reject: false
|
|
255
256
|
});
|
|
256
|
-
if ((r.exitCode ??
|
|
257
|
+
if ((r.exitCode ?? 1) !== 0)
|
|
257
258
|
process.exit(r.exitCode ?? 1);
|
|
258
259
|
return r.exitCode ?? 0;
|
|
259
260
|
};
|
|
@@ -300,7 +301,10 @@ const pruneClaudeVersions = (active) => {
|
|
|
300
301
|
const versionsDir = path.join(HOME, ".local/share/claude/versions");
|
|
301
302
|
if (!fs.existsSync(versionsDir))
|
|
302
303
|
return;
|
|
303
|
-
|
|
304
|
+
const versions = fs.readdirSync(versionsDir);
|
|
305
|
+
if (!versions.includes(active))
|
|
306
|
+
return;
|
|
307
|
+
for (const f of versions) {
|
|
304
308
|
if (f === active)
|
|
305
309
|
continue;
|
|
306
310
|
try {
|
|
@@ -315,6 +319,8 @@ const pruneClaudeVersions = (active) => {
|
|
|
315
319
|
const detectActiveClaudeVersion = (binName) => {
|
|
316
320
|
try {
|
|
317
321
|
const r = execaSync(path.join(HOME, ".local/bin", binName), ["--version"], { reject: false });
|
|
322
|
+
if (r.exitCode !== 0)
|
|
323
|
+
return null;
|
|
318
324
|
const m = /^(\S+)/.exec(r.stdout ?? "");
|
|
319
325
|
if (m)
|
|
320
326
|
return m[1];
|
|
@@ -345,11 +351,11 @@ const actionInstall = async (capsula) => {
|
|
|
345
351
|
info("install Tmux / LazyGit / Git");
|
|
346
352
|
await self("internal", "capsula", "-s", "sudo", "-E", "apt", "install", "-qq", "-y", "tmux", "lazygit", "git");
|
|
347
353
|
info("install Node.js");
|
|
348
|
-
await self("internal", "capsula", "-s", "sudo", "-E", "bash", "-c", "curl -fsSL https://deb.nodesource.com/setup_24.x | bash -");
|
|
354
|
+
await self("internal", "capsula", "-s", "sudo", "-E", "bash", "-o", "pipefail", "-c", "curl -fsSL https://deb.nodesource.com/setup_24.x | bash -");
|
|
349
355
|
await self("internal", "capsula", "-s", "sudo", "-E", "apt", "install", "-qq", "-y", "nodejs");
|
|
350
356
|
await self("internal", "capsula", "-s", "sudo", "-E", "apt", "install", "-qq", "-y", "binutils", "gcc", "g++", "make");
|
|
351
357
|
info("install Claude Code");
|
|
352
|
-
await self("internal", "capsula", "bash", "-c", `PATH="${HOME}/.local/bin:$PATH"; curl -fsSL https://claude.ai/install.sh | bash`);
|
|
358
|
+
await self("internal", "capsula", "bash", "-o", "pipefail", "-c", `PATH="${HOME}/.local/bin:$PATH"; curl -fsSL https://claude.ai/install.sh | bash`);
|
|
353
359
|
info("install ANSI-Recolor");
|
|
354
360
|
await self("internal", "capsula", "-s", "sudo", "-E", "npm", "install", "-y", "-g", "--allow-scripts=node-pty,tty-attr", "ansi-recolor");
|
|
355
361
|
info("install TypeScript LS");
|
|
@@ -365,6 +371,7 @@ const actionInstall = async (capsula) => {
|
|
|
365
371
|
"[ -d \"$VERSIONS\" ] || exit 0; " +
|
|
366
372
|
"ACTIVE=$(\"$HOME/.local/bin/claude\" --version 2>/dev/null | awk '{print $1; exit}'); " +
|
|
367
373
|
"[ -n \"$ACTIVE\" ] || exit 0; " +
|
|
374
|
+
"[ -f \"$VERSIONS/$ACTIVE\" ] || exit 0; " +
|
|
368
375
|
"find \"$VERSIONS\" -mindepth 1 -maxdepth 1 ! -name \"$ACTIVE\" -exec rm -rf {} +");
|
|
369
376
|
}
|
|
370
377
|
else {
|
|
@@ -429,7 +436,7 @@ const actionInstall = async (capsula) => {
|
|
|
429
436
|
"windows:choco": "choco install -y --accept-license --no-progress nodejs",
|
|
430
437
|
"macos:ports": "sudo port -N install nodejs26 npm11",
|
|
431
438
|
"macos:brew": "brew install node",
|
|
432
|
-
"linux:apt": "curl -fsSL https://deb.nodesource.com/setup_26.x | sudo -E bash - && sudo apt install -y nodejs",
|
|
439
|
+
"linux:apt": ["bash", "-o", "pipefail", "-c", "curl -fsSL https://deb.nodesource.com/setup_26.x | sudo -E bash - && sudo apt install -y nodejs"],
|
|
433
440
|
"linux:dnf": "sudo dnf install -y nodejs npm",
|
|
434
441
|
"linux:yum": "sudo yum install -y nodejs npm",
|
|
435
442
|
"linux:zypper": "sudo zypper --non-interactive install nodejs npm",
|
|
@@ -470,8 +477,8 @@ const actionInstall = async (capsula) => {
|
|
|
470
477
|
/* run installation script */
|
|
471
478
|
ensureTool("bash", { hint: "https://www.gnu.org/software/bash/" });
|
|
472
479
|
ensureTool("curl", { hint: "https://curl.se/" });
|
|
473
|
-
await execa("bash", ["-c", `PATH="${HOME}/.local/bin:$PATH"; curl -fsSL https://claude.ai/install.sh | bash`], {
|
|
474
|
-
stdio: "inherit"
|
|
480
|
+
await execa("bash", ["-o", "pipefail", "-c", `PATH="${HOME}/.local/bin:$PATH"; curl -fsSL https://claude.ai/install.sh | bash`], {
|
|
481
|
+
stdio: "inherit"
|
|
475
482
|
});
|
|
476
483
|
/* prune obsolete versions only after successful install */
|
|
477
484
|
pruneClaudeVersions(detectActiveClaudeVersion("claude"));
|
|
@@ -482,7 +489,7 @@ const actionInstall = async (capsula) => {
|
|
|
482
489
|
/* run installation script */
|
|
483
490
|
ensureTool("powershell");
|
|
484
491
|
await execa("powershell", ["-NoProfile", "-Command", "irm https://claude.ai/install.ps1 | iex"], {
|
|
485
|
-
stdio: "inherit"
|
|
492
|
+
stdio: "inherit"
|
|
486
493
|
});
|
|
487
494
|
/* prune obsolete versions only after successful install */
|
|
488
495
|
pruneClaudeVersions(detectActiveClaudeVersion("claude.exe"));
|
|
@@ -593,7 +600,7 @@ const actionUpdate = async (capsula) => {
|
|
|
593
600
|
if (process.platform !== "win32") {
|
|
594
601
|
ensureTool("bash");
|
|
595
602
|
await execa("bash", ["-c", `PATH="${HOME}/.local/bin:$PATH"; ${HOME}/.local/bin/claude update`], {
|
|
596
|
-
stdio: "inherit"
|
|
603
|
+
stdio: "inherit"
|
|
597
604
|
});
|
|
598
605
|
/* prune obsolete versions only after successful update */
|
|
599
606
|
pruneClaudeVersions(detectActiveClaudeVersion("claude"));
|
|
@@ -603,7 +610,7 @@ const actionUpdate = async (capsula) => {
|
|
|
603
610
|
fatal("on Windows the \"update\" command has to be run from within a PowerShell session");
|
|
604
611
|
ensureTool("powershell");
|
|
605
612
|
await execa("powershell", ["-NoProfile", "-Command", "claude update"], {
|
|
606
|
-
stdio: "inherit"
|
|
613
|
+
stdio: "inherit"
|
|
607
614
|
});
|
|
608
615
|
/* prune obsolete versions only after successful update */
|
|
609
616
|
pruneClaudeVersions(detectActiveClaudeVersion("claude.exe"));
|
|
@@ -655,7 +662,7 @@ const actionInternalTmux = (opts, args) => {
|
|
|
655
662
|
}
|
|
656
663
|
conf = conf.replace(/@USER@/g, USER);
|
|
657
664
|
const confFile = path.join(os.tmpdir(), `claudex-tmux-${process.pid}.conf`);
|
|
658
|
-
fs.writeFileSync(confFile, conf, { mode: 0o600 });
|
|
665
|
+
fs.writeFileSync(confFile, conf, { mode: 0o600, flag: "wx" });
|
|
659
666
|
/* ensure the temp config is removed on normal exit AND on signal-driven
|
|
660
667
|
termination (SIGINT/SIGTERM); SIGKILL and process panics remain
|
|
661
668
|
uncoverable. tmux.conf is read once at startup and not re-read via
|
|
@@ -678,7 +685,7 @@ const actionInternalTmux = (opts, args) => {
|
|
|
678
685
|
windowsHide: false
|
|
679
686
|
});
|
|
680
687
|
cleanup();
|
|
681
|
-
return process.exit(r.exitCode ??
|
|
688
|
+
return process.exit(r.exitCode ?? 1);
|
|
682
689
|
};
|
|
683
690
|
/* action: internal "shell" -- spawn an interactive login shell */
|
|
684
691
|
const actionInternalShell = (_opts, args) => {
|
|
@@ -744,6 +751,8 @@ const actionInternalCapsula = (_opts, args) => {
|
|
|
744
751
|
const envOpts = ["-e", "!"];
|
|
745
752
|
for (const e of envs)
|
|
746
753
|
envOpts.push("-e", e);
|
|
754
|
+
if (process.env.OPENROUTER_API_KEY !== undefined)
|
|
755
|
+
envOpts.push("-e", "OPENROUTER_API_KEY");
|
|
747
756
|
/* find list of dot-files (relative to $HOME) */
|
|
748
757
|
const dotfiles = [
|
|
749
758
|
".inputrc",
|
|
@@ -849,7 +858,7 @@ const actionInternal = async (opts, args) => {
|
|
|
849
858
|
}
|
|
850
859
|
};
|
|
851
860
|
/* action: top-level command -- run "claude" */
|
|
852
|
-
const actionDefault = (opts, args) => {
|
|
861
|
+
const actionDefault = async (opts, args) => {
|
|
853
862
|
/* build the inner self-invocation flag list. Pass-through "-R"/"-A" only,
|
|
854
863
|
as "-C" and "-T" are consumed at the outer layer to avoid recursion. */
|
|
855
864
|
const innerFlags = [];
|
|
@@ -883,14 +892,20 @@ const actionDefault = (opts, args) => {
|
|
|
883
892
|
execaSync("docker", ["start", container], { reject: false, stdio: "ignore" });
|
|
884
893
|
/* enter already running container and run tmux */
|
|
885
894
|
return execInherit("docker", [
|
|
886
|
-
"exec", "-i", "-t"
|
|
895
|
+
"exec", "-i", ...(process.stdin.isTTY ? ["-t"] : []),
|
|
896
|
+
"-w", process.cwd(),
|
|
897
|
+
"-e", `CLAUDE_MODEL=${process.env.CLAUDE_MODEL ?? ""}`,
|
|
898
|
+
...(process.env.OPENROUTER_API_KEY !== undefined ? ["-e", "OPENROUTER_API_KEY"] : []),
|
|
899
|
+
container,
|
|
887
900
|
"bash", "-c",
|
|
888
901
|
`TERM=${shQ.quote([TERM])} ` +
|
|
889
902
|
`HOME=${shQ.quote([HOME])} ` +
|
|
890
903
|
`CLAUDEX_FLAGS=${shQ.quote([claudexFlags])} ` +
|
|
904
|
+
`CLAUDEX_INTERNAL_EXEC=${shQ.quote([inPane])} ` +
|
|
891
905
|
`sudo -E -u ${shQ.quote([USER])} ` +
|
|
892
906
|
`${shQ.quote(["node" /* process.execPath is not valid inside container! */, selfPathJS])} ` +
|
|
893
|
-
`${opts.ase ? "-A " : ""}internal tmux new-session -A -s ${shQ.quote([session])}`
|
|
907
|
+
`${opts.ase ? "-A " : ""}internal tmux new-session -A -s ${shQ.quote([session])} ` +
|
|
908
|
+
`-n claude ${shQ.quote(["claudex internal exec"])}`
|
|
894
909
|
]);
|
|
895
910
|
}
|
|
896
911
|
else {
|
|
@@ -936,7 +951,11 @@ const actionDefault = (opts, args) => {
|
|
|
936
951
|
execaSync("docker", ["start", container], { reject: false, stdio: "ignore" });
|
|
937
952
|
/* enter already running container and run claude (single-quote shell-escape) */
|
|
938
953
|
return execInherit("docker", [
|
|
939
|
-
"exec", "-i", "-t"
|
|
954
|
+
"exec", "-i", ...(process.stdin.isTTY ? ["-t"] : []),
|
|
955
|
+
"-w", process.cwd(),
|
|
956
|
+
"-e", `CLAUDE_MODEL=${process.env.CLAUDE_MODEL ?? ""}`,
|
|
957
|
+
...(process.env.OPENROUTER_API_KEY !== undefined ? ["-e", "OPENROUTER_API_KEY"] : []),
|
|
958
|
+
container,
|
|
940
959
|
"bash", "-c",
|
|
941
960
|
`TERM=${shQ.quote([TERM])} ` +
|
|
942
961
|
`HOME=${shQ.quote([HOME])} ` +
|
|
@@ -960,7 +979,7 @@ const actionDefault = (opts, args) => {
|
|
|
960
979
|
const recolor = opts.recolor === true;
|
|
961
980
|
if (recolor)
|
|
962
981
|
ensureTool("ansi-recolor");
|
|
963
|
-
process.env.PATH = `${HOME
|
|
982
|
+
process.env.PATH = `${path.join(HOME, ".local/bin")}${path.delimiter}${process.env.PATH ?? ""}`;
|
|
964
983
|
ensureTool("claude");
|
|
965
984
|
const env = { ...process.env };
|
|
966
985
|
const claudeModel = process.env.CLAUDE_MODEL ?? "";
|
|
@@ -1006,9 +1025,10 @@ const actionDefault = (opts, args) => {
|
|
|
1006
1025
|
env.ANTHROPIC_AUTH_TOKEN = "ollama";
|
|
1007
1026
|
env.ANTHROPIC_BASE_URL = `http://${ohost}`;
|
|
1008
1027
|
env.ANTHROPIC_CUSTOM_MODEL_OPTION_SUPPORTED_CAPABILITIES = capabilities;
|
|
1009
|
-
env.
|
|
1028
|
+
env.ANTHROPIC_DEFAULT_FABLE_MODEL = model;
|
|
1010
1029
|
env.ANTHROPIC_DEFAULT_OPUS_MODEL = model;
|
|
1011
1030
|
env.ANTHROPIC_DEFAULT_SONNET_MODEL = model;
|
|
1031
|
+
env.ANTHROPIC_DEFAULT_HAIKU_MODEL = model;
|
|
1012
1032
|
env.CLAUDE_CODE_SUBAGENT_MODEL = model;
|
|
1013
1033
|
env.CLAUDE_CODE_ATTRIBUTION_HEADER = "0";
|
|
1014
1034
|
env.CLAUDE_CODE_AUTO_COMPACT_WINDOW = context;
|
|
@@ -1045,9 +1065,10 @@ const actionDefault = (opts, args) => {
|
|
|
1045
1065
|
env.ANTHROPIC_AUTH_TOKEN = process.env.OPENROUTER_API_KEY;
|
|
1046
1066
|
env.ANTHROPIC_BASE_URL = "https://openrouter.ai/api";
|
|
1047
1067
|
env.ANTHROPIC_CUSTOM_MODEL_OPTION_SUPPORTED_CAPABILITIES = capabilities;
|
|
1048
|
-
env.
|
|
1068
|
+
env.ANTHROPIC_DEFAULT_FABLE_MODEL = model;
|
|
1049
1069
|
env.ANTHROPIC_DEFAULT_OPUS_MODEL = model;
|
|
1050
1070
|
env.ANTHROPIC_DEFAULT_SONNET_MODEL = model;
|
|
1071
|
+
env.ANTHROPIC_DEFAULT_HAIKU_MODEL = model;
|
|
1051
1072
|
env.CLAUDE_CODE_SUBAGENT_MODEL = model;
|
|
1052
1073
|
env.CLAUDE_CODE_ATTRIBUTION_HEADER = "0";
|
|
1053
1074
|
env.CLAUDE_CODE_AUTO_COMPACT_WINDOW = context;
|
|
@@ -1055,10 +1076,67 @@ const actionDefault = (opts, args) => {
|
|
|
1055
1076
|
env.DISABLE_LOGOUT_COMMAND = "1";
|
|
1056
1077
|
env.ENABLE_TOOL_SEARCH = "auto";
|
|
1057
1078
|
}
|
|
1079
|
+
else if (/^codex:/.test(claudeModel)) {
|
|
1080
|
+
const model = claudeModel.slice("codex:".length);
|
|
1081
|
+
if (model.trim() === "")
|
|
1082
|
+
fatal("invalid CLAUDE_MODEL: missing model name in " +
|
|
1083
|
+
`"${claudeModel}" (expected: codex:<model>)`);
|
|
1084
|
+
/* reuse a healthy proxy or start a persistent detached server */
|
|
1085
|
+
const baseURL = "http://127.0.0.1:18765";
|
|
1086
|
+
const deadline = Date.now() + 10000;
|
|
1087
|
+
let proxy;
|
|
1088
|
+
let proxyError = "";
|
|
1089
|
+
while (true) {
|
|
1090
|
+
try {
|
|
1091
|
+
const response = await fetch(`${baseURL}/healthz`, { signal: AbortSignal.timeout(500) });
|
|
1092
|
+
await response.body?.cancel();
|
|
1093
|
+
if (response.ok)
|
|
1094
|
+
break;
|
|
1095
|
+
}
|
|
1096
|
+
catch (_e) {
|
|
1097
|
+
/* not ready yet */
|
|
1098
|
+
}
|
|
1099
|
+
if (proxy === undefined) {
|
|
1100
|
+
ensureTool("claude-code-proxy", { hint: "install claude-code-proxy and configure its Codex authentication first" });
|
|
1101
|
+
proxy = spawn("claude-code-proxy", ["serve", "--port", "18765", "--no-monitor"], {
|
|
1102
|
+
detached: true,
|
|
1103
|
+
stdio: "ignore",
|
|
1104
|
+
windowsHide: true
|
|
1105
|
+
});
|
|
1106
|
+
proxy.on("error", (err) => { proxyError = err.message; });
|
|
1107
|
+
proxy.unref();
|
|
1108
|
+
}
|
|
1109
|
+
else if (proxyError !== "" || proxy.exitCode !== null || proxy.signalCode !== null)
|
|
1110
|
+
fatal("failed to start claude-code-proxy" +
|
|
1111
|
+
(proxyError !== "" ? `: ${proxyError}` : ` (exit ${proxy.exitCode ?? proxy.signalCode})`) +
|
|
1112
|
+
" -- run \"claude-code-proxy serve --port 18765 --no-monitor\" for details");
|
|
1113
|
+
if (Date.now() >= deadline) {
|
|
1114
|
+
proxy.kill();
|
|
1115
|
+
fatal(`claude-code-proxy did not become ready at ${baseURL} within 10 seconds`);
|
|
1116
|
+
}
|
|
1117
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
1118
|
+
}
|
|
1119
|
+
/* override Claude Code configuration as in the claude-codex wrapper */
|
|
1120
|
+
env.ANTHROPIC_BASE_URL = baseURL;
|
|
1121
|
+
env.ANTHROPIC_API_KEY = "";
|
|
1122
|
+
env.ANTHROPIC_AUTH_TOKEN = "unused";
|
|
1123
|
+
env.ANTHROPIC_DEFAULT_MODEL = model;
|
|
1124
|
+
env.ANTHROPIC_DEFAULT_FABLE_MODEL = "gpt-6-astra[1m]";
|
|
1125
|
+
env.ANTHROPIC_DEFAULT_OPUS_MODEL = "gpt-6.1-sol[1m]";
|
|
1126
|
+
env.ANTHROPIC_DEFAULT_SONNET_MODEL = "gpt-6-luna[1m]";
|
|
1127
|
+
env.ANTHROPIC_DEFAULT_HAIKU_MODEL = "gpt-6-luna[1m]";
|
|
1128
|
+
env.CLAUDE_CODE_SUBAGENT_MODEL = "inherit";
|
|
1129
|
+
env.CLAUDE_CODE_AUTO_COMPACT_WINDOW = "272000";
|
|
1130
|
+
env.CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC = "1";
|
|
1131
|
+
env.CLAUDE_CODE_DISABLE_NONSTREAMING_FALLBACK = "1";
|
|
1132
|
+
env.DISABLE_LOGIN_COMMAND = "1";
|
|
1133
|
+
env.DISABLE_LOGOUT_COMMAND = "1";
|
|
1134
|
+
env.ENABLE_TOOL_SEARCH = "auto";
|
|
1135
|
+
}
|
|
1058
1136
|
else if (claudeModel !== "")
|
|
1059
1137
|
fatal(`invalid CLAUDE_MODEL "${claudeModel}" ` +
|
|
1060
|
-
"(supports only: \"ollama[://<host>[:<port>]]/<model>[?[context=<size>],[capabilities=<list>]]\" " +
|
|
1061
|
-
"
|
|
1138
|
+
"(supports only: \"ollama[://<host>[:<port>]]/<model>[?[context=<size>],[capabilities=<list>]]\", " +
|
|
1139
|
+
"\"openrouter:<model>[?[context=<size>],[capabilities=<list>]]\" and \"codex:<model>\")");
|
|
1062
1140
|
/* override ASE configuration (for its diagram rendering) */
|
|
1063
1141
|
if (opts.ase) {
|
|
1064
1142
|
if (env.ASE_TERM_WIDTH === undefined) {
|
|
@@ -1072,7 +1150,7 @@ const actionDefault = (opts, args) => {
|
|
|
1072
1150
|
}
|
|
1073
1151
|
if (env.ASE_TERM_COLORS === undefined) {
|
|
1074
1152
|
let colorMode = "none";
|
|
1075
|
-
const depth = process.stdout.getColorDepth();
|
|
1153
|
+
const depth = process.stdout.isTTY ? process.stdout.getColorDepth() : 1;
|
|
1076
1154
|
if (depth >= 8)
|
|
1077
1155
|
colorMode = "ansi256";
|
|
1078
1156
|
else if (depth >= 4)
|
|
@@ -1134,7 +1212,7 @@ const actionDefault = (opts, args) => {
|
|
|
1134
1212
|
/* action: top-level "-h/--help" */
|
|
1135
1213
|
const actionHelp = () => {
|
|
1136
1214
|
/* run "claude --help" */
|
|
1137
|
-
process.env.PATH = `${HOME
|
|
1215
|
+
process.env.PATH = `${path.join(HOME, ".local/bin")}${path.delimiter}${process.env.PATH ?? ""}`;
|
|
1138
1216
|
ensureTool("claude");
|
|
1139
1217
|
const claudeBin = path.join(HOME, ".local/bin/claude");
|
|
1140
1218
|
execaSync(claudeBin, ["--help"], { reject: false, stdio: ["ignore", "inherit", "inherit"] });
|
|
@@ -1156,7 +1234,7 @@ const actionHelp = () => {
|
|
|
1156
1234
|
/* action: top-level "-v/-V/--version" */
|
|
1157
1235
|
const actionVersion = () => {
|
|
1158
1236
|
/* run "claude --version" */
|
|
1159
|
-
process.env.PATH = `${HOME
|
|
1237
|
+
process.env.PATH = `${path.join(HOME, ".local/bin")}${path.delimiter}${process.env.PATH ?? ""}`;
|
|
1160
1238
|
ensureTool("claude");
|
|
1161
1239
|
const claudeBin = path.join(HOME, ".local/bin/claude");
|
|
1162
1240
|
execaSync(claudeBin, ["--version"], { reject: false, stdio: ["ignore", "inherit", "inherit"] });
|
|
@@ -1248,8 +1326,8 @@ const main = async () => {
|
|
|
1248
1326
|
.option("-R, --recolor", "wrap Claude Code with ANSI recoloring for improved theming")
|
|
1249
1327
|
.option("-A, --ase", "enable ASE-specific ASE_* environment variables and Tmux settings")
|
|
1250
1328
|
.argument("[args...]", "arguments passed unparsed to Claude Code")
|
|
1251
|
-
.action((args, opts) => {
|
|
1252
|
-
actionDefault(opts, args);
|
|
1329
|
+
.action(async (args, opts) => {
|
|
1330
|
+
await actionDefault(opts, args);
|
|
1253
1331
|
});
|
|
1254
1332
|
/* dispatch "install" sub-command */
|
|
1255
1333
|
program
|
package/claudex.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import * as fs from "node:fs"
|
|
9
9
|
import * as path from "node:path"
|
|
10
10
|
import * as os from "node:os"
|
|
11
|
+
import { spawn } from "node:child_process"
|
|
11
12
|
import { execa, execaSync } from "execa"
|
|
12
13
|
import which from "which"
|
|
13
14
|
import chalk from "chalk"
|
|
@@ -179,7 +180,7 @@ const execInherit = (file: string, args: string[], opts: { env?: Env } = {}): ne
|
|
|
179
180
|
reject: false,
|
|
180
181
|
windowsHide: false
|
|
181
182
|
})
|
|
182
|
-
process.exit(r.exitCode ??
|
|
183
|
+
process.exit(r.exitCode ?? 1)
|
|
183
184
|
}
|
|
184
185
|
|
|
185
186
|
/* helper to execute a platform-specific command */
|
|
@@ -197,7 +198,7 @@ const executeCommand = (config: { [ platform: string ]: string[] | string }, pla
|
|
|
197
198
|
reject: false,
|
|
198
199
|
windowsHide: false
|
|
199
200
|
})
|
|
200
|
-
return result.exitCode
|
|
201
|
+
return result.exitCode ?? 1
|
|
201
202
|
}
|
|
202
203
|
|
|
203
204
|
/* helper to update an externally managed tool with exactly the package
|
|
@@ -283,7 +284,7 @@ const self = async (...args: string[]): Promise<number> => {
|
|
|
283
284
|
stdio: "inherit",
|
|
284
285
|
reject: false
|
|
285
286
|
})
|
|
286
|
-
if ((r.exitCode ??
|
|
287
|
+
if ((r.exitCode ?? 1) !== 0)
|
|
287
288
|
process.exit(r.exitCode ?? 1)
|
|
288
289
|
return r.exitCode ?? 0
|
|
289
290
|
}
|
|
@@ -333,7 +334,10 @@ const pruneClaudeVersions = (active: string | null): void => {
|
|
|
333
334
|
const versionsDir = path.join(HOME, ".local/share/claude/versions")
|
|
334
335
|
if (!fs.existsSync(versionsDir))
|
|
335
336
|
return
|
|
336
|
-
|
|
337
|
+
const versions = fs.readdirSync(versionsDir)
|
|
338
|
+
if (!versions.includes(active))
|
|
339
|
+
return
|
|
340
|
+
for (const f of versions) {
|
|
337
341
|
if (f === active)
|
|
338
342
|
continue
|
|
339
343
|
try {
|
|
@@ -349,6 +353,8 @@ const pruneClaudeVersions = (active: string | null): void => {
|
|
|
349
353
|
const detectActiveClaudeVersion = (binName: string): string | null => {
|
|
350
354
|
try {
|
|
351
355
|
const r = execaSync(path.join(HOME, ".local/bin", binName), [ "--version" ], { reject: false })
|
|
356
|
+
if (r.exitCode !== 0)
|
|
357
|
+
return null
|
|
352
358
|
const m = /^(\S+)/.exec(r.stdout ?? "")
|
|
353
359
|
if (m)
|
|
354
360
|
return m[1]
|
|
@@ -392,12 +398,12 @@ const actionInstall = async (capsula: boolean): Promise<void> => {
|
|
|
392
398
|
await self("internal", "capsula", "-s", "sudo", "-E", "apt", "install", "-qq", "-y", "tmux", "lazygit", "git")
|
|
393
399
|
|
|
394
400
|
info("install Node.js")
|
|
395
|
-
await self("internal", "capsula", "-s", "sudo", "-E", "bash", "-c", "curl -fsSL https://deb.nodesource.com/setup_24.x | bash -")
|
|
401
|
+
await self("internal", "capsula", "-s", "sudo", "-E", "bash", "-o", "pipefail", "-c", "curl -fsSL https://deb.nodesource.com/setup_24.x | bash -")
|
|
396
402
|
await self("internal", "capsula", "-s", "sudo", "-E", "apt", "install", "-qq", "-y", "nodejs")
|
|
397
403
|
await self("internal", "capsula", "-s", "sudo", "-E", "apt", "install", "-qq", "-y", "binutils", "gcc", "g++", "make")
|
|
398
404
|
|
|
399
405
|
info("install Claude Code")
|
|
400
|
-
await self("internal", "capsula", "bash", "-c", `PATH="${HOME}/.local/bin:$PATH"; curl -fsSL https://claude.ai/install.sh | bash`)
|
|
406
|
+
await self("internal", "capsula", "bash", "-o", "pipefail", "-c", `PATH="${HOME}/.local/bin:$PATH"; curl -fsSL https://claude.ai/install.sh | bash`)
|
|
401
407
|
|
|
402
408
|
info("install ANSI-Recolor")
|
|
403
409
|
await self("internal", "capsula", "-s", "sudo", "-E", "npm", "install", "-y", "-g", "--allow-scripts=node-pty,tty-attr", "ansi-recolor")
|
|
@@ -420,6 +426,7 @@ const actionInstall = async (capsula: boolean): Promise<void> => {
|
|
|
420
426
|
"[ -d \"$VERSIONS\" ] || exit 0; " +
|
|
421
427
|
"ACTIVE=$(\"$HOME/.local/bin/claude\" --version 2>/dev/null | awk '{print $1; exit}'); " +
|
|
422
428
|
"[ -n \"$ACTIVE\" ] || exit 0; " +
|
|
429
|
+
"[ -f \"$VERSIONS/$ACTIVE\" ] || exit 0; " +
|
|
423
430
|
"find \"$VERSIONS\" -mindepth 1 -maxdepth 1 ! -name \"$ACTIVE\" -exec rm -rf {} +"
|
|
424
431
|
)
|
|
425
432
|
}
|
|
@@ -489,7 +496,7 @@ const actionInstall = async (capsula: boolean): Promise<void> => {
|
|
|
489
496
|
"windows:choco": "choco install -y --accept-license --no-progress nodejs",
|
|
490
497
|
"macos:ports": "sudo port -N install nodejs26 npm11",
|
|
491
498
|
"macos:brew": "brew install node",
|
|
492
|
-
"linux:apt": "curl -fsSL https://deb.nodesource.com/setup_26.x | sudo -E bash - && sudo apt install -y nodejs",
|
|
499
|
+
"linux:apt": [ "bash", "-o", "pipefail", "-c", "curl -fsSL https://deb.nodesource.com/setup_26.x | sudo -E bash - && sudo apt install -y nodejs" ],
|
|
493
500
|
"linux:dnf": "sudo dnf install -y nodejs npm",
|
|
494
501
|
"linux:yum": "sudo yum install -y nodejs npm",
|
|
495
502
|
"linux:zypper": "sudo zypper --non-interactive install nodejs npm",
|
|
@@ -535,8 +542,8 @@ const actionInstall = async (capsula: boolean): Promise<void> => {
|
|
|
535
542
|
/* run installation script */
|
|
536
543
|
ensureTool("bash", { hint: "https://www.gnu.org/software/bash/" })
|
|
537
544
|
ensureTool("curl", { hint: "https://curl.se/" })
|
|
538
|
-
await execa("bash", [ "-c", `PATH="${HOME}/.local/bin:$PATH"; curl -fsSL https://claude.ai/install.sh | bash` ], {
|
|
539
|
-
stdio: "inherit"
|
|
545
|
+
await execa("bash", [ "-o", "pipefail", "-c", `PATH="${HOME}/.local/bin:$PATH"; curl -fsSL https://claude.ai/install.sh | bash` ], {
|
|
546
|
+
stdio: "inherit"
|
|
540
547
|
})
|
|
541
548
|
|
|
542
549
|
/* prune obsolete versions only after successful install */
|
|
@@ -549,7 +556,7 @@ const actionInstall = async (capsula: boolean): Promise<void> => {
|
|
|
549
556
|
/* run installation script */
|
|
550
557
|
ensureTool("powershell")
|
|
551
558
|
await execa("powershell", [ "-NoProfile", "-Command", "irm https://claude.ai/install.ps1 | iex" ], {
|
|
552
|
-
stdio: "inherit"
|
|
559
|
+
stdio: "inherit"
|
|
553
560
|
})
|
|
554
561
|
|
|
555
562
|
/* prune obsolete versions only after successful install */
|
|
@@ -678,7 +685,7 @@ const actionUpdate = async (capsula: boolean): Promise<void> => {
|
|
|
678
685
|
if (process.platform !== "win32") {
|
|
679
686
|
ensureTool("bash")
|
|
680
687
|
await execa("bash", [ "-c", `PATH="${HOME}/.local/bin:$PATH"; ${HOME}/.local/bin/claude update` ], {
|
|
681
|
-
stdio: "inherit"
|
|
688
|
+
stdio: "inherit"
|
|
682
689
|
})
|
|
683
690
|
|
|
684
691
|
/* prune obsolete versions only after successful update */
|
|
@@ -689,7 +696,7 @@ const actionUpdate = async (capsula: boolean): Promise<void> => {
|
|
|
689
696
|
fatal("on Windows the \"update\" command has to be run from within a PowerShell session")
|
|
690
697
|
ensureTool("powershell")
|
|
691
698
|
await execa("powershell", [ "-NoProfile", "-Command", "claude update" ], {
|
|
692
|
-
stdio: "inherit"
|
|
699
|
+
stdio: "inherit"
|
|
693
700
|
})
|
|
694
701
|
|
|
695
702
|
/* prune obsolete versions only after successful update */
|
|
@@ -743,7 +750,7 @@ const actionInternalTmux = (opts: TopOpts, args: string[]): never => {
|
|
|
743
750
|
}
|
|
744
751
|
conf = conf.replace(/@USER@/g, USER)
|
|
745
752
|
const confFile = path.join(os.tmpdir(), `claudex-tmux-${process.pid}.conf`)
|
|
746
|
-
fs.writeFileSync(confFile, conf, { mode: 0o600 })
|
|
753
|
+
fs.writeFileSync(confFile, conf, { mode: 0o600, flag: "wx" })
|
|
747
754
|
/* ensure the temp config is removed on normal exit AND on signal-driven
|
|
748
755
|
termination (SIGINT/SIGTERM); SIGKILL and process panics remain
|
|
749
756
|
uncoverable. tmux.conf is read once at startup and not re-read via
|
|
@@ -764,7 +771,7 @@ const actionInternalTmux = (opts: TopOpts, args: string[]): never => {
|
|
|
764
771
|
windowsHide: false
|
|
765
772
|
})
|
|
766
773
|
cleanup()
|
|
767
|
-
return process.exit(r.exitCode ??
|
|
774
|
+
return process.exit(r.exitCode ?? 1)
|
|
768
775
|
}
|
|
769
776
|
|
|
770
777
|
/* action: internal "shell" -- spawn an interactive login shell */
|
|
@@ -835,6 +842,8 @@ const actionInternalCapsula = (_opts: TopOpts, args: string[]): never => {
|
|
|
835
842
|
const envOpts: string[] = [ "-e", "!" ]
|
|
836
843
|
for (const e of envs)
|
|
837
844
|
envOpts.push("-e", e)
|
|
845
|
+
if (process.env.OPENROUTER_API_KEY !== undefined)
|
|
846
|
+
envOpts.push("-e", "OPENROUTER_API_KEY")
|
|
838
847
|
|
|
839
848
|
/* find list of dot-files (relative to $HOME) */
|
|
840
849
|
const dotfiles = [
|
|
@@ -947,7 +956,7 @@ const actionInternal = async (opts: TopOpts, args: string[]): Promise<void> => {
|
|
|
947
956
|
}
|
|
948
957
|
|
|
949
958
|
/* action: top-level command -- run "claude" */
|
|
950
|
-
const actionDefault = (opts: TopOpts, args: string[]): never => {
|
|
959
|
+
const actionDefault = async (opts: TopOpts, args: string[]): Promise<never> => {
|
|
951
960
|
/* build the inner self-invocation flag list. Pass-through "-R"/"-A" only,
|
|
952
961
|
as "-C" and "-T" are consumed at the outer layer to avoid recursion. */
|
|
953
962
|
const innerFlags: string[] = []
|
|
@@ -986,14 +995,20 @@ const actionDefault = (opts: TopOpts, args: string[]): never => {
|
|
|
986
995
|
|
|
987
996
|
/* enter already running container and run tmux */
|
|
988
997
|
return execInherit("docker", [
|
|
989
|
-
"exec", "-i", "-t"
|
|
998
|
+
"exec", "-i", ...(process.stdin.isTTY ? [ "-t" ] : []),
|
|
999
|
+
"-w", process.cwd(),
|
|
1000
|
+
"-e", `CLAUDE_MODEL=${process.env.CLAUDE_MODEL ?? ""}`,
|
|
1001
|
+
...(process.env.OPENROUTER_API_KEY !== undefined ? [ "-e", "OPENROUTER_API_KEY" ] : []),
|
|
1002
|
+
container,
|
|
990
1003
|
"bash", "-c",
|
|
991
1004
|
`TERM=${shQ.quote([ TERM ])} ` +
|
|
992
1005
|
`HOME=${shQ.quote([ HOME ])} ` +
|
|
993
1006
|
`CLAUDEX_FLAGS=${shQ.quote([ claudexFlags ])} ` +
|
|
1007
|
+
`CLAUDEX_INTERNAL_EXEC=${shQ.quote([ inPane ])} ` +
|
|
994
1008
|
`sudo -E -u ${shQ.quote([ USER ])} ` +
|
|
995
1009
|
`${shQ.quote([ "node" /* process.execPath is not valid inside container! */, selfPathJS ])} ` +
|
|
996
|
-
`${opts.ase ? "-A " : ""}internal tmux new-session -A -s ${shQ.quote([ session ])}`
|
|
1010
|
+
`${opts.ase ? "-A " : ""}internal tmux new-session -A -s ${shQ.quote([ session ])} ` +
|
|
1011
|
+
`-n claude ${shQ.quote([ "claudex internal exec" ])}`
|
|
997
1012
|
])
|
|
998
1013
|
}
|
|
999
1014
|
else {
|
|
@@ -1041,7 +1056,11 @@ const actionDefault = (opts: TopOpts, args: string[]): never => {
|
|
|
1041
1056
|
|
|
1042
1057
|
/* enter already running container and run claude (single-quote shell-escape) */
|
|
1043
1058
|
return execInherit("docker", [
|
|
1044
|
-
"exec", "-i", "-t"
|
|
1059
|
+
"exec", "-i", ...(process.stdin.isTTY ? [ "-t" ] : []),
|
|
1060
|
+
"-w", process.cwd(),
|
|
1061
|
+
"-e", `CLAUDE_MODEL=${process.env.CLAUDE_MODEL ?? ""}`,
|
|
1062
|
+
...(process.env.OPENROUTER_API_KEY !== undefined ? [ "-e", "OPENROUTER_API_KEY" ] : []),
|
|
1063
|
+
container,
|
|
1045
1064
|
"bash", "-c",
|
|
1046
1065
|
`TERM=${shQ.quote([ TERM ])} ` +
|
|
1047
1066
|
`HOME=${shQ.quote([ HOME ])} ` +
|
|
@@ -1066,7 +1085,7 @@ const actionDefault = (opts: TopOpts, args: string[]): never => {
|
|
|
1066
1085
|
const recolor = opts.recolor === true
|
|
1067
1086
|
if (recolor)
|
|
1068
1087
|
ensureTool("ansi-recolor")
|
|
1069
|
-
process.env.PATH = `${HOME
|
|
1088
|
+
process.env.PATH = `${path.join(HOME, ".local/bin")}${path.delimiter}${process.env.PATH ?? ""}`
|
|
1070
1089
|
ensureTool("claude")
|
|
1071
1090
|
const env: Env = { ...process.env }
|
|
1072
1091
|
const claudeModel = process.env.CLAUDE_MODEL ?? ""
|
|
@@ -1111,9 +1130,10 @@ const actionDefault = (opts: TopOpts, args: string[]): never => {
|
|
|
1111
1130
|
env.ANTHROPIC_AUTH_TOKEN = "ollama"
|
|
1112
1131
|
env.ANTHROPIC_BASE_URL = `http://${ohost}`
|
|
1113
1132
|
env.ANTHROPIC_CUSTOM_MODEL_OPTION_SUPPORTED_CAPABILITIES = capabilities
|
|
1114
|
-
env.
|
|
1133
|
+
env.ANTHROPIC_DEFAULT_FABLE_MODEL = model
|
|
1115
1134
|
env.ANTHROPIC_DEFAULT_OPUS_MODEL = model
|
|
1116
1135
|
env.ANTHROPIC_DEFAULT_SONNET_MODEL = model
|
|
1136
|
+
env.ANTHROPIC_DEFAULT_HAIKU_MODEL = model
|
|
1117
1137
|
env.CLAUDE_CODE_SUBAGENT_MODEL = model
|
|
1118
1138
|
env.CLAUDE_CODE_ATTRIBUTION_HEADER = "0"
|
|
1119
1139
|
env.CLAUDE_CODE_AUTO_COMPACT_WINDOW = context
|
|
@@ -1149,9 +1169,10 @@ const actionDefault = (opts: TopOpts, args: string[]): never => {
|
|
|
1149
1169
|
env.ANTHROPIC_AUTH_TOKEN = process.env.OPENROUTER_API_KEY
|
|
1150
1170
|
env.ANTHROPIC_BASE_URL = "https://openrouter.ai/api"
|
|
1151
1171
|
env.ANTHROPIC_CUSTOM_MODEL_OPTION_SUPPORTED_CAPABILITIES = capabilities
|
|
1152
|
-
env.
|
|
1172
|
+
env.ANTHROPIC_DEFAULT_FABLE_MODEL = model
|
|
1153
1173
|
env.ANTHROPIC_DEFAULT_OPUS_MODEL = model
|
|
1154
1174
|
env.ANTHROPIC_DEFAULT_SONNET_MODEL = model
|
|
1175
|
+
env.ANTHROPIC_DEFAULT_HAIKU_MODEL = model
|
|
1155
1176
|
env.CLAUDE_CODE_SUBAGENT_MODEL = model
|
|
1156
1177
|
env.CLAUDE_CODE_ATTRIBUTION_HEADER = "0"
|
|
1157
1178
|
env.CLAUDE_CODE_AUTO_COMPACT_WINDOW = context
|
|
@@ -1159,10 +1180,69 @@ const actionDefault = (opts: TopOpts, args: string[]): never => {
|
|
|
1159
1180
|
env.DISABLE_LOGOUT_COMMAND = "1"
|
|
1160
1181
|
env.ENABLE_TOOL_SEARCH = "auto"
|
|
1161
1182
|
}
|
|
1183
|
+
else if (/^codex:/.test(claudeModel)) {
|
|
1184
|
+
const model = claudeModel.slice("codex:".length)
|
|
1185
|
+
if (model.trim() === "")
|
|
1186
|
+
fatal("invalid CLAUDE_MODEL: missing model name in " +
|
|
1187
|
+
`"${claudeModel}" (expected: codex:<model>)`)
|
|
1188
|
+
|
|
1189
|
+
/* reuse a healthy proxy or start a persistent detached server */
|
|
1190
|
+
const baseURL = "http://127.0.0.1:18765"
|
|
1191
|
+
const deadline = Date.now() + 10000
|
|
1192
|
+
let proxy: ReturnType<typeof spawn> | undefined
|
|
1193
|
+
let proxyError = ""
|
|
1194
|
+
while (true) {
|
|
1195
|
+
try {
|
|
1196
|
+
const response = await fetch(`${baseURL}/healthz`, { signal: AbortSignal.timeout(500) })
|
|
1197
|
+
await response.body?.cancel()
|
|
1198
|
+
if (response.ok)
|
|
1199
|
+
break
|
|
1200
|
+
}
|
|
1201
|
+
catch (_e) {
|
|
1202
|
+
/* not ready yet */
|
|
1203
|
+
}
|
|
1204
|
+
if (proxy === undefined) {
|
|
1205
|
+
ensureTool("claude-code-proxy", { hint: "install claude-code-proxy and configure its Codex authentication first" })
|
|
1206
|
+
proxy = spawn("claude-code-proxy", [ "serve", "--port", "18765", "--no-monitor" ], {
|
|
1207
|
+
detached: true,
|
|
1208
|
+
stdio: "ignore",
|
|
1209
|
+
windowsHide: true
|
|
1210
|
+
})
|
|
1211
|
+
proxy.on("error", (err: Error) => { proxyError = err.message })
|
|
1212
|
+
proxy.unref()
|
|
1213
|
+
}
|
|
1214
|
+
else if (proxyError !== "" || proxy.exitCode !== null || proxy.signalCode !== null)
|
|
1215
|
+
fatal("failed to start claude-code-proxy" +
|
|
1216
|
+
(proxyError !== "" ? `: ${proxyError}` : ` (exit ${proxy.exitCode ?? proxy.signalCode})`) +
|
|
1217
|
+
" -- run \"claude-code-proxy serve --port 18765 --no-monitor\" for details")
|
|
1218
|
+
if (Date.now() >= deadline) {
|
|
1219
|
+
proxy.kill()
|
|
1220
|
+
fatal(`claude-code-proxy did not become ready at ${baseURL} within 10 seconds`)
|
|
1221
|
+
}
|
|
1222
|
+
await new Promise((resolve) => setTimeout(resolve, 100))
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
/* override Claude Code configuration as in the claude-codex wrapper */
|
|
1226
|
+
env.ANTHROPIC_BASE_URL = baseURL
|
|
1227
|
+
env.ANTHROPIC_API_KEY = ""
|
|
1228
|
+
env.ANTHROPIC_AUTH_TOKEN = "unused"
|
|
1229
|
+
env.ANTHROPIC_DEFAULT_MODEL = model
|
|
1230
|
+
env.ANTHROPIC_DEFAULT_FABLE_MODEL = "gpt-6-astra[1m]"
|
|
1231
|
+
env.ANTHROPIC_DEFAULT_OPUS_MODEL = "gpt-6.1-sol[1m]"
|
|
1232
|
+
env.ANTHROPIC_DEFAULT_SONNET_MODEL = "gpt-6-luna[1m]"
|
|
1233
|
+
env.ANTHROPIC_DEFAULT_HAIKU_MODEL = "gpt-6-luna[1m]"
|
|
1234
|
+
env.CLAUDE_CODE_SUBAGENT_MODEL = "inherit"
|
|
1235
|
+
env.CLAUDE_CODE_AUTO_COMPACT_WINDOW = "272000"
|
|
1236
|
+
env.CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC = "1"
|
|
1237
|
+
env.CLAUDE_CODE_DISABLE_NONSTREAMING_FALLBACK = "1"
|
|
1238
|
+
env.DISABLE_LOGIN_COMMAND = "1"
|
|
1239
|
+
env.DISABLE_LOGOUT_COMMAND = "1"
|
|
1240
|
+
env.ENABLE_TOOL_SEARCH = "auto"
|
|
1241
|
+
}
|
|
1162
1242
|
else if (claudeModel !== "")
|
|
1163
1243
|
fatal(`invalid CLAUDE_MODEL "${claudeModel}" ` +
|
|
1164
|
-
"(supports only: \"ollama[://<host>[:<port>]]/<model>[?[context=<size>],[capabilities=<list>]]\" " +
|
|
1165
|
-
"
|
|
1244
|
+
"(supports only: \"ollama[://<host>[:<port>]]/<model>[?[context=<size>],[capabilities=<list>]]\", " +
|
|
1245
|
+
"\"openrouter:<model>[?[context=<size>],[capabilities=<list>]]\" and \"codex:<model>\")")
|
|
1166
1246
|
|
|
1167
1247
|
/* override ASE configuration (for its diagram rendering) */
|
|
1168
1248
|
if (opts.ase) {
|
|
@@ -1177,7 +1257,7 @@ const actionDefault = (opts: TopOpts, args: string[]): never => {
|
|
|
1177
1257
|
}
|
|
1178
1258
|
if (env.ASE_TERM_COLORS === undefined) {
|
|
1179
1259
|
let colorMode = "none"
|
|
1180
|
-
const depth = process.stdout.getColorDepth()
|
|
1260
|
+
const depth = process.stdout.isTTY ? process.stdout.getColorDepth() : 1
|
|
1181
1261
|
if (depth >= 8)
|
|
1182
1262
|
colorMode = "ansi256"
|
|
1183
1263
|
else if (depth >= 4)
|
|
@@ -1242,7 +1322,7 @@ const actionDefault = (opts: TopOpts, args: string[]): never => {
|
|
|
1242
1322
|
/* action: top-level "-h/--help" */
|
|
1243
1323
|
const actionHelp = (): never => {
|
|
1244
1324
|
/* run "claude --help" */
|
|
1245
|
-
process.env.PATH = `${HOME
|
|
1325
|
+
process.env.PATH = `${path.join(HOME, ".local/bin")}${path.delimiter}${process.env.PATH ?? ""}`
|
|
1246
1326
|
ensureTool("claude")
|
|
1247
1327
|
const claudeBin = path.join(HOME, ".local/bin/claude")
|
|
1248
1328
|
execaSync(claudeBin, [ "--help" ], { reject: false, stdio: [ "ignore", "inherit", "inherit" ] })
|
|
@@ -1268,7 +1348,7 @@ const actionHelp = (): never => {
|
|
|
1268
1348
|
/* action: top-level "-v/-V/--version" */
|
|
1269
1349
|
const actionVersion = (): never => {
|
|
1270
1350
|
/* run "claude --version" */
|
|
1271
|
-
process.env.PATH = `${HOME
|
|
1351
|
+
process.env.PATH = `${path.join(HOME, ".local/bin")}${path.delimiter}${process.env.PATH ?? ""}`
|
|
1272
1352
|
ensureTool("claude")
|
|
1273
1353
|
const claudeBin = path.join(HOME, ".local/bin/claude")
|
|
1274
1354
|
execaSync(claudeBin, [ "--version" ], { reject: false, stdio: [ "ignore", "inherit", "inherit" ] })
|
|
@@ -1367,8 +1447,8 @@ const main = async (): Promise<void> => {
|
|
|
1367
1447
|
.option("-R, --recolor", "wrap Claude Code with ANSI recoloring for improved theming")
|
|
1368
1448
|
.option("-A, --ase", "enable ASE-specific ASE_* environment variables and Tmux settings")
|
|
1369
1449
|
.argument("[args...]", "arguments passed unparsed to Claude Code")
|
|
1370
|
-
.action((args: string[], opts: TopOpts) => {
|
|
1371
|
-
actionDefault(opts, args)
|
|
1450
|
+
.action(async (args: string[], opts: TopOpts) => {
|
|
1451
|
+
await actionDefault(opts, args)
|
|
1372
1452
|
})
|
|
1373
1453
|
|
|
1374
1454
|
/* dispatch "install" sub-command */
|
package/lazygit.yaml
CHANGED
|
@@ -40,10 +40,10 @@ gui:
|
|
|
40
40
|
- blue
|
|
41
41
|
sidePanels:
|
|
42
42
|
- [ files ]
|
|
43
|
-
- [ worktrees ]
|
|
44
|
-
- [ branches, submodules ]
|
|
45
|
-
- [ commits, reflog, tags ]
|
|
46
43
|
- [ stash ]
|
|
44
|
+
- [ commits, reflog, tags ]
|
|
45
|
+
- [ branches, submodules ]
|
|
46
|
+
- [ worktrees ]
|
|
47
47
|
spinner:
|
|
48
48
|
frames:
|
|
49
49
|
- ●∙∙∙
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rse/claudex",
|
|
3
3
|
"publishConfig": { "access": "public" },
|
|
4
|
-
"version": "1.0
|
|
4
|
+
"version": "1.1.0",
|
|
5
5
|
"description": "Claude Code eXtended",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"keywords": [ "claude", "code", "extension", "wrapper" ],
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"which": "7.0.0",
|
|
20
20
|
"execa": "10.0.1",
|
|
21
|
-
"chalk": "6.0.
|
|
21
|
+
"chalk": "6.0.1",
|
|
22
22
|
"commander": "15.0.0",
|
|
23
23
|
"deepmerge": "4.3.1",
|
|
24
24
|
"shescape": "3.0.2",
|
|
@@ -26,19 +26,19 @@
|
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"typescript": "6.0.3",
|
|
29
|
-
"@types/node": "26.
|
|
29
|
+
"@types/node": "26.6.3",
|
|
30
30
|
"@types/which": "3.0.4",
|
|
31
31
|
"@types/shell-quote": "1.7.5",
|
|
32
32
|
|
|
33
|
-
"@rse/stx": "1.1.
|
|
33
|
+
"@rse/stx": "1.1.7",
|
|
34
34
|
"eslint": "9.39.5",
|
|
35
35
|
"@eslint/js": "9.39.5",
|
|
36
|
-
"typescript-eslint": "8.
|
|
37
|
-
"@typescript-eslint/parser": "8.
|
|
36
|
+
"typescript-eslint": "8.70.1",
|
|
37
|
+
"@typescript-eslint/parser": "8.70.1",
|
|
38
38
|
"eslint-plugin-promise": "7.3.0",
|
|
39
39
|
"eslint-plugin-import": "2.32.0",
|
|
40
40
|
"neostandard": "0.13.0",
|
|
41
|
-
"globals": "17.
|
|
41
|
+
"globals": "17.12.0",
|
|
42
42
|
"shx": "0.4.0"
|
|
43
43
|
},
|
|
44
44
|
"engines": {
|