@bgicli/bgicli 2.6.0 → 2.7.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/dist/bgi.js +36 -33
- package/dist/bio.js +36 -33
- package/dist/mbp.js +36 -33
- package/package.json +1 -1
package/dist/bgi.js
CHANGED
|
@@ -13603,14 +13603,14 @@ var DEFAULT_PROVIDER = "bailian";
|
|
|
13603
13603
|
// src/config.ts
|
|
13604
13604
|
var BGI_DIR = (0, import_path2.join)((0, import_os.homedir)(), ".bgicli");
|
|
13605
13605
|
var TOOLS_DIR = (0, import_path2.join)(BGI_DIR, "tools");
|
|
13606
|
-
var
|
|
13606
|
+
var BIO_SKILLS_DIR = (0, import_path2.join)(BGI_DIR, "bio-skills");
|
|
13607
|
+
var SKILLS_DIR = BIO_SKILLS_DIR;
|
|
13607
13608
|
var USER_SKILLS_DIR = (0, import_path2.join)(BGI_DIR, "user-skills");
|
|
13608
|
-
var CUSTOM_SKILLS_DIR = (0, import_path2.join)(BGI_DIR, "custom-skills");
|
|
13609
13609
|
var DATABASES_FILE = (0, import_path2.join)(BGI_DIR, "databases.json");
|
|
13610
13610
|
var DATA_VERSION_FILE = (0, import_path2.join)(BGI_DIR, ".data-version");
|
|
13611
13611
|
var CONFIG_FILE = (0, import_path2.join)(BGI_DIR, "config.json");
|
|
13612
13612
|
function ensureDirs() {
|
|
13613
|
-
for (const dir of [BGI_DIR, TOOLS_DIR,
|
|
13613
|
+
for (const dir of [BGI_DIR, TOOLS_DIR, BIO_SKILLS_DIR, USER_SKILLS_DIR]) {
|
|
13614
13614
|
if (!(0, import_fs2.existsSync)(dir)) (0, import_fs2.mkdirSync)(dir, { recursive: true });
|
|
13615
13615
|
}
|
|
13616
13616
|
}
|
|
@@ -17200,7 +17200,7 @@ function clearCheckpoints(sessionId) {
|
|
|
17200
17200
|
|
|
17201
17201
|
// src/index.ts
|
|
17202
17202
|
var import_fs7 = require("fs");
|
|
17203
|
-
var VERSION2 = "2.
|
|
17203
|
+
var VERSION2 = "2.7.1";
|
|
17204
17204
|
var BRAND2 = "bgi".toLowerCase();
|
|
17205
17205
|
var SKILLHUB_HUBS = {
|
|
17206
17206
|
bgi: { label: "BGI\u5185\u7F51", apiBase: "https://clawhub.ai", backend: "clawhub" },
|
|
@@ -17357,7 +17357,7 @@ function installBundledData() {
|
|
|
17357
17357
|
try {
|
|
17358
17358
|
for (const entry of (0, import_fs6.readdirSync)(legacyWorkflowsDir)) {
|
|
17359
17359
|
const src = (0, import_path6.join)(legacyWorkflowsDir, entry);
|
|
17360
|
-
const dest = (0, import_path6.join)(
|
|
17360
|
+
const dest = (0, import_path6.join)(BIO_SKILLS_DIR, entry);
|
|
17361
17361
|
if ((0, import_fs6.statSync)(src).isDirectory() && !(0, import_fs6.existsSync)(dest)) {
|
|
17362
17362
|
(0, import_fs6.cpSync)(src, dest, { recursive: true });
|
|
17363
17363
|
}
|
|
@@ -17366,10 +17366,18 @@ function installBundledData() {
|
|
|
17366
17366
|
} catch {
|
|
17367
17367
|
}
|
|
17368
17368
|
}
|
|
17369
|
+
const legacySkillsDir = (0, import_path6.join)(BGI_DIR, "skills");
|
|
17370
|
+
if ((0, import_fs6.existsSync)(legacySkillsDir) && !(0, import_fs6.existsSync)(BIO_SKILLS_DIR)) {
|
|
17371
|
+
try {
|
|
17372
|
+
(0, import_fs6.cpSync)(legacySkillsDir, BIO_SKILLS_DIR, { recursive: true });
|
|
17373
|
+
(0, import_fs6.rmSync)(legacySkillsDir, { recursive: true, force: true });
|
|
17374
|
+
} catch {
|
|
17375
|
+
}
|
|
17376
|
+
}
|
|
17369
17377
|
const installedDataVersion = (0, import_fs6.existsSync)(DATA_VERSION_FILE) ? (0, import_fs6.readFileSync)(DATA_VERSION_FILE, "utf8").trim() : "";
|
|
17370
17378
|
const needsUpdate = installedDataVersion !== VERSION2;
|
|
17371
17379
|
const targets = [
|
|
17372
|
-
{ src: (0, import_path6.join)(bundledData, "skills"), dest:
|
|
17380
|
+
{ src: (0, import_path6.join)(bundledData, "skills"), dest: BIO_SKILLS_DIR, name: "\u751F\u7269\u4FE1\u606F Skills" },
|
|
17373
17381
|
{ src: (0, import_path6.join)(bundledData, "tools"), dest: TOOLS_DIR, name: "\u5DE5\u5177" }
|
|
17374
17382
|
];
|
|
17375
17383
|
let installed = false;
|
|
@@ -17590,9 +17598,8 @@ function collectAllSkills() {
|
|
|
17590
17598
|
}
|
|
17591
17599
|
});
|
|
17592
17600
|
};
|
|
17593
|
-
addFrom(
|
|
17601
|
+
addFrom(BIO_SKILLS_DIR, "bio");
|
|
17594
17602
|
addFrom(USER_SKILLS_DIR, "downloaded");
|
|
17595
|
-
addFrom(CUSTOM_SKILLS_DIR, "custom");
|
|
17596
17603
|
return entries;
|
|
17597
17604
|
}
|
|
17598
17605
|
function listSkills(keyword) {
|
|
@@ -18500,7 +18507,7 @@ ${paramSummary}
|
|
|
18500
18507
|
console.log("\u7528\u6CD5: /uninstall <skill-id>");
|
|
18501
18508
|
break;
|
|
18502
18509
|
}
|
|
18503
|
-
const uninstallPath = (0,
|
|
18510
|
+
const uninstallPath = (0, import_path6.join)(USER_SKILLS_DIR, arg);
|
|
18504
18511
|
if (!(0, import_fs6.existsSync)(uninstallPath)) {
|
|
18505
18512
|
console.log(source_default.red(`\u672A\u627E\u5230\u5DF2\u5B89\u88C5\u7684 Skill: ${arg}`));
|
|
18506
18513
|
console.log(source_default.dim("\u6CE8\u610F: \u53EA\u80FD\u5378\u8F7D\u901A\u8FC7 /install \u5B89\u88C5\u7684\u7B2C\u4E09\u65B9 Skill"));
|
|
@@ -18889,18 +18896,6 @@ ${summary}` },
|
|
|
18889
18896
|
console.log(source_default.dim(` \u2026 \u8FD8\u6709 ${downloaded.length - 10} \u4E2A\uFF0C\u4F7F\u7528 /sk <\u5173\u952E\u8BCD> \u641C\u7D22`));
|
|
18890
18897
|
}
|
|
18891
18898
|
console.log();
|
|
18892
|
-
const custom = allInstalled.filter((e2) => e2.tag === "custom");
|
|
18893
|
-
console.log(` \u270F\uFE0F ${source_default.bold("\u81EA\u5B9A\u4E49 Skills")} ${source_default.dim(`(${custom.length} \u4E2A\uFF0C\u653E\u5165 ${CUSTOM_SKILLS_DIR} \u9700\u6FC0\u6D3B)`)}`);
|
|
18894
|
-
if (custom.length === 0) {
|
|
18895
|
-
console.log(source_default.dim(` \u6682\u65E0\uFF0C\u5728 ${CUSTOM_SKILLS_DIR}/<skill-id>/SKILL.md \u521B\u5EFA`));
|
|
18896
|
-
} else {
|
|
18897
|
-
for (const e2 of custom) {
|
|
18898
|
-
const skillPath = (0, import_path6.join)(e2.dir, e2.id, "SKILL.md");
|
|
18899
|
-
const name = (0, import_fs6.existsSync)(skillPath) ? parseSkillMeta((0, import_fs6.readFileSync)(skillPath, "utf8")).name || e2.id : e2.id;
|
|
18900
|
-
console.log(` ${source_default.white(e2.id)} ${source_default.dim("\u2014 " + name)}`);
|
|
18901
|
-
}
|
|
18902
|
-
}
|
|
18903
|
-
console.log();
|
|
18904
18899
|
break;
|
|
18905
18900
|
}
|
|
18906
18901
|
case "pin": {
|
|
@@ -19376,20 +19371,29 @@ ${expanded}` : expanded;
|
|
|
19376
19371
|
try {
|
|
19377
19372
|
const currentCfg = loadConfig();
|
|
19378
19373
|
currentAbortController = new AbortController();
|
|
19379
|
-
const
|
|
19380
|
-
const
|
|
19374
|
+
const roundT0 = Date.now();
|
|
19375
|
+
const tokensBefore = { in: sessionStats.inputTokens, out: sessionStats.outputTokens };
|
|
19381
19376
|
const reply = await chat(history, currentCfg, systemPrompt, sessionStats, currentAbortController.signal);
|
|
19382
19377
|
currentAbortController = null;
|
|
19383
|
-
if (
|
|
19384
|
-
const elapsedMs = Date.now() -
|
|
19385
|
-
const dIn = sessionStats.inputTokens -
|
|
19386
|
-
const dOut = sessionStats.outputTokens -
|
|
19378
|
+
if (reply) {
|
|
19379
|
+
const elapsedMs = Date.now() - roundT0;
|
|
19380
|
+
const dIn = sessionStats.inputTokens - tokensBefore.in;
|
|
19381
|
+
const dOut = sessionStats.outputTokens - tokensBefore.out;
|
|
19382
|
+
const elapsed = (elapsedMs / 1e3).toFixed(2);
|
|
19383
|
+
console.log(
|
|
19384
|
+
source_default.dim(`
|
|
19385
|
+
\u23F1 ${elapsed}s`) + source_default.dim(" \xB7 ") + source_default.dim(`\u2191 ${dIn}`) + source_default.dim(" ") + source_default.dim(`\u2193 ${dOut} tokens`)
|
|
19386
|
+
);
|
|
19387
|
+
}
|
|
19388
|
+
if (debugMode && reply) {
|
|
19389
|
+
const elapsedMs = Date.now() - roundT0;
|
|
19390
|
+
const dIn = sessionStats.inputTokens - tokensBefore.in;
|
|
19391
|
+
const dOut = sessionStats.outputTokens - tokensBefore.out;
|
|
19387
19392
|
try {
|
|
19388
19393
|
appendDebugRound(systemPrompt, history, reply, elapsedMs, dIn, dOut);
|
|
19389
19394
|
} catch {
|
|
19390
19395
|
}
|
|
19391
|
-
console.log(source_default.bold.yellow(`
|
|
19392
|
-
[DEBUG] \u5DF2\u8BB0\u5F55 \u2192 ${debugFilePath}`));
|
|
19396
|
+
console.log(source_default.bold.yellow(` [DEBUG] \u5DF2\u8BB0\u5F55 \u2192 ${debugFilePath}`));
|
|
19393
19397
|
}
|
|
19394
19398
|
if (!reply && history[history.length - 1]?.role === "user") {
|
|
19395
19399
|
history.pop();
|
|
@@ -19404,10 +19408,9 @@ ${expanded}` : expanded;
|
|
|
19404
19408
|
saveCheckpoint(sessionId, label, history, Array.from(injectedSkills.keys()));
|
|
19405
19409
|
lastCheckpointMsgCount = history.length;
|
|
19406
19410
|
}
|
|
19407
|
-
|
|
19408
|
-
|
|
19409
|
-
console.log(source_default.dim(`
|
|
19410
|
-
[\u6FC0\u6D3B Skill: ${ids}]`));
|
|
19411
|
+
const activeNonPerm = Array.from(injectedSkills.keys()).filter((id) => !permanentSkillIds.has(id));
|
|
19412
|
+
if (activeNonPerm.length > 0) {
|
|
19413
|
+
console.log(source_default.dim(` [\u6FC0\u6D3B Skill: ${activeNonPerm.join(" \xB7 ")}]`));
|
|
19411
19414
|
}
|
|
19412
19415
|
} catch (err) {
|
|
19413
19416
|
currentAbortController = null;
|
package/dist/bio.js
CHANGED
|
@@ -13603,14 +13603,14 @@ var DEFAULT_PROVIDER = "bailian";
|
|
|
13603
13603
|
// src/config.ts
|
|
13604
13604
|
var BGI_DIR = (0, import_path2.join)((0, import_os.homedir)(), ".bgicli");
|
|
13605
13605
|
var TOOLS_DIR = (0, import_path2.join)(BGI_DIR, "tools");
|
|
13606
|
-
var
|
|
13606
|
+
var BIO_SKILLS_DIR = (0, import_path2.join)(BGI_DIR, "bio-skills");
|
|
13607
|
+
var SKILLS_DIR = BIO_SKILLS_DIR;
|
|
13607
13608
|
var USER_SKILLS_DIR = (0, import_path2.join)(BGI_DIR, "user-skills");
|
|
13608
|
-
var CUSTOM_SKILLS_DIR = (0, import_path2.join)(BGI_DIR, "custom-skills");
|
|
13609
13609
|
var DATABASES_FILE = (0, import_path2.join)(BGI_DIR, "databases.json");
|
|
13610
13610
|
var DATA_VERSION_FILE = (0, import_path2.join)(BGI_DIR, ".data-version");
|
|
13611
13611
|
var CONFIG_FILE = (0, import_path2.join)(BGI_DIR, "config.json");
|
|
13612
13612
|
function ensureDirs() {
|
|
13613
|
-
for (const dir of [BGI_DIR, TOOLS_DIR,
|
|
13613
|
+
for (const dir of [BGI_DIR, TOOLS_DIR, BIO_SKILLS_DIR, USER_SKILLS_DIR]) {
|
|
13614
13614
|
if (!(0, import_fs2.existsSync)(dir)) (0, import_fs2.mkdirSync)(dir, { recursive: true });
|
|
13615
13615
|
}
|
|
13616
13616
|
}
|
|
@@ -17200,7 +17200,7 @@ function clearCheckpoints(sessionId) {
|
|
|
17200
17200
|
|
|
17201
17201
|
// src/index.ts
|
|
17202
17202
|
var import_fs7 = require("fs");
|
|
17203
|
-
var VERSION2 = "2.
|
|
17203
|
+
var VERSION2 = "2.7.1";
|
|
17204
17204
|
var BRAND2 = "bio".toLowerCase();
|
|
17205
17205
|
var SKILLHUB_HUBS = {
|
|
17206
17206
|
bgi: { label: "BGI\u5185\u7F51", apiBase: "https://clawhub.ai", backend: "clawhub" },
|
|
@@ -17357,7 +17357,7 @@ function installBundledData() {
|
|
|
17357
17357
|
try {
|
|
17358
17358
|
for (const entry of (0, import_fs6.readdirSync)(legacyWorkflowsDir)) {
|
|
17359
17359
|
const src = (0, import_path6.join)(legacyWorkflowsDir, entry);
|
|
17360
|
-
const dest = (0, import_path6.join)(
|
|
17360
|
+
const dest = (0, import_path6.join)(BIO_SKILLS_DIR, entry);
|
|
17361
17361
|
if ((0, import_fs6.statSync)(src).isDirectory() && !(0, import_fs6.existsSync)(dest)) {
|
|
17362
17362
|
(0, import_fs6.cpSync)(src, dest, { recursive: true });
|
|
17363
17363
|
}
|
|
@@ -17366,10 +17366,18 @@ function installBundledData() {
|
|
|
17366
17366
|
} catch {
|
|
17367
17367
|
}
|
|
17368
17368
|
}
|
|
17369
|
+
const legacySkillsDir = (0, import_path6.join)(BGI_DIR, "skills");
|
|
17370
|
+
if ((0, import_fs6.existsSync)(legacySkillsDir) && !(0, import_fs6.existsSync)(BIO_SKILLS_DIR)) {
|
|
17371
|
+
try {
|
|
17372
|
+
(0, import_fs6.cpSync)(legacySkillsDir, BIO_SKILLS_DIR, { recursive: true });
|
|
17373
|
+
(0, import_fs6.rmSync)(legacySkillsDir, { recursive: true, force: true });
|
|
17374
|
+
} catch {
|
|
17375
|
+
}
|
|
17376
|
+
}
|
|
17369
17377
|
const installedDataVersion = (0, import_fs6.existsSync)(DATA_VERSION_FILE) ? (0, import_fs6.readFileSync)(DATA_VERSION_FILE, "utf8").trim() : "";
|
|
17370
17378
|
const needsUpdate = installedDataVersion !== VERSION2;
|
|
17371
17379
|
const targets = [
|
|
17372
|
-
{ src: (0, import_path6.join)(bundledData, "skills"), dest:
|
|
17380
|
+
{ src: (0, import_path6.join)(bundledData, "skills"), dest: BIO_SKILLS_DIR, name: "\u751F\u7269\u4FE1\u606F Skills" },
|
|
17373
17381
|
{ src: (0, import_path6.join)(bundledData, "tools"), dest: TOOLS_DIR, name: "\u5DE5\u5177" }
|
|
17374
17382
|
];
|
|
17375
17383
|
let installed = false;
|
|
@@ -17590,9 +17598,8 @@ function collectAllSkills() {
|
|
|
17590
17598
|
}
|
|
17591
17599
|
});
|
|
17592
17600
|
};
|
|
17593
|
-
addFrom(
|
|
17601
|
+
addFrom(BIO_SKILLS_DIR, "bio");
|
|
17594
17602
|
addFrom(USER_SKILLS_DIR, "downloaded");
|
|
17595
|
-
addFrom(CUSTOM_SKILLS_DIR, "custom");
|
|
17596
17603
|
return entries;
|
|
17597
17604
|
}
|
|
17598
17605
|
function listSkills(keyword) {
|
|
@@ -18500,7 +18507,7 @@ ${paramSummary}
|
|
|
18500
18507
|
console.log("\u7528\u6CD5: /uninstall <skill-id>");
|
|
18501
18508
|
break;
|
|
18502
18509
|
}
|
|
18503
|
-
const uninstallPath = (0,
|
|
18510
|
+
const uninstallPath = (0, import_path6.join)(USER_SKILLS_DIR, arg);
|
|
18504
18511
|
if (!(0, import_fs6.existsSync)(uninstallPath)) {
|
|
18505
18512
|
console.log(source_default.red(`\u672A\u627E\u5230\u5DF2\u5B89\u88C5\u7684 Skill: ${arg}`));
|
|
18506
18513
|
console.log(source_default.dim("\u6CE8\u610F: \u53EA\u80FD\u5378\u8F7D\u901A\u8FC7 /install \u5B89\u88C5\u7684\u7B2C\u4E09\u65B9 Skill"));
|
|
@@ -18889,18 +18896,6 @@ ${summary}` },
|
|
|
18889
18896
|
console.log(source_default.dim(` \u2026 \u8FD8\u6709 ${downloaded.length - 10} \u4E2A\uFF0C\u4F7F\u7528 /sk <\u5173\u952E\u8BCD> \u641C\u7D22`));
|
|
18890
18897
|
}
|
|
18891
18898
|
console.log();
|
|
18892
|
-
const custom = allInstalled.filter((e2) => e2.tag === "custom");
|
|
18893
|
-
console.log(` \u270F\uFE0F ${source_default.bold("\u81EA\u5B9A\u4E49 Skills")} ${source_default.dim(`(${custom.length} \u4E2A\uFF0C\u653E\u5165 ${CUSTOM_SKILLS_DIR} \u9700\u6FC0\u6D3B)`)}`);
|
|
18894
|
-
if (custom.length === 0) {
|
|
18895
|
-
console.log(source_default.dim(` \u6682\u65E0\uFF0C\u5728 ${CUSTOM_SKILLS_DIR}/<skill-id>/SKILL.md \u521B\u5EFA`));
|
|
18896
|
-
} else {
|
|
18897
|
-
for (const e2 of custom) {
|
|
18898
|
-
const skillPath = (0, import_path6.join)(e2.dir, e2.id, "SKILL.md");
|
|
18899
|
-
const name = (0, import_fs6.existsSync)(skillPath) ? parseSkillMeta((0, import_fs6.readFileSync)(skillPath, "utf8")).name || e2.id : e2.id;
|
|
18900
|
-
console.log(` ${source_default.white(e2.id)} ${source_default.dim("\u2014 " + name)}`);
|
|
18901
|
-
}
|
|
18902
|
-
}
|
|
18903
|
-
console.log();
|
|
18904
18899
|
break;
|
|
18905
18900
|
}
|
|
18906
18901
|
case "pin": {
|
|
@@ -19376,20 +19371,29 @@ ${expanded}` : expanded;
|
|
|
19376
19371
|
try {
|
|
19377
19372
|
const currentCfg = loadConfig();
|
|
19378
19373
|
currentAbortController = new AbortController();
|
|
19379
|
-
const
|
|
19380
|
-
const
|
|
19374
|
+
const roundT0 = Date.now();
|
|
19375
|
+
const tokensBefore = { in: sessionStats.inputTokens, out: sessionStats.outputTokens };
|
|
19381
19376
|
const reply = await chat(history, currentCfg, systemPrompt, sessionStats, currentAbortController.signal);
|
|
19382
19377
|
currentAbortController = null;
|
|
19383
|
-
if (
|
|
19384
|
-
const elapsedMs = Date.now() -
|
|
19385
|
-
const dIn = sessionStats.inputTokens -
|
|
19386
|
-
const dOut = sessionStats.outputTokens -
|
|
19378
|
+
if (reply) {
|
|
19379
|
+
const elapsedMs = Date.now() - roundT0;
|
|
19380
|
+
const dIn = sessionStats.inputTokens - tokensBefore.in;
|
|
19381
|
+
const dOut = sessionStats.outputTokens - tokensBefore.out;
|
|
19382
|
+
const elapsed = (elapsedMs / 1e3).toFixed(2);
|
|
19383
|
+
console.log(
|
|
19384
|
+
source_default.dim(`
|
|
19385
|
+
\u23F1 ${elapsed}s`) + source_default.dim(" \xB7 ") + source_default.dim(`\u2191 ${dIn}`) + source_default.dim(" ") + source_default.dim(`\u2193 ${dOut} tokens`)
|
|
19386
|
+
);
|
|
19387
|
+
}
|
|
19388
|
+
if (debugMode && reply) {
|
|
19389
|
+
const elapsedMs = Date.now() - roundT0;
|
|
19390
|
+
const dIn = sessionStats.inputTokens - tokensBefore.in;
|
|
19391
|
+
const dOut = sessionStats.outputTokens - tokensBefore.out;
|
|
19387
19392
|
try {
|
|
19388
19393
|
appendDebugRound(systemPrompt, history, reply, elapsedMs, dIn, dOut);
|
|
19389
19394
|
} catch {
|
|
19390
19395
|
}
|
|
19391
|
-
console.log(source_default.bold.yellow(`
|
|
19392
|
-
[DEBUG] \u5DF2\u8BB0\u5F55 \u2192 ${debugFilePath}`));
|
|
19396
|
+
console.log(source_default.bold.yellow(` [DEBUG] \u5DF2\u8BB0\u5F55 \u2192 ${debugFilePath}`));
|
|
19393
19397
|
}
|
|
19394
19398
|
if (!reply && history[history.length - 1]?.role === "user") {
|
|
19395
19399
|
history.pop();
|
|
@@ -19404,10 +19408,9 @@ ${expanded}` : expanded;
|
|
|
19404
19408
|
saveCheckpoint(sessionId, label, history, Array.from(injectedSkills.keys()));
|
|
19405
19409
|
lastCheckpointMsgCount = history.length;
|
|
19406
19410
|
}
|
|
19407
|
-
|
|
19408
|
-
|
|
19409
|
-
console.log(source_default.dim(`
|
|
19410
|
-
[\u6FC0\u6D3B Skill: ${ids}]`));
|
|
19411
|
+
const activeNonPerm = Array.from(injectedSkills.keys()).filter((id) => !permanentSkillIds.has(id));
|
|
19412
|
+
if (activeNonPerm.length > 0) {
|
|
19413
|
+
console.log(source_default.dim(` [\u6FC0\u6D3B Skill: ${activeNonPerm.join(" \xB7 ")}]`));
|
|
19411
19414
|
}
|
|
19412
19415
|
} catch (err) {
|
|
19413
19416
|
currentAbortController = null;
|
package/dist/mbp.js
CHANGED
|
@@ -13603,14 +13603,14 @@ var DEFAULT_PROVIDER = "bailian";
|
|
|
13603
13603
|
// src/config.ts
|
|
13604
13604
|
var BGI_DIR = (0, import_path2.join)((0, import_os.homedir)(), ".bgicli");
|
|
13605
13605
|
var TOOLS_DIR = (0, import_path2.join)(BGI_DIR, "tools");
|
|
13606
|
-
var
|
|
13606
|
+
var BIO_SKILLS_DIR = (0, import_path2.join)(BGI_DIR, "bio-skills");
|
|
13607
|
+
var SKILLS_DIR = BIO_SKILLS_DIR;
|
|
13607
13608
|
var USER_SKILLS_DIR = (0, import_path2.join)(BGI_DIR, "user-skills");
|
|
13608
|
-
var CUSTOM_SKILLS_DIR = (0, import_path2.join)(BGI_DIR, "custom-skills");
|
|
13609
13609
|
var DATABASES_FILE = (0, import_path2.join)(BGI_DIR, "databases.json");
|
|
13610
13610
|
var DATA_VERSION_FILE = (0, import_path2.join)(BGI_DIR, ".data-version");
|
|
13611
13611
|
var CONFIG_FILE = (0, import_path2.join)(BGI_DIR, "config.json");
|
|
13612
13612
|
function ensureDirs() {
|
|
13613
|
-
for (const dir of [BGI_DIR, TOOLS_DIR,
|
|
13613
|
+
for (const dir of [BGI_DIR, TOOLS_DIR, BIO_SKILLS_DIR, USER_SKILLS_DIR]) {
|
|
13614
13614
|
if (!(0, import_fs2.existsSync)(dir)) (0, import_fs2.mkdirSync)(dir, { recursive: true });
|
|
13615
13615
|
}
|
|
13616
13616
|
}
|
|
@@ -17200,7 +17200,7 @@ function clearCheckpoints(sessionId) {
|
|
|
17200
17200
|
|
|
17201
17201
|
// src/index.ts
|
|
17202
17202
|
var import_fs7 = require("fs");
|
|
17203
|
-
var VERSION2 = "2.
|
|
17203
|
+
var VERSION2 = "2.7.1";
|
|
17204
17204
|
var BRAND2 = "mbp".toLowerCase();
|
|
17205
17205
|
var SKILLHUB_HUBS = {
|
|
17206
17206
|
bgi: { label: "BGI\u5185\u7F51", apiBase: "https://clawhub.ai", backend: "clawhub" },
|
|
@@ -17357,7 +17357,7 @@ function installBundledData() {
|
|
|
17357
17357
|
try {
|
|
17358
17358
|
for (const entry of (0, import_fs6.readdirSync)(legacyWorkflowsDir)) {
|
|
17359
17359
|
const src = (0, import_path6.join)(legacyWorkflowsDir, entry);
|
|
17360
|
-
const dest = (0, import_path6.join)(
|
|
17360
|
+
const dest = (0, import_path6.join)(BIO_SKILLS_DIR, entry);
|
|
17361
17361
|
if ((0, import_fs6.statSync)(src).isDirectory() && !(0, import_fs6.existsSync)(dest)) {
|
|
17362
17362
|
(0, import_fs6.cpSync)(src, dest, { recursive: true });
|
|
17363
17363
|
}
|
|
@@ -17366,10 +17366,18 @@ function installBundledData() {
|
|
|
17366
17366
|
} catch {
|
|
17367
17367
|
}
|
|
17368
17368
|
}
|
|
17369
|
+
const legacySkillsDir = (0, import_path6.join)(BGI_DIR, "skills");
|
|
17370
|
+
if ((0, import_fs6.existsSync)(legacySkillsDir) && !(0, import_fs6.existsSync)(BIO_SKILLS_DIR)) {
|
|
17371
|
+
try {
|
|
17372
|
+
(0, import_fs6.cpSync)(legacySkillsDir, BIO_SKILLS_DIR, { recursive: true });
|
|
17373
|
+
(0, import_fs6.rmSync)(legacySkillsDir, { recursive: true, force: true });
|
|
17374
|
+
} catch {
|
|
17375
|
+
}
|
|
17376
|
+
}
|
|
17369
17377
|
const installedDataVersion = (0, import_fs6.existsSync)(DATA_VERSION_FILE) ? (0, import_fs6.readFileSync)(DATA_VERSION_FILE, "utf8").trim() : "";
|
|
17370
17378
|
const needsUpdate = installedDataVersion !== VERSION2;
|
|
17371
17379
|
const targets = [
|
|
17372
|
-
{ src: (0, import_path6.join)(bundledData, "skills"), dest:
|
|
17380
|
+
{ src: (0, import_path6.join)(bundledData, "skills"), dest: BIO_SKILLS_DIR, name: "\u751F\u7269\u4FE1\u606F Skills" },
|
|
17373
17381
|
{ src: (0, import_path6.join)(bundledData, "tools"), dest: TOOLS_DIR, name: "\u5DE5\u5177" }
|
|
17374
17382
|
];
|
|
17375
17383
|
let installed = false;
|
|
@@ -17590,9 +17598,8 @@ function collectAllSkills() {
|
|
|
17590
17598
|
}
|
|
17591
17599
|
});
|
|
17592
17600
|
};
|
|
17593
|
-
addFrom(
|
|
17601
|
+
addFrom(BIO_SKILLS_DIR, "bio");
|
|
17594
17602
|
addFrom(USER_SKILLS_DIR, "downloaded");
|
|
17595
|
-
addFrom(CUSTOM_SKILLS_DIR, "custom");
|
|
17596
17603
|
return entries;
|
|
17597
17604
|
}
|
|
17598
17605
|
function listSkills(keyword) {
|
|
@@ -18500,7 +18507,7 @@ ${paramSummary}
|
|
|
18500
18507
|
console.log("\u7528\u6CD5: /uninstall <skill-id>");
|
|
18501
18508
|
break;
|
|
18502
18509
|
}
|
|
18503
|
-
const uninstallPath = (0,
|
|
18510
|
+
const uninstallPath = (0, import_path6.join)(USER_SKILLS_DIR, arg);
|
|
18504
18511
|
if (!(0, import_fs6.existsSync)(uninstallPath)) {
|
|
18505
18512
|
console.log(source_default.red(`\u672A\u627E\u5230\u5DF2\u5B89\u88C5\u7684 Skill: ${arg}`));
|
|
18506
18513
|
console.log(source_default.dim("\u6CE8\u610F: \u53EA\u80FD\u5378\u8F7D\u901A\u8FC7 /install \u5B89\u88C5\u7684\u7B2C\u4E09\u65B9 Skill"));
|
|
@@ -18889,18 +18896,6 @@ ${summary}` },
|
|
|
18889
18896
|
console.log(source_default.dim(` \u2026 \u8FD8\u6709 ${downloaded.length - 10} \u4E2A\uFF0C\u4F7F\u7528 /sk <\u5173\u952E\u8BCD> \u641C\u7D22`));
|
|
18890
18897
|
}
|
|
18891
18898
|
console.log();
|
|
18892
|
-
const custom = allInstalled.filter((e2) => e2.tag === "custom");
|
|
18893
|
-
console.log(` \u270F\uFE0F ${source_default.bold("\u81EA\u5B9A\u4E49 Skills")} ${source_default.dim(`(${custom.length} \u4E2A\uFF0C\u653E\u5165 ${CUSTOM_SKILLS_DIR} \u9700\u6FC0\u6D3B)`)}`);
|
|
18894
|
-
if (custom.length === 0) {
|
|
18895
|
-
console.log(source_default.dim(` \u6682\u65E0\uFF0C\u5728 ${CUSTOM_SKILLS_DIR}/<skill-id>/SKILL.md \u521B\u5EFA`));
|
|
18896
|
-
} else {
|
|
18897
|
-
for (const e2 of custom) {
|
|
18898
|
-
const skillPath = (0, import_path6.join)(e2.dir, e2.id, "SKILL.md");
|
|
18899
|
-
const name = (0, import_fs6.existsSync)(skillPath) ? parseSkillMeta((0, import_fs6.readFileSync)(skillPath, "utf8")).name || e2.id : e2.id;
|
|
18900
|
-
console.log(` ${source_default.white(e2.id)} ${source_default.dim("\u2014 " + name)}`);
|
|
18901
|
-
}
|
|
18902
|
-
}
|
|
18903
|
-
console.log();
|
|
18904
18899
|
break;
|
|
18905
18900
|
}
|
|
18906
18901
|
case "pin": {
|
|
@@ -19376,20 +19371,29 @@ ${expanded}` : expanded;
|
|
|
19376
19371
|
try {
|
|
19377
19372
|
const currentCfg = loadConfig();
|
|
19378
19373
|
currentAbortController = new AbortController();
|
|
19379
|
-
const
|
|
19380
|
-
const
|
|
19374
|
+
const roundT0 = Date.now();
|
|
19375
|
+
const tokensBefore = { in: sessionStats.inputTokens, out: sessionStats.outputTokens };
|
|
19381
19376
|
const reply = await chat(history, currentCfg, systemPrompt, sessionStats, currentAbortController.signal);
|
|
19382
19377
|
currentAbortController = null;
|
|
19383
|
-
if (
|
|
19384
|
-
const elapsedMs = Date.now() -
|
|
19385
|
-
const dIn = sessionStats.inputTokens -
|
|
19386
|
-
const dOut = sessionStats.outputTokens -
|
|
19378
|
+
if (reply) {
|
|
19379
|
+
const elapsedMs = Date.now() - roundT0;
|
|
19380
|
+
const dIn = sessionStats.inputTokens - tokensBefore.in;
|
|
19381
|
+
const dOut = sessionStats.outputTokens - tokensBefore.out;
|
|
19382
|
+
const elapsed = (elapsedMs / 1e3).toFixed(2);
|
|
19383
|
+
console.log(
|
|
19384
|
+
source_default.dim(`
|
|
19385
|
+
\u23F1 ${elapsed}s`) + source_default.dim(" \xB7 ") + source_default.dim(`\u2191 ${dIn}`) + source_default.dim(" ") + source_default.dim(`\u2193 ${dOut} tokens`)
|
|
19386
|
+
);
|
|
19387
|
+
}
|
|
19388
|
+
if (debugMode && reply) {
|
|
19389
|
+
const elapsedMs = Date.now() - roundT0;
|
|
19390
|
+
const dIn = sessionStats.inputTokens - tokensBefore.in;
|
|
19391
|
+
const dOut = sessionStats.outputTokens - tokensBefore.out;
|
|
19387
19392
|
try {
|
|
19388
19393
|
appendDebugRound(systemPrompt, history, reply, elapsedMs, dIn, dOut);
|
|
19389
19394
|
} catch {
|
|
19390
19395
|
}
|
|
19391
|
-
console.log(source_default.bold.yellow(`
|
|
19392
|
-
[DEBUG] \u5DF2\u8BB0\u5F55 \u2192 ${debugFilePath}`));
|
|
19396
|
+
console.log(source_default.bold.yellow(` [DEBUG] \u5DF2\u8BB0\u5F55 \u2192 ${debugFilePath}`));
|
|
19393
19397
|
}
|
|
19394
19398
|
if (!reply && history[history.length - 1]?.role === "user") {
|
|
19395
19399
|
history.pop();
|
|
@@ -19404,10 +19408,9 @@ ${expanded}` : expanded;
|
|
|
19404
19408
|
saveCheckpoint(sessionId, label, history, Array.from(injectedSkills.keys()));
|
|
19405
19409
|
lastCheckpointMsgCount = history.length;
|
|
19406
19410
|
}
|
|
19407
|
-
|
|
19408
|
-
|
|
19409
|
-
console.log(source_default.dim(`
|
|
19410
|
-
[\u6FC0\u6D3B Skill: ${ids}]`));
|
|
19411
|
+
const activeNonPerm = Array.from(injectedSkills.keys()).filter((id) => !permanentSkillIds.has(id));
|
|
19412
|
+
if (activeNonPerm.length > 0) {
|
|
19413
|
+
console.log(source_default.dim(` [\u6FC0\u6D3B Skill: ${activeNonPerm.join(" \xB7 ")}]`));
|
|
19411
19414
|
}
|
|
19412
19415
|
} catch (err) {
|
|
19413
19416
|
currentAbortController = null;
|