@bgicli/bgicli 2.2.2 → 2.2.4
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/dist/bgi.js +46 -13
- package/package.json +1 -1
package/dist/bgi.js
CHANGED
|
@@ -13762,20 +13762,33 @@ function executeTool(name, args) {
|
|
|
13762
13762
|
return { output: "", error: String(err) };
|
|
13763
13763
|
}
|
|
13764
13764
|
}
|
|
13765
|
+
function decodeBuffer(buf) {
|
|
13766
|
+
if (!buf) return "";
|
|
13767
|
+
if (typeof buf === "string") return buf;
|
|
13768
|
+
try {
|
|
13769
|
+
return new TextDecoder("utf-8", { fatal: true }).decode(buf);
|
|
13770
|
+
} catch {
|
|
13771
|
+
try {
|
|
13772
|
+
return new TextDecoder("gbk").decode(buf);
|
|
13773
|
+
} catch {
|
|
13774
|
+
return buf.toString("latin1");
|
|
13775
|
+
}
|
|
13776
|
+
}
|
|
13777
|
+
}
|
|
13765
13778
|
function toolBash(command, workdir, timeoutMs = 3e4) {
|
|
13766
13779
|
try {
|
|
13767
|
-
const
|
|
13780
|
+
const buf = (0, import_child_process.execSync)(command, {
|
|
13768
13781
|
cwd: workdir ?? process.cwd(),
|
|
13769
13782
|
timeout: timeoutMs,
|
|
13770
|
-
encoding: "
|
|
13783
|
+
encoding: "buffer",
|
|
13771
13784
|
stdio: ["pipe", "pipe", "pipe"],
|
|
13772
|
-
maxBuffer: 10 * 1024 * 1024
|
|
13773
|
-
|
|
13785
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
13786
|
+
env: { ...process.env, PYTHONIOENCODING: "utf-8" }
|
|
13774
13787
|
});
|
|
13775
|
-
return { output:
|
|
13788
|
+
return { output: decodeBuffer(buf).trim() };
|
|
13776
13789
|
} catch (err) {
|
|
13777
13790
|
const e2 = err;
|
|
13778
|
-
const out = ((e2.stdout
|
|
13791
|
+
const out = (decodeBuffer(e2.stdout) + "\n" + decodeBuffer(e2.stderr)).trim();
|
|
13779
13792
|
return { output: out, error: e2.message ?? String(err) };
|
|
13780
13793
|
}
|
|
13781
13794
|
}
|
|
@@ -15144,14 +15157,34 @@ ${summary}` },
|
|
|
15144
15157
|
case "sk": {
|
|
15145
15158
|
if (!arg) {
|
|
15146
15159
|
listSkills();
|
|
15160
|
+
break;
|
|
15161
|
+
}
|
|
15162
|
+
const allSkills = collectAllSkills();
|
|
15163
|
+
const idMatch = allSkills.find((e2) => e2.id === arg || e2.id.startsWith(arg) || e2.id.includes(arg));
|
|
15164
|
+
if (idMatch) {
|
|
15165
|
+
injectSkill(arg, history);
|
|
15166
|
+
break;
|
|
15167
|
+
}
|
|
15168
|
+
const { routes, topScore } = routeSkill(arg);
|
|
15169
|
+
if (routes.length === 0 || topScore < 4) {
|
|
15170
|
+
listSkills(arg);
|
|
15171
|
+
break;
|
|
15172
|
+
}
|
|
15173
|
+
if (routes.length === 1 || topScore >= 10) {
|
|
15174
|
+
console.log(source_default.dim(`\u6839\u636E\u63CF\u8FF0\u5339\u914D\u5230: ${routes[0].id}`));
|
|
15175
|
+
injectSkill(routes[0].id, history);
|
|
15147
15176
|
} else {
|
|
15148
|
-
|
|
15149
|
-
|
|
15150
|
-
|
|
15151
|
-
|
|
15152
|
-
|
|
15153
|
-
|
|
15154
|
-
|
|
15177
|
+
console.log(source_default.bold(`
|
|
15178
|
+
\u6839\u636E\u63CF\u8FF0\u63A8\u8350\u4EE5\u4E0B Skills:
|
|
15179
|
+
`));
|
|
15180
|
+
routes.forEach((r2, i2) => {
|
|
15181
|
+
const marker = i2 === 0 ? source_default.green("\u25B6") : source_default.dim(" ");
|
|
15182
|
+
console.log(` ${marker} ${source_default.cyan(r2.id)} \u2014 ${r2.name}`);
|
|
15183
|
+
if (i2 > 0) console.log(source_default.dim(` /sk ${r2.id} \u53EF\u6FC0\u6D3B\u6B64\u9879`));
|
|
15184
|
+
});
|
|
15185
|
+
console.log();
|
|
15186
|
+
console.log(source_default.dim("\u5DF2\u81EA\u52A8\u6FC0\u6D3B\u7B2C\u4E00\u4E2A\uFF0C\u5982\u9700\u5207\u6362\u8BF7\u4F7F\u7528\u4E0A\u65B9\u547D\u4EE4"));
|
|
15187
|
+
injectSkill(routes[0].id, history);
|
|
15155
15188
|
}
|
|
15156
15189
|
break;
|
|
15157
15190
|
}
|