@botconnector/bccli 0.4.0-beta.5 → 0.4.0-beta.51
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 +97 -2
- package/dist/acp-NWP4FFTG.js +182 -0
- package/dist/args-2R45YZ42.js +13 -0
- package/dist/{chunk-U7DLMVPZ.js → chunk-2QYHSESB.js} +2 -1
- package/dist/{chunk-UESQNU4A.js → chunk-4WVIPZFV.js} +14 -9
- package/dist/chunk-7F3IWBPQ.js +191 -0
- package/dist/chunk-DP7EBW53.js +341 -0
- package/dist/{chunk-SJH3YLW4.js → chunk-F6ACN47V.js} +60 -6
- package/dist/chunk-FTFVW7XD.js +235 -0
- package/dist/{chunk-ELML4KVQ.js → chunk-GAFJEQTJ.js} +32 -2
- package/dist/{chunk-NGLKANMD.js → chunk-H73FO5YK.js} +24 -2
- package/dist/chunk-KD2LMIS4.js +145 -0
- package/dist/chunk-KIZC5XV4.js +2141 -0
- package/dist/chunk-N7KP6RNP.js +76 -0
- package/dist/chunk-NDEJUL44.js +361 -0
- package/dist/chunk-PSO7R5AD.js +10 -0
- package/dist/chunk-QXOV4DUZ.js +56 -0
- package/dist/chunk-QZKLZELZ.js +64 -0
- package/dist/chunk-R4BJBTWC.js +940 -0
- package/dist/chunk-SNKVS26H.js +63 -0
- package/dist/chunk-TQWCM5RO.js +231 -0
- package/dist/chunk-VU5HNQHX.js +8 -0
- package/dist/chunk-XLC6T4SX.js +500 -0
- package/dist/chunk-YIYX3FFS.js +733 -0
- package/dist/cli.js +157 -1281
- package/dist/completion-OV3MW2N4.js +125 -0
- package/dist/{config-NPSYFAFD.js → config-AZZFOXKV.js} +5 -2
- package/dist/config-H5A7XHHK.js +30 -0
- package/dist/ghBotCli-7WDYF4L7.js +677 -0
- package/dist/integrationCli-ZMTSILYF.js +685 -0
- package/dist/login-W4Y6WHLV.js +16 -0
- package/dist/{mcpCli-Q2H63ISP.js → mcpCli-5QISTOFK.js} +42 -9
- package/dist/modelsCli-FZMBD4OE.js +36 -0
- package/dist/npmRunner-LU43GM3W.js +46 -0
- package/dist/oauthLogin-VESMXG4M.js +210 -0
- package/dist/pluginsCli-GEHR7FQR.js +284 -0
- package/dist/prCli-JXA7DJW4.js +72 -0
- package/dist/providerCli-EUZGKP5F.js +15 -0
- package/dist/sdk.js +5486 -0
- package/dist/serve-6KX4MXHC.js +178 -0
- package/dist/serve-YSUJD57D.js +515 -0
- package/dist/session-F6MG3UCU.js +12 -0
- package/dist/setup-LLWREJQH.js +24 -0
- package/dist/statsCli-H4HEY5ID.js +353 -0
- package/dist/transferCli-2XUKBG2L.js +71 -0
- package/dist/ui-6HJVYI46.js +2370 -0
- package/dist/update-O4WCLKOO.js +109 -0
- package/package.json +24 -3
- package/dist/args-FCLPQ7TO.js +0 -11
- package/dist/chunk-5O4HD7IU.js +0 -253
- package/dist/chunk-C5AFWX7H.js +0 -328
- package/dist/chunk-GW36UMHZ.js +0 -52
- package/dist/chunk-RZUJYAQV.js +0 -112
- package/dist/chunk-UN7QXPCB.js +0 -82
- package/dist/login-F4G5QXOU.js +0 -9
- package/dist/providerCli-MXV6PD6F.js +0 -11
- package/dist/session-7UB77CEG.js +0 -9
- package/dist/ui-RYTSKEIA.js +0 -1344
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
VERSION
|
|
4
|
+
} from "./chunk-VU5HNQHX.js";
|
|
5
|
+
import {
|
|
6
|
+
t
|
|
7
|
+
} from "./chunk-XLC6T4SX.js";
|
|
8
|
+
|
|
9
|
+
// src/update.ts
|
|
10
|
+
import { spawnSync } from "child_process";
|
|
11
|
+
import { mkdirSync, readFileSync, renameSync, writeFileSync } from "fs";
|
|
12
|
+
import { join } from "path";
|
|
13
|
+
var REGISTRY_URL = "https://registry.npmjs.org/-/package/@botconnector/bccli/dist-tags";
|
|
14
|
+
var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
|
|
15
|
+
function splitVersion(v) {
|
|
16
|
+
const i = v.indexOf("-");
|
|
17
|
+
const coreStr = i < 0 ? v : v.slice(0, i);
|
|
18
|
+
const preStr = i < 0 ? "" : v.slice(i + 1);
|
|
19
|
+
return {
|
|
20
|
+
core: coreStr.split(".").map((p) => Number.parseInt(p, 10) || 0),
|
|
21
|
+
pre: preStr ? preStr.split(".") : []
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function compareVersions(a, b) {
|
|
25
|
+
const A = splitVersion(a);
|
|
26
|
+
const B = splitVersion(b);
|
|
27
|
+
for (let i = 0; i < Math.max(A.core.length, B.core.length); i++) {
|
|
28
|
+
const x = A.core[i] ?? 0;
|
|
29
|
+
const y = B.core[i] ?? 0;
|
|
30
|
+
if (x !== y) return x < y ? -1 : 1;
|
|
31
|
+
}
|
|
32
|
+
if (!A.pre.length && !B.pre.length) return 0;
|
|
33
|
+
if (!A.pre.length) return 1;
|
|
34
|
+
if (!B.pre.length) return -1;
|
|
35
|
+
for (let i = 0; i < Math.max(A.pre.length, B.pre.length); i++) {
|
|
36
|
+
const x = A.pre[i];
|
|
37
|
+
const y = B.pre[i];
|
|
38
|
+
if (x === void 0) return -1;
|
|
39
|
+
if (y === void 0) return 1;
|
|
40
|
+
const nx = Number.parseInt(x, 10);
|
|
41
|
+
const ny = Number.parseInt(y, 10);
|
|
42
|
+
if (String(nx) === x && String(ny) === y) {
|
|
43
|
+
if (nx !== ny) return nx < ny ? -1 : 1;
|
|
44
|
+
} else if (x !== y) {
|
|
45
|
+
return x < y ? -1 : 1;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return 0;
|
|
49
|
+
}
|
|
50
|
+
function channelFor(version) {
|
|
51
|
+
return version.includes("-") ? "next" : "latest";
|
|
52
|
+
}
|
|
53
|
+
function cachePath(home) {
|
|
54
|
+
return join(home, "update-check.json");
|
|
55
|
+
}
|
|
56
|
+
function readCache(home) {
|
|
57
|
+
try {
|
|
58
|
+
const parsed = JSON.parse(readFileSync(cachePath(home), "utf8"));
|
|
59
|
+
return typeof parsed?.checkedAt === "string" ? parsed : void 0;
|
|
60
|
+
} catch {
|
|
61
|
+
return void 0;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function writeCache(home, cache) {
|
|
65
|
+
mkdirSync(home, { recursive: true });
|
|
66
|
+
const tmp = `${cachePath(home)}.tmp`;
|
|
67
|
+
writeFileSync(tmp, JSON.stringify(cache));
|
|
68
|
+
renameSync(tmp, cachePath(home));
|
|
69
|
+
}
|
|
70
|
+
function dueForCheck(cache, now, intervalMs = CHECK_INTERVAL_MS) {
|
|
71
|
+
if (!cache) return true;
|
|
72
|
+
const at = Date.parse(cache.checkedAt);
|
|
73
|
+
if (!Number.isFinite(at)) return true;
|
|
74
|
+
return now.getTime() - at >= intervalMs;
|
|
75
|
+
}
|
|
76
|
+
function updateNotice(current, latest) {
|
|
77
|
+
if (!latest || compareVersions(current, latest) >= 0) return void 0;
|
|
78
|
+
return t("A new bccli is available: {latest} (you have {current}). Run: bccli update", { latest, current });
|
|
79
|
+
}
|
|
80
|
+
async function checkForUpdate(deps) {
|
|
81
|
+
try {
|
|
82
|
+
const cached = readCache(deps.home);
|
|
83
|
+
if (!dueForCheck(cached, deps.now)) return updateNotice(VERSION, cached?.latest);
|
|
84
|
+
const res = await deps.fetch(REGISTRY_URL, { signal: AbortSignal.timeout(deps.timeoutMs ?? 3e3) });
|
|
85
|
+
if (!res.ok) return updateNotice(VERSION, cached?.latest);
|
|
86
|
+
const tags = await res.json();
|
|
87
|
+
const latest = tags[channelFor(VERSION)] ?? tags.latest;
|
|
88
|
+
writeCache(deps.home, { checkedAt: deps.now.toISOString(), latest });
|
|
89
|
+
return updateNotice(VERSION, latest);
|
|
90
|
+
} catch {
|
|
91
|
+
return void 0;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
async function runUpdateCommand(deps) {
|
|
95
|
+
const version = deps.env.BCCLI_VERSION_OVERRIDE ?? VERSION;
|
|
96
|
+
const spec = `@botconnector/bccli@${channelFor(version)}`;
|
|
97
|
+
const spawnFn = deps.spawn ?? spawnSync;
|
|
98
|
+
const cmd = process.platform === "win32" ? "npm.cmd" : "npm";
|
|
99
|
+
const r = spawnFn(cmd, ["i", "-g", spec], { stdio: "inherit", env: deps.env });
|
|
100
|
+
return typeof r.status === "number" ? r.status : 1;
|
|
101
|
+
}
|
|
102
|
+
export {
|
|
103
|
+
channelFor,
|
|
104
|
+
checkForUpdate,
|
|
105
|
+
compareVersions,
|
|
106
|
+
dueForCheck,
|
|
107
|
+
runUpdateCommand,
|
|
108
|
+
updateNotice
|
|
109
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botconnector/bccli",
|
|
3
|
-
"version": "0.4.0-beta.
|
|
3
|
+
"version": "0.4.0-beta.51",
|
|
4
4
|
"description": "BCCLI — BotConnector AI coding agent for the terminal",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -26,18 +26,39 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@modelcontextprotocol/sdk": "^1.30.1",
|
|
28
28
|
"diff": "^9.0.0",
|
|
29
|
-
"fast-glob": "^3.3.3",
|
|
30
29
|
"ink": "^7.1.1",
|
|
30
|
+
"openai": "^7.27.0",
|
|
31
31
|
"react": "^19.3.0",
|
|
32
|
+
"undici": "^7.28.0",
|
|
33
|
+
"ws": "^8.22.0",
|
|
34
|
+
"yaml": "^2.9.1",
|
|
32
35
|
"zod": "^4.6.5"
|
|
33
36
|
},
|
|
34
37
|
"devDependencies": {
|
|
35
38
|
"@biomejs/biome": "^2.5.14",
|
|
36
39
|
"@types/node": "^26.6.3",
|
|
37
40
|
"@types/react": "^19.3.0",
|
|
41
|
+
"@types/ws": "^8.18.2",
|
|
38
42
|
"ink-testing-library": "^4.0.0",
|
|
39
43
|
"tsup": "^8.5.1",
|
|
40
44
|
"typescript": "^7.0.2",
|
|
41
45
|
"vitest": "^5.0.2"
|
|
42
|
-
}
|
|
46
|
+
},
|
|
47
|
+
"overrides": {
|
|
48
|
+
"esbuild": "0.28.2"
|
|
49
|
+
},
|
|
50
|
+
"main": "dist/sdk.js",
|
|
51
|
+
"exports": {
|
|
52
|
+
".": "./dist/sdk.js"
|
|
53
|
+
},
|
|
54
|
+
"directories": {
|
|
55
|
+
"doc": "docs",
|
|
56
|
+
"test": "test"
|
|
57
|
+
},
|
|
58
|
+
"keywords": [],
|
|
59
|
+
"author": "",
|
|
60
|
+
"bugs": {
|
|
61
|
+
"url": "https://github.com/farijarifriyanto-debug/bccli/issues"
|
|
62
|
+
},
|
|
63
|
+
"homepage": "https://github.com/farijarifriyanto-debug/bccli#readme"
|
|
43
64
|
}
|
package/dist/args-FCLPQ7TO.js
DELETED
package/dist/chunk-5O4HD7IU.js
DELETED
|
@@ -1,253 +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
|
-
- 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.
|
|
132
|
-
- Never expose secrets, never run destructive commands (rm -rf, force push, dropping data) unless the user explicitly asks.
|
|
133
|
-
|
|
134
|
-
Environment:
|
|
135
|
-
- Working directory: ${opts.cwd}
|
|
136
|
-
- Git repository: ${isGitRepo(opts.cwd) ? "yes" : "no"}
|
|
137
|
-
- Platform: ${opts.platform ?? process.platform}
|
|
138
|
-
- Date: ${opts.date ?? (/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}
|
|
139
|
-
- Model: ${opts.model}${skillText}${instructions ? `
|
|
140
|
-
|
|
141
|
-
Project and user instructions (follow them):
|
|
142
|
-
|
|
143
|
-
${instructions}` : ""}`;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// src/extensions.ts
|
|
147
|
-
import { existsSync as existsSync2, readdirSync, readFileSync as readFileSync2, statSync } from "fs";
|
|
148
|
-
import { basename, join as join2 } from "path";
|
|
149
|
-
function parseFrontmatter(text) {
|
|
150
|
-
const match = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?/.exec(text);
|
|
151
|
-
if (!match) return { data: {}, body: text };
|
|
152
|
-
const data = {};
|
|
153
|
-
for (const line of match[1].split(/\r?\n/)) {
|
|
154
|
-
const kv = /^([A-Za-z0-9_-]+):\s*(.*)$/.exec(line);
|
|
155
|
-
if (!kv) continue;
|
|
156
|
-
let value = kv[2].trim();
|
|
157
|
-
if (value.startsWith("[") && value.endsWith("]")) {
|
|
158
|
-
data[kv[1]] = value.slice(1, -1).split(",").map((s) => s.trim().replace(/^["']|["']$/g, "")).filter(Boolean);
|
|
159
|
-
continue;
|
|
160
|
-
}
|
|
161
|
-
if (/^(["']).*\1$/.test(value)) value = value.slice(1, -1);
|
|
162
|
-
data[kv[1]] = value;
|
|
163
|
-
}
|
|
164
|
-
return { data, body: text.slice(match[0].length) };
|
|
165
|
-
}
|
|
166
|
-
var str = (v) => Array.isArray(v) ? v.join(", ") : v;
|
|
167
|
-
function dirs(r, kind) {
|
|
168
|
-
return [join2(r.userHome, ".claude", kind), join2(r.home, kind), join2(r.cwd, ".claude", kind), join2(r.cwd, ".bccli", kind)];
|
|
169
|
-
}
|
|
170
|
-
function list(dir) {
|
|
171
|
-
try {
|
|
172
|
-
return readdirSync(dir).sort();
|
|
173
|
-
} catch {
|
|
174
|
-
return [];
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
function loadSkills(r) {
|
|
178
|
-
const byName = /* @__PURE__ */ new Map();
|
|
179
|
-
for (const dir of dirs(r, "skills")) {
|
|
180
|
-
for (const entry of list(dir)) {
|
|
181
|
-
const file = join2(dir, entry, "SKILL.md");
|
|
182
|
-
if (!existsSync2(file)) continue;
|
|
183
|
-
const { data } = parseFrontmatter(readFileSync2(file, "utf8"));
|
|
184
|
-
const name = str(data.name) || entry;
|
|
185
|
-
byName.set(name, { name, description: str(data.description) ?? "", dir: join2(dir, entry), file });
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
return [...byName.values()];
|
|
189
|
-
}
|
|
190
|
-
function loadCommands(r) {
|
|
191
|
-
const byName = /* @__PURE__ */ new Map();
|
|
192
|
-
for (const dir of dirs(r, "commands")) {
|
|
193
|
-
for (const entry of list(dir)) {
|
|
194
|
-
const file = join2(dir, entry);
|
|
195
|
-
if (!entry.endsWith(".md") || !statSync(file).isFile()) continue;
|
|
196
|
-
const { data, body } = parseFrontmatter(readFileSync2(file, "utf8"));
|
|
197
|
-
const def = { name: basename(entry, ".md"), body: body.trim() };
|
|
198
|
-
if (data.description) def.description = str(data.description);
|
|
199
|
-
if (data["argument-hint"]) def.argumentHint = str(data["argument-hint"]);
|
|
200
|
-
byName.set(def.name, def);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
return [...byName.values()];
|
|
204
|
-
}
|
|
205
|
-
function loadAgentDefs(r) {
|
|
206
|
-
const byName = /* @__PURE__ */ new Map();
|
|
207
|
-
for (const dir of dirs(r, "agents")) {
|
|
208
|
-
for (const entry of list(dir)) {
|
|
209
|
-
if (!entry.endsWith(".md")) continue;
|
|
210
|
-
const { data, body } = parseFrontmatter(readFileSync2(join2(dir, entry), "utf8"));
|
|
211
|
-
const name = str(data.name) || basename(entry, ".md");
|
|
212
|
-
const def = { name, description: str(data.description) ?? "", prompt: body.trim() };
|
|
213
|
-
if (data.tools)
|
|
214
|
-
def.tools = Array.isArray(data.tools) ? data.tools : String(data.tools).split(",").map((s) => s.trim()).filter(Boolean);
|
|
215
|
-
if (data.model) def.model = str(data.model);
|
|
216
|
-
byName.set(name, def);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
return [...byName.values()];
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
// src/tools/ignore.ts
|
|
223
|
-
import { readFileSync as readFileSync3 } from "fs";
|
|
224
|
-
import { join as join3 } from "path";
|
|
225
|
-
function ignorePatterns(root) {
|
|
226
|
-
const patterns = ["**/node_modules/**", "**/.git/**"];
|
|
227
|
-
let lines = [];
|
|
228
|
-
try {
|
|
229
|
-
lines = readFileSync3(join3(root, ".gitignore"), "utf8").split(/\r?\n/);
|
|
230
|
-
} catch {
|
|
231
|
-
return patterns;
|
|
232
|
-
}
|
|
233
|
-
for (const raw of lines) {
|
|
234
|
-
const line = raw.trim();
|
|
235
|
-
if (!line || line.startsWith("#") || line.startsWith("!")) continue;
|
|
236
|
-
const p = line.replace(/^\//, "").replace(/\/$/, "");
|
|
237
|
-
patterns.push(`**/${p}`, `**/${p}/**`);
|
|
238
|
-
}
|
|
239
|
-
return patterns;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
export {
|
|
243
|
-
toolLabel,
|
|
244
|
-
runPrint,
|
|
245
|
-
ignorePatterns,
|
|
246
|
-
BUILTIN_AGENTS,
|
|
247
|
-
instructionPaths,
|
|
248
|
-
buildSystemPrompt,
|
|
249
|
-
parseFrontmatter,
|
|
250
|
-
loadSkills,
|
|
251
|
-
loadCommands,
|
|
252
|
-
loadAgentDefs
|
|
253
|
-
};
|