bankai-cli 0.2.0 → 0.3.0

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 (3) hide show
  1. package/README.md +2 -4
  2. package/dist/main.js +54 -58
  3. package/package.json +3 -2
package/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # bankai
2
2
 
3
- CLI tool that prints approval-bypass startup commands for coding agent CLIs.
4
-
5
- bankai does **not** execute the agents — it only outputs the commands for copy-paste.
3
+ CLI tool that launches coding agent CLIs with approval-bypass flags.
6
4
 
7
5
  ## Install
8
6
 
@@ -13,7 +11,7 @@ bun install -g bankai-cli
13
11
  ## Usage
14
12
 
15
13
  ```bash
16
- # Print bypass command for a specific agent
14
+ # Launch a specific agent with bypass flags
17
15
  bankai claude
18
16
 
19
17
  # Interactive agent picker
package/dist/main.js CHANGED
@@ -3,8 +3,9 @@
3
3
  // src/main.ts
4
4
  import { Command } from "commander";
5
5
 
6
- // src/commands/print.ts
7
- import chalk3 from "chalk";
6
+ // src/commands/run.ts
7
+ import { spawn } from "child_process";
8
+ import chalk2 from "chalk";
8
9
 
9
10
  // src/registry/builtin.ts
10
11
  var builtinAgents = [
@@ -248,18 +249,8 @@ function resolveAll(customFilePath) {
248
249
  return [...merged.values()];
249
250
  }
250
251
 
251
- // src/format.ts
252
- import chalk from "chalk";
253
- function formatOutput(agent) {
254
- const name = agent.displayName ?? agent.cmd;
255
- const header = chalk.bold.cyan(`# ${name}`);
256
- const lines = agent.lines.map((l) => chalk.green(l)).join("\n");
257
- return `${header}
258
- ${lines}`;
259
- }
260
-
261
252
  // src/commands/apply.ts
262
- import chalk2 from "chalk";
253
+ import chalk from "chalk";
263
254
  import select from "@inquirer/select";
264
255
  import confirm from "@inquirer/confirm";
265
256
 
@@ -436,8 +427,8 @@ function setNestedValue(obj, path3, value) {
436
427
  // src/commands/apply.ts
437
428
  async function applySettingsAgent(agent) {
438
429
  const name = agent.displayName ?? agent.cmd;
439
- console.log(chalk2.bold.cyan(`# ${name}`));
440
- console.log(chalk2.dim("This agent uses settings files instead of CLI flags.\n"));
430
+ console.log(chalk.bold.cyan(`# ${name}`));
431
+ console.log(chalk.dim("This agent uses settings files instead of CLI flags.\n"));
441
432
  const statuses = agent.targets.map((t) => ({
442
433
  target: t,
443
434
  applied: isAlreadyApplied(t)
@@ -445,19 +436,19 @@ async function applySettingsAgent(agent) {
445
436
  const allApplied = statuses.every((s) => s.applied);
446
437
  if (allApplied) {
447
438
  console.log(
448
- chalk2.green("All settings are already applied:")
439
+ chalk.green("All settings are already applied:")
449
440
  );
450
441
  for (const s of statuses) {
451
- console.log(chalk2.green(` \u2713 ${s.target.description ?? s.target.kind}`));
442
+ console.log(chalk.green(` \u2713 ${s.target.description ?? s.target.kind}`));
452
443
  }
453
444
  return;
454
445
  }
455
446
  for (const s of statuses) {
456
447
  const label2 = s.target.description ?? s.target.kind;
457
448
  if (s.applied) {
458
- console.log(chalk2.green(` \u2713 ${label2} (already applied)`));
449
+ console.log(chalk.green(` \u2713 ${label2} (already applied)`));
459
450
  } else {
460
- console.log(chalk2.yellow(` \u25CB ${label2} (not applied)`));
451
+ console.log(chalk.yellow(` \u25CB ${label2} (not applied)`));
461
452
  }
462
453
  }
463
454
  console.log();
@@ -481,31 +472,42 @@ async function applySettingsAgent(agent) {
481
472
  default: true
482
473
  });
483
474
  if (!ok) {
484
- console.log(chalk2.dim("Cancelled."));
475
+ console.log(chalk.dim("Cancelled."));
485
476
  return;
486
477
  }
487
478
  try {
488
479
  applySettings(target);
489
- console.log(chalk2.green(`
480
+ console.log(chalk.green(`
490
481
  \u2713 Applied settings to ${label}`));
491
482
  if (target.kind === "sqlite") {
492
- console.log(chalk2.yellow("\nRestart the application for changes to take effect."));
483
+ console.log(chalk.yellow("\nRestart the application for changes to take effect."));
493
484
  }
494
485
  } catch (err) {
495
486
  const msg = err instanceof Error ? err.message : String(err);
496
- console.error(chalk2.red(`
487
+ console.error(chalk.red(`
497
488
  Failed to apply settings: ${msg}`));
498
489
  process.exitCode = 1;
499
490
  }
500
491
  }
501
492
 
502
- // src/commands/print.ts
503
- async function printAgent(cmd) {
493
+ // src/commands/run.ts
494
+ function execAgent(line) {
495
+ const [cmd, ...args] = line.split(/\s+/);
496
+ return new Promise((resolve) => {
497
+ const child = spawn(cmd, args, { stdio: "inherit", shell: true });
498
+ child.on("close", (code) => resolve(code ?? 1));
499
+ child.on("error", (err) => {
500
+ console.error(chalk2.red(`Failed to start: ${err.message}`));
501
+ resolve(1);
502
+ });
503
+ });
504
+ }
505
+ async function runAgent(cmd) {
504
506
  const agent = resolveAgent(cmd);
505
507
  if (!agent) {
506
508
  console.error(
507
- chalk3.red(`Unsupported agent: "${cmd}".`) + `
508
- Run ${chalk3.yellow("bankai agents")} to see available agents, or ${chalk3.yellow("bankai add")} to register a custom one.`
509
+ chalk2.red(`Unsupported agent: "${cmd}".`) + `
510
+ Run ${chalk2.yellow("bankai agents")} to see available agents, or ${chalk2.yellow("bankai add")} to register a custom one.`
509
511
  );
510
512
  process.exitCode = 1;
511
513
  return;
@@ -513,12 +515,14 @@ Run ${chalk3.yellow("bankai agents")} to see available agents, or ${chalk3.yello
513
515
  if (agent.type === "settings") {
514
516
  await applySettingsAgent(agent);
515
517
  } else {
516
- console.log(formatOutput(agent));
518
+ const line = agent.lines[0];
519
+ const code = await execAgent(line);
520
+ process.exitCode = code;
517
521
  }
518
522
  }
519
523
 
520
524
  // src/commands/agents.ts
521
- import chalk4 from "chalk";
525
+ import chalk3 from "chalk";
522
526
 
523
527
  // src/detect.ts
524
528
  import { spawnSync } from "child_process";
@@ -539,24 +543,24 @@ function listAgents(opts) {
539
543
  if (opts.installed) {
540
544
  agents = filterInstalled(agents);
541
545
  if (agents.length === 0) {
542
- console.log(chalk4.yellow("No supported agents detected on this system."));
546
+ console.log(chalk3.yellow("No supported agents detected on this system."));
543
547
  return;
544
548
  }
545
549
  }
546
550
  for (const agent of agents) {
547
- const name = agent.displayName ? `${chalk4.bold(agent.cmd)} ${chalk4.dim(`(${agent.displayName})`)}` : chalk4.bold(agent.cmd);
551
+ const name = agent.displayName ? `${chalk3.bold(agent.cmd)} ${chalk3.dim(`(${agent.displayName})`)}` : chalk3.bold(agent.cmd);
548
552
  if (agent.type === "settings") {
549
553
  const targets = agent.targets.map((t) => t.description ?? t.kind).join(", ");
550
- console.log(` ${name} \u2192 ${chalk4.magenta(`[settings: ${targets}]`)}`);
554
+ console.log(` ${name} \u2192 ${chalk3.magenta(`[settings: ${targets}]`)}`);
551
555
  } else {
552
- const lines = agent.lines.map((l) => chalk4.green(l)).join(", ");
556
+ const lines = agent.lines.map((l) => chalk3.green(l)).join(", ");
553
557
  console.log(` ${name} \u2192 ${lines}`);
554
558
  }
555
559
  }
556
560
  }
557
561
 
558
562
  // src/commands/add.ts
559
- import chalk5 from "chalk";
563
+ import chalk4 from "chalk";
560
564
  import input from "@inquirer/input";
561
565
  async function addAgentCommand(opts) {
562
566
  let cmd = opts.cmd;
@@ -578,7 +582,7 @@ async function addAgentCommand(opts) {
578
582
  aliases = aliasRaw ? aliasRaw.split(",").map((a) => a.trim()).filter(Boolean) : void 0;
579
583
  }
580
584
  if (!lines || lines.length === 0) {
581
- console.error(chalk5.red("At least one --line is required."));
585
+ console.error(chalk4.red("At least one --line is required."));
582
586
  process.exitCode = 1;
583
587
  return;
584
588
  }
@@ -590,15 +594,15 @@ async function addAgentCommand(opts) {
590
594
  });
591
595
  try {
592
596
  addAgent(agent);
593
- console.log(chalk5.green(`Added custom agent "${cmd}".`));
597
+ console.log(chalk4.green(`Added custom agent "${cmd}".`));
594
598
  } catch (err) {
595
- console.error(chalk5.red(err.message));
599
+ console.error(chalk4.red(err.message));
596
600
  process.exitCode = 1;
597
601
  }
598
602
  }
599
603
 
600
604
  // src/commands/edit.ts
601
- import chalk6 from "chalk";
605
+ import chalk5 from "chalk";
602
606
  import input2 from "@inquirer/input";
603
607
  async function editAgentCommand(cmd) {
604
608
  const custom = loadCustomAgents();
@@ -607,10 +611,10 @@ async function editAgentCommand(cmd) {
607
611
  const builtin = resolveAgent(cmd);
608
612
  if (builtin) {
609
613
  console.error(
610
- chalk6.red(`"${cmd}" is a built-in agent. Use ${chalk6.yellow("bankai add")} to create a custom override.`)
614
+ chalk5.red(`"${cmd}" is a built-in agent. Use ${chalk5.yellow("bankai add")} to create a custom override.`)
611
615
  );
612
616
  } else {
613
- console.error(chalk6.red(`Custom agent "${cmd}" not found.`));
617
+ console.error(chalk5.red(`Custom agent "${cmd}" not found.`));
614
618
  }
615
619
  process.exitCode = 1;
616
620
  return;
@@ -635,34 +639,34 @@ async function editAgentCommand(cmd) {
635
639
  lines,
636
640
  cmdAliases: aliases && aliases.length > 0 ? aliases : void 0
637
641
  });
638
- console.log(chalk6.green(`Updated agent "${cmd}".`));
642
+ console.log(chalk5.green(`Updated agent "${cmd}".`));
639
643
  } catch (err) {
640
- console.error(chalk6.red(err.message));
644
+ console.error(chalk5.red(err.message));
641
645
  process.exitCode = 1;
642
646
  }
643
647
  }
644
648
 
645
649
  // src/commands/remove.ts
646
- import chalk7 from "chalk";
650
+ import chalk6 from "chalk";
647
651
  function removeAgentCommand(cmd) {
648
652
  try {
649
653
  removeAgent(cmd);
650
- console.log(chalk7.green(`Removed agent "${cmd}".`));
654
+ console.log(chalk6.green(`Removed agent "${cmd}".`));
651
655
  } catch (err) {
652
- console.error(chalk7.red(err.message));
656
+ console.error(chalk6.red(err.message));
653
657
  process.exitCode = 1;
654
658
  }
655
659
  }
656
660
 
657
661
  // src/commands/select.ts
658
- import chalk8 from "chalk";
662
+ import chalk7 from "chalk";
659
663
  import select2 from "@inquirer/select";
660
664
  async function selectAgent() {
661
665
  const all = resolveAll();
662
666
  const installed = filterInstalled(all);
663
667
  const agents = installed.length > 0 ? installed : all;
664
668
  const label = installed.length > 0 ? "Detected agents on this system" : "No agents detected \u2014 showing all supported agents";
665
- console.log(chalk8.dim(label));
669
+ console.log(chalk7.dim(label));
666
670
  const chosen = await select2({
667
671
  message: "Select an agent:",
668
672
  choices: agents.map((a) => ({
@@ -670,24 +674,16 @@ async function selectAgent() {
670
674
  value: a.cmd
671
675
  }))
672
676
  });
673
- const agent = agents.find((a) => a.cmd === chosen);
674
- if (agent) {
675
- console.log();
676
- if (agent.type === "settings") {
677
- await applySettingsAgent(agent);
678
- } else {
679
- console.log(formatOutput(agent));
680
- }
681
- }
677
+ await runAgent(chosen);
682
678
  }
683
679
 
684
680
  // src/main.ts
685
681
  var program = new Command();
686
- program.name("bankai").description("Print approval-bypass startup commands for coding agent CLIs").version("0.2.0");
682
+ program.name("bankai").description("Launch coding agent CLIs with approval-bypass flags").version("0.3.0");
687
683
  program.argument("[cmd]", "agent command to look up").option("-a, --agent <cmd>", "agent command to look up (alternative)").action(async (cmd, opts) => {
688
684
  const target = cmd || opts.agent;
689
685
  if (target) {
690
- await printAgent(target);
686
+ await runAgent(target);
691
687
  } else {
692
688
  await selectAgent();
693
689
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bankai-cli",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "files": ["dist", "README.md"],
6
6
  "bin": {
@@ -9,7 +9,8 @@
9
9
  "scripts": {
10
10
  "build": "tsup",
11
11
  "dev": "bun run src/main.ts",
12
- "test": "vitest run"
12
+ "test": "vitest run",
13
+ "typecheck": "tsc --noEmit"
13
14
  },
14
15
  "dependencies": {
15
16
  "@inquirer/confirm": "^6.0.4",