bravecode-cli 0.1.21 → 0.1.23
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 +146 -11
- package/dist/cli-main.mjs.map +3 -3
- package/dist/cli.cjs +1 -1
- package/package.json +1 -1
- package/scripts/build.js +1 -1
package/dist/cli-main.mjs
CHANGED
|
@@ -16725,9 +16725,9 @@ function isNodeDefaultFetch(fetch2) {
|
|
|
16725
16725
|
return source.includes("internal/deps/undici") || source.includes("lazy loading of undici");
|
|
16726
16726
|
}
|
|
16727
16727
|
function createSafeNodeFetch() {
|
|
16728
|
-
const { createRequire } = loadBuiltinModule("node:module");
|
|
16728
|
+
const { createRequire: createRequire2 } = loadBuiltinModule("node:module");
|
|
16729
16729
|
const { lookup } = loadBuiltinModule("node:dns");
|
|
16730
|
-
const { Agent: Agent2, fetch: fetch2 } =
|
|
16730
|
+
const { Agent: Agent2, fetch: fetch2 } = createRequire2(getCurrentModulePath())(
|
|
16731
16731
|
"undici"
|
|
16732
16732
|
);
|
|
16733
16733
|
const dispatcher = new Agent2({
|
|
@@ -38185,7 +38185,7 @@ var APP_VERSION, APP_NAME;
|
|
|
38185
38185
|
var init_version = __esm({
|
|
38186
38186
|
"src/version.ts"() {
|
|
38187
38187
|
"use strict";
|
|
38188
|
-
APP_VERSION = "0.1.
|
|
38188
|
+
APP_VERSION = "0.1.23";
|
|
38189
38189
|
APP_NAME = "BraveCode";
|
|
38190
38190
|
}
|
|
38191
38191
|
});
|
|
@@ -42527,9 +42527,132 @@ __export(tui_exports, {
|
|
|
42527
42527
|
TUILauncher: () => TUILauncher
|
|
42528
42528
|
});
|
|
42529
42529
|
import React5 from "react";
|
|
42530
|
-
import { createCliRenderer } from "@opentui/core";
|
|
42530
|
+
import { createCliRenderer, setRenderLibPath } from "@opentui/core";
|
|
42531
42531
|
import { createRoot as createReactRoot } from "@opentui/react";
|
|
42532
|
-
|
|
42532
|
+
import { existsSync as existsSync8 } from "node:fs";
|
|
42533
|
+
import { createRequire } from "node:module";
|
|
42534
|
+
import { dirname, join as join7 } from "node:path";
|
|
42535
|
+
import { fileURLToPath } from "node:url";
|
|
42536
|
+
function getCurrentTarget() {
|
|
42537
|
+
const p = process.platform;
|
|
42538
|
+
const a = process.arch;
|
|
42539
|
+
if (p !== "darwin" && p !== "linux" && p !== "win32") return null;
|
|
42540
|
+
if (a !== "arm64" && a !== "x64") return null;
|
|
42541
|
+
const target = { platform: p, arch: a };
|
|
42542
|
+
if (p === "linux") {
|
|
42543
|
+
const libcEnv = process.env.OPENTUI_LIBC;
|
|
42544
|
+
if (libcEnv === "musl") target.libc = "musl";
|
|
42545
|
+
}
|
|
42546
|
+
return target;
|
|
42547
|
+
}
|
|
42548
|
+
function makePackageName(target) {
|
|
42549
|
+
const libcSuffix = target.platform === "linux" && target.libc === "musl" ? "-musl" : "";
|
|
42550
|
+
return `@opentui/core-${target.platform}-${target.arch}${libcSuffix}`;
|
|
42551
|
+
}
|
|
42552
|
+
async function resolveNativeLibViaImport(pkgName) {
|
|
42553
|
+
try {
|
|
42554
|
+
const mod = await import(pkgName);
|
|
42555
|
+
const p = mod?.default ?? mod;
|
|
42556
|
+
if (typeof p === "string" && existsSync8(p)) return p;
|
|
42557
|
+
return null;
|
|
42558
|
+
} catch {
|
|
42559
|
+
return null;
|
|
42560
|
+
}
|
|
42561
|
+
}
|
|
42562
|
+
function resolveNativeLibViaRequire(pkgName, libFile) {
|
|
42563
|
+
try {
|
|
42564
|
+
const req = createRequire(import.meta.url);
|
|
42565
|
+
let pkgDir = null;
|
|
42566
|
+
try {
|
|
42567
|
+
const resolved = req.resolve(pkgName);
|
|
42568
|
+
pkgDir = dirname(resolved);
|
|
42569
|
+
} catch {
|
|
42570
|
+
try {
|
|
42571
|
+
const url2 = import.meta.resolve(pkgName + "/index.js");
|
|
42572
|
+
pkgDir = dirname(fileURLToPath(url2));
|
|
42573
|
+
} catch {
|
|
42574
|
+
try {
|
|
42575
|
+
const url2 = import.meta.resolve(pkgName);
|
|
42576
|
+
pkgDir = dirname(fileURLToPath(url2));
|
|
42577
|
+
} catch {
|
|
42578
|
+
}
|
|
42579
|
+
}
|
|
42580
|
+
}
|
|
42581
|
+
if (pkgDir) {
|
|
42582
|
+
const candidate = join7(pkgDir, libFile);
|
|
42583
|
+
if (existsSync8(candidate)) return candidate;
|
|
42584
|
+
const parentCandidate = join7(dirname(pkgDir), libFile);
|
|
42585
|
+
if (existsSync8(parentCandidate)) return parentCandidate;
|
|
42586
|
+
}
|
|
42587
|
+
return null;
|
|
42588
|
+
} catch {
|
|
42589
|
+
return null;
|
|
42590
|
+
}
|
|
42591
|
+
}
|
|
42592
|
+
function resolveNativeLibViaSearch(libFile) {
|
|
42593
|
+
const searchBases = [];
|
|
42594
|
+
try {
|
|
42595
|
+
const req = createRequire(import.meta.url);
|
|
42596
|
+
searchBases.push(dirname(req.resolve("@opentui/core/package.json")));
|
|
42597
|
+
} catch {
|
|
42598
|
+
}
|
|
42599
|
+
searchBases.push(join7(process.cwd(), "node_modules", "@opentui", "core"));
|
|
42600
|
+
try {
|
|
42601
|
+
searchBases.push(dirname(fileURLToPath(import.meta.url)));
|
|
42602
|
+
} catch {
|
|
42603
|
+
}
|
|
42604
|
+
const dedupedBases = [...new Set(searchBases.filter(Boolean))];
|
|
42605
|
+
for (const coreBase of dedupedBases) {
|
|
42606
|
+
const nmDir = join7(dirname(coreBase), "..");
|
|
42607
|
+
for (const target of buildSearchTargets()) {
|
|
42608
|
+
const nmPath = join7(nmDir, makePackageName(target), libFile);
|
|
42609
|
+
if (existsSync8(nmPath)) return nmPath;
|
|
42610
|
+
const siblingPath = join7(dirname(coreBase), makePackageName(target), libFile);
|
|
42611
|
+
if (existsSync8(siblingPath)) return siblingPath;
|
|
42612
|
+
}
|
|
42613
|
+
}
|
|
42614
|
+
try {
|
|
42615
|
+
const execDir = dirname(process.execPath);
|
|
42616
|
+
for (const target of buildSearchTargets()) {
|
|
42617
|
+
const candidate = join7(execDir, "..", "lib", "node_modules", "bravecode-cli", "node_modules", makePackageName(target), libFile);
|
|
42618
|
+
if (existsSync8(candidate)) return candidate;
|
|
42619
|
+
const flat = join7(execDir, "..", "lib", "node_modules", makePackageName(target), libFile);
|
|
42620
|
+
if (existsSync8(flat)) return flat;
|
|
42621
|
+
}
|
|
42622
|
+
} catch {
|
|
42623
|
+
}
|
|
42624
|
+
return null;
|
|
42625
|
+
}
|
|
42626
|
+
function buildSearchTargets() {
|
|
42627
|
+
const primary = getCurrentTarget();
|
|
42628
|
+
const targets = [];
|
|
42629
|
+
if (primary) targets.push(primary);
|
|
42630
|
+
if (primary?.platform === "linux" && !primary.libc) {
|
|
42631
|
+
targets.push({ ...primary, libc: "glibc" });
|
|
42632
|
+
targets.push({ ...primary, libc: "musl" });
|
|
42633
|
+
}
|
|
42634
|
+
if (primary?.platform === "linux" && primary.libc === "musl") {
|
|
42635
|
+
targets.push({ platform: "linux", arch: primary.arch, libc: "glibc" });
|
|
42636
|
+
}
|
|
42637
|
+
return targets;
|
|
42638
|
+
}
|
|
42639
|
+
async function preflightResolveNativeLib() {
|
|
42640
|
+
const primary = getCurrentTarget();
|
|
42641
|
+
if (!primary) return null;
|
|
42642
|
+
const libFile = NATIVE_FILE_NAMES[primary.platform];
|
|
42643
|
+
const targets = buildSearchTargets();
|
|
42644
|
+
for (const t of targets) {
|
|
42645
|
+
const pkgName = makePackageName(t);
|
|
42646
|
+
const viaImport = await resolveNativeLibViaImport(pkgName);
|
|
42647
|
+
if (viaImport) return viaImport;
|
|
42648
|
+
const viaRequire = resolveNativeLibViaRequire(pkgName, NATIVE_FILE_NAMES[t.platform]);
|
|
42649
|
+
if (viaRequire) return viaRequire;
|
|
42650
|
+
}
|
|
42651
|
+
const viaSearch = resolveNativeLibViaSearch(libFile);
|
|
42652
|
+
if (viaSearch) return viaSearch;
|
|
42653
|
+
return null;
|
|
42654
|
+
}
|
|
42655
|
+
var NATIVE_FILE_NAMES, TUILauncher;
|
|
42533
42656
|
var init_tui = __esm({
|
|
42534
42657
|
"src/core/tui/index.tsx"() {
|
|
42535
42658
|
"use strict";
|
|
@@ -42537,6 +42660,11 @@ var init_tui = __esm({
|
|
|
42537
42660
|
init_providers();
|
|
42538
42661
|
init_app();
|
|
42539
42662
|
init_config();
|
|
42663
|
+
NATIVE_FILE_NAMES = {
|
|
42664
|
+
darwin: "libopentui.dylib",
|
|
42665
|
+
linux: "libopentui.so",
|
|
42666
|
+
win32: "opentui.dll"
|
|
42667
|
+
};
|
|
42540
42668
|
TUILauncher = class {
|
|
42541
42669
|
options;
|
|
42542
42670
|
constructor(options = {}) {
|
|
@@ -42544,6 +42672,13 @@ var init_tui = __esm({
|
|
|
42544
42672
|
}
|
|
42545
42673
|
async start() {
|
|
42546
42674
|
process.env.BRAVECODE_TUI = "1";
|
|
42675
|
+
const resolvedLibPath = await preflightResolveNativeLib();
|
|
42676
|
+
if (resolvedLibPath) {
|
|
42677
|
+
try {
|
|
42678
|
+
setRenderLibPath(resolvedLibPath);
|
|
42679
|
+
} catch {
|
|
42680
|
+
}
|
|
42681
|
+
}
|
|
42547
42682
|
const cfg = getConfig();
|
|
42548
42683
|
const initialAgent = this.options.agent ?? cfg.getNested("agent.default") ?? "build";
|
|
42549
42684
|
const initialModel = this.options.model ?? cfg.getNested("model.default");
|
|
@@ -42597,9 +42732,9 @@ var init_tui = __esm({
|
|
|
42597
42732
|
|
|
42598
42733
|
// src/cli-main.ts
|
|
42599
42734
|
var cli_main_exports = {};
|
|
42600
|
-
import { existsSync as
|
|
42735
|
+
import { existsSync as existsSync9, writeFileSync as writeFileSync6 } from "fs";
|
|
42601
42736
|
import { execSync as execSync4 } from "child_process";
|
|
42602
|
-
import { join as
|
|
42737
|
+
import { join as join8 } from "path";
|
|
42603
42738
|
async function launchTUI(model, agent) {
|
|
42604
42739
|
const { TUILauncher: TUILauncher2 } = await Promise.resolve().then(() => (init_tui(), tui_exports));
|
|
42605
42740
|
const launcher = new TUILauncher2({ model, agent });
|
|
@@ -42795,8 +42930,8 @@ Fetching ${url2} (${method})...
|
|
|
42795
42930
|
});
|
|
42796
42931
|
program2.command("init").description("Initialize BraveCode in current directory (creates AGENTS.md)").action(() => {
|
|
42797
42932
|
const config2 = getConfig();
|
|
42798
|
-
const agensMd =
|
|
42799
|
-
if (
|
|
42933
|
+
const agensMd = join8(process.cwd(), "AGENTS.md");
|
|
42934
|
+
if (existsSync9(agensMd)) {
|
|
42800
42935
|
console.log("AGENTS.md already exists. Use --force to overwrite.");
|
|
42801
42936
|
return;
|
|
42802
42937
|
}
|
|
@@ -42845,8 +42980,8 @@ Fetching ${url2} (${method})...
|
|
|
42845
42980
|
writeFileSync6(agensMd, content);
|
|
42846
42981
|
console.log("Created AGENTS.md");
|
|
42847
42982
|
console.log("Customize it with your project-specific instructions.");
|
|
42848
|
-
const configPath =
|
|
42849
|
-
if (!
|
|
42983
|
+
const configPath = join8(process.cwd(), ".bravecode", "config.json");
|
|
42984
|
+
if (!existsSync9(join8(process.cwd(), ".bravecode"))) {
|
|
42850
42985
|
console.log("Config directory created at .bravecode/");
|
|
42851
42986
|
}
|
|
42852
42987
|
});
|