bankai-cli 0.6.10 → 0.6.12
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/README.md +9 -0
- package/dist/main.js +101 -47
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,6 +23,12 @@
|
|
|
23
23
|
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
+
[](https://www.npmjs.com/package/bankai-cli)
|
|
27
|
+
[](https://github.com/lark1115/bankai/actions/workflows/ci.yml)
|
|
28
|
+
[](https://opensource.org/licenses/MIT)
|
|
29
|
+
[](https://nodejs.org/)
|
|
30
|
+
[](https://open.vscode.dev/lark1115/bankai)
|
|
31
|
+
|
|
26
32
|
CLI tool that launches coding agent CLIs with approval-bypass flags.
|
|
27
33
|
|
|
28
34
|
## Requirements
|
|
@@ -43,6 +49,9 @@ npm install -g bankai-cli
|
|
|
43
49
|
# Launch a specific agent with bypass flags
|
|
44
50
|
bankai claude
|
|
45
51
|
|
|
52
|
+
# Pass args directly to the target agent
|
|
53
|
+
bankai codex -C /path/to/project
|
|
54
|
+
|
|
46
55
|
# Interactive agent picker
|
|
47
56
|
bankai
|
|
48
57
|
|
package/dist/main.js
CHANGED
|
@@ -6,6 +6,9 @@ import { createRequire } from "module";
|
|
|
6
6
|
|
|
7
7
|
// src/commands/run.ts
|
|
8
8
|
import { spawn } from "child_process";
|
|
9
|
+
import { readFileSync, writeFileSync, appendFileSync, mkdirSync } from "fs";
|
|
10
|
+
import { join } from "path";
|
|
11
|
+
import { homedir } from "os";
|
|
9
12
|
import chalk2 from "chalk";
|
|
10
13
|
|
|
11
14
|
// src/registry/builtin.ts
|
|
@@ -32,7 +35,7 @@ var builtinAgents = [
|
|
|
32
35
|
type: "cli",
|
|
33
36
|
cmd: "gemini",
|
|
34
37
|
displayName: "Gemini CLI",
|
|
35
|
-
lines: ["gemini --yolo"],
|
|
38
|
+
lines: ["gemini --yolo --sandbox=false"],
|
|
36
39
|
cmdAliases: ["gemini-cli"]
|
|
37
40
|
},
|
|
38
41
|
{
|
|
@@ -60,10 +63,18 @@ var builtinAgents = [
|
|
|
60
63
|
displayName: "Kimi Code",
|
|
61
64
|
lines: ["kimi --yolo"]
|
|
62
65
|
},
|
|
66
|
+
{
|
|
67
|
+
type: "cli",
|
|
68
|
+
cmd: "opencode",
|
|
69
|
+
displayName: "OpenCode",
|
|
70
|
+
lines: ["OPENCODE_YOLO=true opencode"],
|
|
71
|
+
cmdAliases: ["opencode-yolo"]
|
|
72
|
+
},
|
|
63
73
|
{
|
|
64
74
|
type: "settings",
|
|
65
75
|
cmd: "cursor-agent",
|
|
66
76
|
displayName: "Cursor Agent CLI",
|
|
77
|
+
lines: ["cursor-agent --yolo"],
|
|
67
78
|
targets: [
|
|
68
79
|
{
|
|
69
80
|
kind: "json",
|
|
@@ -78,7 +89,8 @@ var builtinAgents = [
|
|
|
78
89
|
"Delete(**)",
|
|
79
90
|
"Grep(**)",
|
|
80
91
|
"LS(**)"
|
|
81
|
-
]
|
|
92
|
+
],
|
|
93
|
+
deny: []
|
|
82
94
|
}
|
|
83
95
|
},
|
|
84
96
|
description: "Project (.cursor/cli.json)"
|
|
@@ -96,7 +108,8 @@ var builtinAgents = [
|
|
|
96
108
|
"Delete(**)",
|
|
97
109
|
"Grep(**)",
|
|
98
110
|
"LS(**)"
|
|
99
|
-
]
|
|
111
|
+
],
|
|
112
|
+
deny: []
|
|
100
113
|
}
|
|
101
114
|
},
|
|
102
115
|
description: "Global (~/.cursor/cli-config.json)"
|
|
@@ -176,7 +189,8 @@ var SettingsAgentDefSchema = z.object({
|
|
|
176
189
|
cmd: z.string().min(1),
|
|
177
190
|
displayName: z.string().optional(),
|
|
178
191
|
cmdAliases: z.array(z.string().min(1)).optional(),
|
|
179
|
-
targets: z.array(SettingsTargetSchema).min(1)
|
|
192
|
+
targets: z.array(SettingsTargetSchema).min(1),
|
|
193
|
+
lines: z.array(z.string().min(1)).optional()
|
|
180
194
|
});
|
|
181
195
|
var AgentDefSchema = z.preprocess(
|
|
182
196
|
(val) => typeof val === "object" && val !== null && !("type" in val) ? { ...val, type: "cli" } : val,
|
|
@@ -254,8 +268,6 @@ function resolveAll(customFilePath) {
|
|
|
254
268
|
|
|
255
269
|
// src/commands/apply.ts
|
|
256
270
|
import chalk from "chalk";
|
|
257
|
-
import select from "@inquirer/select";
|
|
258
|
-
import confirm from "@inquirer/confirm";
|
|
259
271
|
|
|
260
272
|
// src/settings.ts
|
|
261
273
|
import fs2 from "fs";
|
|
@@ -447,57 +459,34 @@ async function applySettingsAgent(agent) {
|
|
|
447
459
|
return;
|
|
448
460
|
}
|
|
449
461
|
for (const s of statuses) {
|
|
450
|
-
const
|
|
462
|
+
const label = s.target.description ?? s.target.kind;
|
|
451
463
|
if (s.applied) {
|
|
452
|
-
console.log(chalk.green(` \u2713 ${
|
|
464
|
+
console.log(chalk.green(` \u2713 ${label} (already applied)`));
|
|
453
465
|
} else {
|
|
454
|
-
console.log(chalk.yellow(` \u25CB ${
|
|
466
|
+
console.log(chalk.yellow(` \u25CB ${label} (not applied)`));
|
|
455
467
|
}
|
|
456
468
|
}
|
|
457
469
|
console.log();
|
|
458
470
|
const unapplied = statuses.filter((s) => !s.applied);
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
}))
|
|
469
|
-
});
|
|
470
|
-
target = chosen;
|
|
471
|
-
}
|
|
472
|
-
const label = target.description ?? target.kind;
|
|
473
|
-
const ok = await confirm({
|
|
474
|
-
message: `Apply settings to ${label}?`,
|
|
475
|
-
default: true
|
|
476
|
-
});
|
|
477
|
-
if (!ok) {
|
|
478
|
-
console.log(chalk.dim("Cancelled."));
|
|
479
|
-
return;
|
|
480
|
-
}
|
|
481
|
-
try {
|
|
482
|
-
applySettings(target);
|
|
483
|
-
console.log(chalk.green(`
|
|
484
|
-
\u2713 Applied settings to ${label}`));
|
|
485
|
-
if (target.kind === "sqlite") {
|
|
486
|
-
console.log(chalk.yellow("\nRestart the application for changes to take effect."));
|
|
471
|
+
for (const s of unapplied) {
|
|
472
|
+
const label = s.target.description ?? s.target.kind;
|
|
473
|
+
try {
|
|
474
|
+
applySettings(s.target);
|
|
475
|
+
console.log(chalk.green(` \u2713 Applied: ${label}`));
|
|
476
|
+
} catch (err) {
|
|
477
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
478
|
+
console.error(chalk.red(` \u2717 Failed: ${label} \u2014 ${msg}`));
|
|
479
|
+
process.exitCode = 1;
|
|
487
480
|
}
|
|
488
|
-
} catch (err) {
|
|
489
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
490
|
-
console.error(chalk.red(`
|
|
491
|
-
Failed to apply settings: ${msg}`));
|
|
492
|
-
process.exitCode = 1;
|
|
493
481
|
}
|
|
494
482
|
}
|
|
495
483
|
|
|
496
484
|
// src/commands/run.ts
|
|
497
485
|
function execAgent(line, extraArgs = []) {
|
|
498
486
|
const [cmd, ...args2] = line.split(/\s+/);
|
|
487
|
+
const { GH_TOKEN, ...cleanEnv } = process.env;
|
|
499
488
|
return new Promise((resolve) => {
|
|
500
|
-
const child = spawn(cmd, [...args2, ...extraArgs], { stdio: "inherit", shell: true });
|
|
489
|
+
const child = spawn(cmd, [...args2, ...extraArgs], { stdio: "inherit", shell: true, env: cleanEnv });
|
|
501
490
|
child.on("close", (code) => resolve(code ?? 1));
|
|
502
491
|
child.on("error", (err) => {
|
|
503
492
|
console.error(chalk2.red(`Failed to start: ${err.message}`));
|
|
@@ -505,6 +494,35 @@ function execAgent(line, extraArgs = []) {
|
|
|
505
494
|
});
|
|
506
495
|
});
|
|
507
496
|
}
|
|
497
|
+
function ensureCursorAgentTrust() {
|
|
498
|
+
const cwd = process.cwd();
|
|
499
|
+
const slug = cwd.replace(/^\//, "").replace(/[/.]/g, "-");
|
|
500
|
+
const dir = join(homedir(), ".cursor", "projects", slug);
|
|
501
|
+
const file = join(dir, ".workspace-trusted");
|
|
502
|
+
try {
|
|
503
|
+
readFileSync(file, "utf-8");
|
|
504
|
+
return;
|
|
505
|
+
} catch {
|
|
506
|
+
mkdirSync(dir, { recursive: true });
|
|
507
|
+
}
|
|
508
|
+
const content = JSON.stringify({ trustedAt: (/* @__PURE__ */ new Date()).toISOString(), workspacePath: cwd });
|
|
509
|
+
writeFileSync(file, content);
|
|
510
|
+
}
|
|
511
|
+
function ensureCodexTrust() {
|
|
512
|
+
const configPath = join(homedir(), ".codex", "config.toml");
|
|
513
|
+
const cwd = process.cwd();
|
|
514
|
+
const key = `[projects."${cwd}"]`;
|
|
515
|
+
try {
|
|
516
|
+
const content = readFileSync(configPath, "utf-8");
|
|
517
|
+
if (content.match(new RegExp(`^\\[projects\\."${cwd.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}"\\]`, "m"))) return;
|
|
518
|
+
} catch {
|
|
519
|
+
mkdirSync(join(homedir(), ".codex"), { recursive: true });
|
|
520
|
+
}
|
|
521
|
+
appendFileSync(configPath, `
|
|
522
|
+
${key}
|
|
523
|
+
trust_level = "trusted"
|
|
524
|
+
`);
|
|
525
|
+
}
|
|
508
526
|
async function runAgent(cmd, extraArgs = []) {
|
|
509
527
|
const agent = resolveAgent(cmd);
|
|
510
528
|
if (!agent) {
|
|
@@ -516,10 +534,13 @@ Run ${chalk2.yellow("bankai agents")} to see available agents, or ${chalk2.yello
|
|
|
516
534
|
return;
|
|
517
535
|
}
|
|
518
536
|
if (agent.type === "settings") {
|
|
537
|
+
if (agent.cmd === "cursor-agent") ensureCursorAgentTrust();
|
|
519
538
|
await applySettingsAgent(agent);
|
|
520
|
-
const
|
|
539
|
+
const line = agent.lines?.[0] ?? agent.cmd;
|
|
540
|
+
const code = await execAgent(line, extraArgs);
|
|
521
541
|
process.exitCode = code;
|
|
522
542
|
} else {
|
|
543
|
+
if (agent.cmd === "codex") ensureCodexTrust();
|
|
523
544
|
const line = agent.lines[0];
|
|
524
545
|
const code = await execAgent(line, extraArgs);
|
|
525
546
|
process.exitCode = code;
|
|
@@ -665,7 +686,7 @@ function removeAgentCommand(cmd) {
|
|
|
665
686
|
|
|
666
687
|
// src/commands/select.ts
|
|
667
688
|
import chalk8 from "chalk";
|
|
668
|
-
import
|
|
689
|
+
import select from "@inquirer/select";
|
|
669
690
|
|
|
670
691
|
// src/ui/fade.ts
|
|
671
692
|
import chalk7 from "chalk";
|
|
@@ -769,7 +790,7 @@ async function selectAgent() {
|
|
|
769
790
|
const agents = installed.length > 0 ? installed : all;
|
|
770
791
|
const label = installed.length > 0 ? "Detected agents on this system" : "No agents detected \u2014 showing all supported agents";
|
|
771
792
|
console.log(chalk8.dim(label));
|
|
772
|
-
const chosen = await
|
|
793
|
+
const chosen = await select({
|
|
773
794
|
message: "Select an agent:",
|
|
774
795
|
choices: agents.map((a) => ({
|
|
775
796
|
name: a.displayName ?? a.cmd,
|
|
@@ -779,6 +800,31 @@ async function selectAgent() {
|
|
|
779
800
|
await runAgent(chosen);
|
|
780
801
|
}
|
|
781
802
|
|
|
803
|
+
// src/argv.ts
|
|
804
|
+
var RESERVED_TOP_LEVEL_COMMANDS = /* @__PURE__ */ new Set(["agents", "add", "edit", "remove", "help"]);
|
|
805
|
+
var RESERVED_TOP_LEVEL_FLAGS = /* @__PURE__ */ new Set(["-h", "--help", "-V", "--version"]);
|
|
806
|
+
function stripLeadingSeparator(args2) {
|
|
807
|
+
return args2[0] === "--" ? args2.slice(1) : args2;
|
|
808
|
+
}
|
|
809
|
+
function extractDirectAgentInvocation(argv) {
|
|
810
|
+
if (argv.length === 0) return null;
|
|
811
|
+
const [first, ...rest] = argv;
|
|
812
|
+
if (RESERVED_TOP_LEVEL_FLAGS.has(first)) return null;
|
|
813
|
+
if (RESERVED_TOP_LEVEL_COMMANDS.has(first)) return null;
|
|
814
|
+
if (first === "-a" || first === "--agent") {
|
|
815
|
+
const [cmd, ...extraArgs] = rest;
|
|
816
|
+
if (!cmd || cmd.startsWith("-")) return null;
|
|
817
|
+
return { cmd, extraArgs: stripLeadingSeparator(extraArgs) };
|
|
818
|
+
}
|
|
819
|
+
if (first.startsWith("--agent=")) {
|
|
820
|
+
const cmd = first.slice("--agent=".length).trim();
|
|
821
|
+
if (!cmd || cmd.startsWith("-")) return null;
|
|
822
|
+
return { cmd, extraArgs: stripLeadingSeparator(rest) };
|
|
823
|
+
}
|
|
824
|
+
if (first.startsWith("-")) return null;
|
|
825
|
+
return { cmd: first, extraArgs: stripLeadingSeparator(rest) };
|
|
826
|
+
}
|
|
827
|
+
|
|
782
828
|
// src/main.ts
|
|
783
829
|
var require2 = createRequire(import.meta.url);
|
|
784
830
|
var { version } = require2("../package.json");
|
|
@@ -807,7 +853,15 @@ program.command("remove <cmd>").description("Remove a custom agent").action((cmd
|
|
|
807
853
|
var args = process.argv.slice(2);
|
|
808
854
|
var isTopLevelHelp = args.length <= 1 && (args.includes("--help") || args.includes("-h"));
|
|
809
855
|
if (isTopLevelHelp) await showFade();
|
|
810
|
-
|
|
856
|
+
var directInvocation = extractDirectAgentInvocation(args);
|
|
857
|
+
var run = async () => {
|
|
858
|
+
if (directInvocation) {
|
|
859
|
+
await runAgent(directInvocation.cmd, directInvocation.extraArgs);
|
|
860
|
+
return;
|
|
861
|
+
}
|
|
862
|
+
await program.parseAsync();
|
|
863
|
+
};
|
|
864
|
+
run().catch((err) => {
|
|
811
865
|
if (err?.name === "ExitPromptError") {
|
|
812
866
|
process.exit(130);
|
|
813
867
|
}
|