jinzd-ai-cli 0.4.136 → 0.4.138

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.
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  ConfigManager
4
- } from "./chunk-2S27S4DO.js";
4
+ } from "./chunk-SVLXF7ZG.js";
5
5
  import "./chunk-2ZD3YTVM.js";
6
- import "./chunk-DPT5HN3D.js";
6
+ import "./chunk-HB7W44IO.js";
7
7
  import "./chunk-PDX44BCA.js";
8
8
 
9
9
  // src/cli/batch.ts
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/core/constants.ts
4
- var VERSION = "0.4.136";
4
+ var VERSION = "0.4.138";
5
5
  var APP_NAME = "ai-cli";
6
6
  var CONFIG_DIR_NAME = ".aicli";
7
7
  var CONFIG_FILE_NAME = "config.json";
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  CONFIG_DIR_NAME
4
- } from "./chunk-DPT5HN3D.js";
4
+ } from "./chunk-HB7W44IO.js";
5
5
 
6
6
  // src/diagnostics/tool-stats.ts
7
7
  import { existsSync, readFileSync, writeFileSync, mkdirSync, renameSync } from "fs";
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  truncateForPersist
4
- } from "./chunk-6N5IWWPQ.js";
4
+ } from "./chunk-ZE7SHDSI.js";
5
5
  import {
6
6
  APP_NAME,
7
7
  CONFIG_DIR_NAME,
@@ -11,7 +11,7 @@ import {
11
11
  MCP_PROTOCOL_VERSION,
12
12
  MCP_TOOL_PREFIX,
13
13
  VERSION
14
- } from "./chunk-DPT5HN3D.js";
14
+ } from "./chunk-HB7W44IO.js";
15
15
  import {
16
16
  redactJson
17
17
  } from "./chunk-7ZJN4KLV.js";
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  CONFIG_DIR_NAME,
4
4
  VERSION
5
- } from "./chunk-DPT5HN3D.js";
5
+ } from "./chunk-HB7W44IO.js";
6
6
 
7
7
  // src/diagnostics/crash-log.ts
8
8
  import {
@@ -6,7 +6,7 @@ import { platform } from "os";
6
6
  import chalk from "chalk";
7
7
 
8
8
  // src/core/constants.ts
9
- var VERSION = "0.4.136";
9
+ var VERSION = "0.4.138";
10
10
  var APP_NAME = "ai-cli";
11
11
  var CONFIG_DIR_NAME = ".aicli";
12
12
  var CONFIG_FILE_NAME = "config.json";
@@ -8,7 +8,7 @@ import {
8
8
  CONFIG_FILE_NAME,
9
9
  HISTORY_DIR_NAME,
10
10
  PLUGINS_DIR_NAME
11
- } from "./chunk-DPT5HN3D.js";
11
+ } from "./chunk-HB7W44IO.js";
12
12
 
13
13
  // src/config/config-manager.ts
14
14
  import { readFileSync, writeFileSync, existsSync, mkdirSync } from "fs";
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  schemaToJsonSchema
4
- } from "./chunk-STUFQVOX.js";
4
+ } from "./chunk-HFCZNQSW.js";
5
5
  import {
6
6
  AuthError,
7
7
  ProviderError,
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  TEST_TIMEOUT
4
- } from "./chunk-DPT5HN3D.js";
4
+ } from "./chunk-HB7W44IO.js";
5
5
 
6
6
  // src/tools/builtin/run-tests.ts
7
7
  import { execSync, spawnSync } from "child_process";
@@ -5,12 +5,12 @@ import {
5
5
  } from "./chunk-3BICTI5M.js";
6
6
  import {
7
7
  runTestsTool
8
- } from "./chunk-U5YSA4XD.js";
8
+ } from "./chunk-XXFGS2WM.js";
9
9
  import {
10
10
  getDangerLevel,
11
11
  isFileWriteTool,
12
12
  runTool
13
- } from "./chunk-STUFQVOX.js";
13
+ } from "./chunk-HFCZNQSW.js";
14
14
  import {
15
15
  EnvLoader,
16
16
  NetworkError,
@@ -23,7 +23,7 @@ import {
23
23
  SUBAGENT_ALLOWED_TOOLS,
24
24
  SUBAGENT_DEFAULT_MAX_ROUNDS,
25
25
  SUBAGENT_MAX_ROUNDS_LIMIT
26
- } from "./chunk-DPT5HN3D.js";
26
+ } from "./chunk-HB7W44IO.js";
27
27
  import {
28
28
  fileCheckpoints
29
29
  } from "./chunk-4BKXL7SM.js";
@@ -403,11 +403,16 @@ function buildErrorHint(command, stderr) {
403
403
  `Hint: On Windows the launcher is 'python' (or 'py'), not 'python3'. Replace 'python3' with 'python' and retry.`
404
404
  );
405
405
  }
406
- if (IS_WINDOWS && /^\s*ssh\b/.test(command) && /\\"/.test(command) && /(syntax error|ERROR:|ParserError|unexpected|parser|意外的|语法|不是此版本)/i.test(stderr)) {
406
+ if (IS_WINDOWS && /^\s*ssh\b/.test(command) && /\\"/.test(command) && /(syntax error|ERROR:|ParserError|unexpected|parser|意外的|语法|不是此版本|所在位置\s+行)/i.test(stderr)) {
407
407
  hints.push(
408
408
  `Hint: SSH + nested quotes ("...\\"...\\"") is fragile across PS \u2192 ssh \u2192 remote-shell \u2192 psql layers. Use the file-based flow: (1) write_file locally to a .sql file, (2) 'scp x.sql root@host:/tmp/', (3) 'ssh root@host "sudo -u postgres psql -d <db> -f /tmp/x.sql"'. Or for remote-only SQL: 'ssh host "cat > /tmp/x.sql << \\'SQLEOF\\'\\n...\\nSQLEOF"' then run psql -f. Avoid inline psql -c with embedded quotes.`
409
409
  );
410
410
  }
411
+ if (IS_WINDOWS && /\bmkdir\b/.test(command) && /\s-p\b/.test(command) && /(已存在|already exists|ItemExistsUnauthorizedAccessError|exists)/i.test(stderr)) {
412
+ hints.push(
413
+ `Hint: PowerShell's mkdir does not support the '-p' flag. When the directory already exists it exits with code 1. Use instead: New-Item -ItemType Directory -Force -Path <dir> ('-Force' silently succeeds even if the directory already exists, mimicking 'mkdir -p').`
414
+ );
415
+ }
411
416
  if (IS_WINDOWS && /Remove-Item/i.test(command) && /cannot find path|no such file|exit 1/i.test(stderr || command)) {
412
417
  hints.push(
413
418
  `Hint: On Windows, "Remove-Item ... -ErrorAction SilentlyContinue" still makes the powershell process exit 1 when no files match (even though the error is silenced). Use Test-Path as a guard: @('tmp_a.sql','tmp_b.sql','tmp_c.csv') | Where-Object { Test-Path $_ } | Remove-Item -Force \u2014 Test-Path returns a bool without raising, so missing paths are filtered out and exit code is 0.`
@@ -3427,6 +3432,8 @@ var webSearchTool = {
3427
3432
  }
3428
3433
  const order = engine === "auto" ? ["bing", "google"] : engine === "bing" ? ["bing"] : ["google"];
3429
3434
  const errors = [];
3435
+ let weakBingFallback = null;
3436
+ let weakBingReason = null;
3430
3437
  for (let i = 0; i < order.length; i++) {
3431
3438
  const eng = order[i];
3432
3439
  const isLastEngine = i === order.length - 1;
@@ -3436,15 +3443,25 @@ var webSearchTool = {
3436
3443
  errors.push(`${eng}: 0 results`);
3437
3444
  continue;
3438
3445
  }
3439
- if (eng === "bing" && !isLastEngine && isWeakBingResult(results)) {
3440
- errors.push(`bing: weak results (likely long-tail fallback), trying ${order[i + 1]}`);
3441
- continue;
3446
+ if (eng === "bing" && !isLastEngine) {
3447
+ const verdict = classifyBingWeakness(query, results);
3448
+ if (verdict !== null) {
3449
+ errors.push(`bing: ${verdict}, trying ${order[i + 1]}`);
3450
+ weakBingFallback = results;
3451
+ weakBingReason = verdict;
3452
+ continue;
3453
+ }
3442
3454
  }
3443
3455
  return formatResults(query, eng, results);
3444
3456
  } catch (err) {
3445
3457
  errors.push(`${eng}: ${err instanceof Error ? err.message : String(err)}`);
3446
3458
  }
3447
3459
  }
3460
+ if (weakBingFallback) {
3461
+ return formatResults(query, "bing", weakBingFallback, {
3462
+ warning: `engine signaled weak relevance (${weakBingReason}). These results may be Bing's "popular sites" fallback rather than real matches. Consider rephrasing the query (shorter, fewer constraints), or use web_fetch against a known authoritative URL (e.g. baike.baidu.com, mfa.gov.cn, news.cctv.com).`
3463
+ });
3464
+ }
3448
3465
  throw new NetworkError(
3449
3466
  `web_search failed across all engines.
3450
3467
  ${errors.map((e) => " - " + e).join("\n")}
@@ -3452,8 +3469,11 @@ Tip: a CAPTCHA wall or a result-page redesign can cause this. Try web_fetch with
3452
3469
  );
3453
3470
  }
3454
3471
  };
3455
- function isWeakBingResult(results) {
3456
- if (results.length < 3) return false;
3472
+ function classifyBingWeakness(query, results) {
3473
+ if (results.length < 3) return null;
3474
+ if (hasZeroKeywordOverlap(query, results)) {
3475
+ return "zero query-keyword overlap (no result mentions any query term)";
3476
+ }
3457
3477
  const hostCounts = /* @__PURE__ */ new Map();
3458
3478
  for (const r of results) {
3459
3479
  try {
@@ -3463,11 +3483,79 @@ function isWeakBingResult(results) {
3463
3483
  }
3464
3484
  }
3465
3485
  const maxSameHost = Math.max(0, ...hostCounts.values());
3466
- if (maxSameHost / results.length >= 0.6) return true;
3467
- const noiseRe = /\b(speedtest\.net|fast\.com|ookla\.com|samh130|91secomic|baike\.baidu\.com\/item\/[^\/]+\d{4,}|baidu\.com\/s\?|encompasshealth|kansas)\b/i;
3468
- const noiseCount = results.filter((r) => noiseRe.test(r.url)).length;
3469
- if (noiseCount / results.length >= 0.4) return true;
3470
- return false;
3486
+ if (maxSameHost / results.length >= 0.6) {
3487
+ return `domain monoculture (${maxSameHost}/${results.length} same host)`;
3488
+ }
3489
+ const noiseRe = NOISE_DOMAIN_RE;
3490
+ const noiseCount = results.filter((r) => noiseRe.test(r.url) || noiseRe.test(r.title)).length;
3491
+ if (noiseCount / results.length >= 0.4) {
3492
+ return `${noiseCount}/${results.length} results from known-noise domains`;
3493
+ }
3494
+ return null;
3495
+ }
3496
+ var NOISE_DOMAIN_RE = new RegExp(
3497
+ "\\b(" + [
3498
+ // Network/CDN noise tests
3499
+ "speedtest\\.net",
3500
+ "fast\\.com",
3501
+ "ookla\\.com",
3502
+ // Adult content sites observed in v0.4.135/136 traces
3503
+ "samh130",
3504
+ "91secomic",
3505
+ "cnshaik",
3506
+ "suishenpu",
3507
+ // CN entertainment / video portals Bing uses as "popular sites" filler
3508
+ "youku\\.(com|tv)",
3509
+ "iqiyi\\.com",
3510
+ "world-iqiyi\\.com",
3511
+ "4gtv\\.tv",
3512
+ "doubao\\.com",
3513
+ "doubao\\.zube\\.cn",
3514
+ "gamersky\\.com",
3515
+ // CN academic noise (when query is news-y, not academic)
3516
+ "cnki\\.(net|com\\.cn)",
3517
+ // Non-news health spam
3518
+ "encompasshealth",
3519
+ // Baidu Baike "single digit / single character" entries
3520
+ "baike\\.baidu\\.com\\/item\\/5\\b",
3521
+ "baike\\.baidu\\.com\\/item\\/[^/]*\\d{4,}",
3522
+ // Generic baidu redirect / 知道 / 经验 / 健康 when off-topic — caught via TITLE match
3523
+ "baidu\\.com\\/s\\?",
3524
+ // Kansas Rehab Hospital pattern (observed v0.4.135 dev)
3525
+ "kansas",
3526
+ // 麻豆 entertainment (TW/CN content site)
3527
+ "\u9EBB\u8C46",
3528
+ // 抖音 / Steam tutorials (Baidu Jingyan) — common popular noise
3529
+ "\u6296\u97F3",
3530
+ "17c\u5F71\u89C6"
3531
+ ].join("|") + ")",
3532
+ "i"
3533
+ );
3534
+ function extractQueryTokens(query) {
3535
+ const tokens = /* @__PURE__ */ new Set();
3536
+ const cjkRuns = query.match(/[一-鿿]+/g) ?? [];
3537
+ for (const run of cjkRuns) {
3538
+ if (run.length < 2) continue;
3539
+ for (let i = 0; i < run.length - 1; i++) {
3540
+ tokens.add(run.slice(i, i + 2));
3541
+ }
3542
+ }
3543
+ const ascii = query.match(/[a-zA-Z]{3,}/g) ?? [];
3544
+ for (const w of ascii) tokens.add(w.toLowerCase());
3545
+ const digits = query.match(/\d{2,}/g) ?? [];
3546
+ for (const d of digits) tokens.add(d);
3547
+ return tokens;
3548
+ }
3549
+ function hasZeroKeywordOverlap(query, results) {
3550
+ const tokens = extractQueryTokens(query);
3551
+ if (tokens.size === 0) return false;
3552
+ for (const r of results) {
3553
+ const haystack = (r.title + " " + r.snippet).toLowerCase();
3554
+ for (const t of tokens) {
3555
+ if (haystack.includes(t.toLowerCase())) return false;
3556
+ }
3557
+ }
3558
+ return true;
3471
3559
  }
3472
3560
  async function searchBing(query, num) {
3473
3561
  const url = new URL("https://cn.bing.com/search");
@@ -3556,13 +3644,18 @@ function stripTags2(html) {
3556
3644
  function decodeHtmlEntities(s) {
3557
3645
  return s.replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&#39;/g, "'").replace(/&#x2F;/g, "/").replace(/&nbsp;/g, " ");
3558
3646
  }
3559
- function formatResults(query, engine, results) {
3560
- const header = `Search results for "${query}" via ${engine} (${results.length} results):
3647
+ function formatResults(query, engine, results, opts) {
3648
+ let preamble = `Search results for "${query}" via ${engine} (${results.length} results):
3561
3649
  `;
3650
+ if (opts?.warning) {
3651
+ preamble = `\u26A0\uFE0F WEAK RESULTS WARNING: ${opts.warning}
3652
+
3653
+ ${preamble}`;
3654
+ }
3562
3655
  const body = results.map((r, i) => `${i + 1}. **${r.title}**
3563
3656
  URL: ${r.url}
3564
3657
  ${decodeHtmlEntities(r.snippet) || "(no snippet extracted)"}`).join("\n\n");
3565
- return header + "\n" + body;
3658
+ return preamble + "\n" + body;
3566
3659
  }
3567
3660
 
3568
3661
  // src/tools/builtin/save-last-response.ts
@@ -36,7 +36,7 @@ import {
36
36
  TEST_TIMEOUT,
37
37
  VERSION,
38
38
  buildUserIdentityPrompt
39
- } from "./chunk-DPT5HN3D.js";
39
+ } from "./chunk-HB7W44IO.js";
40
40
  import "./chunk-PDX44BCA.js";
41
41
  export {
42
42
  AGENTIC_BEHAVIOR_GUIDELINE,
@@ -2,25 +2,25 @@
2
2
  import {
3
3
  getConfigDirUsage,
4
4
  listRecentCrashes
5
- } from "./chunk-RZFAK5XL.js";
5
+ } from "./chunk-PRX4DJRB.js";
6
6
  import {
7
7
  ProviderRegistry
8
- } from "./chunk-UGKFU3I5.js";
8
+ } from "./chunk-SZGKLZCW.js";
9
9
  import {
10
10
  ConfigManager
11
- } from "./chunk-2S27S4DO.js";
11
+ } from "./chunk-SVLXF7ZG.js";
12
12
  import {
13
13
  getStatsSnapshot,
14
14
  getTopFailingTools,
15
15
  getTopUsedTools,
16
16
  resetStats
17
- } from "./chunk-STUFQVOX.js";
17
+ } from "./chunk-HFCZNQSW.js";
18
18
  import "./chunk-2ZD3YTVM.js";
19
19
  import {
20
20
  DEV_STATE_FILE_NAME,
21
21
  MEMORY_FILE_NAME,
22
22
  VERSION
23
- } from "./chunk-DPT5HN3D.js";
23
+ } from "./chunk-HB7W44IO.js";
24
24
  import "./chunk-PDX44BCA.js";
25
25
 
26
26
  // src/diagnostics/doctor-cli.ts
@@ -36,7 +36,7 @@ import {
36
36
  VERSION,
37
37
  buildUserIdentityPrompt,
38
38
  runTestsTool
39
- } from "./chunk-QCFTOP3R.js";
39
+ } from "./chunk-RAAP7PMN.js";
40
40
  import {
41
41
  hasSemanticIndex,
42
42
  semanticSearch
@@ -4049,11 +4049,16 @@ function buildErrorHint(command, stderr) {
4049
4049
  `Hint: On Windows the launcher is 'python' (or 'py'), not 'python3'. Replace 'python3' with 'python' and retry.`
4050
4050
  );
4051
4051
  }
4052
- if (IS_WINDOWS && /^\s*ssh\b/.test(command) && /\\"/.test(command) && /(syntax error|ERROR:|ParserError|unexpected|parser|意外的|语法|不是此版本)/i.test(stderr)) {
4052
+ if (IS_WINDOWS && /^\s*ssh\b/.test(command) && /\\"/.test(command) && /(syntax error|ERROR:|ParserError|unexpected|parser|意外的|语法|不是此版本|所在位置\s+行)/i.test(stderr)) {
4053
4053
  hints.push(
4054
4054
  `Hint: SSH + nested quotes ("...\\"...\\"") is fragile across PS \u2192 ssh \u2192 remote-shell \u2192 psql layers. Use the file-based flow: (1) write_file locally to a .sql file, (2) 'scp x.sql root@host:/tmp/', (3) 'ssh root@host "sudo -u postgres psql -d <db> -f /tmp/x.sql"'. Or for remote-only SQL: 'ssh host "cat > /tmp/x.sql << \\'SQLEOF\\'\\n...\\nSQLEOF"' then run psql -f. Avoid inline psql -c with embedded quotes.`
4055
4055
  );
4056
4056
  }
4057
+ if (IS_WINDOWS && /\bmkdir\b/.test(command) && /\s-p\b/.test(command) && /(已存在|already exists|ItemExistsUnauthorizedAccessError|exists)/i.test(stderr)) {
4058
+ hints.push(
4059
+ `Hint: PowerShell's mkdir does not support the '-p' flag. When the directory already exists it exits with code 1. Use instead: New-Item -ItemType Directory -Force -Path <dir> ('-Force' silently succeeds even if the directory already exists, mimicking 'mkdir -p').`
4060
+ );
4061
+ }
4057
4062
  if (IS_WINDOWS && /Remove-Item/i.test(command) && /cannot find path|no such file|exit 1/i.test(stderr || command)) {
4058
4063
  hints.push(
4059
4064
  `Hint: On Windows, "Remove-Item ... -ErrorAction SilentlyContinue" still makes the powershell process exit 1 when no files match (even though the error is silenced). Use Test-Path as a guard: @('tmp_a.sql','tmp_b.sql','tmp_c.csv') | Where-Object { Test-Path $_ } | Remove-Item -Force \u2014 Test-Path returns a bool without raising, so missing paths are filtered out and exit code is 0.`
@@ -7123,6 +7128,8 @@ var webSearchTool = {
7123
7128
  }
7124
7129
  const order = engine === "auto" ? ["bing", "google"] : engine === "bing" ? ["bing"] : ["google"];
7125
7130
  const errors = [];
7131
+ let weakBingFallback = null;
7132
+ let weakBingReason = null;
7126
7133
  for (let i = 0; i < order.length; i++) {
7127
7134
  const eng = order[i];
7128
7135
  const isLastEngine = i === order.length - 1;
@@ -7132,15 +7139,25 @@ var webSearchTool = {
7132
7139
  errors.push(`${eng}: 0 results`);
7133
7140
  continue;
7134
7141
  }
7135
- if (eng === "bing" && !isLastEngine && isWeakBingResult(results)) {
7136
- errors.push(`bing: weak results (likely long-tail fallback), trying ${order[i + 1]}`);
7137
- continue;
7142
+ if (eng === "bing" && !isLastEngine) {
7143
+ const verdict = classifyBingWeakness(query, results);
7144
+ if (verdict !== null) {
7145
+ errors.push(`bing: ${verdict}, trying ${order[i + 1]}`);
7146
+ weakBingFallback = results;
7147
+ weakBingReason = verdict;
7148
+ continue;
7149
+ }
7138
7150
  }
7139
7151
  return formatResults(query, eng, results);
7140
7152
  } catch (err) {
7141
7153
  errors.push(`${eng}: ${err instanceof Error ? err.message : String(err)}`);
7142
7154
  }
7143
7155
  }
7156
+ if (weakBingFallback) {
7157
+ return formatResults(query, "bing", weakBingFallback, {
7158
+ warning: `engine signaled weak relevance (${weakBingReason}). These results may be Bing's "popular sites" fallback rather than real matches. Consider rephrasing the query (shorter, fewer constraints), or use web_fetch against a known authoritative URL (e.g. baike.baidu.com, mfa.gov.cn, news.cctv.com).`
7159
+ });
7160
+ }
7144
7161
  throw new NetworkError(
7145
7162
  `web_search failed across all engines.
7146
7163
  ${errors.map((e) => " - " + e).join("\n")}
@@ -7148,8 +7165,11 @@ Tip: a CAPTCHA wall or a result-page redesign can cause this. Try web_fetch with
7148
7165
  );
7149
7166
  }
7150
7167
  };
7151
- function isWeakBingResult(results) {
7152
- if (results.length < 3) return false;
7168
+ function classifyBingWeakness(query, results) {
7169
+ if (results.length < 3) return null;
7170
+ if (hasZeroKeywordOverlap(query, results)) {
7171
+ return "zero query-keyword overlap (no result mentions any query term)";
7172
+ }
7153
7173
  const hostCounts = /* @__PURE__ */ new Map();
7154
7174
  for (const r of results) {
7155
7175
  try {
@@ -7159,11 +7179,79 @@ function isWeakBingResult(results) {
7159
7179
  }
7160
7180
  }
7161
7181
  const maxSameHost = Math.max(0, ...hostCounts.values());
7162
- if (maxSameHost / results.length >= 0.6) return true;
7163
- const noiseRe = /\b(speedtest\.net|fast\.com|ookla\.com|samh130|91secomic|baike\.baidu\.com\/item\/[^\/]+\d{4,}|baidu\.com\/s\?|encompasshealth|kansas)\b/i;
7164
- const noiseCount = results.filter((r) => noiseRe.test(r.url)).length;
7165
- if (noiseCount / results.length >= 0.4) return true;
7166
- return false;
7182
+ if (maxSameHost / results.length >= 0.6) {
7183
+ return `domain monoculture (${maxSameHost}/${results.length} same host)`;
7184
+ }
7185
+ const noiseRe = NOISE_DOMAIN_RE;
7186
+ const noiseCount = results.filter((r) => noiseRe.test(r.url) || noiseRe.test(r.title)).length;
7187
+ if (noiseCount / results.length >= 0.4) {
7188
+ return `${noiseCount}/${results.length} results from known-noise domains`;
7189
+ }
7190
+ return null;
7191
+ }
7192
+ var NOISE_DOMAIN_RE = new RegExp(
7193
+ "\\b(" + [
7194
+ // Network/CDN noise tests
7195
+ "speedtest\\.net",
7196
+ "fast\\.com",
7197
+ "ookla\\.com",
7198
+ // Adult content sites observed in v0.4.135/136 traces
7199
+ "samh130",
7200
+ "91secomic",
7201
+ "cnshaik",
7202
+ "suishenpu",
7203
+ // CN entertainment / video portals Bing uses as "popular sites" filler
7204
+ "youku\\.(com|tv)",
7205
+ "iqiyi\\.com",
7206
+ "world-iqiyi\\.com",
7207
+ "4gtv\\.tv",
7208
+ "doubao\\.com",
7209
+ "doubao\\.zube\\.cn",
7210
+ "gamersky\\.com",
7211
+ // CN academic noise (when query is news-y, not academic)
7212
+ "cnki\\.(net|com\\.cn)",
7213
+ // Non-news health spam
7214
+ "encompasshealth",
7215
+ // Baidu Baike "single digit / single character" entries
7216
+ "baike\\.baidu\\.com\\/item\\/5\\b",
7217
+ "baike\\.baidu\\.com\\/item\\/[^/]*\\d{4,}",
7218
+ // Generic baidu redirect / 知道 / 经验 / 健康 when off-topic — caught via TITLE match
7219
+ "baidu\\.com\\/s\\?",
7220
+ // Kansas Rehab Hospital pattern (observed v0.4.135 dev)
7221
+ "kansas",
7222
+ // 麻豆 entertainment (TW/CN content site)
7223
+ "\u9EBB\u8C46",
7224
+ // 抖音 / Steam tutorials (Baidu Jingyan) — common popular noise
7225
+ "\u6296\u97F3",
7226
+ "17c\u5F71\u89C6"
7227
+ ].join("|") + ")",
7228
+ "i"
7229
+ );
7230
+ function extractQueryTokens(query) {
7231
+ const tokens = /* @__PURE__ */ new Set();
7232
+ const cjkRuns = query.match(/[一-鿿]+/g) ?? [];
7233
+ for (const run of cjkRuns) {
7234
+ if (run.length < 2) continue;
7235
+ for (let i = 0; i < run.length - 1; i++) {
7236
+ tokens.add(run.slice(i, i + 2));
7237
+ }
7238
+ }
7239
+ const ascii = query.match(/[a-zA-Z]{3,}/g) ?? [];
7240
+ for (const w of ascii) tokens.add(w.toLowerCase());
7241
+ const digits = query.match(/\d{2,}/g) ?? [];
7242
+ for (const d of digits) tokens.add(d);
7243
+ return tokens;
7244
+ }
7245
+ function hasZeroKeywordOverlap(query, results) {
7246
+ const tokens = extractQueryTokens(query);
7247
+ if (tokens.size === 0) return false;
7248
+ for (const r of results) {
7249
+ const haystack = (r.title + " " + r.snippet).toLowerCase();
7250
+ for (const t of tokens) {
7251
+ if (haystack.includes(t.toLowerCase())) return false;
7252
+ }
7253
+ }
7254
+ return true;
7167
7255
  }
7168
7256
  async function searchBing(query, num) {
7169
7257
  const url = new URL("https://cn.bing.com/search");
@@ -7252,13 +7340,18 @@ function stripTags2(html) {
7252
7340
  function decodeHtmlEntities(s) {
7253
7341
  return s.replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&#39;/g, "'").replace(/&#x2F;/g, "/").replace(/&nbsp;/g, " ");
7254
7342
  }
7255
- function formatResults(query, engine, results) {
7256
- const header = `Search results for "${query}" via ${engine} (${results.length} results):
7343
+ function formatResults(query, engine, results, opts) {
7344
+ let preamble = `Search results for "${query}" via ${engine} (${results.length} results):
7257
7345
  `;
7346
+ if (opts?.warning) {
7347
+ preamble = `\u26A0\uFE0F WEAK RESULTS WARNING: ${opts.warning}
7348
+
7349
+ ${preamble}`;
7350
+ }
7258
7351
  const body = results.map((r, i) => `${i + 1}. **${r.title}**
7259
7352
  URL: ${r.url}
7260
7353
  ${decodeHtmlEntities(r.snippet) || "(no snippet extracted)"}`).join("\n\n");
7261
- return header + "\n" + body;
7354
+ return preamble + "\n" + body;
7262
7355
  }
7263
7356
 
7264
7357
  // src/tools/builtin/save-last-response.ts
@@ -12418,7 +12511,7 @@ ${undoResults.map((r) => ` \u2022 ${r}`).join("\n")}` });
12418
12511
  case "test": {
12419
12512
  this.send({ type: "info", message: "\u{1F9EA} Running tests..." });
12420
12513
  try {
12421
- const { executeTests } = await import("./run-tests-AUBA7PAV.js");
12514
+ const { executeTests } = await import("./run-tests-EDPOEYLW.js");
12422
12515
  const argStr = args.join(" ").trim();
12423
12516
  let testArgs = {};
12424
12517
  if (argStr) {
@@ -386,7 +386,7 @@ ${content}`);
386
386
  }
387
387
  }
388
388
  async function runTaskMode(config, providers, configManager, topic) {
389
- const { TaskOrchestrator } = await import("./task-orchestrator-PHHK3KWD.js");
389
+ const { TaskOrchestrator } = await import("./task-orchestrator-2HGNRT75.js");
390
390
  const orchestrator = new TaskOrchestrator(config, providers, configManager);
391
391
  let interrupted = false;
392
392
  const onSigint = () => {
package/dist/index.js CHANGED
@@ -16,12 +16,12 @@ import {
16
16
  saveDevState,
17
17
  sessionHasMeaningfulContent,
18
18
  setupProxy
19
- } from "./chunk-UGNMM6TM.js";
19
+ } from "./chunk-ICZRDITE.js";
20
20
  import {
21
21
  getConfigDirUsage,
22
22
  listRecentCrashes,
23
23
  writeCrashLog
24
- } from "./chunk-RZFAK5XL.js";
24
+ } from "./chunk-PRX4DJRB.js";
25
25
  import {
26
26
  CONTENT_ONLY_STREAM_REMINDER,
27
27
  HALLUCINATION_CORRECTION_MESSAGE,
@@ -39,10 +39,10 @@ import {
39
39
  looksLikeDocumentBody,
40
40
  stripPseudoToolCalls,
41
41
  stripToolCallReminder
42
- } from "./chunk-UGKFU3I5.js";
42
+ } from "./chunk-SZGKLZCW.js";
43
43
  import {
44
44
  ConfigManager
45
- } from "./chunk-2S27S4DO.js";
45
+ } from "./chunk-SVLXF7ZG.js";
46
46
  import {
47
47
  ToolExecutor,
48
48
  ToolRegistry,
@@ -61,16 +61,16 @@ import {
61
61
  spawnAgentContext,
62
62
  theme,
63
63
  undoStack
64
- } from "./chunk-6N5IWWPQ.js";
64
+ } from "./chunk-ZE7SHDSI.js";
65
65
  import "./chunk-3BICTI5M.js";
66
66
  import "./chunk-2DXY7UGF.js";
67
- import "./chunk-U5YSA4XD.js";
67
+ import "./chunk-XXFGS2WM.js";
68
68
  import {
69
69
  getStatsSnapshot,
70
70
  getTopFailingTools,
71
71
  getTopUsedTools,
72
72
  installFlushOnExit
73
- } from "./chunk-STUFQVOX.js";
73
+ } from "./chunk-HFCZNQSW.js";
74
74
  import "./chunk-2ZD3YTVM.js";
75
75
  import {
76
76
  AGENTIC_BEHAVIOR_GUIDELINE,
@@ -93,7 +93,7 @@ import {
93
93
  SKILLS_DIR_NAME,
94
94
  VERSION,
95
95
  buildUserIdentityPrompt
96
- } from "./chunk-DPT5HN3D.js";
96
+ } from "./chunk-HB7W44IO.js";
97
97
  import {
98
98
  formatGitContextForPrompt,
99
99
  getGitContext,
@@ -1812,7 +1812,7 @@ No tools match "${filter}".
1812
1812
  const { join: join6 } = await import("path");
1813
1813
  const { existsSync: existsSync6 } = await import("fs");
1814
1814
  const { getGitRoot: getGitRoot2 } = await import("./git-context-7KIP4X2V.js");
1815
- const { MCP_PROJECT_CONFIG_NAME: MCP_PROJECT_CONFIG_NAME2 } = await import("./constants-T5DUKPIU.js");
1815
+ const { MCP_PROJECT_CONFIG_NAME: MCP_PROJECT_CONFIG_NAME2 } = await import("./constants-CVJFNRKM.js");
1816
1816
  const { approveProject, hashMcpFile } = await import("./project-trust-IFM7FXEV.js");
1817
1817
  const cwd = process.cwd();
1818
1818
  const projectRoot = getGitRoot2(cwd) ?? cwd;
@@ -2873,7 +2873,7 @@ ${hint}` : "")
2873
2873
  usage: "/test [command|filter]",
2874
2874
  async execute(args, ctx) {
2875
2875
  try {
2876
- const { executeTests } = await import("./run-tests-V3HUOGWE.js");
2876
+ const { executeTests } = await import("./run-tests-PLITC5SK.js");
2877
2877
  const argStr = args.join(" ").trim();
2878
2878
  let testArgs = {};
2879
2879
  if (argStr) {
@@ -7327,7 +7327,7 @@ program.command("web").description("Start Web UI server with browser-based chat
7327
7327
  console.error("Error: Invalid port number. Must be between 1 and 65535.");
7328
7328
  process.exit(1);
7329
7329
  }
7330
- const { startWebServer } = await import("./server-BSCDYGH7.js");
7330
+ const { startWebServer } = await import("./server-GPD37JVY.js");
7331
7331
  await startWebServer({ port, host: options.host });
7332
7332
  });
7333
7333
  program.command("user [action] [username]").description("Manage Web UI users (list | create <name> | delete <name> | reset-password <name> | logout-all <name> | migrate <name>)").action(async (action, username) => {
@@ -7494,12 +7494,12 @@ program.command("sessions").description("List recent conversation sessions").opt
7494
7494
  console.log(footer + "\n");
7495
7495
  });
7496
7496
  program.command("doctor").description("Health check: API keys, config, MCP, recent crashes, tool usage, disk usage").option("--json", "Output as JSON (for scripting)").option("--reset-stats", "Reset accumulated tool usage statistics").action(async (options) => {
7497
- const { runDoctorCli } = await import("./doctor-cli-WGUJO6LJ.js");
7497
+ const { runDoctorCli } = await import("./doctor-cli-L3C2FPNQ.js");
7498
7498
  await runDoctorCli({ json: !!options.json, resetStats: !!options.resetStats });
7499
7499
  });
7500
7500
  program.command("batch <action> [arg] [arg2]").description("Anthropic Message Batches: submit | list | status <id> | results <id> [out] | cancel <id>").option("--dry-run", "Parse and validate input without submitting (submit only)").action(async (action, arg, arg2, options) => {
7501
7501
  try {
7502
- const batch = await import("./batch-PLWYBV75.js");
7502
+ const batch = await import("./batch-YJFHEZFS.js");
7503
7503
  switch (action) {
7504
7504
  case "submit":
7505
7505
  if (!arg) {
@@ -7542,7 +7542,7 @@ program.command("batch <action> [arg] [arg2]").description("Anthropic Message Ba
7542
7542
  }
7543
7543
  });
7544
7544
  program.command("mcp-serve").description("Start an MCP server over STDIO, exposing aicli's built-in tools to Claude Desktop / Cursor / other MCP clients").option("--allow-destructive", "Allow bash / run_interactive / task_create (always destructive in MCP mode)").option("--allow-outside-cwd", "Allow tool path arguments to escape the sandbox root \u2014 disabled by default").option("--tools <list>", "Comma-separated whitelist of tools to expose (default: all eligible tools)").option("--cwd <path>", "Working directory AND sandbox root (default: current directory)").action(async (options) => {
7545
- const { startMcpServer } = await import("./server-STXQEXTU.js");
7545
+ const { startMcpServer } = await import("./server-HLQS6CDV.js");
7546
7546
  await startMcpServer({
7547
7547
  allowDestructive: !!options.allowDestructive,
7548
7548
  allowOutsideCwd: !!options.allowOutsideCwd,
@@ -7669,7 +7669,7 @@ program.command("hub [topic]").description("Start multi-agent hub (discuss / bra
7669
7669
  }),
7670
7670
  config.get("customProviders")
7671
7671
  );
7672
- const { startHub } = await import("./hub-YJFLXIG4.js");
7672
+ const { startHub } = await import("./hub-C2TEGD53.js");
7673
7673
  await startHub(
7674
7674
  {
7675
7675
  topic: topic ?? "",
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  executeTests,
3
3
  runTestsTool
4
- } from "./chunk-QCFTOP3R.js";
4
+ } from "./chunk-RAAP7PMN.js";
5
5
  import "./chunk-3RG5ZIWI.js";
6
6
  export {
7
7
  executeTests,
@@ -2,8 +2,8 @@
2
2
  import {
3
3
  executeTests,
4
4
  runTestsTool
5
- } from "./chunk-U5YSA4XD.js";
6
- import "./chunk-DPT5HN3D.js";
5
+ } from "./chunk-XXFGS2WM.js";
6
+ import "./chunk-HB7W44IO.js";
7
7
  import "./chunk-PDX44BCA.js";
8
8
  export {
9
9
  executeTests,
@@ -14,7 +14,7 @@ import {
14
14
  loadDevState,
15
15
  persistToolRound,
16
16
  setupProxy
17
- } from "./chunk-UGNMM6TM.js";
17
+ } from "./chunk-ICZRDITE.js";
18
18
  import {
19
19
  CONTENT_ONLY_STREAM_REMINDER,
20
20
  HALLUCINATION_CORRECTION_MESSAGE,
@@ -28,10 +28,10 @@ import {
28
28
  looksLikeDocumentBody,
29
29
  stripPseudoToolCalls,
30
30
  stripToolCallReminder
31
- } from "./chunk-UGKFU3I5.js";
31
+ } from "./chunk-SZGKLZCW.js";
32
32
  import {
33
33
  ConfigManager
34
- } from "./chunk-2S27S4DO.js";
34
+ } from "./chunk-SVLXF7ZG.js";
35
35
  import {
36
36
  ToolExecutor,
37
37
  ToolRegistry,
@@ -49,14 +49,14 @@ import {
49
49
  spawnAgentContext,
50
50
  truncateOutput,
51
51
  undoStack
52
- } from "./chunk-6N5IWWPQ.js";
52
+ } from "./chunk-ZE7SHDSI.js";
53
53
  import "./chunk-3BICTI5M.js";
54
54
  import "./chunk-2DXY7UGF.js";
55
- import "./chunk-U5YSA4XD.js";
55
+ import "./chunk-XXFGS2WM.js";
56
56
  import {
57
57
  getDangerLevel,
58
58
  runTool
59
- } from "./chunk-STUFQVOX.js";
59
+ } from "./chunk-HFCZNQSW.js";
60
60
  import "./chunk-2ZD3YTVM.js";
61
61
  import {
62
62
  AGENTIC_BEHAVIOR_GUIDELINE,
@@ -76,7 +76,7 @@ import {
76
76
  SKILLS_DIR_NAME,
77
77
  VERSION,
78
78
  buildUserIdentityPrompt
79
- } from "./chunk-DPT5HN3D.js";
79
+ } from "./chunk-HB7W44IO.js";
80
80
  import {
81
81
  formatGitContextForPrompt,
82
82
  getGitContext,
@@ -2460,7 +2460,7 @@ ${undoResults.map((r) => ` \u2022 ${r}`).join("\n")}` });
2460
2460
  case "test": {
2461
2461
  this.send({ type: "info", message: "\u{1F9EA} Running tests..." });
2462
2462
  try {
2463
- const { executeTests } = await import("./run-tests-V3HUOGWE.js");
2463
+ const { executeTests } = await import("./run-tests-PLITC5SK.js");
2464
2464
  const argStr = args.join(" ").trim();
2465
2465
  let testArgs = {};
2466
2466
  if (argStr) {
@@ -1,19 +1,19 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  ToolRegistry
4
- } from "./chunk-6N5IWWPQ.js";
4
+ } from "./chunk-ZE7SHDSI.js";
5
5
  import "./chunk-3BICTI5M.js";
6
6
  import "./chunk-2DXY7UGF.js";
7
- import "./chunk-U5YSA4XD.js";
7
+ import "./chunk-XXFGS2WM.js";
8
8
  import {
9
9
  getDangerLevel,
10
10
  runTool,
11
11
  schemaToJsonSchema
12
- } from "./chunk-STUFQVOX.js";
12
+ } from "./chunk-HFCZNQSW.js";
13
13
  import "./chunk-2ZD3YTVM.js";
14
14
  import {
15
15
  VERSION
16
- } from "./chunk-DPT5HN3D.js";
16
+ } from "./chunk-HB7W44IO.js";
17
17
  import "./chunk-4BKXL7SM.js";
18
18
  import "./chunk-7ZJN4KLV.js";
19
19
  import "./chunk-KHYD3WXE.js";
@@ -3,18 +3,18 @@ import {
3
3
  ToolRegistry,
4
4
  googleSearchContext,
5
5
  truncateOutput
6
- } from "./chunk-6N5IWWPQ.js";
6
+ } from "./chunk-ZE7SHDSI.js";
7
7
  import "./chunk-3BICTI5M.js";
8
8
  import "./chunk-2DXY7UGF.js";
9
- import "./chunk-U5YSA4XD.js";
9
+ import "./chunk-XXFGS2WM.js";
10
10
  import {
11
11
  getDangerLevel,
12
12
  runTool
13
- } from "./chunk-STUFQVOX.js";
13
+ } from "./chunk-HFCZNQSW.js";
14
14
  import "./chunk-2ZD3YTVM.js";
15
15
  import {
16
16
  SUBAGENT_ALLOWED_TOOLS
17
- } from "./chunk-DPT5HN3D.js";
17
+ } from "./chunk-HB7W44IO.js";
18
18
  import "./chunk-4BKXL7SM.js";
19
19
  import "./chunk-7ZJN4KLV.js";
20
20
  import "./chunk-KHYD3WXE.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jinzd-ai-cli",
3
- "version": "0.4.136",
3
+ "version": "0.4.138",
4
4
  "description": "Cross-platform REPL-style AI CLI with multi-provider support",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",