@duheso/zerocli 0.7.7 → 0.7.9
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/zero +103 -96
- package/dist/cli.mjs +2197 -974
- package/package.json +1 -1
package/bin/zero
CHANGED
|
@@ -1,96 +1,103 @@
|
|
|
1
|
-
#!/usr/bin/env
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
if
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// Zero CLI — Cross-platform wrapper for env var mapping and V8 heap configuration
|
|
4
|
+
//
|
|
5
|
+
// Maps COPILOT_PROVIDER_* / COPILOT_MODEL vars to the native OpenAI-shim
|
|
6
|
+
// vars, then boots the app.
|
|
7
|
+
//
|
|
8
|
+
// Internal (localhost):
|
|
9
|
+
// export COPILOT_PROVIDER_BASE_URL=http://localhost:3052/v1
|
|
10
|
+
// export COPILOT_PROVIDER_TYPE=openai
|
|
11
|
+
// export COPILOT_PROVIDER_API_KEY=not-required
|
|
12
|
+
// export COPILOT_MODEL=gemma4:code
|
|
13
|
+
// zero
|
|
14
|
+
//
|
|
15
|
+
// External (remote server):
|
|
16
|
+
// export COPILOT_PROVIDER_BASE_URL=http://10.11.36.131:3052/v1
|
|
17
|
+
// export COPILOT_PROVIDER_TYPE=openai
|
|
18
|
+
// export COPILOT_PROVIDER_API_KEY=not-required
|
|
19
|
+
// export COPILOT_MODEL=gemma4:code
|
|
20
|
+
// zero
|
|
21
|
+
|
|
22
|
+
import { spawn } from 'child_process';
|
|
23
|
+
import { existsSync } from 'fs';
|
|
24
|
+
import { fileURLToPath } from 'url';
|
|
25
|
+
import { dirname, join } from 'path';
|
|
26
|
+
import os from 'os';
|
|
27
|
+
|
|
28
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
29
|
+
const env = { ...process.env };
|
|
30
|
+
|
|
31
|
+
// ── COPILOT_* → native env var mapping ──────────────────────────────────────
|
|
32
|
+
|
|
33
|
+
const providerType = (env.COPILOT_PROVIDER_TYPE ?? '').toLowerCase();
|
|
34
|
+
|
|
35
|
+
if (providerType === 'openai' && env.COPILOT_PROVIDER_BASE_URL) {
|
|
36
|
+
env.CLAUDE_CODE_USE_OPENAI = '1';
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (env.COPILOT_PROVIDER_BASE_URL && !env.OPENAI_BASE_URL) {
|
|
40
|
+
env.OPENAI_BASE_URL = env.COPILOT_PROVIDER_BASE_URL;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (env.COPILOT_PROVIDER_API_KEY && !env.OPENAI_API_KEY) {
|
|
44
|
+
env.OPENAI_API_KEY = env.COPILOT_PROVIDER_API_KEY;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (env.COPILOT_MODEL && !env.OPENAI_MODEL) {
|
|
48
|
+
env.OPENAI_MODEL = env.COPILOT_MODEL;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// COPILOT_TOOLLESS=1 → disable tool calling (text-only mode).
|
|
52
|
+
if (env.COPILOT_TOOLLESS && !env.OPENAI_TOOLLESS) {
|
|
53
|
+
env.OPENAI_TOOLLESS = env.COPILOT_TOOLLESS;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// ── V8 heap configuration ────────────────────────────────────────────────────
|
|
57
|
+
//
|
|
58
|
+
// Prevent "JavaScript heap out of memory" crashes during long-running
|
|
59
|
+
// sessions (large context windows, agent waves, file editing). The default
|
|
60
|
+
// V8 heap limit (~4GB) is insufficient for the Zero CLI's context buildup.
|
|
61
|
+
//
|
|
62
|
+
// When running in CCR (remote containers), use 8GB. Otherwise, allocate
|
|
63
|
+
// 8GB on machines with enough RAM, falling back to 6GB as minimum.
|
|
64
|
+
|
|
65
|
+
let heapSize;
|
|
66
|
+
if (env.CLAUDE_CODE_REMOTE === 'true') {
|
|
67
|
+
heapSize = 8192;
|
|
68
|
+
} else {
|
|
69
|
+
const totalMemMB = os.totalmem() / (1024 * 1024);
|
|
70
|
+
heapSize = totalMemMB > 16384 ? 8192 : 6144;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Preserve existing NODE_OPTIONS (user may set --inspect, etc.)
|
|
74
|
+
env.NODE_OPTIONS = env.NODE_OPTIONS
|
|
75
|
+
? `${env.NODE_OPTIONS} --max-old-space-size=${heapSize}`
|
|
76
|
+
: `--max-old-space-size=${heapSize}`;
|
|
77
|
+
|
|
78
|
+
// ── Boot the compiled bundle ─────────────────────────────────────────────────
|
|
79
|
+
|
|
80
|
+
const distPath = join(__dirname, '..', 'dist', 'cli.mjs');
|
|
81
|
+
|
|
82
|
+
if (!existsSync(distPath)) {
|
|
83
|
+
process.stderr.write(
|
|
84
|
+
' zero: dist/cli.mjs not found.\n\n' +
|
|
85
|
+
' Build first:\n bun run build\n\n' +
|
|
86
|
+
' Or run directly with Bun:\n bun run dev\n\n' +
|
|
87
|
+
' See README.md for setup instructions.\n'
|
|
88
|
+
);
|
|
89
|
+
process.exit(1);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const child = spawn(process.execPath, [distPath, ...process.argv.slice(2)], {
|
|
93
|
+
stdio: 'inherit',
|
|
94
|
+
env,
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
child.on('exit', (code, signal) => {
|
|
98
|
+
if (signal) {
|
|
99
|
+
process.kill(process.pid, signal);
|
|
100
|
+
} else {
|
|
101
|
+
process.exit(code ?? 0);
|
|
102
|
+
}
|
|
103
|
+
});
|