@duheso/zerocli 0.7.6 → 0.7.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.
Files changed (3) hide show
  1. package/bin/zero +87 -66
  2. package/dist/cli.mjs +11875 -11404
  3. package/package.json +2 -1
package/bin/zero CHANGED
@@ -1,66 +1,87 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Zero CLI — COPILOT_* env var support
5
- *
6
- * Maps COPILOT_PROVIDER_* / COPILOT_MODEL vars to the native OpenAI-shim
7
- * vars, then boots the app.
8
- *
9
- * Internal (localhost):
10
- * export COPILOT_PROVIDER_BASE_URL=http://localhost:3052/v1
11
- * export COPILOT_PROVIDER_TYPE=openai
12
- * export COPILOT_PROVIDER_API_KEY=not-required
13
- * export COPILOT_MODEL=gemma4:code
14
- * zero
15
- *
16
- * External (remote server):
17
- * export COPILOT_PROVIDER_BASE_URL=http://10.11.36.131:3052/v1
18
- * export COPILOT_PROVIDER_TYPE=openai
19
- * export COPILOT_PROVIDER_API_KEY=not-required
20
- * export COPILOT_MODEL=gemma4:code
21
- * zero
22
- */
23
-
24
- // ── COPILOT_* → native env var mapping ──────────────────────────────────────
25
-
26
- const providerType = (process.env.COPILOT_PROVIDER_TYPE ?? '').toLowerCase()
27
-
28
- if (providerType === 'openai' || process.env.COPILOT_PROVIDER_BASE_URL) {
29
- // Activate OpenAI-compatible shim
30
- process.env.CLAUDE_CODE_USE_OPENAI = '1'
31
- }
32
-
33
- if (process.env.COPILOT_PROVIDER_BASE_URL && !process.env.OPENAI_BASE_URL) {
34
- process.env.OPENAI_BASE_URL = process.env.COPILOT_PROVIDER_BASE_URL
35
- }
36
-
37
- if (process.env.COPILOT_PROVIDER_API_KEY && !process.env.OPENAI_API_KEY) {
38
- process.env.OPENAI_API_KEY = process.env.COPILOT_PROVIDER_API_KEY
39
- }
40
-
41
- if (process.env.COPILOT_MODEL && !process.env.OPENAI_MODEL) {
42
- process.env.OPENAI_MODEL = process.env.COPILOT_MODEL
43
- }
44
-
45
- // COPILOT_TOOLLESS=1 → disable tool calling (text-only mode).
46
- // Useful for models that loop on tool calls instead of answering.
47
- if (process.env.COPILOT_TOOLLESS && !process.env.OPENAI_TOOLLESS) {
48
- process.env.OPENAI_TOOLLESS = process.env.COPILOT_TOOLLESS
49
- }
50
-
51
- // ── Boot the compiled bundle ─────────────────────────────────────────────────
52
-
53
- import { existsSync } from 'fs'
54
- import { join, dirname } from 'path'
55
- import { fileURLToPath, pathToFileURL } from 'url'
56
-
57
- const __dirname = dirname(fileURLToPath(import.meta.url))
58
- const distPath = join(__dirname, '..', 'dist', 'cli.mjs')
59
-
60
- if (existsSync(distPath)) {
61
- await import(pathToFileURL(distPath).href)
62
- } else {
63
- console.error(`
1
+ #!/usr/bin/env bash
2
+
3
+ # Zero CLI — Shell 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
+ # ── COPILOT_* → native env var mapping ──────────────────────────────────────
23
+
24
+ providerType="${COPILOT_PROVIDER_TYPE,,}"
25
+
26
+ if [[ "$providerType" == "openai" ]] && [[ -n "$COPILOT_PROVIDER_BASE_URL" ]]; then
27
+ export CLAUDE_CODE_USE_OPENAI=1
28
+ fi
29
+
30
+ if [[ -n "$COPILOT_PROVIDER_BASE_URL" ]] && [[ -z "$OPENAI_BASE_URL" ]]; then
31
+ export OPENAI_BASE_URL="$COPILOT_PROVIDER_BASE_URL"
32
+ fi
33
+
34
+ if [[ -n "$COPILOT_PROVIDER_API_KEY" ]] && [[ -z "$OPENAI_API_KEY" ]]; then
35
+ export OPENAI_API_KEY="$COPILOT_PROVIDER_API_KEY"
36
+ fi
37
+
38
+ if [[ -n "$COPILOT_MODEL" ]] && [[ -z "$OPENAI_MODEL" ]]; then
39
+ export OPENAI_MODEL="$COPILOT_MODEL"
40
+ fi
41
+
42
+ # COPILOT_TOOLLESS=1 → disable tool calling (text-only mode).
43
+ if [[ -n "$COPILOT_TOOLLESS" ]] && [[ -z "$OPENAI_TOOLLESS" ]]; then
44
+ export OPENAI_TOOLLESS="$COPILOT_TOOLLESS"
45
+ fi
46
+
47
+ # ── V8 heap configuration ────────────────────────────────────────────────────
48
+ #
49
+ # Prevent "JavaScript heap out of memory" crashes during long-running
50
+ # sessions (large context windows, agent waves, file editing). The default
51
+ # V8 heap limit (~4GB) is insufficient for the Zero CLI's context buildup.
52
+ #
53
+ # When running in CCR (remote containers), use 8GB. Otherwise, allocate
54
+ # 8GB on machines with enough RAM, falling back to 6GB as minimum.
55
+
56
+ if [[ "$CLAUDE_CODE_REMOTE" == "true" ]]; then
57
+ HEAP_SIZE=8192
58
+ else
59
+ totalMemMB=$(free -m 2>/dev/null | awk '/^Mem:/{print $2}')
60
+ if [[ -n "$totalMemMB" ]] && [[ "$totalMemMB" -gt 16384 ]]; then
61
+ HEAP_SIZE=8192
62
+ else
63
+ HEAP_SIZE=6144
64
+ fi
65
+ fi
66
+
67
+ # Preserve existing NODE_OPTIONS (user may set --inspect, etc.)
68
+ if [[ -n "$NODE_OPTIONS" ]]; then
69
+ export NODE_OPTIONS="${NODE_OPTIONS} --max-old-space-size=${HEAP_SIZE}"
70
+ else
71
+ export NODE_OPTIONS="--max-old-space-size=${HEAP_SIZE}"
72
+ fi
73
+
74
+ # ── Boot the compiled bundle ─────────────────────────────────────────────────
75
+
76
+ # Resolve through symlinks (npm link creates symlink chains)
77
+ RESOLVED="$(cd -P "$(dirname "$0")" && pwd)"
78
+ SCRIPT_DIR="$(dirname "$(realpath "$0")" 2>/dev/null || echo "$RESOLVED")"
79
+ DIST_PATH="${SCRIPT_DIR}/../dist/cli.mjs"
80
+
81
+ if [[ -f "$DIST_PATH" ]]; then
82
+ exec node "$DIST_PATH" "$@"
83
+ else
84
+ cat >&2 <<'USAGE'
64
85
  zero: dist/cli.mjs not found.
65
86
 
66
87
  Build first:
@@ -70,6 +91,6 @@ if (existsSync(distPath)) {
70
91
  bun run dev
71
92
 
72
93
  See README.md for setup instructions.
73
- `)
74
- process.exit(1)
75
- }
94
+ USAGE
95
+ exit 1
96
+ fi