@botconnector/bccli 0.4.0-beta.4 → 0.4.0-beta.40

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 (46) hide show
  1. package/README.md +80 -1
  2. package/dist/acp-5A7EXLCG.js +114 -0
  3. package/dist/args-4SMOHFN5.js +13 -0
  4. package/dist/chunk-3HCOAJEQ.js +190 -0
  5. package/dist/chunk-AS7VV7D3.js +195 -0
  6. package/dist/{chunk-NGLKANMD.js → chunk-AVB6M4JE.js} +24 -2
  7. package/dist/{chunk-GW36UMHZ.js → chunk-DSFHN5CH.js} +2 -2
  8. package/dist/{chunk-ELML4KVQ.js → chunk-GAFJEQTJ.js} +32 -2
  9. package/dist/chunk-GGNXHJL6.js +884 -0
  10. package/dist/chunk-HE33XAPZ.js +341 -0
  11. package/dist/{chunk-UESQNU4A.js → chunk-ISCT3PN3.js} +14 -9
  12. package/dist/chunk-JROUQ5YS.js +76 -0
  13. package/dist/chunk-LN32JIZR.js +56 -0
  14. package/dist/chunk-M23QBX3V.js +419 -0
  15. package/dist/chunk-M7LLJQ7M.js +310 -0
  16. package/dist/chunk-NI5JZUZ3.js +63 -0
  17. package/dist/chunk-PDVS4UWM.js +8 -0
  18. package/dist/chunk-PSO7R5AD.js +10 -0
  19. package/dist/chunk-RV74TCEP.js +231 -0
  20. package/dist/{chunk-U7DLMVPZ.js → chunk-SESBH44L.js} +2 -1
  21. package/dist/{chunk-SJH3YLW4.js → chunk-VM7HYAJS.js} +4 -1
  22. package/dist/chunk-WH7XLDGZ.js +2125 -0
  23. package/dist/chunk-ZMU7MXCH.js +674 -0
  24. package/dist/cli.js +94 -1278
  25. package/dist/{config-NPSYFAFD.js → config-C4KLLDC6.js} +5 -2
  26. package/dist/integrationCli-HR7CDUSI.js +685 -0
  27. package/dist/{login-F4G5QXOU.js → login-T5S6SPZA.js} +1 -1
  28. package/dist/{mcpCli-Q2H63ISP.js → mcpCli-5QTXH7XJ.js} +42 -9
  29. package/dist/modelsCli-DKTT3UZD.js +36 -0
  30. package/dist/providerCli-DDH4ZZUY.js +15 -0
  31. package/dist/sdk.js +5130 -0
  32. package/dist/serve-I2VQUTHR.js +178 -0
  33. package/dist/serve-JNQUP7CZ.js +514 -0
  34. package/dist/session-H2YL5RSB.js +12 -0
  35. package/dist/setup-I7UY7X7C.js +23 -0
  36. package/dist/ui-GVIMUZNS.js +2280 -0
  37. package/dist/update-SZUG3YSB.js +109 -0
  38. package/package.json +24 -3
  39. package/dist/args-FCLPQ7TO.js +0 -11
  40. package/dist/chunk-C5AFWX7H.js +0 -328
  41. package/dist/chunk-OSWQPSA4.js +0 -252
  42. package/dist/chunk-RZUJYAQV.js +0 -112
  43. package/dist/chunk-UN7QXPCB.js +0 -82
  44. package/dist/providerCli-MXV6PD6F.js +0 -11
  45. package/dist/session-7UB77CEG.js +0 -9
  46. package/dist/ui-7FXPXXGN.js +0 -1333
@@ -1,252 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // src/print.ts
4
- function toolLabel(tool) {
5
- return tool.charAt(0).toUpperCase() + tool.slice(1);
6
- }
7
- async function runPrint(rt, prompt, io = { out: process.stdout, err: process.stderr }, opts = {}) {
8
- rt.interaction.approvePlan = async () => {
9
- if (opts.allowAll) return "allowAll";
10
- io.err.write("Rencana butuh persetujuan; jalankan dengan --allow-all.\n");
11
- return "no";
12
- };
13
- let failed = false;
14
- let wroteText = false;
15
- rt.agent.onEvent = (event) => {
16
- switch (event.type) {
17
- case "text":
18
- io.out.write(event.delta);
19
- wroteText = true;
20
- break;
21
- case "toolStart":
22
- io.err.write(`\u23BF ${toolLabel(event.tool)} ${event.target}
23
- `);
24
- break;
25
- case "toolEnd":
26
- if (event.isError) io.err.write(` \u2717 ${event.output.split("\n")[0]}
27
- `);
28
- break;
29
- case "stepLimit":
30
- io.err.write("Batas langkah tercapai.\n");
31
- failed = true;
32
- break;
33
- case "aborted":
34
- io.err.write("Dibatalkan.\n");
35
- failed = true;
36
- break;
37
- case "error":
38
- io.err.write(`Error: ${event.message}
39
- `);
40
- failed = true;
41
- break;
42
- }
43
- };
44
- rt.agent.askPermission = async (req) => {
45
- io.err.write(` Butuh izin untuk ${req.tool}. Jalankan dengan --allow-all atau --allowed-tools ${req.kind}.
46
- `);
47
- return "no";
48
- };
49
- const controller = new AbortController();
50
- const onSigint = () => controller.abort();
51
- process.once("SIGINT", onSigint);
52
- try {
53
- await rt.agent.run(prompt, controller.signal);
54
- } finally {
55
- process.off("SIGINT", onSigint);
56
- }
57
- if (wroteText) io.out.write("\n");
58
- return failed ? 1 : 0;
59
- }
60
-
61
- // src/agents.ts
62
- var EXPLORE_PROMPT = "You are a read-only research agent working for another agent. Search and read the codebase to answer the request. You cannot edit files or run commands. Reply with a concise report: the answer, the relevant file paths with line numbers, and nothing else.";
63
- var GENERAL_PROMPT = "You are an agent handling a delegated task for another agent. Complete the task end to end with the tools you have, verify the result, and reply with a short report of what you did and what you found.";
64
- var BUILTIN_AGENTS = [
65
- {
66
- name: "explore",
67
- description: "Read-only: search and read code to answer a question (fast, safe, can run in parallel).",
68
- tools: ["read", "grep", "glob"],
69
- prompt: EXPLORE_PROMPT,
70
- maxSteps: 30
71
- },
72
- {
73
- name: "general",
74
- description: "Full tools: carry out a self-contained sub-task (edits and commands still need user permission).",
75
- prompt: GENERAL_PROMPT,
76
- maxSteps: 50
77
- }
78
- ];
79
-
80
- // src/context.ts
81
- import { existsSync, readFileSync } from "fs";
82
- import { dirname, join } from "path";
83
- var FILES = ["AGENTS.md", "BCCLI.md"];
84
- function readIf(path) {
85
- try {
86
- return existsSync(path) ? readFileSync(path, "utf8").trim() : void 0;
87
- } catch {
88
- return void 0;
89
- }
90
- }
91
- function instructionPaths(cwd, home) {
92
- const dirs2 = [];
93
- for (let dir = cwd; ; dir = dirname(dir)) {
94
- dirs2.unshift(dir);
95
- if (dirname(dir) === dir) break;
96
- }
97
- return [join(home, "BCCLI.md"), ...dirs2.flatMap((dir) => FILES.map((name) => join(dir, name)))];
98
- }
99
- function loadInstructions(cwd, home) {
100
- const parts = [];
101
- for (const path of instructionPaths(cwd, home)) {
102
- const text = readIf(path);
103
- if (text) parts.push(`# ${path}
104
- ${text}`);
105
- }
106
- return parts.join("\n\n");
107
- }
108
- function isGitRepo(cwd) {
109
- for (let dir = cwd; ; dir = dirname(dir)) {
110
- if (existsSync(join(dir, ".git"))) return true;
111
- if (dirname(dir) === dir) return false;
112
- }
113
- }
114
- function buildSystemPrompt(opts) {
115
- const instructions = loadInstructions(opts.cwd, opts.home);
116
- const skills = (opts.skills ?? []).slice(0, 50);
117
- const skillText = skills.length ? `
118
-
119
- Skills (load one with the skill tool when it matches the task):
120
- ${skills.map((s) => `- ${s.name}: ${s.description.slice(0, 200)}`).join("\n")}` : "";
121
- return `You are BCCLI, a coding agent by BotConnector running in the user's terminal. You help with software engineering tasks by reading code, editing files, and running commands with the tools provided.
122
-
123
- How to work:
124
- - Understand before changing: read the relevant files and search the codebase first. Never guess file contents.
125
- - Always read a file before editing it. Make the smallest correct change; match the existing style.
126
- - For tasks with 3 or more steps, keep a todo list with todo_write and update it as you go.
127
- - In plan mode you can only read and search. When the plan is ready, call exit_plan with it and wait for approval.
128
- - Verify your work: run the tests, build or the command that proves the change works, and report the real result.
129
- - The user must approve edits and commands. If they decline, ask what they want instead of retrying.
130
- - Be concise. Reply in the user's language. No preamble; lead with the answer or the action.
131
- - Never expose secrets, never run destructive commands (rm -rf, force push, dropping data) unless the user explicitly asks.
132
-
133
- Environment:
134
- - Working directory: ${opts.cwd}
135
- - Git repository: ${isGitRepo(opts.cwd) ? "yes" : "no"}
136
- - Platform: ${opts.platform ?? process.platform}
137
- - Date: ${opts.date ?? (/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}
138
- - Model: ${opts.model}${skillText}${instructions ? `
139
-
140
- Project and user instructions (follow them):
141
-
142
- ${instructions}` : ""}`;
143
- }
144
-
145
- // src/extensions.ts
146
- import { existsSync as existsSync2, readdirSync, readFileSync as readFileSync2, statSync } from "fs";
147
- import { basename, join as join2 } from "path";
148
- function parseFrontmatter(text) {
149
- const match = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?/.exec(text);
150
- if (!match) return { data: {}, body: text };
151
- const data = {};
152
- for (const line of match[1].split(/\r?\n/)) {
153
- const kv = /^([A-Za-z0-9_-]+):\s*(.*)$/.exec(line);
154
- if (!kv) continue;
155
- let value = kv[2].trim();
156
- if (value.startsWith("[") && value.endsWith("]")) {
157
- data[kv[1]] = value.slice(1, -1).split(",").map((s) => s.trim().replace(/^["']|["']$/g, "")).filter(Boolean);
158
- continue;
159
- }
160
- if (/^(["']).*\1$/.test(value)) value = value.slice(1, -1);
161
- data[kv[1]] = value;
162
- }
163
- return { data, body: text.slice(match[0].length) };
164
- }
165
- var str = (v) => Array.isArray(v) ? v.join(", ") : v;
166
- function dirs(r, kind) {
167
- return [join2(r.userHome, ".claude", kind), join2(r.home, kind), join2(r.cwd, ".claude", kind), join2(r.cwd, ".bccli", kind)];
168
- }
169
- function list(dir) {
170
- try {
171
- return readdirSync(dir).sort();
172
- } catch {
173
- return [];
174
- }
175
- }
176
- function loadSkills(r) {
177
- const byName = /* @__PURE__ */ new Map();
178
- for (const dir of dirs(r, "skills")) {
179
- for (const entry of list(dir)) {
180
- const file = join2(dir, entry, "SKILL.md");
181
- if (!existsSync2(file)) continue;
182
- const { data } = parseFrontmatter(readFileSync2(file, "utf8"));
183
- const name = str(data.name) || entry;
184
- byName.set(name, { name, description: str(data.description) ?? "", dir: join2(dir, entry), file });
185
- }
186
- }
187
- return [...byName.values()];
188
- }
189
- function loadCommands(r) {
190
- const byName = /* @__PURE__ */ new Map();
191
- for (const dir of dirs(r, "commands")) {
192
- for (const entry of list(dir)) {
193
- const file = join2(dir, entry);
194
- if (!entry.endsWith(".md") || !statSync(file).isFile()) continue;
195
- const { data, body } = parseFrontmatter(readFileSync2(file, "utf8"));
196
- const def = { name: basename(entry, ".md"), body: body.trim() };
197
- if (data.description) def.description = str(data.description);
198
- if (data["argument-hint"]) def.argumentHint = str(data["argument-hint"]);
199
- byName.set(def.name, def);
200
- }
201
- }
202
- return [...byName.values()];
203
- }
204
- function loadAgentDefs(r) {
205
- const byName = /* @__PURE__ */ new Map();
206
- for (const dir of dirs(r, "agents")) {
207
- for (const entry of list(dir)) {
208
- if (!entry.endsWith(".md")) continue;
209
- const { data, body } = parseFrontmatter(readFileSync2(join2(dir, entry), "utf8"));
210
- const name = str(data.name) || basename(entry, ".md");
211
- const def = { name, description: str(data.description) ?? "", prompt: body.trim() };
212
- if (data.tools)
213
- def.tools = Array.isArray(data.tools) ? data.tools : String(data.tools).split(",").map((s) => s.trim()).filter(Boolean);
214
- if (data.model) def.model = str(data.model);
215
- byName.set(name, def);
216
- }
217
- }
218
- return [...byName.values()];
219
- }
220
-
221
- // src/tools/ignore.ts
222
- import { readFileSync as readFileSync3 } from "fs";
223
- import { join as join3 } from "path";
224
- function ignorePatterns(root) {
225
- const patterns = ["**/node_modules/**", "**/.git/**"];
226
- let lines = [];
227
- try {
228
- lines = readFileSync3(join3(root, ".gitignore"), "utf8").split(/\r?\n/);
229
- } catch {
230
- return patterns;
231
- }
232
- for (const raw of lines) {
233
- const line = raw.trim();
234
- if (!line || line.startsWith("#") || line.startsWith("!")) continue;
235
- const p = line.replace(/^\//, "").replace(/\/$/, "");
236
- patterns.push(`**/${p}`, `**/${p}/**`);
237
- }
238
- return patterns;
239
- }
240
-
241
- export {
242
- toolLabel,
243
- runPrint,
244
- ignorePatterns,
245
- BUILTIN_AGENTS,
246
- instructionPaths,
247
- buildSystemPrompt,
248
- parseFrontmatter,
249
- loadSkills,
250
- loadCommands,
251
- loadAgentDefs
252
- };
@@ -1,112 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // src/presets.ts
4
- var PRESETS = [
5
- { id: "bc-cloud", name: "BotConnector Cloud", baseURL: "https://api.botconnector.id/v1", apiKeyEnv: "BOTCONNECTOR_API_KEY" },
6
- { id: "openrouter", name: "OpenRouter", baseURL: "https://openrouter.ai/api/v1", apiKeyEnv: "OPENROUTER_API_KEY" },
7
- { id: "openai", name: "OpenAI", baseURL: "https://api.openai.com/v1", apiKeyEnv: "OPENAI_API_KEY" },
8
- { id: "gemini", name: "Google Gemini", baseURL: "https://generativelanguage.googleapis.com/v1beta/openai", apiKeyEnv: "GEMINI_API_KEY" },
9
- { id: "deepseek", name: "DeepSeek", baseURL: "https://api.deepseek.com/v1", apiKeyEnv: "DEEPSEEK_API_KEY" },
10
- { id: "groq", name: "Groq", baseURL: "https://api.groq.com/openai/v1", apiKeyEnv: "GROQ_API_KEY" },
11
- { id: "ollama-cloud", name: "Ollama Cloud", baseURL: "https://ollama.com/v1", apiKeyEnv: "OLLAMA_API_KEY" },
12
- { id: "ollama", name: "Ollama lokal", baseURL: "http://127.0.0.1:11434/v1", local: true },
13
- { id: "lmstudio", name: "LM Studio lokal", baseURL: "http://127.0.0.1:1234/v1", local: true }
14
- ];
15
-
16
- // src/config.ts
17
- import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
18
- import { homedir } from "os";
19
- import { join } from "path";
20
- var ConfigError = class extends Error {
21
- };
22
- var DEFAULT_CONFIG = {
23
- model: "bc-cloud/glm-5.3-flash",
24
- permissionMode: "default",
25
- providers: Object.fromEntries(PRESETS.map((p) => [p.id, { baseURL: p.baseURL, apiKeyEnv: p.apiKeyEnv }])),
26
- allow: []
27
- };
28
- function bccliHome(env = process.env) {
29
- return env.BCCLI_HOME ?? join(homedir(), ".bccli");
30
- }
31
- function readJsonConfig(path) {
32
- if (!existsSync(path)) return {};
33
- try {
34
- return JSON.parse(readFileSync(path, "utf8"));
35
- } catch (error) {
36
- throw new ConfigError(`Config tidak valid: ${path} (${error.message})`);
37
- }
38
- }
39
- function untrustedProviders(project, known) {
40
- const out = {};
41
- for (const [id, provider] of Object.entries(project.providers ?? {})) {
42
- if (known[id] || typeof provider?.baseURL !== "string") continue;
43
- out[id] = { baseURL: provider.baseURL };
44
- }
45
- return out;
46
- }
47
- function loadConfig(cwd, env = process.env) {
48
- const global = readJsonConfig(join(bccliHome(env), "config.json"));
49
- const project = readJsonConfig(join(cwd, ".bccli", "config.json"));
50
- const known = { ...DEFAULT_CONFIG.providers, ...global.providers };
51
- const fromProject = untrustedProviders(project, known);
52
- return {
53
- model: project.model ?? global.model ?? DEFAULT_CONFIG.model,
54
- permissionMode: global.permissionMode ?? DEFAULT_CONFIG.permissionMode,
55
- providers: { ...known, ...fromProject },
56
- projectProviders: Object.keys(fromProject),
57
- allow: [...global.allow ?? []]
58
- };
59
- }
60
- function readCredentials(env = process.env) {
61
- const path = join(bccliHome(env), "credentials");
62
- if (!existsSync(path)) return {};
63
- try {
64
- return JSON.parse(readFileSync(path, "utf8"));
65
- } catch {
66
- return {};
67
- }
68
- }
69
- function saveCredential(providerId, key, env = process.env) {
70
- const home = bccliHome(env);
71
- mkdirSync(home, { recursive: true });
72
- const path = join(home, "credentials");
73
- writeFileSync(path, JSON.stringify({ ...readCredentials(env), [providerId]: key }, null, 2), { mode: 384 });
74
- chmodSync(path, 384);
75
- }
76
- function resolveModel(config, modelRef, env = process.env) {
77
- const slash = modelRef.indexOf("/");
78
- if (slash <= 0 || slash === modelRef.length - 1) {
79
- throw new ConfigError(`Model harus berformat provider/model, contoh bc-cloud/glm-5.3-flash (dapat: ${modelRef})`);
80
- }
81
- const providerId = modelRef.slice(0, slash);
82
- const provider = config.providers[providerId];
83
- if (!provider) {
84
- throw new ConfigError(`Provider "${providerId}" tidak ada di config. Tersedia: ${Object.keys(config.providers).join(", ")}`);
85
- }
86
- const apiKey = (provider.apiKeyEnv ? env[provider.apiKeyEnv] : void 0) || readCredentials(env)[providerId] || void 0;
87
- if (provider.apiKeyEnv && !apiKey) {
88
- throw new ConfigError(`API key untuk ${providerId} belum ada. Jalankan \`bccli login\` atau set env ${provider.apiKeyEnv}.`);
89
- }
90
- return { providerId, model: modelRef.slice(slash + 1), baseURL: provider.baseURL.replace(/\/+$/, ""), apiKey };
91
- }
92
- function removeCredential(providerId, env = process.env) {
93
- const creds = readCredentials(env);
94
- if (!(providerId in creds)) return false;
95
- delete creds[providerId];
96
- const path = join(bccliHome(env), "credentials");
97
- writeFileSync(path, JSON.stringify(creds, null, 2), { mode: 384 });
98
- chmodSync(path, 384);
99
- return true;
100
- }
101
-
102
- export {
103
- PRESETS,
104
- ConfigError,
105
- bccliHome,
106
- readJsonConfig,
107
- loadConfig,
108
- readCredentials,
109
- saveCredential,
110
- resolveModel,
111
- removeCredential
112
- };
@@ -1,82 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- MODE_ORDER
4
- } from "./chunk-ELML4KVQ.js";
5
- import {
6
- ConfigError
7
- } from "./chunk-RZUJYAQV.js";
8
-
9
- // src/args.ts
10
- import { parseArgs } from "util";
11
- var HELP_TEXT = `BCCLI \u2014 agent AI BotConnector di terminal
12
-
13
- Pemakaian:
14
- bccli [tugas] mode interaktif (opsional langsung dengan tugas)
15
- bccli -p "tugas" jalankan satu tugas tanpa interaksi (skrip/CI)
16
- bccli login [provider] simpan API key (default: bc-cloud)
17
- bccli models daftar model dari provider aktif
18
- bccli provider list|add <id>|remove <id> kelola provider (custom: --url <url> [--name N] [--key-env ENV])
19
- bccli mcp list|add <nama>|remove <nama> kelola server MCP (katalog, atau --url <url>)
20
-
21
- Opsi:
22
- -m, --model <provider/model> pilih model, contoh bc-cloud/glm-5.3-flash
23
- -c, --continue lanjutkan sesi terakhir di folder ini
24
- -r, --resume pilih sesi untuk dilanjutkan
25
- --allow-all jalankan semua alat tanpa minta izin
26
- --allowed-tools <a,b> alat yang boleh tanpa izin: bash, edit, fetch
27
- --permission-mode <mode> default | acceptEdits | plan | allowAll
28
- -v, --version versi
29
- -h, --help bantuan ini`;
30
- function parseCliArgs(argv) {
31
- const { values, positionals } = parseArgs({
32
- args: argv,
33
- allowPositionals: true,
34
- options: {
35
- print: { type: "boolean", short: "p" },
36
- model: { type: "string", short: "m" },
37
- continue: { type: "boolean", short: "c" },
38
- resume: { type: "boolean", short: "r" },
39
- "allow-all": { type: "boolean" },
40
- "allowed-tools": { type: "string" },
41
- "permission-mode": { type: "string" },
42
- help: { type: "boolean", short: "h" },
43
- version: { type: "boolean", short: "v" },
44
- url: { type: "string" },
45
- name: { type: "string" },
46
- "key-env": { type: "string" },
47
- value: { type: "string", multiple: true }
48
- }
49
- });
50
- const mode = values["permission-mode"];
51
- if (mode && !MODE_ORDER.includes(mode)) {
52
- throw new ConfigError(`--permission-mode harus salah satu dari: ${MODE_ORDER.join(", ")}`);
53
- }
54
- const [first, ...rest] = positionals;
55
- const SUBCOMMANDS = ["login", "models", "provider", "mcp"];
56
- const command = SUBCOMMANDS.includes(first) ? first : "run";
57
- const words = command === "run" ? positionals : rest;
58
- return {
59
- command,
60
- prompt: command === "run" && words.length ? words.join(" ") : void 0,
61
- print: !!values.print,
62
- model: values.model,
63
- continue: !!values.continue,
64
- resume: !!values.resume,
65
- allowAll: !!values["allow-all"],
66
- allowedTools: (values["allowed-tools"] ?? "").split(",").map((s) => s.trim()).filter(Boolean),
67
- permissionMode: mode,
68
- help: !!values.help,
69
- version: !!values.version,
70
- loginProvider: command === "login" ? rest[0] ?? "bc-cloud" : void 0,
71
- subArgs: command === "provider" || command === "mcp" ? rest : [],
72
- url: values.url,
73
- name: values.name,
74
- keyEnv: values["key-env"],
75
- values: values.value ?? []
76
- };
77
- }
78
-
79
- export {
80
- HELP_TEXT,
81
- parseCliArgs
82
- };
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- addProviderKey,
4
- runProviderCommand
5
- } from "./chunk-C5AFWX7H.js";
6
- import "./chunk-U7DLMVPZ.js";
7
- import "./chunk-RZUJYAQV.js";
8
- export {
9
- addProviderKey,
10
- runProviderCommand
11
- };
@@ -1,9 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- Session,
4
- pruneSessions
5
- } from "./chunk-SJH3YLW4.js";
6
- export {
7
- Session,
8
- pruneSessions
9
- };