@botconnector/bccli 0.3.0-beta.2 → 0.4.0-beta.1
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 +30 -1
- package/dist/{args-EVIFNGPQ.js → args-EAKPBBGX.js} +2 -2
- package/dist/{chunk-MANM7HY6.js → chunk-5ISYVAXI.js} +19 -1
- package/dist/{chunk-5XN44Q55.js → chunk-ELML4KVQ.js} +7 -1
- package/dist/{chunk-RDQ7HPWS.js → chunk-M7INIL2C.js} +1 -1
- package/dist/chunk-OSWQPSA4.js +252 -0
- package/dist/{chunk-E4BWUMQ2.js → chunk-QH7XXNHU.js} +2 -2
- package/dist/cli.js +121 -106
- package/dist/{login-IXJD5O7Z.js → login-FTMR64IA.js} +1 -1
- package/dist/{providerCli-7QNAYIFT.js → providerCli-SJRCBSRE.js} +1 -1
- package/dist/{ui-HNIC4DQ6.js → ui-LWZ75D7H.js} +538 -157
- package/package.json +1 -1
- package/dist/chunk-TBPPXOOZ.js +0 -165
package/package.json
CHANGED
package/dist/chunk-TBPPXOOZ.js
DELETED
|
@@ -1,165 +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/extensions.ts
|
|
62
|
-
import { existsSync, readdirSync, readFileSync, statSync } from "fs";
|
|
63
|
-
import { basename, join } from "path";
|
|
64
|
-
function parseFrontmatter(text) {
|
|
65
|
-
const match = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?/.exec(text);
|
|
66
|
-
if (!match) return { data: {}, body: text };
|
|
67
|
-
const data = {};
|
|
68
|
-
for (const line of match[1].split(/\r?\n/)) {
|
|
69
|
-
const kv = /^([A-Za-z0-9_-]+):\s*(.*)$/.exec(line);
|
|
70
|
-
if (!kv) continue;
|
|
71
|
-
let value = kv[2].trim();
|
|
72
|
-
if (value.startsWith("[") && value.endsWith("]")) {
|
|
73
|
-
data[kv[1]] = value.slice(1, -1).split(",").map((s) => s.trim().replace(/^["']|["']$/g, "")).filter(Boolean);
|
|
74
|
-
continue;
|
|
75
|
-
}
|
|
76
|
-
if (/^(["']).*\1$/.test(value)) value = value.slice(1, -1);
|
|
77
|
-
data[kv[1]] = value;
|
|
78
|
-
}
|
|
79
|
-
return { data, body: text.slice(match[0].length) };
|
|
80
|
-
}
|
|
81
|
-
var str = (v) => Array.isArray(v) ? v.join(", ") : v;
|
|
82
|
-
function dirs(r, kind) {
|
|
83
|
-
return [join(r.userHome, ".claude", kind), join(r.home, kind), join(r.cwd, ".claude", kind), join(r.cwd, ".bccli", kind)];
|
|
84
|
-
}
|
|
85
|
-
function list(dir) {
|
|
86
|
-
try {
|
|
87
|
-
return readdirSync(dir).sort();
|
|
88
|
-
} catch {
|
|
89
|
-
return [];
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
function loadSkills(r) {
|
|
93
|
-
const byName = /* @__PURE__ */ new Map();
|
|
94
|
-
for (const dir of dirs(r, "skills")) {
|
|
95
|
-
for (const entry of list(dir)) {
|
|
96
|
-
const file = join(dir, entry, "SKILL.md");
|
|
97
|
-
if (!existsSync(file)) continue;
|
|
98
|
-
const { data } = parseFrontmatter(readFileSync(file, "utf8"));
|
|
99
|
-
const name = str(data.name) || entry;
|
|
100
|
-
byName.set(name, { name, description: str(data.description) ?? "", dir: join(dir, entry), file });
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
return [...byName.values()];
|
|
104
|
-
}
|
|
105
|
-
function loadCommands(r) {
|
|
106
|
-
const byName = /* @__PURE__ */ new Map();
|
|
107
|
-
for (const dir of dirs(r, "commands")) {
|
|
108
|
-
for (const entry of list(dir)) {
|
|
109
|
-
const file = join(dir, entry);
|
|
110
|
-
if (!entry.endsWith(".md") || !statSync(file).isFile()) continue;
|
|
111
|
-
const { data, body } = parseFrontmatter(readFileSync(file, "utf8"));
|
|
112
|
-
const def = { name: basename(entry, ".md"), body: body.trim() };
|
|
113
|
-
if (data.description) def.description = str(data.description);
|
|
114
|
-
if (data["argument-hint"]) def.argumentHint = str(data["argument-hint"]);
|
|
115
|
-
byName.set(def.name, def);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
return [...byName.values()];
|
|
119
|
-
}
|
|
120
|
-
function loadAgentDefs(r) {
|
|
121
|
-
const byName = /* @__PURE__ */ new Map();
|
|
122
|
-
for (const dir of dirs(r, "agents")) {
|
|
123
|
-
for (const entry of list(dir)) {
|
|
124
|
-
if (!entry.endsWith(".md")) continue;
|
|
125
|
-
const { data, body } = parseFrontmatter(readFileSync(join(dir, entry), "utf8"));
|
|
126
|
-
const name = str(data.name) || basename(entry, ".md");
|
|
127
|
-
const def = { name, description: str(data.description) ?? "", prompt: body.trim() };
|
|
128
|
-
if (data.tools)
|
|
129
|
-
def.tools = Array.isArray(data.tools) ? data.tools : String(data.tools).split(",").map((s) => s.trim()).filter(Boolean);
|
|
130
|
-
if (data.model) def.model = str(data.model);
|
|
131
|
-
byName.set(name, def);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
return [...byName.values()];
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// src/tools/ignore.ts
|
|
138
|
-
import { readFileSync as readFileSync2 } from "fs";
|
|
139
|
-
import { join as join2 } from "path";
|
|
140
|
-
function ignorePatterns(root) {
|
|
141
|
-
const patterns = ["**/node_modules/**", "**/.git/**"];
|
|
142
|
-
let lines = [];
|
|
143
|
-
try {
|
|
144
|
-
lines = readFileSync2(join2(root, ".gitignore"), "utf8").split(/\r?\n/);
|
|
145
|
-
} catch {
|
|
146
|
-
return patterns;
|
|
147
|
-
}
|
|
148
|
-
for (const raw of lines) {
|
|
149
|
-
const line = raw.trim();
|
|
150
|
-
if (!line || line.startsWith("#") || line.startsWith("!")) continue;
|
|
151
|
-
const p = line.replace(/^\//, "").replace(/\/$/, "");
|
|
152
|
-
patterns.push(`**/${p}`, `**/${p}/**`);
|
|
153
|
-
}
|
|
154
|
-
return patterns;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
export {
|
|
158
|
-
toolLabel,
|
|
159
|
-
runPrint,
|
|
160
|
-
ignorePatterns,
|
|
161
|
-
parseFrontmatter,
|
|
162
|
-
loadSkills,
|
|
163
|
-
loadCommands,
|
|
164
|
-
loadAgentDefs
|
|
165
|
-
};
|