@gaburieuru/claudio 0.24.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/LICENSE +29 -0
- package/README.md +424 -0
- package/bin/claudio +124 -0
- package/bin/import-specifier.mjs +13 -0
- package/bin/import-specifier.test.mjs +13 -0
- package/bin/openclaude +124 -0
- package/dist/cli.mjs +11188 -0
- package/dist/sdk.mjs +274613 -0
- package/docs/windows-aliases-and-launchers.md +162 -0
- package/package.json +211 -0
- package/scripts/windows/openclaude-aliases.ps1 +206 -0
- package/src/entrypoints/sdk/coreTypes.generated.ts +2385 -0
- package/src/entrypoints/sdk.d.ts +601 -0
- package/vendor/node-domexception-shim/index.js +3 -0
- package/vendor/node-domexception-shim/package.json +8 -0
package/bin/openclaude
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* OpenClaude — Claude Code with any LLM
|
|
5
|
+
*
|
|
6
|
+
* If dist/cli.mjs exists (built), run that.
|
|
7
|
+
* Otherwise, tell the user to build first or use `bun run dev`.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { existsSync } from 'fs'
|
|
11
|
+
import { join, dirname } from 'path'
|
|
12
|
+
import { fileURLToPath, pathToFileURL } from 'url'
|
|
13
|
+
import { spawnSync } from 'child_process'
|
|
14
|
+
|
|
15
|
+
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
16
|
+
const distPath = join(__dirname, '..', 'dist', 'cli.mjs')
|
|
17
|
+
|
|
18
|
+
const HEAP_RELAUNCHED_ENV = 'OPENCLAUDE_HEAP_RELAUNCHED'
|
|
19
|
+
const DISABLE_HEAP_RELAUNCH_ENV = 'OPENCLAUDE_DISABLE_HEAP_RELAUNCH'
|
|
20
|
+
const HEAP_SIZE_ENV = 'OPENCLAUDE_NODE_MAX_OLD_SPACE_SIZE_MB'
|
|
21
|
+
const DEFAULT_HEAP_SIZE_MB = 8192
|
|
22
|
+
|
|
23
|
+
function hasNodeFlag(args, flag) {
|
|
24
|
+
return args.some(arg => arg === flag || arg.startsWith(`${flag}=`))
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function hasNodeOptionFlag(flag) {
|
|
28
|
+
return hasNodeFlag([
|
|
29
|
+
...process.execArgv,
|
|
30
|
+
...(process.env.NODE_OPTIONS || '').split(/\s+/).filter(Boolean),
|
|
31
|
+
], flag)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function getHeapSizeMb() {
|
|
35
|
+
// --max-memory flag overrides env var
|
|
36
|
+
const maxMemArg = process.argv.find(a => a.startsWith('--max-memory='))
|
|
37
|
+
if (maxMemArg) {
|
|
38
|
+
const mb = Number.parseInt(maxMemArg.split('=')[1] || '0', 10)
|
|
39
|
+
if (Number.isSafeInteger(mb) && mb > 0) {
|
|
40
|
+
process.env[HEAP_SIZE_ENV] = String(mb)
|
|
41
|
+
process.env.OPENCLAUDE_MAX_MEMORY_MB = String(mb)
|
|
42
|
+
return mb
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const raw = process.env[HEAP_SIZE_ENV]
|
|
47
|
+
if (!raw) return DEFAULT_HEAP_SIZE_MB
|
|
48
|
+
const parsed = Number.parseInt(raw, 10)
|
|
49
|
+
return Number.isSafeInteger(parsed) && parsed > 0
|
|
50
|
+
? parsed
|
|
51
|
+
: DEFAULT_HEAP_SIZE_MB
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function relaunchWithLongSessionHeapIfNeeded() {
|
|
55
|
+
if (process.env[DISABLE_HEAP_RELAUNCH_ENV] === '1') return
|
|
56
|
+
if (process.env[HEAP_RELAUNCHED_ENV] === '1') return
|
|
57
|
+
const hasHeapLimit = hasNodeOptionFlag('--max-old-space-size')
|
|
58
|
+
const hasExplicitGc = hasNodeOptionFlag('--expose-gc')
|
|
59
|
+
if (hasHeapLimit && hasExplicitGc) return
|
|
60
|
+
|
|
61
|
+
const execArgv = [...process.execArgv]
|
|
62
|
+
if (!hasHeapLimit) {
|
|
63
|
+
execArgv.push(`--max-old-space-size=${getHeapSizeMb()}`)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Expose explicit GC for long interactive sessions. NODE_OPTIONS cannot
|
|
67
|
+
// carry --expose-gc, so the executable wrapper must add it before startup.
|
|
68
|
+
if (!hasExplicitGc) {
|
|
69
|
+
execArgv.push('--expose-gc')
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Strip --max-memory flag before relaunching — it's a launcher-only arg
|
|
73
|
+
// that Commander in the built CLI would reject as unknown.
|
|
74
|
+
const childArgs = process.argv.slice(2).filter(
|
|
75
|
+
arg => !arg.startsWith('--max-memory=') && arg !== '--max-memory',
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
// Preserve the original argv[1] (which may be a symlink like
|
|
79
|
+
// /usr/local/bin/openclaude) instead of resolving it via import.meta.url.
|
|
80
|
+
// Resolving symlinks here defeats install-type detection downstream: a real
|
|
81
|
+
// npm global install (symlink → node_modules/@gitlawb/openclaude/bin) would
|
|
82
|
+
// resolve to the package's real path inside node_modules, which is fine, but
|
|
83
|
+
// a `npm install -g .` dev symlink resolves back to the repo and looks like
|
|
84
|
+
// a source-tree dev run. Using argv[1] keeps the invocation path stable so
|
|
85
|
+
// doctorDiagnostic's npm-global path markers can match correctly.
|
|
86
|
+
const launcherPath = process.argv[1] || fileURLToPath(import.meta.url)
|
|
87
|
+
|
|
88
|
+
const result = spawnSync(process.execPath, [
|
|
89
|
+
...execArgv,
|
|
90
|
+
launcherPath,
|
|
91
|
+
...childArgs,
|
|
92
|
+
], {
|
|
93
|
+
stdio: 'inherit',
|
|
94
|
+
env: {
|
|
95
|
+
...process.env,
|
|
96
|
+
[HEAP_RELAUNCHED_ENV]: '1',
|
|
97
|
+
},
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
if (result.error) {
|
|
101
|
+
console.error(`openclaude: failed to restart with long-session heap: ${result.error.message}`)
|
|
102
|
+
process.exit(1)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
process.exit(result.status ?? 1)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (existsSync(distPath)) {
|
|
109
|
+
relaunchWithLongSessionHeapIfNeeded()
|
|
110
|
+
await import(pathToFileURL(distPath).href)
|
|
111
|
+
} else {
|
|
112
|
+
console.error(`
|
|
113
|
+
openclaude: dist/cli.mjs not found.
|
|
114
|
+
|
|
115
|
+
Build first:
|
|
116
|
+
bun run build
|
|
117
|
+
|
|
118
|
+
Or run directly with Bun:
|
|
119
|
+
bun run dev
|
|
120
|
+
|
|
121
|
+
See README.md for setup instructions.
|
|
122
|
+
`)
|
|
123
|
+
process.exit(1)
|
|
124
|
+
}
|