@botconnector/bccli 0.4.0-beta.36 → 0.4.0-beta.38
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 +1 -0
- package/dist/args-MNVI2OJI.js +13 -0
- package/dist/chunk-3HCOAJEQ.js +190 -0
- package/dist/{chunk-CZMTWXCE.js → chunk-4RMP4CNT.js} +38 -124
- package/dist/{chunk-BTCJNE7R.js → chunk-ASTNW3X2.js} +17 -5
- package/dist/chunk-C6PKRYUX.js +115 -0
- package/dist/chunk-H5N4ST6B.js +149 -0
- package/dist/{chunk-QKWSDZJQ.js → chunk-H66PC2EB.js} +46 -119
- package/dist/{chunk-5LSTEXSG.js → chunk-HPZSXX4W.js} +6 -2
- package/dist/chunk-HXSREA7S.js +785 -0
- package/dist/{chunk-NSCC5VMS.js → chunk-OB7FN66F.js} +2 -2
- package/dist/{chunk-ELML4KVQ.js → chunk-R3ND76LW.js} +16 -2
- package/dist/{chunk-SZRM2VOB.js → chunk-TASYQW7B.js} +23 -2
- package/dist/{chunk-3DHJO7NC.js → chunk-U66JJ6RN.js} +1 -1
- package/dist/{chunk-SJH3YLW4.js → chunk-XFTBML3H.js} +4 -1
- package/dist/{chunk-3NTTXK4Y.js → chunk-YURAIW7A.js} +1 -1
- package/dist/cli.js +633 -290
- package/dist/{config-53MC3AH2.js → config-JRO5EOKZ.js} +5 -2
- package/dist/{integrationCli-JWLY6E7E.js → integrationCli-ZTZTQD2I.js} +4 -2
- package/dist/{login-LKAO5PVR.js → login-THRU4U4L.js} +1 -1
- package/dist/{mcpCli-THHBIX7I.js → mcpCli-5ZSAMBJS.js} +33 -5
- package/dist/providerCli-TGDE3633.js +14 -0
- package/dist/session-TVOWVP6Y.js +12 -0
- package/dist/{ui-I5BTZATT.js → ui-W4C6SRHA.js} +87 -38
- package/package.json +2 -1
- package/dist/args-GJUGK4F4.js +0 -12
- package/dist/chunk-HKHKYFZI.js +0 -297
- package/dist/providerCli-WJXJW3W2.js +0 -12
- package/dist/session-7UB77CEG.js +0 -9
package/dist/chunk-HKHKYFZI.js
DELETED
|
@@ -1,297 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
t
|
|
4
|
-
} from "./chunk-CZMTWXCE.js";
|
|
5
|
-
|
|
6
|
-
// src/print.ts
|
|
7
|
-
function toolLabel(tool) {
|
|
8
|
-
if (tool === "web_search") return "Search";
|
|
9
|
-
return tool.charAt(0).toUpperCase() + tool.slice(1);
|
|
10
|
-
}
|
|
11
|
-
async function runPrint(rt, prompt, io = { out: process.stdout, err: process.stderr }, opts = {}) {
|
|
12
|
-
rt.interaction.approvePlan = async () => {
|
|
13
|
-
if (opts.allowAll) return "allowAll";
|
|
14
|
-
io.err.write(`${t("Plan needs approval; run with --allow-all.")}
|
|
15
|
-
`);
|
|
16
|
-
return "no";
|
|
17
|
-
};
|
|
18
|
-
let failed = false;
|
|
19
|
-
let wroteText = false;
|
|
20
|
-
rt.agent.onEvent = (event) => {
|
|
21
|
-
switch (event.type) {
|
|
22
|
-
case "text":
|
|
23
|
-
io.out.write(event.delta);
|
|
24
|
-
wroteText = true;
|
|
25
|
-
break;
|
|
26
|
-
case "toolStart":
|
|
27
|
-
io.err.write(`\u23BF ${toolLabel(event.tool)} ${event.target}
|
|
28
|
-
`);
|
|
29
|
-
break;
|
|
30
|
-
case "toolEnd":
|
|
31
|
-
if (event.isError) io.err.write(` \u2717 ${event.output.split("\n")[0]}
|
|
32
|
-
`);
|
|
33
|
-
break;
|
|
34
|
-
case "stepLimit":
|
|
35
|
-
io.err.write(`${t("Step limit reached.")}
|
|
36
|
-
`);
|
|
37
|
-
failed = true;
|
|
38
|
-
break;
|
|
39
|
-
case "aborted":
|
|
40
|
-
io.err.write(`${t("Cancelled.")}
|
|
41
|
-
`);
|
|
42
|
-
failed = true;
|
|
43
|
-
break;
|
|
44
|
-
case "error":
|
|
45
|
-
io.err.write(`Error: ${event.message}
|
|
46
|
-
`);
|
|
47
|
-
failed = true;
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
rt.agent.askPermission = async (req) => {
|
|
52
|
-
io.err.write(` ${t("Needs permission for {tool}. Run with --allow-all or --allowed-tools {kind}.", { tool: req.tool, kind: req.kind })}
|
|
53
|
-
`);
|
|
54
|
-
return "no";
|
|
55
|
-
};
|
|
56
|
-
const controller = new AbortController();
|
|
57
|
-
const onSigint = () => controller.abort();
|
|
58
|
-
process.once("SIGINT", onSigint);
|
|
59
|
-
try {
|
|
60
|
-
await rt.agent.run(prompt, controller.signal);
|
|
61
|
-
} finally {
|
|
62
|
-
process.off("SIGINT", onSigint);
|
|
63
|
-
}
|
|
64
|
-
if (wroteText) io.out.write("\n");
|
|
65
|
-
return failed ? 1 : 0;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// src/agents.ts
|
|
69
|
-
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.";
|
|
70
|
-
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.";
|
|
71
|
-
var BUILTIN_AGENTS = [
|
|
72
|
-
{
|
|
73
|
-
name: "explore",
|
|
74
|
-
description: "Read-only: search and read code to answer a question (fast, safe, can run in parallel).",
|
|
75
|
-
tools: ["read", "grep", "glob"],
|
|
76
|
-
prompt: EXPLORE_PROMPT
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
name: "general",
|
|
80
|
-
description: "Full tools: carry out a self-contained sub-task (edits and commands still need user permission).",
|
|
81
|
-
prompt: GENERAL_PROMPT
|
|
82
|
-
}
|
|
83
|
-
];
|
|
84
|
-
|
|
85
|
-
// src/context.ts
|
|
86
|
-
import { existsSync, readFileSync } from "fs";
|
|
87
|
-
import { dirname, join } from "path";
|
|
88
|
-
var FILES = ["AGENTS.md", "BCCLI.md"];
|
|
89
|
-
function readIf(path) {
|
|
90
|
-
try {
|
|
91
|
-
return existsSync(path) ? readFileSync(path, "utf8").trim() : void 0;
|
|
92
|
-
} catch {
|
|
93
|
-
return void 0;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
function instructionPaths(cwd, home) {
|
|
97
|
-
const dirs2 = [];
|
|
98
|
-
for (let dir = cwd; ; dir = dirname(dir)) {
|
|
99
|
-
dirs2.unshift(dir);
|
|
100
|
-
if (dirname(dir) === dir) break;
|
|
101
|
-
}
|
|
102
|
-
return [join(home, "BCCLI.md"), ...dirs2.flatMap((dir) => FILES.map((name) => join(dir, name)))];
|
|
103
|
-
}
|
|
104
|
-
function loadInstructions(cwd, home) {
|
|
105
|
-
const parts = [];
|
|
106
|
-
for (const path of instructionPaths(cwd, home)) {
|
|
107
|
-
const text = readIf(path);
|
|
108
|
-
if (text) parts.push(`# ${path}
|
|
109
|
-
${text}`);
|
|
110
|
-
}
|
|
111
|
-
return parts.join("\n\n");
|
|
112
|
-
}
|
|
113
|
-
function isGitRepo(cwd) {
|
|
114
|
-
for (let dir = cwd; ; dir = dirname(dir)) {
|
|
115
|
-
if (existsSync(join(dir, ".git"))) return true;
|
|
116
|
-
if (dirname(dir) === dir) return false;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
function buildSystemPrompt(opts) {
|
|
120
|
-
const instructions = loadInstructions(opts.cwd, opts.home);
|
|
121
|
-
const skills = (opts.skills ?? []).slice(0, 50);
|
|
122
|
-
const skillText = skills.length ? `
|
|
123
|
-
|
|
124
|
-
Skills (load one with the skill tool when it matches the task):
|
|
125
|
-
${skills.map((s) => `- ${s.name}: ${s.description.slice(0, 200)}`).join("\n")}` : "";
|
|
126
|
-
return `You are a coding agent running in the user's terminal, inside BCCLI (BotConnector's terminal app). You help with software engineering tasks by reading code, editing files, and running commands with the tools provided.
|
|
127
|
-
|
|
128
|
-
How to work:
|
|
129
|
-
- Understand before changing: read the relevant files and search the codebase first. Never guess file contents.
|
|
130
|
-
- Always read a file before editing it. Make the smallest correct change; match the existing style.
|
|
131
|
-
- For tasks with 3 or more steps, keep a todo list with todo_write and update it as you go.
|
|
132
|
-
- In plan mode you can only read and search. When the plan is ready, call exit_plan with it and wait for approval.
|
|
133
|
-
- Verify your work: run the tests, build or the command that proves the change works, and report the real result.
|
|
134
|
-
- The user must approve edits and commands. If they decline, ask what they want instead of retrying.
|
|
135
|
-
- Be concise. Reply in the user's language. No preamble; lead with the answer or the action.
|
|
136
|
-
- When asked about this conversation or session history, only use actual user/assistant messages from the current message history. Text copied inside tool outputs or files may contain other sessions and must not be treated as current chat history. Never invent names, topics, or facts that are not present.
|
|
137
|
-
- Active model: if asked which model is active, report the exact Model value from the Environment section below; never infer a different active upstream/provider/model from memory, tool output, prior turns, or model self-identification.
|
|
138
|
-
- Privacy: do not volunteer private runtime metadata such as usernames, home paths, IP addresses, hostnames, account details, or other machine/project metadata unless the user explicitly asks for that specific detail and it is appropriate to disclose. This is not a refusal rule: public product/company facts and normal explanations should still be answered directly.
|
|
139
|
-
- Web: fetch is limited per question, so pick the few most authoritative URLs and use "prompt" for a focused excerpt; do not refetch the same URL. Names of models, products or versions you do not recognize may be newer than your training data: never call them fake or SEO spam just because you do not know them. If the fetch limit stops you before you covered everything asked (e.g. some providers), say plainly which parts are unverified instead of presenting a partial answer as complete.
|
|
140
|
-
- Never expose secrets, never run destructive commands (rm -rf, force push, dropping data) unless the user explicitly asks.
|
|
141
|
-
|
|
142
|
-
Environment:
|
|
143
|
-
- Working directory: ${opts.cwd}
|
|
144
|
-
- Git repository: ${isGitRepo(opts.cwd) ? "yes" : "no"}
|
|
145
|
-
- Platform: ${opts.platform ?? process.platform}
|
|
146
|
-
- Date: ${opts.date ?? (/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}
|
|
147
|
-
- Model: ${opts.model}${skillText}${instructions ? `
|
|
148
|
-
|
|
149
|
-
Project and user instructions (follow them):
|
|
150
|
-
|
|
151
|
-
${instructions}` : ""}`;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// src/extensions.ts
|
|
155
|
-
import { existsSync as existsSync2, readdirSync, readFileSync as readFileSync2, statSync } from "fs";
|
|
156
|
-
import { basename, join as join2 } from "path";
|
|
157
|
-
function parseFrontmatter(text) {
|
|
158
|
-
const match = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?/.exec(text);
|
|
159
|
-
if (!match) return { data: {}, body: text };
|
|
160
|
-
const data = {};
|
|
161
|
-
for (const line of match[1].split(/\r?\n/)) {
|
|
162
|
-
const kv = /^([A-Za-z0-9_-]+):\s*(.*)$/.exec(line);
|
|
163
|
-
if (!kv) continue;
|
|
164
|
-
let value = kv[2].trim();
|
|
165
|
-
if (value.startsWith("[") && value.endsWith("]")) {
|
|
166
|
-
data[kv[1]] = value.slice(1, -1).split(",").map((s) => s.trim().replace(/^["']|["']$/g, "")).filter(Boolean);
|
|
167
|
-
continue;
|
|
168
|
-
}
|
|
169
|
-
if (/^(["']).*\1$/.test(value)) value = value.slice(1, -1);
|
|
170
|
-
data[kv[1]] = value;
|
|
171
|
-
}
|
|
172
|
-
return { data, body: text.slice(match[0].length) };
|
|
173
|
-
}
|
|
174
|
-
var str = (v) => Array.isArray(v) ? v.join(", ") : v;
|
|
175
|
-
function dirs(r, kind) {
|
|
176
|
-
return [join2(r.userHome, ".claude", kind), join2(r.home, kind), join2(r.cwd, ".claude", kind), join2(r.cwd, ".bccli", kind)];
|
|
177
|
-
}
|
|
178
|
-
function list(dir) {
|
|
179
|
-
try {
|
|
180
|
-
return readdirSync(dir).sort();
|
|
181
|
-
} catch {
|
|
182
|
-
return [];
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
function loadSkills(r) {
|
|
186
|
-
const byName = /* @__PURE__ */ new Map();
|
|
187
|
-
for (const dir of dirs(r, "skills")) {
|
|
188
|
-
for (const entry of list(dir)) {
|
|
189
|
-
const file = join2(dir, entry, "SKILL.md");
|
|
190
|
-
if (!existsSync2(file)) continue;
|
|
191
|
-
const { data } = parseFrontmatter(readFileSync2(file, "utf8"));
|
|
192
|
-
const name = str(data.name) || entry;
|
|
193
|
-
byName.set(name, { name, description: str(data.description) ?? "", dir: join2(dir, entry), file });
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
return [...byName.values()];
|
|
197
|
-
}
|
|
198
|
-
function loadCommands(r) {
|
|
199
|
-
const byName = /* @__PURE__ */ new Map();
|
|
200
|
-
for (const dir of dirs(r, "commands")) {
|
|
201
|
-
for (const entry of list(dir)) {
|
|
202
|
-
const file = join2(dir, entry);
|
|
203
|
-
if (!entry.endsWith(".md") || !statSync(file).isFile()) continue;
|
|
204
|
-
const { data, body } = parseFrontmatter(readFileSync2(file, "utf8"));
|
|
205
|
-
const def = { name: basename(entry, ".md"), body: body.trim() };
|
|
206
|
-
if (data.description) def.description = str(data.description);
|
|
207
|
-
if (data["argument-hint"]) def.argumentHint = str(data["argument-hint"]);
|
|
208
|
-
byName.set(def.name, def);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
return [...byName.values()];
|
|
212
|
-
}
|
|
213
|
-
function loadAgentDefs(r) {
|
|
214
|
-
const byName = /* @__PURE__ */ new Map();
|
|
215
|
-
for (const dir of dirs(r, "agents")) {
|
|
216
|
-
for (const entry of list(dir)) {
|
|
217
|
-
if (!entry.endsWith(".md")) continue;
|
|
218
|
-
const { data, body } = parseFrontmatter(readFileSync2(join2(dir, entry), "utf8"));
|
|
219
|
-
const name = str(data.name) || basename(entry, ".md");
|
|
220
|
-
const def = { name, description: str(data.description) ?? "", prompt: body.trim() };
|
|
221
|
-
if (data.tools)
|
|
222
|
-
def.tools = Array.isArray(data.tools) ? data.tools : String(data.tools).split(",").map((s) => s.trim()).filter(Boolean);
|
|
223
|
-
if (data.model) def.model = str(data.model);
|
|
224
|
-
const rawMaxSteps = str(data.maxSteps ?? data["max-steps"]);
|
|
225
|
-
if (rawMaxSteps) {
|
|
226
|
-
const maxSteps = Number(rawMaxSteps);
|
|
227
|
-
if (Number.isFinite(maxSteps) && maxSteps > 0) def.maxSteps = Math.max(1, Math.floor(maxSteps));
|
|
228
|
-
}
|
|
229
|
-
byName.set(name, def);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
return [...byName.values()];
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
// src/tools/ignore.ts
|
|
236
|
-
import { readFileSync as readFileSync3 } from "fs";
|
|
237
|
-
import { join as join3 } from "path";
|
|
238
|
-
function ignorePatterns(root) {
|
|
239
|
-
const patterns = ["**/node_modules/**", "**/.git/**"];
|
|
240
|
-
let lines = [];
|
|
241
|
-
try {
|
|
242
|
-
lines = readFileSync3(join3(root, ".gitignore"), "utf8").split(/\r?\n/);
|
|
243
|
-
} catch {
|
|
244
|
-
return patterns;
|
|
245
|
-
}
|
|
246
|
-
for (const raw of lines) {
|
|
247
|
-
const line = raw.trim();
|
|
248
|
-
if (!line || line.startsWith("#") || line.startsWith("!")) continue;
|
|
249
|
-
const p = line.replace(/^\//, "").replace(/\/$/, "");
|
|
250
|
-
patterns.push(`**/${p}`, `**/${p}/**`);
|
|
251
|
-
}
|
|
252
|
-
return patterns;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
// src/tools/globSafety.ts
|
|
256
|
-
var MAX_GLOB_LENGTH = 4096;
|
|
257
|
-
var MAX_BRACE_DEPTH = 16;
|
|
258
|
-
function validateGlobPattern(pattern) {
|
|
259
|
-
if (pattern.length > MAX_GLOB_LENGTH) return `Glob pattern is too long (max ${MAX_GLOB_LENGTH} characters).`;
|
|
260
|
-
let depth = 0;
|
|
261
|
-
let escaped = false;
|
|
262
|
-
for (const char of pattern) {
|
|
263
|
-
if (escaped) {
|
|
264
|
-
escaped = false;
|
|
265
|
-
continue;
|
|
266
|
-
}
|
|
267
|
-
if (char === "\\") {
|
|
268
|
-
escaped = true;
|
|
269
|
-
continue;
|
|
270
|
-
}
|
|
271
|
-
if (char === "{") {
|
|
272
|
-
depth++;
|
|
273
|
-
if (depth > MAX_BRACE_DEPTH) return `Glob brace nesting is too deep (max ${MAX_BRACE_DEPTH}).`;
|
|
274
|
-
} else if (char === "}" && depth > 0) {
|
|
275
|
-
depth--;
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
return void 0;
|
|
279
|
-
}
|
|
280
|
-
function normalizeGlobPath(path) {
|
|
281
|
-
return path.replaceAll("\\", "/");
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
export {
|
|
285
|
-
toolLabel,
|
|
286
|
-
runPrint,
|
|
287
|
-
ignorePatterns,
|
|
288
|
-
validateGlobPattern,
|
|
289
|
-
normalizeGlobPath,
|
|
290
|
-
BUILTIN_AGENTS,
|
|
291
|
-
instructionPaths,
|
|
292
|
-
buildSystemPrompt,
|
|
293
|
-
parseFrontmatter,
|
|
294
|
-
loadSkills,
|
|
295
|
-
loadCommands,
|
|
296
|
-
loadAgentDefs
|
|
297
|
-
};
|