@xkei/openclaude 0.30.0-antigravity

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