@bgicli/bgicli 2.3.1 → 2.3.3

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.
Files changed (2) hide show
  1. package/dist/bgi.js +43 -10
  2. package/package.json +1 -1
package/dist/bgi.js CHANGED
@@ -14006,6 +14006,15 @@ function decodeBuffer(buf) {
14006
14006
  }
14007
14007
  }
14008
14008
  }
14009
+ function injectProgressFlags(cmd) {
14010
+ if (/\bwget\b/.test(cmd) && !/-q\b|--quiet|--show-progress|--progress/.test(cmd)) {
14011
+ cmd = cmd.replace(/\bwget\b/, "wget --show-progress");
14012
+ }
14013
+ if (/\bcurl\b/.test(cmd) && !/-s\b|--silent|-S\b|-#|--progress-bar|--no-progress-meter/.test(cmd)) {
14014
+ cmd = cmd.replace(/\bcurl\b/, "curl --progress-bar");
14015
+ }
14016
+ return cmd;
14017
+ }
14009
14018
  async function toolBash(command, workdir, timeoutMs = 3e5, onStream) {
14010
14019
  const scan = scanCommand(command);
14011
14020
  const criticals = scan.matches.filter((m2) => m2.pattern.level === "CRITICAL");
@@ -14023,11 +14032,19 @@ async function toolBash(command, workdir, timeoutMs = 3e5, onStream) {
14023
14032
  if (onStream) onStream(`\u26A0 \u5B89\u5168\u8B66\u544A [HIGH]: ${reasons}
14024
14033
  `);
14025
14034
  }
14035
+ const processedCommand = injectProgressFlags(command);
14026
14036
  return new Promise((resolve4) => {
14027
14037
  const isWin = process.platform === "win32";
14028
- const child = (0, import_child_process.spawn)(isWin ? "cmd" : "/bin/sh", isWin ? ["/c", command] : ["-c", command], {
14038
+ const child = (0, import_child_process.spawn)(isWin ? "cmd" : "/bin/sh", isWin ? ["/c", processedCommand] : ["-c", processedCommand], {
14029
14039
  cwd: workdir ?? process.cwd(),
14030
- env: { ...process.env, PYTHONIOENCODING: "utf-8" },
14040
+ env: {
14041
+ ...process.env,
14042
+ PYTHONIOENCODING: "utf-8",
14043
+ PYTHONUNBUFFERED: "1",
14044
+ // prevent Python stdout buffering
14045
+ FORCE_COLOR: "1"
14046
+ // hint color support to tools that check
14047
+ },
14031
14048
  stdio: ["pipe", "pipe", "pipe"]
14032
14049
  });
14033
14050
  const outChunks = [];
@@ -14295,12 +14312,22 @@ ${label} `);
14295
14312
  clearInterval(spin);
14296
14313
  process.stdout.write("\r\x1B[2K");
14297
14314
  };
14315
+ let lastChunkTime = t0;
14316
+ let heartbeat = null;
14298
14317
  const onStream = isBash ? (chunk) => {
14318
+ lastChunkTime = Date.now();
14299
14319
  if (streamedLines >= MAX_STREAM_LINES) return;
14300
14320
  if (streamedLines === 0) {
14301
14321
  clearSpinner();
14302
14322
  process.stdout.write(`${label}
14303
14323
  `);
14324
+ heartbeat = setInterval(() => {
14325
+ if (Date.now() - lastChunkTime >= 5e3) {
14326
+ const totalSecs = ((Date.now() - t0) / 1e3).toFixed(0);
14327
+ process.stdout.write(source_default.dim(`
14328
+ \u2502 \u23F1 \u8FD0\u884C\u4E2D... ${totalSecs}s`));
14329
+ }
14330
+ }, 5e3);
14304
14331
  }
14305
14332
  const lines = chunk.split("\n");
14306
14333
  for (let i2 = 0; i2 < lines.length; i2++) {
@@ -14322,6 +14349,10 @@ ${label} `);
14322
14349
  }
14323
14350
  } : void 0;
14324
14351
  const result = await executeTool(tc.name, args, onStream);
14352
+ if (heartbeat) {
14353
+ clearInterval(heartbeat);
14354
+ heartbeat = null;
14355
+ }
14325
14356
  if (stats) {
14326
14357
  if (result.error) stats.failCmds++;
14327
14358
  else stats.successCmds++;
@@ -15910,7 +15941,7 @@ function clearCheckpoints(sessionId) {
15910
15941
 
15911
15942
  // src/index.ts
15912
15943
  var import_fs7 = require("fs");
15913
- var VERSION2 = "2.3.1";
15944
+ var VERSION2 = "2.3.3";
15914
15945
  var SKILLHUB_HUBS = {
15915
15946
  bgi: { label: "BGI\u5185\u7F51", apiBase: "https://clawhub.ai", backend: "clawhub" },
15916
15947
  clawhub: { label: "clawhub.ai", apiBase: "https://clawhub.ai", backend: "clawhub" },
@@ -16051,6 +16082,8 @@ var SESSION_CTX = {
16051
16082
  createdAt: "",
16052
16083
  wdirSnapshot: null
16053
16084
  };
16085
+ var dbRegistry = { version: 1, lastScan: null, databases: {} };
16086
+ var systemPrompt = "";
16054
16087
  function installBundledData() {
16055
16088
  const bundledData = (0, import_path6.join)(__dirname, "..", "data");
16056
16089
  if (!(0, import_fs6.existsSync)(bundledData)) return;
@@ -17580,14 +17613,14 @@ async function main() {
17580
17613
  }
17581
17614
  console.log(source_default.dim(" \u8F93\u5165\u95EE\u9898\u5F00\u59CB\u5BF9\u8BDD /help \u67E5\u770B\u547D\u4EE4 /cat \u6280\u80FD\u5206\u7C7B @\u6587\u4EF6\u8DEF\u5F84 \u5185\u5D4C\u6587\u4EF6"));
17582
17615
  console.log();
17583
- let dbRegistry2 = loadDbRegistry();
17584
- if (Object.keys(dbRegistry2.databases).length === 0) {
17616
+ dbRegistry = loadDbRegistry();
17617
+ if (Object.keys(dbRegistry.databases).length === 0) {
17585
17618
  process.stdout.write(source_default.dim(" \u6B63\u5728\u81EA\u52A8\u626B\u63CF\u53C2\u8003\u6570\u636E\u5E93...\n"));
17586
17619
  const report = scanForDatabases([]);
17587
17620
  if (report.found.length > 0) {
17588
- for (const entry of report.found) dbRegistry2.databases[entry.id] = entry;
17589
- dbRegistry2.lastScan = (/* @__PURE__ */ new Date()).toISOString();
17590
- saveDbRegistry(dbRegistry2);
17621
+ for (const entry of report.found) dbRegistry.databases[entry.id] = entry;
17622
+ dbRegistry.lastScan = (/* @__PURE__ */ new Date()).toISOString();
17623
+ saveDbRegistry(dbRegistry);
17591
17624
  process.stdout.write(source_default.green(` \u2713 \u53D1\u73B0 ${report.found.length} \u4E2A\u6570\u636E\u5E93\uFF0C\u5DF2\u81EA\u52A8\u6CE8\u518C (/db list \u67E5\u770B)
17592
17625
  `));
17593
17626
  } else {
@@ -17595,7 +17628,7 @@ async function main() {
17595
17628
  }
17596
17629
  console.log();
17597
17630
  }
17598
- let systemPrompt2 = buildSystemPrompt(buildDbPromptSection(dbRegistry2));
17631
+ systemPrompt = buildSystemPrompt(buildDbPromptSection(dbRegistry));
17599
17632
  let history = [];
17600
17633
  let thinkMode = false;
17601
17634
  const injectedSkills = /* @__PURE__ */ new Map();
@@ -17766,7 +17799,7 @@ ${expanded}` : expanded;
17766
17799
  try {
17767
17800
  const currentCfg = loadConfig();
17768
17801
  currentAbortController = new AbortController();
17769
- const reply = await chat(history, currentCfg, systemPrompt2, sessionStats, currentAbortController.signal);
17802
+ const reply = await chat(history, currentCfg, systemPrompt, sessionStats, currentAbortController.signal);
17770
17803
  currentAbortController = null;
17771
17804
  if (!reply && history[history.length - 1]?.role === "user") {
17772
17805
  history.pop();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bgicli/bgicli",
3
- "version": "2.3.1",
3
+ "version": "2.3.3",
4
4
  "description": "BGI CLI — Bioinformatics AI terminal for Chinese researchers (百炼/DeepSeek/Kimi/Qwen)",
5
5
  "bin": {
6
6
  "bgi": "dist/bgi.js"