bravecode-cli 0.1.18 → 0.1.20

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.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.18",
3
+ "version": "0.1.20",
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.mjs"
8
+ "bravecode": "./dist/cli.cjs"
9
9
  },
10
10
  "files": [
11
11
  "dist/**/*",
@@ -16,7 +16,7 @@
16
16
  "scripts": {
17
17
  "build": "node scripts/build.js",
18
18
  "dev": "tsx watch src/cli.ts",
19
- "lint": "eslint src/ --ext .ts",
19
+ "lint": "eslint \"src/**/*.{ts,tsx}\"",
20
20
  "typecheck": "tsc --noEmit",
21
21
  "prepublishOnly": "npm run build",
22
22
  "postinstall": ""
@@ -50,6 +50,8 @@
50
50
  "@ai-sdk/mistral": "^4.0.32",
51
51
  "@ai-sdk/openai": "^4.0.46",
52
52
  "@ai-sdk/openai-compatible": "^3.0.36",
53
+ "@opentui/core": "^0.5.8",
54
+ "@opentui/react": "^0.5.8",
53
55
  "ai": "^7.0.78",
54
56
  "chalk": "^5.4.1",
55
57
  "commander": "^13.1.0",
@@ -64,8 +66,8 @@
64
66
  "zod": "^3.25.67"
65
67
  },
66
68
  "devDependencies": {
67
- "@types/node": "^24.0.10",
68
69
  "@types/ink": "^2.0.3",
70
+ "@types/node": "^24.0.10",
69
71
  "@types/react": "^19.2.18",
70
72
  "esbuild": "^0.25.5",
71
73
  "eslint": "^9.28.0",
package/scripts/build.js CHANGED
@@ -17,11 +17,21 @@ 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
- "#!/usr/bin/env node",
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"),
@@ -31,4 +41,52 @@ await build({
31
41
  external: ["react-devtools-core", "ink", "ink-text-input", "react", "yoga-layout"],
32
42
  });
33
43
 
44
+ // Write the CJS bootstrap wrapper. This is the actual `bravecode` bin entry.
45
+ // It runs in CommonJS mode (no hoisted imports) so the polyfill is guaranteed
46
+ // to apply BEFORE any ESM imports of ink / react-devtools-core / @opentui.
47
+ // The polyfill is written to the wrapper itself to guarantee ordering.
48
+ import { writeFileSync, mkdirSync, existsSync, chmodSync } from "fs";
49
+ import { dirname, join } from "path";
50
+ import { fileURLToPath } from "url";
51
+
52
+ const __dirname = dirname(fileURLToPath(import.meta.url));
53
+ const distDir = join(__dirname, "..", "dist");
54
+ if (!existsSync(distDir)) mkdirSync(distDir, { recursive: true });
55
+
56
+ const cjsWrapper = `#!/usr/bin/env node
57
+ /* CJS bootstrap wrapper for bravecode CLI.
58
+ *
59
+ * Why a separate CJS wrapper?
60
+ * ESM static imports are ALWAYS hoisted by Node's loader, even if they appear
61
+ * textually after polyfill code in the same file. This means a top-level
62
+ * import devtools from "react-devtools-core"
63
+ * emitted by esbuild (because react-devtools-core is marked external) runs
64
+ * BEFORE any polyfill we place in the ESM bundle body.
65
+ *
66
+ * CommonJS does NOT hoist require() calls — they execute in source order.
67
+ * So by launching from a tiny CJS file that applies the polyfill first, then
68
+ * dynamically imports the ESM bundle via import(), we guarantee that the
69
+ * polyfill on globalThis is installed well before react-devtools-core or ink
70
+ * ever evaluates.
71
+ */
72
+ (function () {
73
+ var g = globalThis;
74
+ try { if (typeof g.self === 'undefined') Object.defineProperty(g,'self',{value:g,writable:true,configurable:true,enumerable:false}); }
75
+ catch(e) { if (typeof g.self === 'undefined') g.self = g; }
76
+ try { if (typeof g.window === 'undefined') Object.defineProperty(g,'window',{value:g,writable:true,configurable:true,enumerable:false}); }
77
+ catch(e) { if (typeof g.window === 'undefined') g.window = g; }
78
+ try { if (typeof g.document === 'undefined') Object.defineProperty(g,'document',{value:{createElement:function(){return {}},addEventListener:function(){},readyState:'complete'},writable:true,configurable:true,enumerable:false}); }
79
+ catch(e) { if (typeof g.document === 'undefined') g.document = {createElement:function(){return {}},addEventListener:function(){},readyState:'complete'}; }
80
+ })();
81
+
82
+ import('./cli-main.mjs').catch(function (err) {
83
+ console.error('[bravecode] Fatal error during startup:', err);
84
+ process.exit(1);
85
+ });
86
+ `;
87
+
88
+ const wrapperPath = join(distDir, "cli.cjs");
89
+ writeFileSync(wrapperPath, cjsWrapper, "utf-8");
90
+ chmodSync(wrapperPath, 0o755);
91
+
34
92
  console.log("Build completed successfully!");