@bazilio-san/glm-cc 1.0.16 → 1.0.19
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/README.md +12 -12
- package/bin/glm.js +71 -19
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,23 +10,23 @@ npm install -g @bazilio-san/glm-cc
|
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
```bash
|
|
15
|
-
glm
|
|
16
|
-
```
|
|
13
|
+
All arguments are passed through to `claude`, so you can use `glm` as a drop-in replacement:
|
|
17
14
|
|
|
18
|
-
### Interactive configuration
|
|
19
15
|
```bash
|
|
20
|
-
glm
|
|
21
|
-
#
|
|
22
|
-
glm
|
|
16
|
+
glm # launch claude interactively
|
|
17
|
+
glm -h # claude -h
|
|
18
|
+
glm plugin -h # claude plugin -h
|
|
19
|
+
glm -p "hello" # claude -p "hello"
|
|
20
|
+
glm --version # claude --version
|
|
21
|
+
glm mcp serve # claude mcp serve
|
|
23
22
|
```
|
|
24
23
|
|
|
25
|
-
###
|
|
24
|
+
### glm-specific commands
|
|
25
|
+
|
|
26
26
|
```bash
|
|
27
|
-
glm -
|
|
28
|
-
#
|
|
29
|
-
glm --
|
|
27
|
+
glm -c # interactive configuration (alias: --glm-config)
|
|
28
|
+
glm --glm-show # show current settings
|
|
29
|
+
glm --glm-version # show glm version
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
## Configuration
|
package/bin/glm.js
CHANGED
|
@@ -78,16 +78,8 @@ async function runConfig(fields) {
|
|
|
78
78
|
return config;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
function
|
|
81
|
+
function showConfig(config) {
|
|
82
82
|
const lines = [
|
|
83
|
-
'',
|
|
84
|
-
'Usage: glm [options]',
|
|
85
|
-
'',
|
|
86
|
-
'Options:',
|
|
87
|
-
' -c, --config Interactive configuration',
|
|
88
|
-
' -h, --help Show this help',
|
|
89
|
-
'',
|
|
90
|
-
'Without options: applies config to environment and launches claude.',
|
|
91
83
|
'',
|
|
92
84
|
`Config file: ${CONFIG_FILE}`,
|
|
93
85
|
'',
|
|
@@ -103,18 +95,76 @@ function showHelp(config) {
|
|
|
103
95
|
console.log(lines.join('\n'));
|
|
104
96
|
}
|
|
105
97
|
|
|
106
|
-
|
|
98
|
+
// Resolve `claude` into { cmd, args, useShell } without an extra cmd.exe
|
|
99
|
+
// layer on Windows. A nested cmd.exe breaks ConPty stdin for Ink-based TUIs
|
|
100
|
+
// (e.g. when glm is spawned via node-pty from a test harness).
|
|
101
|
+
function resolveClaude() {
|
|
102
|
+
if (process.platform !== 'win32') {
|
|
103
|
+
return { cmd: 'claude', prefix: [], useShell: false };
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const pathExts = (process.env.PATHEXT || '.COM;.EXE;.BAT;.CMD')
|
|
107
|
+
.split(';').map(e => e.toLowerCase()).filter(Boolean);
|
|
108
|
+
const pathDirs = (process.env.PATH || '').split(path.delimiter).filter(Boolean);
|
|
109
|
+
|
|
110
|
+
let exePath = null;
|
|
111
|
+
let cmdPath = null;
|
|
112
|
+
for (const dir of pathDirs) {
|
|
113
|
+
for (const ext of pathExts) {
|
|
114
|
+
const full = path.join(dir, 'claude' + ext);
|
|
115
|
+
if (!fs.existsSync(full)) continue;
|
|
116
|
+
if (ext === '.exe' && !exePath) exePath = full;
|
|
117
|
+
else if ((ext === '.cmd' || ext === '.bat') && !cmdPath) cmdPath = full;
|
|
118
|
+
}
|
|
119
|
+
if (exePath) break;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Prefer native .exe — spawn directly, no shell layer.
|
|
123
|
+
if (exePath) {
|
|
124
|
+
return { cmd: exePath, prefix: [], useShell: false };
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// npm shim on Windows looks like:
|
|
128
|
+
// @"C:\Program Files\nodejs\node.exe" "...\cli.js" %*
|
|
129
|
+
// Parse it and spawn node directly so we skip the shim's cmd.exe.
|
|
130
|
+
if (cmdPath) {
|
|
131
|
+
try {
|
|
132
|
+
const shim = fs.readFileSync(cmdPath, 'utf8');
|
|
133
|
+
const m = shim.match(/"([^"]+\\node\.exe)"\s+"([^"]+\.(?:js|mjs|cjs))"/i);
|
|
134
|
+
if (m) {
|
|
135
|
+
return { cmd: m[1], prefix: [m[2]], useShell: false };
|
|
136
|
+
}
|
|
137
|
+
} catch { /* fall through */ }
|
|
138
|
+
// Can't parse — must go through shell for .cmd execution.
|
|
139
|
+
return { cmd: cmdPath, prefix: [], useShell: true };
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Nothing found — let cmd.exe resolve at runtime (legacy behavior).
|
|
143
|
+
return { cmd: 'claude', prefix: [], useShell: true };
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function launchClaude(config, args) {
|
|
107
147
|
const env = { ...process.env };
|
|
108
148
|
for (const field of CONFIG_FIELDS) {
|
|
109
149
|
if (config[field.key]) {
|
|
110
150
|
env[field.key] = config[field.key];
|
|
111
151
|
}
|
|
112
152
|
}
|
|
113
|
-
|
|
153
|
+
|
|
154
|
+
const { cmd, prefix, useShell } = resolveClaude();
|
|
155
|
+
const proc = spawn(cmd, [...prefix, ...args], {
|
|
114
156
|
env,
|
|
115
157
|
stdio: 'inherit',
|
|
116
|
-
shell:
|
|
158
|
+
shell: useShell,
|
|
117
159
|
});
|
|
160
|
+
|
|
161
|
+
const signals = ['SIGINT', 'SIGTERM', 'SIGHUP', 'SIGBREAK'];
|
|
162
|
+
for (const sig of signals) {
|
|
163
|
+
process.on(sig, () => {
|
|
164
|
+
try { proc.kill(sig); } catch { /* */ }
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
|
|
118
168
|
proc.on('exit', code => process.exit(code ?? 0));
|
|
119
169
|
proc.on('error', err => {
|
|
120
170
|
console.error(`Failed to launch claude: ${err.message}`);
|
|
@@ -125,18 +175,19 @@ function launchClaude(config) {
|
|
|
125
175
|
async function main() {
|
|
126
176
|
const args = process.argv.slice(2);
|
|
127
177
|
|
|
128
|
-
|
|
129
|
-
|
|
178
|
+
// Only glm-specific flags: --config, --show-config, --glm-version
|
|
179
|
+
if (args.includes('--glm-config') || args.includes('-c')) {
|
|
180
|
+
await runConfig(CONFIG_FIELDS);
|
|
130
181
|
return;
|
|
131
182
|
}
|
|
132
183
|
|
|
133
|
-
if (args.includes('-
|
|
134
|
-
|
|
184
|
+
if (args.includes('--glm-show')) {
|
|
185
|
+
showConfig(loadConfig());
|
|
135
186
|
return;
|
|
136
187
|
}
|
|
137
188
|
|
|
138
|
-
if (args.includes('-
|
|
139
|
-
|
|
189
|
+
if (args.includes('--glm-version')) {
|
|
190
|
+
console.log(`glm v${pkg.version}`);
|
|
140
191
|
return;
|
|
141
192
|
}
|
|
142
193
|
|
|
@@ -150,7 +201,8 @@ async function main() {
|
|
|
150
201
|
config = loadConfig();
|
|
151
202
|
}
|
|
152
203
|
|
|
153
|
-
|
|
204
|
+
// All arguments are passed through to claude
|
|
205
|
+
launchClaude(config, args);
|
|
154
206
|
}
|
|
155
207
|
|
|
156
208
|
main().catch(err => {
|