@bgicli/bgicli 2.2.3 → 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.
Files changed (2) hide show
  1. package/dist/bgi.js +19 -6
  2. 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 out = (0, import_child_process.execSync)(command, {
13780
+ const buf = (0, import_child_process.execSync)(command, {
13768
13781
  cwd: workdir ?? process.cwd(),
13769
13782
  timeout: timeoutMs,
13770
- encoding: "utf8",
13783
+ encoding: "buffer",
13771
13784
  stdio: ["pipe", "pipe", "pipe"],
13772
- maxBuffer: 10 * 1024 * 1024
13773
- // 10 MB
13785
+ maxBuffer: 10 * 1024 * 1024,
13786
+ env: { ...process.env, PYTHONIOENCODING: "utf-8" }
13774
13787
  });
13775
- return { output: out.trim() };
13788
+ return { output: decodeBuffer(buf).trim() };
13776
13789
  } catch (err) {
13777
13790
  const e2 = err;
13778
- const out = ((e2.stdout ?? "") + "\n" + (e2.stderr ?? "")).trim();
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bgicli/bgicli",
3
- "version": "2.2.3",
3
+ "version": "2.2.4",
4
4
  "description": "BGI CLI — Bioinformatics AI terminal for Chinese researchers (百炼/DeepSeek/Kimi/Qwen)",
5
5
  "bin": {
6
6
  "bgi": "dist/bgi.js"