bravecode-cli 0.1.19 → 0.1.21
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/dist/cli-main.mjs +43041 -0
- package/dist/cli-main.mjs.map +7 -0
- package/dist/cli.cjs +30 -0
- package/package.json +18 -2
- package/scripts/build.js +96 -3
- package/dist/cli.mjs +0 -109046
- package/dist/cli.mjs.map +0 -7
package/dist/cli.cjs
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/* CJS bootstrap wrapper for bravecode CLI.
|
|
3
|
+
*
|
|
4
|
+
* Why a separate CJS wrapper?
|
|
5
|
+
* ESM static imports are ALWAYS hoisted by Node's loader, even if they appear
|
|
6
|
+
* textually after polyfill code in the same file. This means a top-level
|
|
7
|
+
* import devtools from "react-devtools-core"
|
|
8
|
+
* emitted by esbuild (because react-devtools-core is marked external) runs
|
|
9
|
+
* BEFORE any polyfill we place in the ESM bundle body.
|
|
10
|
+
*
|
|
11
|
+
* CommonJS does NOT hoist require() calls — they execute in source order.
|
|
12
|
+
* So by launching from a tiny CJS file that applies the polyfill first, then
|
|
13
|
+
* dynamically imports the ESM bundle via import(), we guarantee that the
|
|
14
|
+
* polyfill on globalThis is installed well before react-devtools-core or ink
|
|
15
|
+
* ever evaluates.
|
|
16
|
+
*/
|
|
17
|
+
(function () {
|
|
18
|
+
var g = globalThis;
|
|
19
|
+
try { if (typeof g.self === 'undefined') Object.defineProperty(g,'self',{value:g,writable:true,configurable:true,enumerable:false}); }
|
|
20
|
+
catch(e) { if (typeof g.self === 'undefined') g.self = g; }
|
|
21
|
+
try { if (typeof g.window === 'undefined') Object.defineProperty(g,'window',{value:g,writable:true,configurable:true,enumerable:false}); }
|
|
22
|
+
catch(e) { if (typeof g.window === 'undefined') g.window = g; }
|
|
23
|
+
try { if (typeof g.document === 'undefined') Object.defineProperty(g,'document',{value:{createElement:function(){return {}},addEventListener:function(){},readyState:'complete'},writable:true,configurable:true,enumerable:false}); }
|
|
24
|
+
catch(e) { if (typeof g.document === 'undefined') g.document = {createElement:function(){return {}},addEventListener:function(){},readyState:'complete'}; }
|
|
25
|
+
})();
|
|
26
|
+
|
|
27
|
+
import('./cli-main.mjs').catch(function (err) {
|
|
28
|
+
console.error('[bravecode] Fatal error during startup:', err);
|
|
29
|
+
process.exit(1);
|
|
30
|
+
});
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bravecode-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.21",
|
|
4
4
|
"description": "Agentic AI vibe coding CLI with free model support",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"bin": {
|
|
8
|
-
"bravecode": "./dist/cli.
|
|
8
|
+
"bravecode": "./dist/cli.cjs"
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
11
|
"dist/**/*",
|
|
@@ -53,8 +53,10 @@
|
|
|
53
53
|
"@opentui/core": "^0.5.8",
|
|
54
54
|
"@opentui/react": "^0.5.8",
|
|
55
55
|
"ai": "^7.0.78",
|
|
56
|
+
"bun-ffi-structs": "0.3.1",
|
|
56
57
|
"chalk": "^5.4.1",
|
|
57
58
|
"commander": "^13.1.0",
|
|
59
|
+
"diff": "9.0.0",
|
|
58
60
|
"ink": "^7.1.1",
|
|
59
61
|
"ink-text-input": "^6.0.0",
|
|
60
62
|
"inquirer": "^12.6.0",
|
|
@@ -63,8 +65,22 @@
|
|
|
63
65
|
"minimatch": "^10.0.3",
|
|
64
66
|
"ora": "^8.2.0",
|
|
65
67
|
"react": "^19.2.8",
|
|
68
|
+
"react-reconciler": "^0.33.0",
|
|
69
|
+
"string-width": "^7.2.0",
|
|
70
|
+
"strip-ansi": "^7.1.2",
|
|
71
|
+
"ws": "^8.18.0",
|
|
66
72
|
"zod": "^3.25.67"
|
|
67
73
|
},
|
|
74
|
+
"optionalDependencies": {
|
|
75
|
+
"@opentui/core-darwin-x64": "0.5.8",
|
|
76
|
+
"@opentui/core-darwin-arm64": "0.5.8",
|
|
77
|
+
"@opentui/core-linux-x64": "0.5.8",
|
|
78
|
+
"@opentui/core-linux-arm64": "0.5.8",
|
|
79
|
+
"@opentui/core-win32-x64": "0.5.8",
|
|
80
|
+
"@opentui/core-win32-arm64": "0.5.8",
|
|
81
|
+
"@opentui/core-linux-x64-musl": "0.5.8",
|
|
82
|
+
"@opentui/core-linux-arm64-musl": "0.5.8"
|
|
83
|
+
},
|
|
68
84
|
"devDependencies": {
|
|
69
85
|
"@types/ink": "^2.0.3",
|
|
70
86
|
"@types/node": "^24.0.10",
|
package/scripts/build.js
CHANGED
|
@@ -17,18 +17,111 @@ await build({
|
|
|
17
17
|
bundle: true,
|
|
18
18
|
platform: "node",
|
|
19
19
|
target: "node18",
|
|
20
|
-
outfile: "dist/cli.mjs",
|
|
20
|
+
outfile: "dist/cli-main.mjs",
|
|
21
21
|
format: "esm",
|
|
22
22
|
banner: {
|
|
23
23
|
js: [
|
|
24
|
-
"
|
|
24
|
+
"// Second-line defense polyfill (first line is in CJS wrapper cli.cjs).",
|
|
25
|
+
"// The CJS wrapper runs first and is the primary polyfill mechanism.",
|
|
26
|
+
"(function(){",
|
|
27
|
+
" var g = globalThis;",
|
|
28
|
+
" try { if (typeof g.self === 'undefined') Object.defineProperty(g,'self',{value:g,writable:true,configurable:true,enumerable:false}); }",
|
|
29
|
+
" catch(e) { if (typeof g.self === 'undefined') g.self = g; }",
|
|
30
|
+
" try { if (typeof g.window === 'undefined') Object.defineProperty(g,'window',{value:g,writable:true,configurable:true,enumerable:false}); }",
|
|
31
|
+
" catch(e) { if (typeof g.window === 'undefined') g.window = g; }",
|
|
32
|
+
" try { if (typeof g.document === 'undefined') Object.defineProperty(g,'document',{value:{createElement:function(){return {}},addEventListener:function(){},readyState:'complete'},writable:true,configurable:true,enumerable:false}); }",
|
|
33
|
+
" catch(e) { if (typeof g.document === 'undefined') g.document = {createElement:function(){return {}},addEventListener:function(){},readyState:'complete'}; }",
|
|
34
|
+
"})();",
|
|
25
35
|
"import { createRequire as __braveCreateRequire } from 'module';",
|
|
26
36
|
"const require = __braveCreateRequire(import.meta.url);",
|
|
27
37
|
].join("\n"),
|
|
28
38
|
},
|
|
29
39
|
sourcemap: true,
|
|
30
40
|
minify: false,
|
|
31
|
-
|
|
41
|
+
// IMPORTANT: do NOT bundle @opentui packages. They use platform-specific
|
|
42
|
+
// optional native dependencies (@opentui/core-linux-x64 etc.) that they
|
|
43
|
+
// locate via __dirname / import.meta.url relative paths. If esbuild inlines
|
|
44
|
+
// them into our bundle, those relative paths break and the native FFI fails
|
|
45
|
+
// with "OpenTUI native FFI is not available for this runtime yet".
|
|
46
|
+
//
|
|
47
|
+
// We also externalize ink, react, react-devtools-core, yoga-layout, and all
|
|
48
|
+
// of @opentui's transitive deps that need intact module resolution (ws,
|
|
49
|
+
// react-reconciler, bun-ffi-structs, diff, string-width, strip-ansi, marked).
|
|
50
|
+
external: [
|
|
51
|
+
// React / Ink ecosystem
|
|
52
|
+
"react-devtools-core",
|
|
53
|
+
"ink",
|
|
54
|
+
"ink-text-input",
|
|
55
|
+
"react",
|
|
56
|
+
"yoga-layout",
|
|
57
|
+
"react-reconciler",
|
|
58
|
+
"ws",
|
|
59
|
+
// @opentui core + react bindings (NEVER bundle these — breaks native FFI)
|
|
60
|
+
"@opentui/core",
|
|
61
|
+
"@opentui/react",
|
|
62
|
+
// @opentui platform-specific native optional dependencies
|
|
63
|
+
"@opentui/core-darwin-x64",
|
|
64
|
+
"@opentui/core-darwin-arm64",
|
|
65
|
+
"@opentui/core-linux-x64",
|
|
66
|
+
"@opentui/core-linux-arm64",
|
|
67
|
+
"@opentui/core-win32-x64",
|
|
68
|
+
"@opentui/core-win32-arm64",
|
|
69
|
+
"@opentui/core-linux-x64-musl",
|
|
70
|
+
"@opentui/core-linux-arm64-musl",
|
|
71
|
+
// @opentui transitive deps used in path-sensitive contexts
|
|
72
|
+
"bun-ffi-structs",
|
|
73
|
+
"diff",
|
|
74
|
+
"string-width",
|
|
75
|
+
"strip-ansi",
|
|
76
|
+
],
|
|
32
77
|
});
|
|
33
78
|
|
|
79
|
+
// Write the CJS bootstrap wrapper. This is the actual `bravecode` bin entry.
|
|
80
|
+
// It runs in CommonJS mode (no hoisted imports) so the polyfill is guaranteed
|
|
81
|
+
// to apply BEFORE any ESM imports of ink / react-devtools-core / @opentui.
|
|
82
|
+
// The polyfill is written to the wrapper itself to guarantee ordering.
|
|
83
|
+
import { writeFileSync, mkdirSync, existsSync, chmodSync } from "fs";
|
|
84
|
+
import { dirname, join } from "path";
|
|
85
|
+
import { fileURLToPath } from "url";
|
|
86
|
+
|
|
87
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
88
|
+
const distDir = join(__dirname, "..", "dist");
|
|
89
|
+
if (!existsSync(distDir)) mkdirSync(distDir, { recursive: true });
|
|
90
|
+
|
|
91
|
+
const cjsWrapper = `#!/usr/bin/env node
|
|
92
|
+
/* CJS bootstrap wrapper for bravecode CLI.
|
|
93
|
+
*
|
|
94
|
+
* Why a separate CJS wrapper?
|
|
95
|
+
* ESM static imports are ALWAYS hoisted by Node's loader, even if they appear
|
|
96
|
+
* textually after polyfill code in the same file. This means a top-level
|
|
97
|
+
* import devtools from "react-devtools-core"
|
|
98
|
+
* emitted by esbuild (because react-devtools-core is marked external) runs
|
|
99
|
+
* BEFORE any polyfill we place in the ESM bundle body.
|
|
100
|
+
*
|
|
101
|
+
* CommonJS does NOT hoist require() calls — they execute in source order.
|
|
102
|
+
* So by launching from a tiny CJS file that applies the polyfill first, then
|
|
103
|
+
* dynamically imports the ESM bundle via import(), we guarantee that the
|
|
104
|
+
* polyfill on globalThis is installed well before react-devtools-core or ink
|
|
105
|
+
* ever evaluates.
|
|
106
|
+
*/
|
|
107
|
+
(function () {
|
|
108
|
+
var g = globalThis;
|
|
109
|
+
try { if (typeof g.self === 'undefined') Object.defineProperty(g,'self',{value:g,writable:true,configurable:true,enumerable:false}); }
|
|
110
|
+
catch(e) { if (typeof g.self === 'undefined') g.self = g; }
|
|
111
|
+
try { if (typeof g.window === 'undefined') Object.defineProperty(g,'window',{value:g,writable:true,configurable:true,enumerable:false}); }
|
|
112
|
+
catch(e) { if (typeof g.window === 'undefined') g.window = g; }
|
|
113
|
+
try { if (typeof g.document === 'undefined') Object.defineProperty(g,'document',{value:{createElement:function(){return {}},addEventListener:function(){},readyState:'complete'},writable:true,configurable:true,enumerable:false}); }
|
|
114
|
+
catch(e) { if (typeof g.document === 'undefined') g.document = {createElement:function(){return {}},addEventListener:function(){},readyState:'complete'}; }
|
|
115
|
+
})();
|
|
116
|
+
|
|
117
|
+
import('./cli-main.mjs').catch(function (err) {
|
|
118
|
+
console.error('[bravecode] Fatal error during startup:', err);
|
|
119
|
+
process.exit(1);
|
|
120
|
+
});
|
|
121
|
+
`;
|
|
122
|
+
|
|
123
|
+
const wrapperPath = join(distDir, "cli.cjs");
|
|
124
|
+
writeFileSync(wrapperPath, cjsWrapper, "utf-8");
|
|
125
|
+
chmodSync(wrapperPath, 0o755);
|
|
126
|
+
|
|
34
127
|
console.log("Build completed successfully!");
|