bravecode-cli 0.1.19 → 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.
@@ -1,4 +1,14 @@
1
- #!/usr/bin/env node
1
+ // Second-line defense polyfill (first line is in CJS wrapper cli.cjs).
2
+ // The CJS wrapper runs first and is the primary polyfill mechanism.
3
+ (function(){
4
+ var g = globalThis;
5
+ try { if (typeof g.self === 'undefined') Object.defineProperty(g,'self',{value:g,writable:true,configurable:true,enumerable:false}); }
6
+ catch(e) { if (typeof g.self === 'undefined') g.self = g; }
7
+ try { if (typeof g.window === 'undefined') Object.defineProperty(g,'window',{value:g,writable:true,configurable:true,enumerable:false}); }
8
+ catch(e) { if (typeof g.window === 'undefined') g.window = g; }
9
+ try { if (typeof g.document === 'undefined') Object.defineProperty(g,'document',{value:{createElement:function(){return {}},addEventListener:function(){},readyState:'complete'},writable:true,configurable:true,enumerable:false}); }
10
+ catch(e) { if (typeof g.document === 'undefined') g.document = {createElement:function(){return {}},addEventListener:function(){},readyState:'complete'}; }
11
+ })();
2
12
  import { createRequire as __braveCreateRequire } from 'module';
3
13
  const require = __braveCreateRequire(import.meta.url);
4
14
  var __create = Object.create;
@@ -3333,6 +3343,30 @@ var require_commander = __commonJS({
3333
3343
  }
3334
3344
  });
3335
3345
 
3346
+ // node_modules/commander/esm.mjs
3347
+ var import_index, program, createCommand, createArgument, createOption, CommanderError, InvalidArgumentError, InvalidOptionArgumentError, Command, Argument, Option, Help;
3348
+ var init_esm = __esm({
3349
+ "node_modules/commander/esm.mjs"() {
3350
+ import_index = __toESM(require_commander(), 1);
3351
+ ({
3352
+ program,
3353
+ createCommand,
3354
+ createArgument,
3355
+ createOption,
3356
+ CommanderError,
3357
+ InvalidArgumentError,
3358
+ InvalidOptionArgumentError,
3359
+ Command: (
3360
+ // deprecated old name
3361
+ Command
3362
+ ),
3363
+ Argument,
3364
+ Option,
3365
+ Help
3366
+ } = import_index.default);
3367
+ }
3368
+ });
3369
+
3336
3370
  // src/models.json
3337
3371
  var models_default;
3338
3372
  var init_models = __esm({
@@ -38151,7 +38185,7 @@ var APP_VERSION, APP_NAME;
38151
38185
  var init_version = __esm({
38152
38186
  "src/version.ts"() {
38153
38187
  "use strict";
38154
- APP_VERSION = "0.1.19";
38188
+ APP_VERSION = "0.1.20";
38155
38189
  APP_NAME = "BraveCode";
38156
38190
  }
38157
38191
  });
@@ -38569,7 +38603,7 @@ var init_tool = __esm({
38569
38603
 
38570
38604
  // node_modules/balanced-match/dist/esm/index.js
38571
38605
  var balanced, maybeMatch, range;
38572
- var init_esm = __esm({
38606
+ var init_esm2 = __esm({
38573
38607
  "node_modules/balanced-match/dist/esm/index.js"() {
38574
38608
  balanced = (a, b2, str) => {
38575
38609
  const ma = a instanceof RegExp ? maybeMatch(a, str) : a;
@@ -38821,9 +38855,9 @@ function expand_(str, max, maxLength, isTop) {
38821
38855
  return acc;
38822
38856
  }
38823
38857
  var escSlash, escOpen, escClose, escComma, escPeriod, escSlashPattern, escOpenPattern, escClosePattern, escCommaPattern, escPeriodPattern, slashPattern, openPattern, closePattern, commaPattern, periodPattern, EXPANSION_MAX, EXPANSION_MAX_LENGTH;
38824
- var init_esm2 = __esm({
38858
+ var init_esm3 = __esm({
38825
38859
  "node_modules/brace-expansion/dist/esm/index.js"() {
38826
- init_esm();
38860
+ init_esm2();
38827
38861
  escSlash = "\0SLASH" + Math.random() + "\0";
38828
38862
  escOpen = "\0OPEN" + Math.random() + "\0";
38829
38863
  escClose = "\0CLOSE" + Math.random() + "\0";
@@ -39652,9 +39686,9 @@ var init_escape = __esm({
39652
39686
 
39653
39687
  // node_modules/minimatch/dist/esm/index.js
39654
39688
  var minimatch, starDotExtRE, starDotExtTest, starDotExtTestDot, starDotExtTestNocase, starDotExtTestNocaseDot, starDotStarRE, starDotStarTest, starDotStarTestDot, dotStarRE, dotStarTest, starRE, starTest, starTestDot, qmarksRE, qmarksTestNocase, qmarksTestNocaseDot, qmarksTestDot, qmarksTest, qmarksTestNoExt, qmarksTestNoExtDot, defaultPlatform, path, sep, GLOBSTAR, qmark2, star2, twoStarDot, twoStarNoDot, filter2, ext, defaults, braceExpand, makeRe, match, globMagic, regExpEscape2, Minimatch;
39655
- var init_esm3 = __esm({
39689
+ var init_esm4 = __esm({
39656
39690
  "node_modules/minimatch/dist/esm/index.js"() {
39657
- init_esm2();
39691
+ init_esm3();
39658
39692
  init_assert_valid_pattern();
39659
39693
  init_ast();
39660
39694
  init_escape();
@@ -40503,7 +40537,7 @@ var PermissionSystem;
40503
40537
  var init_permission = __esm({
40504
40538
  "src/core/permission/index.ts"() {
40505
40539
  "use strict";
40506
- init_esm3();
40540
+ init_esm4();
40507
40541
  PermissionSystem = class {
40508
40542
  globalPermissions;
40509
40543
  agentPermissions = /* @__PURE__ */ new Map();
@@ -41386,6 +41420,223 @@ var init_config = __esm({
41386
41420
  }
41387
41421
  });
41388
41422
 
41423
+ // src/core/share/index.ts
41424
+ import { readFileSync as readFileSync6, writeFileSync as writeFileSync4, existsSync as existsSync6, mkdirSync as mkdirSync3, readdirSync as readdirSync3, unlinkSync } from "fs";
41425
+ import { join as join5 } from "path";
41426
+ import { homedir as homedir2 } from "os";
41427
+ import { randomBytes } from "crypto";
41428
+ var ShareManager;
41429
+ var init_share = __esm({
41430
+ "src/core/share/index.ts"() {
41431
+ "use strict";
41432
+ ShareManager = class {
41433
+ shareDir;
41434
+ constructor() {
41435
+ this.shareDir = join5(homedir2(), ".bravecode", "shares");
41436
+ this.ensureShareDir();
41437
+ }
41438
+ ensureShareDir() {
41439
+ if (!existsSync6(this.shareDir)) {
41440
+ mkdirSync3(this.shareDir, { recursive: true });
41441
+ }
41442
+ }
41443
+ createShare(title, messages, options = {}) {
41444
+ const id = randomBytes(8).toString("hex");
41445
+ const share = {
41446
+ id,
41447
+ title,
41448
+ messages,
41449
+ createdAt: /* @__PURE__ */ new Date(),
41450
+ isPublic: options.isPublic ?? true,
41451
+ expiresAt: options.expiresInHours ? new Date(Date.now() + options.expiresInHours * 36e5) : void 0
41452
+ };
41453
+ const filePath = join5(this.shareDir, `${id}.json`);
41454
+ writeFileSync4(filePath, JSON.stringify(share, null, 2));
41455
+ return share;
41456
+ }
41457
+ getShare(id) {
41458
+ const filePath = join5(this.shareDir, `${id}.json`);
41459
+ if (!existsSync6(filePath)) {
41460
+ return null;
41461
+ }
41462
+ try {
41463
+ const data = readFileSync6(filePath, "utf-8");
41464
+ const share = JSON.parse(data);
41465
+ if (share.expiresAt && new Date(share.expiresAt) < /* @__PURE__ */ new Date()) {
41466
+ this.deleteShare(id);
41467
+ return null;
41468
+ }
41469
+ return share;
41470
+ } catch {
41471
+ return null;
41472
+ }
41473
+ }
41474
+ listShares() {
41475
+ if (!existsSync6(this.shareDir)) {
41476
+ return [];
41477
+ }
41478
+ const files = readdirSync3(this.shareDir).filter((f) => f.endsWith(".json"));
41479
+ return files.map((file2) => {
41480
+ try {
41481
+ const data = readFileSync6(join5(this.shareDir, file2), "utf-8");
41482
+ return JSON.parse(data);
41483
+ } catch {
41484
+ return null;
41485
+ }
41486
+ }).filter(Boolean);
41487
+ }
41488
+ deleteShare(id) {
41489
+ const filePath = join5(this.shareDir, `${id}.json`);
41490
+ if (existsSync6(filePath)) {
41491
+ unlinkSync(filePath);
41492
+ return true;
41493
+ }
41494
+ return false;
41495
+ }
41496
+ getShareUrl(id) {
41497
+ return `https://bravecode.ai/share/${id}`;
41498
+ }
41499
+ formatShareForDisplay(share) {
41500
+ const lines = [
41501
+ `# ${share.title}`,
41502
+ "",
41503
+ `Created: ${new Date(share.createdAt).toLocaleString()}`,
41504
+ `Public: ${share.isPublic ? "Yes" : "No"}`,
41505
+ share.expiresAt ? `Expires: ${new Date(share.expiresAt).toLocaleString()}` : "",
41506
+ "",
41507
+ "---",
41508
+ ""
41509
+ ];
41510
+ for (const msg of share.messages) {
41511
+ const role = msg.role === "user" ? "**You**" : msg.role === "assistant" ? "**AI**" : "**System**";
41512
+ lines.push(`${role}:`);
41513
+ lines.push(msg.content);
41514
+ lines.push("");
41515
+ }
41516
+ return lines.join("\n");
41517
+ }
41518
+ };
41519
+ }
41520
+ });
41521
+
41522
+ // src/core/update/index.ts
41523
+ import { execSync as execSync3 } from "child_process";
41524
+ import { readFileSync as readFileSync7, writeFileSync as writeFileSync5, existsSync as existsSync7, mkdirSync as mkdirSync4 } from "fs";
41525
+ import { join as join6 } from "path";
41526
+ import { homedir as homedir3 } from "os";
41527
+ var PACKAGE_NAME, CURRENT_VERSION, UPDATE_CHECK_INTERVAL, UpdateChecker;
41528
+ var init_update = __esm({
41529
+ "src/core/update/index.ts"() {
41530
+ "use strict";
41531
+ init_version();
41532
+ PACKAGE_NAME = "bravecode-cli";
41533
+ CURRENT_VERSION = APP_VERSION;
41534
+ UPDATE_CHECK_INTERVAL = 24 * 60 * 60 * 1e3;
41535
+ UpdateChecker = class {
41536
+ configDir;
41537
+ lastCheckFile;
41538
+ constructor() {
41539
+ this.configDir = join6(homedir3(), ".bravecode");
41540
+ this.lastCheckFile = join6(this.configDir, "last-update-check");
41541
+ this.ensureConfigDir();
41542
+ }
41543
+ ensureConfigDir() {
41544
+ if (!existsSync7(this.configDir)) {
41545
+ mkdirSync4(this.configDir, { recursive: true });
41546
+ }
41547
+ }
41548
+ getLastCheckTime() {
41549
+ if (!existsSync7(this.lastCheckFile)) {
41550
+ return 0;
41551
+ }
41552
+ try {
41553
+ const data = readFileSync7(this.lastCheckFile, "utf-8");
41554
+ return parseInt(data, 10) || 0;
41555
+ } catch {
41556
+ return 0;
41557
+ }
41558
+ }
41559
+ setLastCheckTime() {
41560
+ writeFileSync5(this.lastCheckFile, Date.now().toString());
41561
+ }
41562
+ async checkForUpdates(force = false) {
41563
+ const lastCheck = this.getLastCheckTime();
41564
+ const now2 = Date.now();
41565
+ if (!force && now2 - lastCheck < UPDATE_CHECK_INTERVAL) {
41566
+ return {
41567
+ currentVersion: CURRENT_VERSION,
41568
+ latestVersion: CURRENT_VERSION,
41569
+ updateAvailable: false
41570
+ };
41571
+ }
41572
+ this.setLastCheckTime();
41573
+ try {
41574
+ const result = execSync3(`npm view ${PACKAGE_NAME} version 2>/dev/null`, {
41575
+ encoding: "utf-8",
41576
+ timeout: 1e4
41577
+ }).trim();
41578
+ const latestVersion = result || CURRENT_VERSION;
41579
+ const updateAvailable = this.compareVersions(latestVersion, CURRENT_VERSION) > 0;
41580
+ return {
41581
+ currentVersion: CURRENT_VERSION,
41582
+ latestVersion,
41583
+ updateAvailable,
41584
+ releaseUrl: `https://www.npmjs.com/package/${PACKAGE_NAME}`
41585
+ };
41586
+ } catch {
41587
+ return {
41588
+ currentVersion: CURRENT_VERSION,
41589
+ latestVersion: CURRENT_VERSION,
41590
+ updateAvailable: false
41591
+ };
41592
+ }
41593
+ }
41594
+ compareVersions(a, b2) {
41595
+ const partsA = a.split(".").map(Number);
41596
+ const partsB = b2.split(".").map(Number);
41597
+ for (let i = 0; i < Math.max(partsA.length, partsB.length); i++) {
41598
+ const partA = partsA[i] || 0;
41599
+ const partB = partsB[i] || 0;
41600
+ if (partA > partB) return 1;
41601
+ if (partA < partB) return -1;
41602
+ }
41603
+ return 0;
41604
+ }
41605
+ async update() {
41606
+ try {
41607
+ console.log(`Updating ${PACKAGE_NAME}...`);
41608
+ execSync3(`npm install -g ${PACKAGE_NAME}@latest`, {
41609
+ stdio: "inherit",
41610
+ timeout: 12e4
41611
+ });
41612
+ return {
41613
+ success: true,
41614
+ message: "Updated successfully. Please restart bravecode."
41615
+ };
41616
+ } catch (error40) {
41617
+ return {
41618
+ success: false,
41619
+ message: `Update failed: ${error40.message}`
41620
+ };
41621
+ }
41622
+ }
41623
+ async getChangelog() {
41624
+ try {
41625
+ const result = execSync3(`npm view ${PACKAGE_NAME} --json 2>/dev/null`, {
41626
+ encoding: "utf-8",
41627
+ timeout: 1e4
41628
+ });
41629
+ const info = JSON.parse(result);
41630
+ const description = info.description || "No changelog available.";
41631
+ return description;
41632
+ } catch {
41633
+ return "Unable to fetch changelog.";
41634
+ }
41635
+ }
41636
+ };
41637
+ }
41638
+ });
41639
+
41389
41640
  // node_modules/@opentui/core/chunk-node-mfda59vq.js
41390
41641
  import { createRequire } from "node:module";
41391
41642
  import { fileURLToPath } from "node:url";
@@ -108364,428 +108615,212 @@ var init_tui = __esm({
108364
108615
  }
108365
108616
  });
108366
108617
 
108367
- // node_modules/commander/esm.mjs
108368
- var import_index = __toESM(require_commander(), 1);
108369
- var {
108370
- program,
108371
- createCommand,
108372
- createArgument,
108373
- createOption,
108374
- CommanderError,
108375
- InvalidArgumentError,
108376
- InvalidOptionArgumentError,
108377
- // deprecated old name
108378
- Command,
108379
- Argument,
108380
- Option,
108381
- Help
108382
- } = import_index.default;
108383
-
108384
- // src/cli.ts
108385
- init_autoModel();
108386
- init_provider();
108387
- init_tool();
108388
- init_agent();
108389
- init_config();
108390
-
108391
- // src/core/share/index.ts
108392
- import { readFileSync as readFileSync6, writeFileSync as writeFileSync4, existsSync as existsSync6, mkdirSync as mkdirSync3, readdirSync as readdirSync3, unlinkSync } from "fs";
108393
- import { join as join5 } from "path";
108394
- import { homedir as homedir2 } from "os";
108395
- import { randomBytes } from "crypto";
108396
- var ShareManager = class {
108397
- shareDir;
108398
- constructor() {
108399
- this.shareDir = join5(homedir2(), ".bravecode", "shares");
108400
- this.ensureShareDir();
108401
- }
108402
- ensureShareDir() {
108403
- if (!existsSync6(this.shareDir)) {
108404
- mkdirSync3(this.shareDir, { recursive: true });
108405
- }
108406
- }
108407
- createShare(title, messages, options = {}) {
108408
- const id = randomBytes(8).toString("hex");
108409
- const share = {
108410
- id,
108411
- title,
108412
- messages,
108413
- createdAt: /* @__PURE__ */ new Date(),
108414
- isPublic: options.isPublic ?? true,
108415
- expiresAt: options.expiresInHours ? new Date(Date.now() + options.expiresInHours * 36e5) : void 0
108416
- };
108417
- const filePath = join5(this.shareDir, `${id}.json`);
108418
- writeFileSync4(filePath, JSON.stringify(share, null, 2));
108419
- return share;
108420
- }
108421
- getShare(id) {
108422
- const filePath = join5(this.shareDir, `${id}.json`);
108423
- if (!existsSync6(filePath)) {
108424
- return null;
108425
- }
108426
- try {
108427
- const data = readFileSync6(filePath, "utf-8");
108428
- const share = JSON.parse(data);
108429
- if (share.expiresAt && new Date(share.expiresAt) < /* @__PURE__ */ new Date()) {
108430
- this.deleteShare(id);
108431
- return null;
108432
- }
108433
- return share;
108434
- } catch {
108435
- return null;
108436
- }
108437
- }
108438
- listShares() {
108439
- if (!existsSync6(this.shareDir)) {
108440
- return [];
108441
- }
108442
- const files = readdirSync3(this.shareDir).filter((f) => f.endsWith(".json"));
108443
- return files.map((file2) => {
108444
- try {
108445
- const data = readFileSync6(join5(this.shareDir, file2), "utf-8");
108446
- return JSON.parse(data);
108447
- } catch {
108448
- return null;
108449
- }
108450
- }).filter(Boolean);
108451
- }
108452
- deleteShare(id) {
108453
- const filePath = join5(this.shareDir, `${id}.json`);
108454
- if (existsSync6(filePath)) {
108455
- unlinkSync(filePath);
108456
- return true;
108457
- }
108458
- return false;
108459
- }
108460
- getShareUrl(id) {
108461
- return `https://bravecode.ai/share/${id}`;
108462
- }
108463
- formatShareForDisplay(share) {
108464
- const lines = [
108465
- `# ${share.title}`,
108466
- "",
108467
- `Created: ${new Date(share.createdAt).toLocaleString()}`,
108468
- `Public: ${share.isPublic ? "Yes" : "No"}`,
108469
- share.expiresAt ? `Expires: ${new Date(share.expiresAt).toLocaleString()}` : "",
108470
- "",
108471
- "---",
108472
- ""
108473
- ];
108474
- for (const msg of share.messages) {
108475
- const role = msg.role === "user" ? "**You**" : msg.role === "assistant" ? "**AI**" : "**System**";
108476
- lines.push(`${role}:`);
108477
- lines.push(msg.content);
108478
- lines.push("");
108479
- }
108480
- return lines.join("\n");
108481
- }
108482
- };
108483
-
108484
- // src/core/update/index.ts
108485
- init_version();
108486
- import { execSync as execSync3 } from "child_process";
108487
- import { readFileSync as readFileSync7, writeFileSync as writeFileSync5, existsSync as existsSync7, mkdirSync as mkdirSync4 } from "fs";
108488
- import { join as join6 } from "path";
108489
- import { homedir as homedir3 } from "os";
108490
- var PACKAGE_NAME = "bravecode-cli";
108491
- var CURRENT_VERSION = APP_VERSION;
108492
- var UPDATE_CHECK_INTERVAL = 24 * 60 * 60 * 1e3;
108493
- var UpdateChecker = class {
108494
- configDir;
108495
- lastCheckFile;
108496
- constructor() {
108497
- this.configDir = join6(homedir3(), ".bravecode");
108498
- this.lastCheckFile = join6(this.configDir, "last-update-check");
108499
- this.ensureConfigDir();
108500
- }
108501
- ensureConfigDir() {
108502
- if (!existsSync7(this.configDir)) {
108503
- mkdirSync4(this.configDir, { recursive: true });
108504
- }
108505
- }
108506
- getLastCheckTime() {
108507
- if (!existsSync7(this.lastCheckFile)) {
108508
- return 0;
108509
- }
108510
- try {
108511
- const data = readFileSync7(this.lastCheckFile, "utf-8");
108512
- return parseInt(data, 10) || 0;
108513
- } catch {
108514
- return 0;
108515
- }
108516
- }
108517
- setLastCheckTime() {
108518
- writeFileSync5(this.lastCheckFile, Date.now().toString());
108519
- }
108520
- async checkForUpdates(force = false) {
108521
- const lastCheck = this.getLastCheckTime();
108522
- const now2 = Date.now();
108523
- if (!force && now2 - lastCheck < UPDATE_CHECK_INTERVAL) {
108524
- return {
108525
- currentVersion: CURRENT_VERSION,
108526
- latestVersion: CURRENT_VERSION,
108527
- updateAvailable: false
108528
- };
108529
- }
108530
- this.setLastCheckTime();
108531
- try {
108532
- const result = execSync3(`npm view ${PACKAGE_NAME} version 2>/dev/null`, {
108533
- encoding: "utf-8",
108534
- timeout: 1e4
108535
- }).trim();
108536
- const latestVersion = result || CURRENT_VERSION;
108537
- const updateAvailable = this.compareVersions(latestVersion, CURRENT_VERSION) > 0;
108538
- return {
108539
- currentVersion: CURRENT_VERSION,
108540
- latestVersion,
108541
- updateAvailable,
108542
- releaseUrl: `https://www.npmjs.com/package/${PACKAGE_NAME}`
108543
- };
108544
- } catch {
108545
- return {
108546
- currentVersion: CURRENT_VERSION,
108547
- latestVersion: CURRENT_VERSION,
108548
- updateAvailable: false
108549
- };
108550
- }
108551
- }
108552
- compareVersions(a, b2) {
108553
- const partsA = a.split(".").map(Number);
108554
- const partsB = b2.split(".").map(Number);
108555
- for (let i = 0; i < Math.max(partsA.length, partsB.length); i++) {
108556
- const partA = partsA[i] || 0;
108557
- const partB = partsB[i] || 0;
108558
- if (partA > partB) return 1;
108559
- if (partA < partB) return -1;
108560
- }
108561
- return 0;
108562
- }
108563
- async update() {
108564
- try {
108565
- console.log(`Updating ${PACKAGE_NAME}...`);
108566
- execSync3(`npm install -g ${PACKAGE_NAME}@latest`, {
108567
- stdio: "inherit",
108568
- timeout: 12e4
108569
- });
108570
- return {
108571
- success: true,
108572
- message: "Updated successfully. Please restart bravecode."
108573
- };
108574
- } catch (error40) {
108575
- return {
108576
- success: false,
108577
- message: `Update failed: ${error40.message}`
108578
- };
108579
- }
108580
- }
108581
- async getChangelog() {
108582
- try {
108583
- const result = execSync3(`npm view ${PACKAGE_NAME} --json 2>/dev/null`, {
108584
- encoding: "utf-8",
108585
- timeout: 1e4
108586
- });
108587
- const info = JSON.parse(result);
108588
- const description = info.description || "No changelog available.";
108589
- return description;
108590
- } catch {
108591
- return "Unable to fetch changelog.";
108592
- }
108593
- }
108594
- };
108595
-
108596
- // src/cli.ts
108597
- init_version();
108618
+ // src/cli-main.ts
108619
+ var cli_main_exports = {};
108598
108620
  import { existsSync as existsSync8, writeFileSync as writeFileSync8 } from "fs";
108599
108621
  import { execSync as execSync4 } from "child_process";
108600
108622
  import { join as join9 } from "path";
108601
- var program2 = new Command();
108602
108623
  async function launchTUI(model, agent) {
108603
108624
  const { TUILauncher: TUILauncher2 } = await init_tui().then(() => tui_exports);
108604
108625
  const launcher = new TUILauncher2({ model, agent });
108605
108626
  await launcher.start();
108606
108627
  }
108607
- program2.name("bravecode").description("BraveCode AI - Agentic AI Vibe Coding CLI with free model support").version(APP_VERSION).action(async () => {
108608
- await launchTUI();
108609
- });
108610
- program2.command("chat").description("Start a chat session").option("-m, --model <model>", "Model to use (or 'auto' for auto-selection)").option("-t, --task <task>", "Task type hint (code, reasoning, vision, audio, general)").option("-a, --agent <agent>", "Agent to use", "build").option("--tui", "Launch interactive TUI mode").argument("[prompt]", "Initial prompt").action(async (prompt, options) => {
108611
- if (!prompt || options.tui) {
108612
- await launchTUI(options.model, options.agent);
108613
- return;
108614
- }
108615
- const provider = new LLMProviderManager();
108616
- const autoModel = new AutoModelSelector();
108617
- let modelId;
108618
- if (options.model === "auto" || !options.model) {
108619
- const taskType = options.task || autoModel.detectTaskType(prompt);
108620
- const selectedModel = autoModel.selectModel(taskType);
108621
- modelId = selectedModel.id;
108622
- console.log(`
108628
+ var program2;
108629
+ var init_cli_main = __esm({
108630
+ "src/cli-main.ts"() {
108631
+ "use strict";
108632
+ init_esm();
108633
+ init_autoModel();
108634
+ init_provider();
108635
+ init_tool();
108636
+ init_agent();
108637
+ init_config();
108638
+ init_share();
108639
+ init_update();
108640
+ init_version();
108641
+ program2 = new Command();
108642
+ program2.name("bravecode").description("BraveCode AI - Agentic AI Vibe Coding CLI with free model support").version(APP_VERSION).action(async () => {
108643
+ await launchTUI();
108644
+ });
108645
+ program2.command("chat").description("Start a chat session").option("-m, --model <model>", "Model to use (or 'auto' for auto-selection)").option("-t, --task <task>", "Task type hint (code, reasoning, vision, audio, general)").option("-a, --agent <agent>", "Agent to use", "build").option("--tui", "Launch interactive TUI mode").argument("[prompt]", "Initial prompt").action(async (prompt, options) => {
108646
+ if (!prompt || options.tui) {
108647
+ await launchTUI(options.model, options.agent);
108648
+ return;
108649
+ }
108650
+ const provider = new LLMProviderManager();
108651
+ const autoModel = new AutoModelSelector();
108652
+ let modelId;
108653
+ if (options.model === "auto" || !options.model) {
108654
+ const taskType = options.task || autoModel.detectTaskType(prompt);
108655
+ const selectedModel = autoModel.selectModel(taskType);
108656
+ modelId = selectedModel.id;
108657
+ console.log(`
108623
108658
  Auto-selected model: ${selectedModel.name} (${modelId})`);
108624
- } else {
108625
- modelId = options.model;
108626
- }
108627
- const messages = [{ role: "user", content: prompt }];
108628
- console.log(`
108659
+ } else {
108660
+ modelId = options.model;
108661
+ }
108662
+ const messages = [{ role: "user", content: prompt }];
108663
+ console.log(`
108629
108664
  Using model: ${modelId}
108630
108665
  `);
108631
- const stream = provider.chatStream({ model: modelId, messages });
108632
- for await (const chunk of stream) {
108633
- if (chunk.type === "text" && chunk.text) {
108634
- process.stdout.write(chunk.text);
108635
- }
108636
- }
108637
- console.log("\n");
108638
- });
108639
- program2.command("run").description("Run a single prompt with tool execution (non-interactive)").option("-m, --model <model>", "Model to use").option("-a, --agent <agent>", "Agent to use (build, plan, debug, testing, security, api-security)", "build").option("--auto", "Auto-approve permission requests").argument("<prompt>", "The prompt to run").action(async (prompt, options) => {
108640
- const provider = new LLMProviderManager();
108641
- const tools = new ToolRegistry();
108642
- const autoModel = new AutoModelSelector();
108643
- let modelId = options.model;
108644
- if (!modelId) {
108645
- const taskType = autoModel.detectTaskType(prompt);
108646
- const selectedModel = autoModel.selectModel(taskType);
108647
- modelId = selectedModel.id;
108648
- }
108649
- const agentConfig = defaultAgents.find((a) => a.id === options.agent) || defaultAgents[0];
108650
- const agent = new Agent(provider, tools, {
108651
- ...agentConfig,
108652
- model: modelId
108653
- });
108654
- if (options.auto) {
108655
- agent.setAutoApprove(true);
108656
- }
108657
- console.log(`
108666
+ const stream = provider.chatStream({ model: modelId, messages });
108667
+ for await (const chunk of stream) {
108668
+ if (chunk.type === "text" && chunk.text) {
108669
+ process.stdout.write(chunk.text);
108670
+ }
108671
+ }
108672
+ console.log("\n");
108673
+ });
108674
+ program2.command("run").description("Run a single prompt with tool execution (non-interactive)").option("-m, --model <model>", "Model to use").option("-a, --agent <agent>", "Agent to use (build, plan, debug, testing, security, api-security)", "build").option("--auto", "Auto-approve permission requests").argument("<prompt>", "The prompt to run").action(async (prompt, options) => {
108675
+ const provider = new LLMProviderManager();
108676
+ const tools = new ToolRegistry();
108677
+ const autoModel = new AutoModelSelector();
108678
+ let modelId = options.model;
108679
+ if (!modelId) {
108680
+ const taskType = autoModel.detectTaskType(prompt);
108681
+ const selectedModel = autoModel.selectModel(taskType);
108682
+ modelId = selectedModel.id;
108683
+ }
108684
+ const agentConfig = defaultAgents.find((a) => a.id === options.agent) || defaultAgents[0];
108685
+ const agent = new Agent(provider, tools, {
108686
+ ...agentConfig,
108687
+ model: modelId
108688
+ });
108689
+ if (options.auto) {
108690
+ agent.setAutoApprove(true);
108691
+ }
108692
+ console.log(`
108658
108693
  BraveCode AI - Running with ${agentConfig.name}`);
108659
- console.log(`Model: ${modelId}`);
108660
- console.log(`Prompt: ${prompt}
108694
+ console.log(`Model: ${modelId}`);
108695
+ console.log(`Prompt: ${prompt}
108661
108696
  `);
108662
- const response = await agent.run(prompt, (chunk) => {
108663
- process.stdout.write(chunk);
108664
- });
108665
- console.log("\n");
108666
- });
108667
- program2.command("models").description("List available models").option("-p, --provider <provider>", "Filter by provider").option("-c, --capability <capability>", "Filter by capability (code, reasoning, vision, audio)").action((options) => {
108668
- const autoModel = new AutoModelSelector();
108669
- let models = autoModel.listModels();
108670
- if (options.provider) {
108671
- models = models.filter((m2) => m2.provider === options.provider);
108672
- }
108673
- if (options.capability) {
108674
- models = models.filter((m2) => m2.capabilities[options.capability]);
108675
- }
108676
- console.log("\nAvailable Models:\n");
108677
- for (const model of models) {
108678
- const tags = model.tags.join(", ");
108679
- console.log(` ${model.id}`);
108680
- console.log(` Name: ${model.name}`);
108681
- console.log(` Provider: ${model.provider}`);
108682
- console.log(` Context: ${model.contextWindow / 1e3}k tokens`);
108683
- console.log(` Tags: ${tags}`);
108684
- console.log("");
108685
- }
108686
- });
108687
- program2.command("providers").description("List available providers and their status").action(() => {
108688
- const provider = new LLMProviderManager();
108689
- const providers = provider.getAvailableProviders();
108690
- console.log("\nAvailable Providers:\n");
108691
- for (const p of providers) {
108692
- const configured = provider.isProviderConfigured(p);
108693
- console.log(` ${p}: ${configured ? "Configured" : "Not configured"}`);
108694
- }
108695
- });
108696
- program2.command("select").description("Auto-select a model for a task").argument("<prompt>", "Task description").action((prompt) => {
108697
- const autoModel = new AutoModelSelector();
108698
- const taskType = autoModel.detectTaskType(prompt);
108699
- const model = autoModel.selectModel(taskType);
108700
- console.log(`
108697
+ const response = await agent.run(prompt, (chunk) => {
108698
+ process.stdout.write(chunk);
108699
+ });
108700
+ console.log("\n");
108701
+ });
108702
+ program2.command("models").description("List available models").option("-p, --provider <provider>", "Filter by provider").option("-c, --capability <capability>", "Filter by capability (code, reasoning, vision, audio)").action((options) => {
108703
+ const autoModel = new AutoModelSelector();
108704
+ let models = autoModel.listModels();
108705
+ if (options.provider) {
108706
+ models = models.filter((m2) => m2.provider === options.provider);
108707
+ }
108708
+ if (options.capability) {
108709
+ models = models.filter((m2) => m2.capabilities[options.capability]);
108710
+ }
108711
+ console.log("\nAvailable Models:\n");
108712
+ for (const model of models) {
108713
+ const tags = model.tags.join(", ");
108714
+ console.log(` ${model.id}`);
108715
+ console.log(` Name: ${model.name}`);
108716
+ console.log(` Provider: ${model.provider}`);
108717
+ console.log(` Context: ${model.contextWindow / 1e3}k tokens`);
108718
+ console.log(` Tags: ${tags}`);
108719
+ console.log("");
108720
+ }
108721
+ });
108722
+ program2.command("providers").description("List available providers and their status").action(() => {
108723
+ const provider = new LLMProviderManager();
108724
+ const providers = provider.getAvailableProviders();
108725
+ console.log("\nAvailable Providers:\n");
108726
+ for (const p of providers) {
108727
+ const configured = provider.isProviderConfigured(p);
108728
+ console.log(` ${p}: ${configured ? "Configured" : "Not configured"}`);
108729
+ }
108730
+ });
108731
+ program2.command("select").description("Auto-select a model for a task").argument("<prompt>", "Task description").action((prompt) => {
108732
+ const autoModel = new AutoModelSelector();
108733
+ const taskType = autoModel.detectTaskType(prompt);
108734
+ const model = autoModel.selectModel(taskType);
108735
+ console.log(`
108701
108736
  Task type: ${taskType}`);
108702
- console.log(`Selected model: ${model.name} (${model.id})`);
108703
- console.log(`Provider: ${model.provider}`);
108704
- console.log(`Context window: ${model.contextWindow / 1e3}k tokens`);
108705
- });
108706
- program2.command("tools").description("List available tools").action(() => {
108707
- const tools = new ToolRegistry();
108708
- const toolList = tools.list();
108709
- console.log("\nAvailable Tools:\n");
108710
- for (const tool2 of toolList) {
108711
- console.log(` ${tool2.name}`);
108712
- console.log(` ${tool2.description}`);
108713
- console.log("");
108714
- }
108715
- });
108716
- program2.command("agents").description("List available agents").action(() => {
108717
- console.log("\nAvailable Agents:\n");
108718
- for (const agent of defaultAgents) {
108719
- console.log(` ${agent.id}`);
108720
- console.log(` Name: ${agent.name}`);
108721
- console.log(` ${agent.description}`);
108722
- console.log(` Model: ${agent.model}`);
108723
- console.log("");
108724
- }
108725
- });
108726
- program2.command("open <url>").description("Open a URL in the default web browser").action((url2) => {
108727
- if (!url2.startsWith("http://") && !url2.startsWith("https://")) {
108728
- url2 = "https://" + url2;
108729
- }
108730
- try {
108731
- let command;
108732
- const platform = process.platform;
108733
- if (platform === "darwin") {
108734
- command = `open "${url2}"`;
108735
- } else if (platform === "win32") {
108736
- command = `start "" "${url2}"`;
108737
- } else {
108738
- command = `xdg-open "${url2}" 2>/dev/null || sensible-browser "${url2}" 2>/dev/null`;
108739
- }
108740
- execSync4(command, { stdio: "ignore" });
108741
- console.log(`
108737
+ console.log(`Selected model: ${model.name} (${model.id})`);
108738
+ console.log(`Provider: ${model.provider}`);
108739
+ console.log(`Context window: ${model.contextWindow / 1e3}k tokens`);
108740
+ });
108741
+ program2.command("tools").description("List available tools").action(() => {
108742
+ const tools = new ToolRegistry();
108743
+ const toolList = tools.list();
108744
+ console.log("\nAvailable Tools:\n");
108745
+ for (const tool2 of toolList) {
108746
+ console.log(` ${tool2.name}`);
108747
+ console.log(` ${tool2.description}`);
108748
+ console.log("");
108749
+ }
108750
+ });
108751
+ program2.command("agents").description("List available agents").action(() => {
108752
+ console.log("\nAvailable Agents:\n");
108753
+ for (const agent of defaultAgents) {
108754
+ console.log(` ${agent.id}`);
108755
+ console.log(` Name: ${agent.name}`);
108756
+ console.log(` ${agent.description}`);
108757
+ console.log(` Model: ${agent.model}`);
108758
+ console.log("");
108759
+ }
108760
+ });
108761
+ program2.command("open <url>").description("Open a URL in the default web browser").action((url2) => {
108762
+ if (!url2.startsWith("http://") && !url2.startsWith("https://")) {
108763
+ url2 = "https://" + url2;
108764
+ }
108765
+ try {
108766
+ let command;
108767
+ const platform = process.platform;
108768
+ if (platform === "darwin") {
108769
+ command = `open "${url2}"`;
108770
+ } else if (platform === "win32") {
108771
+ command = `start "" "${url2}"`;
108772
+ } else {
108773
+ command = `xdg-open "${url2}" 2>/dev/null || sensible-browser "${url2}" 2>/dev/null`;
108774
+ }
108775
+ execSync4(command, { stdio: "ignore" });
108776
+ console.log(`
108742
108777
  Opened ${url2} in browser
108743
108778
  `);
108744
- } catch (error40) {
108745
- console.log(`
108779
+ } catch (error40) {
108780
+ console.log(`
108746
108781
  Could not open browser automatically.`);
108747
- console.log(`Please open this URL manually: ${url2}
108782
+ console.log(`Please open this URL manually: ${url2}
108748
108783
  `);
108749
- }
108750
- });
108751
- program2.command("fetch <url>").description("Fetch content from a URL").option("-m, --method <method>", "HTTP method", "GET").option("-d, --data <data>", "Request body for POST/PUT").action(async (url2, options) => {
108752
- const method = options.method || "GET";
108753
- console.log(`
108784
+ }
108785
+ });
108786
+ program2.command("fetch <url>").description("Fetch content from a URL").option("-m, --method <method>", "HTTP method", "GET").option("-d, --data <data>", "Request body for POST/PUT").action(async (url2, options) => {
108787
+ const method = options.method || "GET";
108788
+ console.log(`
108754
108789
  Fetching ${url2} (${method})...
108755
108790
  `);
108756
- try {
108757
- const response = await fetch(url2, {
108758
- method,
108759
- headers: {
108760
- "User-Agent": "BraveCode-AI/1.0"
108761
- },
108762
- body: options.data
108763
- });
108764
- const contentType = response.headers.get("content-type") || "";
108765
- let content;
108766
- if (contentType.includes("application/json")) {
108767
- const json3 = await response.json();
108768
- content = JSON.stringify(json3, null, 2);
108769
- } else {
108770
- content = await response.text();
108771
- }
108772
- console.log(`Status: ${response.status} ${response.statusText}`);
108773
- console.log(`Content-Type: ${contentType}
108791
+ try {
108792
+ const response = await fetch(url2, {
108793
+ method,
108794
+ headers: {
108795
+ "User-Agent": "BraveCode-AI/1.0"
108796
+ },
108797
+ body: options.data
108798
+ });
108799
+ const contentType = response.headers.get("content-type") || "";
108800
+ let content;
108801
+ if (contentType.includes("application/json")) {
108802
+ const json3 = await response.json();
108803
+ content = JSON.stringify(json3, null, 2);
108804
+ } else {
108805
+ content = await response.text();
108806
+ }
108807
+ console.log(`Status: ${response.status} ${response.statusText}`);
108808
+ console.log(`Content-Type: ${contentType}
108774
108809
  `);
108775
- const truncated = content.length > 2e3 ? content.substring(0, 2e3) + "\n\n... (truncated)" : content;
108776
- console.log(truncated);
108777
- } catch (error40) {
108778
- console.log(`Error: ${error40.message}`);
108779
- }
108780
- });
108781
- program2.command("init").description("Initialize BraveCode in current directory (creates AGENTS.md)").action(() => {
108782
- const config2 = getConfig();
108783
- const agensMd = join9(process.cwd(), "AGENTS.md");
108784
- if (existsSync8(agensMd)) {
108785
- console.log("AGENTS.md already exists. Use --force to overwrite.");
108786
- return;
108787
- }
108788
- const content = `# BraveCode AI - Agent Configuration
108810
+ const truncated = content.length > 2e3 ? content.substring(0, 2e3) + "\n\n... (truncated)" : content;
108811
+ console.log(truncated);
108812
+ } catch (error40) {
108813
+ console.log(`Error: ${error40.message}`);
108814
+ }
108815
+ });
108816
+ program2.command("init").description("Initialize BraveCode in current directory (creates AGENTS.md)").action(() => {
108817
+ const config2 = getConfig();
108818
+ const agensMd = join9(process.cwd(), "AGENTS.md");
108819
+ if (existsSync8(agensMd)) {
108820
+ console.log("AGENTS.md already exists. Use --force to overwrite.");
108821
+ return;
108822
+ }
108823
+ const content = `# BraveCode AI - Agent Configuration
108789
108824
 
108790
108825
  ## Project Instructions
108791
108826
 
@@ -108827,154 +108862,202 @@ program2.command("init").description("Initialize BraveCode in current directory
108827
108862
  - Security auditing
108828
108863
  - Use for: vulnerability assessment, security fixes
108829
108864
  `;
108830
- writeFileSync8(agensMd, content);
108831
- console.log("Created AGENTS.md");
108832
- console.log("Customize it with your project-specific instructions.");
108833
- const configPath = join9(process.cwd(), ".bravecode", "config.json");
108834
- if (!existsSync8(join9(process.cwd(), ".bravecode"))) {
108835
- console.log("Config directory created at .bravecode/");
108836
- }
108837
- });
108838
- program2.command("config").description("View or set configuration").argument("[key]", "Config key (e.g., model.default)").argument("[value]", "Value to set").action((key, value) => {
108839
- const config2 = getConfig();
108840
- if (!key) {
108841
- const current = config2.get();
108842
- console.log("Current configuration:\n");
108843
- console.log(JSON.stringify(current, null, 2));
108844
- return;
108845
- }
108846
- if (!value) {
108847
- const val = config2.getNested(key);
108848
- console.log(`${key}: ${JSON.stringify(val, null, 2)}`);
108849
- return;
108850
- }
108851
- try {
108852
- const parsed = JSON.parse(value);
108853
- config2.setNested(key, parsed);
108854
- } catch {
108855
- config2.setNested(key, value);
108856
- }
108857
- console.log(`Set ${key} = ${value}`);
108858
- });
108859
- program2.command("mcp").description("Manage MCP servers").argument("[action]", "Action: list, add, remove").argument("[args...]", "Additional arguments").action(async (action, args) => {
108860
- if (!action || action === "list") {
108861
- const config2 = getConfig();
108862
- const mcpServers = config2.getNested("mcp.servers") || [];
108863
- console.log("MCP Servers:\n");
108864
- if (mcpServers.length === 0) {
108865
- console.log(" No MCP servers configured.");
108866
- } else {
108867
- for (const server of mcpServers) {
108868
- console.log(` ${server.id}: ${server.name}`);
108869
- console.log(` Command: ${server.command}`);
108870
- console.log(` Enabled: ${server.enabled}`);
108865
+ writeFileSync8(agensMd, content);
108866
+ console.log("Created AGENTS.md");
108867
+ console.log("Customize it with your project-specific instructions.");
108868
+ const configPath = join9(process.cwd(), ".bravecode", "config.json");
108869
+ if (!existsSync8(join9(process.cwd(), ".bravecode"))) {
108870
+ console.log("Config directory created at .bravecode/");
108871
108871
  }
108872
- }
108873
- return;
108874
- }
108875
- if (action === "add" && args && args.length >= 2) {
108876
- const config2 = getConfig();
108877
- const servers = config2.getNested("mcp.servers") || [];
108878
- const newServer = {
108879
- id: args[0],
108880
- name: args[1],
108881
- command: args[2] || args[0],
108882
- args: args.slice(3),
108883
- enabled: true
108884
- };
108885
- servers.push(newServer);
108886
- config2.setNested("mcp.servers", servers);
108887
- console.log(`Added MCP server: ${newServer.id}`);
108888
- return;
108889
- }
108890
- if (action === "remove" && args && args.length > 0) {
108891
- const config2 = getConfig();
108892
- const servers = config2.getNested("mcp.servers") || [];
108893
- const filtered = servers.filter((s) => s.id !== args[0]);
108894
- config2.setNested("mcp.servers", filtered);
108895
- console.log(`Removed MCP server: ${args[0]}`);
108896
- return;
108897
- }
108898
- console.log("Usage: bravecode mcp [list|add|remove] [args...]");
108899
- });
108900
- program2.command("plugins").description("List available plugins").action(async () => {
108901
- const { PluginManager: PluginManager2 } = await Promise.resolve().then(() => (init_plugin(), plugin_exports));
108902
- const manager = new PluginManager2();
108903
- await manager.loadPlugins();
108904
- const plugins = manager.getAllPlugins();
108905
- console.log("Plugins:\n");
108906
- if (plugins.length === 0) {
108907
- console.log(" No plugins loaded.");
108908
- } else {
108909
- for (const plugin of plugins) {
108910
- console.log(` ${plugin.config.name} v${plugin.config.version}`);
108911
- console.log(` ${plugin.config.description}`);
108912
- if (plugin.config.author) {
108913
- console.log(` Author: ${plugin.config.author}`);
108872
+ });
108873
+ program2.command("config").description("View or set configuration").argument("[key]", "Config key (e.g., model.default)").argument("[value]", "Value to set").action((key, value) => {
108874
+ const config2 = getConfig();
108875
+ if (!key) {
108876
+ const current = config2.get();
108877
+ console.log("Current configuration:\n");
108878
+ console.log(JSON.stringify(current, null, 2));
108879
+ return;
108914
108880
  }
108915
- }
108881
+ if (!value) {
108882
+ const val = config2.getNested(key);
108883
+ console.log(`${key}: ${JSON.stringify(val, null, 2)}`);
108884
+ return;
108885
+ }
108886
+ try {
108887
+ const parsed = JSON.parse(value);
108888
+ config2.setNested(key, parsed);
108889
+ } catch {
108890
+ config2.setNested(key, value);
108891
+ }
108892
+ console.log(`Set ${key} = ${value}`);
108893
+ });
108894
+ program2.command("mcp").description("Manage MCP servers").argument("[action]", "Action: list, add, remove").argument("[args...]", "Additional arguments").action(async (action, args) => {
108895
+ if (!action || action === "list") {
108896
+ const config2 = getConfig();
108897
+ const mcpServers = config2.getNested("mcp.servers") || [];
108898
+ console.log("MCP Servers:\n");
108899
+ if (mcpServers.length === 0) {
108900
+ console.log(" No MCP servers configured.");
108901
+ } else {
108902
+ for (const server of mcpServers) {
108903
+ console.log(` ${server.id}: ${server.name}`);
108904
+ console.log(` Command: ${server.command}`);
108905
+ console.log(` Enabled: ${server.enabled}`);
108906
+ }
108907
+ }
108908
+ return;
108909
+ }
108910
+ if (action === "add" && args && args.length >= 2) {
108911
+ const config2 = getConfig();
108912
+ const servers = config2.getNested("mcp.servers") || [];
108913
+ const newServer = {
108914
+ id: args[0],
108915
+ name: args[1],
108916
+ command: args[2] || args[0],
108917
+ args: args.slice(3),
108918
+ enabled: true
108919
+ };
108920
+ servers.push(newServer);
108921
+ config2.setNested("mcp.servers", servers);
108922
+ console.log(`Added MCP server: ${newServer.id}`);
108923
+ return;
108924
+ }
108925
+ if (action === "remove" && args && args.length > 0) {
108926
+ const config2 = getConfig();
108927
+ const servers = config2.getNested("mcp.servers") || [];
108928
+ const filtered = servers.filter((s) => s.id !== args[0]);
108929
+ config2.setNested("mcp.servers", filtered);
108930
+ console.log(`Removed MCP server: ${args[0]}`);
108931
+ return;
108932
+ }
108933
+ console.log("Usage: bravecode mcp [list|add|remove] [args...]");
108934
+ });
108935
+ program2.command("plugins").description("List available plugins").action(async () => {
108936
+ const { PluginManager: PluginManager2 } = await Promise.resolve().then(() => (init_plugin(), plugin_exports));
108937
+ const manager = new PluginManager2();
108938
+ await manager.loadPlugins();
108939
+ const plugins = manager.getAllPlugins();
108940
+ console.log("Plugins:\n");
108941
+ if (plugins.length === 0) {
108942
+ console.log(" No plugins loaded.");
108943
+ } else {
108944
+ for (const plugin of plugins) {
108945
+ console.log(` ${plugin.config.name} v${plugin.config.version}`);
108946
+ console.log(` ${plugin.config.description}`);
108947
+ if (plugin.config.author) {
108948
+ console.log(` Author: ${plugin.config.author}`);
108949
+ }
108950
+ }
108951
+ }
108952
+ });
108953
+ program2.command("share").description("Share a conversation via URL").argument("[action]", "Action: create, list, delete").argument("[args...]", "Additional arguments").action(async (action, args) => {
108954
+ const shareManager = new ShareManager();
108955
+ if (!action || action === "list") {
108956
+ const shares = shareManager.listShares();
108957
+ console.log("Shared Conversations:\n");
108958
+ if (shares.length === 0) {
108959
+ console.log(" No shared conversations.");
108960
+ } else {
108961
+ for (const share of shares) {
108962
+ console.log(` ${share.id}: ${share.title}`);
108963
+ console.log(` Created: ${new Date(share.createdAt).toLocaleString()}`);
108964
+ console.log(` URL: ${shareManager.getShareUrl(share.id)}`);
108965
+ }
108966
+ }
108967
+ return;
108968
+ }
108969
+ if (action === "create" && args && args.length >= 2) {
108970
+ const title = args[0];
108971
+ const content = args.slice(1).join(" ");
108972
+ const messages = [
108973
+ { role: "user", content, timestamp: /* @__PURE__ */ new Date() }
108974
+ ];
108975
+ const share = shareManager.createShare(title, messages);
108976
+ console.log(`Created share: ${share.id}`);
108977
+ console.log(`URL: ${shareManager.getShareUrl(share.id)}`);
108978
+ return;
108979
+ }
108980
+ if (action === "delete" && args && args.length > 0) {
108981
+ if (shareManager.deleteShare(args[0])) {
108982
+ console.log(`Deleted share: ${args[0]}`);
108983
+ } else {
108984
+ console.log(`Share not found: ${args[0]}`);
108985
+ }
108986
+ return;
108987
+ }
108988
+ console.log("Usage: bravecode share [list|create|delete] [args...]");
108989
+ });
108990
+ program2.command("update").description("Check for and install updates").option("--check", "Check for updates only").action(async (options) => {
108991
+ const updateChecker = new UpdateChecker();
108992
+ console.log("Checking for updates...\n");
108993
+ const info = await updateChecker.checkForUpdates(true);
108994
+ console.log(`Current version: ${info.currentVersion}`);
108995
+ console.log(`Latest version: ${info.latestVersion}`);
108996
+ if (info.updateAvailable) {
108997
+ console.log("\n\u2713 Update available!\n");
108998
+ if (options.check) {
108999
+ console.log("Run 'bravecode update' to install.");
109000
+ return;
109001
+ }
109002
+ const result = await updateChecker.update();
109003
+ if (result.success) {
109004
+ console.log(result.message);
109005
+ } else {
109006
+ console.log(`Error: ${result.message}`);
109007
+ }
109008
+ } else {
109009
+ console.log("\n\u2713 You're up to date!");
109010
+ }
109011
+ });
109012
+ program2.parse();
108916
109013
  }
108917
109014
  });
108918
- program2.command("share").description("Share a conversation via URL").argument("[action]", "Action: create, list, delete").argument("[args...]", "Additional arguments").action(async (action, args) => {
108919
- const shareManager = new ShareManager();
108920
- if (!action || action === "list") {
108921
- const shares = shareManager.listShares();
108922
- console.log("Shared Conversations:\n");
108923
- if (shares.length === 0) {
108924
- console.log(" No shared conversations.");
108925
- } else {
108926
- for (const share of shares) {
108927
- console.log(` ${share.id}: ${share.title}`);
108928
- console.log(` Created: ${new Date(share.createdAt).toLocaleString()}`);
108929
- console.log(` URL: ${shareManager.getShareUrl(share.id)}`);
108930
- }
109015
+
109016
+ // src/cli.ts
109017
+ (function polyfillSelfGlobal() {
109018
+ const g2 = globalThis;
109019
+ try {
109020
+ if (typeof g2.self === "undefined") {
109021
+ Object.defineProperty(g2, "self", {
109022
+ value: g2,
109023
+ writable: true,
109024
+ configurable: true,
109025
+ enumerable: false
109026
+ });
108931
109027
  }
108932
- return;
108933
- }
108934
- if (action === "create" && args && args.length >= 2) {
108935
- const title = args[0];
108936
- const content = args.slice(1).join(" ");
108937
- const messages = [
108938
- { role: "user", content, timestamp: /* @__PURE__ */ new Date() }
108939
- ];
108940
- const share = shareManager.createShare(title, messages);
108941
- console.log(`Created share: ${share.id}`);
108942
- console.log(`URL: ${shareManager.getShareUrl(share.id)}`);
108943
- return;
108944
- }
108945
- if (action === "delete" && args && args.length > 0) {
108946
- if (shareManager.deleteShare(args[0])) {
108947
- console.log(`Deleted share: ${args[0]}`);
108948
- } else {
108949
- console.log(`Share not found: ${args[0]}`);
109028
+ } catch {
109029
+ if (typeof g2.self === "undefined") {
109030
+ g2.self = g2;
108950
109031
  }
108951
- return;
108952
109032
  }
108953
- console.log("Usage: bravecode share [list|create|delete] [args...]");
108954
- });
108955
- program2.command("update").description("Check for and install updates").option("--check", "Check for updates only").action(async (options) => {
108956
- const updateChecker = new UpdateChecker();
108957
- console.log("Checking for updates...\n");
108958
- const info = await updateChecker.checkForUpdates(true);
108959
- console.log(`Current version: ${info.currentVersion}`);
108960
- console.log(`Latest version: ${info.latestVersion}`);
108961
- if (info.updateAvailable) {
108962
- console.log("\n\u2713 Update available!\n");
108963
- if (options.check) {
108964
- console.log("Run 'bravecode update' to install.");
108965
- return;
109033
+ if (typeof g2.window === "undefined") {
109034
+ try {
109035
+ Object.defineProperty(g2, "window", {
109036
+ value: g2,
109037
+ writable: true,
109038
+ configurable: true,
109039
+ enumerable: false
109040
+ });
109041
+ } catch {
109042
+ g2.window = g2;
108966
109043
  }
108967
- const result = await updateChecker.update();
108968
- if (result.success) {
108969
- console.log(result.message);
108970
- } else {
108971
- console.log(`Error: ${result.message}`);
109044
+ }
109045
+ if (typeof g2.document === "undefined") {
109046
+ try {
109047
+ Object.defineProperty(g2, "document", {
109048
+ value: { createElement: () => ({}), addEventListener: () => {
109049
+ }, readyState: "complete" },
109050
+ writable: true,
109051
+ configurable: true,
109052
+ enumerable: false
109053
+ });
109054
+ } catch {
109055
+ g2.document = { createElement: () => ({}), addEventListener: () => {
109056
+ }, readyState: "complete" };
108972
109057
  }
108973
- } else {
108974
- console.log("\n\u2713 You're up to date!");
108975
109058
  }
108976
- });
108977
- program2.parse();
109059
+ })();
109060
+ await Promise.resolve().then(() => (init_cli_main(), cli_main_exports));
108978
109061
  /*! Bundled license information:
108979
109062
 
108980
109063
  scheduler/cjs/scheduler.production.js:
@@ -109043,4 +109126,4 @@ react-reconciler/cjs/react-reconciler-constants.development.js:
109043
109126
  * LICENSE file in the root directory of this source tree.
109044
109127
  *)
109045
109128
  */
109046
- //# sourceMappingURL=cli.mjs.map
109129
+ //# sourceMappingURL=cli-main.mjs.map