@rse/claudex 0.9.16 → 0.9.17
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 +5 -0
- package/README.md +2 -2
- package/claudex.js +28 -7
- package/claudex.ts +27 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -76,9 +76,9 @@ Usage
|
|
|
76
76
|
-----
|
|
77
77
|
|
|
78
78
|
```sh
|
|
79
|
-
$ claudex
|
|
79
|
+
$ claudex
|
|
80
80
|
[-C|--capsula] # execute Claude Code inside a Capsula sandbox container")
|
|
81
|
-
[-T|--tmux [session]]
|
|
81
|
+
[-T|--tmux [session]] # wrap Claude Code in a Tmux terminal multiplexing session (optional session name)")
|
|
82
82
|
[-R|--recolor] # wrap Claude Code with ANSI recoloing for improved theming")
|
|
83
83
|
[-A|--ase] # enable ASE-specific Claude Code statusline and ASE_* environment variables")
|
|
84
84
|
[...options...] # arbitrary Claude Code options
|
package/claudex.js
CHANGED
|
@@ -39,9 +39,30 @@ const fatal = (msg) => {
|
|
|
39
39
|
process.stderr.write(`${chalk.red("claudex: ")}${chalk.red.bold("ERROR:")}${chalk.red(` ${msg}`)}\n`);
|
|
40
40
|
process.exit(1);
|
|
41
41
|
};
|
|
42
|
+
/* helper to locate a tool in $PATH (cross-platform).
|
|
43
|
+
On Windows, `which.sync` can fail to find App Execution Aliases
|
|
44
|
+
(zero-byte reparse-point stubs under %LOCALAPPDATA%\Microsoft\WindowsApps,
|
|
45
|
+
e.g. winget.exe, python.exe), because the `stat()` check inside the
|
|
46
|
+
`which` package may not classify them as regular files. As a fallback
|
|
47
|
+
we therefore also consult the native `where` command on Windows. */
|
|
48
|
+
const findTool = (tool) => {
|
|
49
|
+
const r = which.sync(tool, { nothrow: true });
|
|
50
|
+
if (r !== null)
|
|
51
|
+
return r;
|
|
52
|
+
if (process.platform === "win32") {
|
|
53
|
+
const r2 = execaSync("where", [tool], { reject: false, windowsHide: true });
|
|
54
|
+
if ((r2.exitCode ?? 1) === 0) {
|
|
55
|
+
const line = (r2.stdout ?? "").toString().split(/\r?\n/)[0].trim();
|
|
56
|
+
if (line !== "")
|
|
57
|
+
return line;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return null;
|
|
61
|
+
};
|
|
42
62
|
/* helper for detecting the platform and package manager combination */
|
|
43
63
|
const detectPlatform = () => {
|
|
44
|
-
|
|
64
|
+
/* helper function for finding a tool in PATH */
|
|
65
|
+
const has = (tool) => findTool(tool) !== null;
|
|
45
66
|
/* honor explicit override via CLAUDEX_PKG (e.g. "brew", "ports", "apt", ...)
|
|
46
67
|
to disambiguate hosts where multiple package managers are installed */
|
|
47
68
|
const override = process.env.CLAUDEX_PKG ?? "";
|
|
@@ -111,7 +132,7 @@ const executeCommand = (config) => {
|
|
|
111
132
|
const ensureTool = (tool, options = {}) => {
|
|
112
133
|
const tools = typeof tool === "string" ? [tool] : tool;
|
|
113
134
|
for (const tool of tools) {
|
|
114
|
-
let r =
|
|
135
|
+
let r = findTool(tool);
|
|
115
136
|
if (r === null && options.install) {
|
|
116
137
|
const rc = executeCommand(options.install);
|
|
117
138
|
if (rc !== 0) {
|
|
@@ -120,7 +141,7 @@ const ensureTool = (tool, options = {}) => {
|
|
|
120
141
|
fatal(`failed to install required tool "${tool}" (exit ${rc})` +
|
|
121
142
|
(options.hint !== undefined ? ` -- hint: ${options.hint}` : ""));
|
|
122
143
|
}
|
|
123
|
-
r =
|
|
144
|
+
r = findTool(tool);
|
|
124
145
|
}
|
|
125
146
|
if (r !== null)
|
|
126
147
|
continue;
|
|
@@ -828,10 +849,10 @@ const actionHelp = () => {
|
|
|
828
849
|
/* append our claudeX extension information */
|
|
829
850
|
process.stdout.write("\n" +
|
|
830
851
|
"claudeX extension options (honored before claude):\n" +
|
|
831
|
-
" -A, --ase enable ASE-specific Claude Code statusline and ASE_* environment variables\n" +
|
|
832
852
|
" -C, --capsula execute Claude Code inside a Capsula sandbox container\n" +
|
|
833
|
-
" -R, --recolor wrap Claude Code with ANSI recoloring for improved theming\n" +
|
|
834
853
|
" -T, --tmux [session] wrap Claude Code in a Tmux terminal multiplexing session (optional session name)\n" +
|
|
854
|
+
" -R, --recolor wrap Claude Code with ANSI recoloring for improved theming\n" +
|
|
855
|
+
" -A, --ase enable ASE-specific Claude Code statusline and ASE_* environment variables\n" +
|
|
835
856
|
"\n" +
|
|
836
857
|
"claudeX extension subcommands (honored before claude):\n" +
|
|
837
858
|
" install install host-side or in-container dependencies\n" +
|
|
@@ -860,10 +881,10 @@ const main = async () => {
|
|
|
860
881
|
.passThroughOptions()
|
|
861
882
|
.allowUnknownOption()
|
|
862
883
|
.helpOption(false)
|
|
863
|
-
.option("-A, --ase", "enable ASE-specific Claude Code statusline and ASE_* environment variables")
|
|
864
884
|
.option("-C, --capsula", "execute Claude Code inside a Capsula sandbox container")
|
|
865
|
-
.option("-R, --recolor", "wrap Claude Code with ANSI recoloing for improved theming")
|
|
866
885
|
.option("-T, --tmux [session]", "wrap Claude Code in a Tmux terminal multiplexing session (optional session name)")
|
|
886
|
+
.option("-R, --recolor", "wrap Claude Code with ANSI recoloing for improved theming")
|
|
887
|
+
.option("-A, --ase", "enable ASE-specific Claude Code statusline and ASE_* environment variables")
|
|
867
888
|
.argument("[args...]", "arguments passed unparsed to Claude Code")
|
|
868
889
|
.action((args, opts) => {
|
|
869
890
|
actionDefault(opts, args);
|
package/claudex.ts
CHANGED
|
@@ -48,9 +48,33 @@ const fatal = (msg: string): never => {
|
|
|
48
48
|
process.exit(1)
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
/* helper to locate a tool in $PATH (cross-platform).
|
|
52
|
+
On Windows, `which.sync` can fail to find App Execution Aliases
|
|
53
|
+
(zero-byte reparse-point stubs under %LOCALAPPDATA%\Microsoft\WindowsApps,
|
|
54
|
+
e.g. winget.exe, python.exe), because the `stat()` check inside the
|
|
55
|
+
`which` package may not classify them as regular files. As a fallback
|
|
56
|
+
we therefore also consult the native `where` command on Windows. */
|
|
57
|
+
const findTool = (tool: string): string | null => {
|
|
58
|
+
const r = which.sync(tool, { nothrow: true })
|
|
59
|
+
if (r !== null)
|
|
60
|
+
return r
|
|
61
|
+
if (process.platform === "win32") {
|
|
62
|
+
const r2 = execaSync("where", [ tool ], { reject: false, windowsHide: true })
|
|
63
|
+
if ((r2.exitCode ?? 1) === 0) {
|
|
64
|
+
const line = (r2.stdout ?? "").toString().split(/\r?\n/)[0].trim()
|
|
65
|
+
if (line !== "")
|
|
66
|
+
return line
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return null
|
|
70
|
+
}
|
|
71
|
+
|
|
51
72
|
/* helper for detecting the platform and package manager combination */
|
|
52
73
|
const detectPlatform = (): string => {
|
|
53
|
-
|
|
74
|
+
/* helper function for finding a tool in PATH */
|
|
75
|
+
const has = (tool: string): boolean =>
|
|
76
|
+
findTool(tool) !== null
|
|
77
|
+
|
|
54
78
|
/* honor explicit override via CLAUDEX_PKG (e.g. "brew", "ports", "apt", ...)
|
|
55
79
|
to disambiguate hosts where multiple package managers are installed */
|
|
56
80
|
const override = process.env.CLAUDEX_PKG ?? ""
|
|
@@ -127,7 +151,7 @@ const ensureTool = (tool: string | string[], options: {
|
|
|
127
151
|
} = {}): void => {
|
|
128
152
|
const tools = typeof tool === "string" ? [ tool ] : tool
|
|
129
153
|
for (const tool of tools) {
|
|
130
|
-
let r =
|
|
154
|
+
let r = findTool(tool)
|
|
131
155
|
if (r === null && options.install) {
|
|
132
156
|
const rc = executeCommand(options.install)
|
|
133
157
|
if (rc !== 0) {
|
|
@@ -136,7 +160,7 @@ const ensureTool = (tool: string | string[], options: {
|
|
|
136
160
|
fatal(`failed to install required tool "${tool}" (exit ${rc})` +
|
|
137
161
|
(options.hint !== undefined ? ` -- hint: ${options.hint}` : ""))
|
|
138
162
|
}
|
|
139
|
-
r =
|
|
163
|
+
r = findTool(tool)
|
|
140
164
|
}
|
|
141
165
|
if (r !== null)
|
|
142
166
|
continue
|
package/package.json
CHANGED