argo-search 2.10.0 → 2.10.2
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/README.en.md +50 -10
- package/README.es.md +49 -9
- package/README.ja.md +50 -10
- package/README.ko.md +50 -10
- package/README.md +50 -30
- package/SKILL.md +11 -10
- package/backends/concept_vectors.bin +0 -0
- package/backends/engine_concept_vectors.json +3104 -0
- package/backends/engine_registry.yaml +2 -2
- package/backends/source_types_cn.json +9 -0
- package/config.yaml +105 -24
- package/docs/ENGINE_CATALOG.md +8 -8
- package/docs/RELEASE_NOTES_v2.10.1.md +57 -0
- package/docs/RELEASE_NOTES_v2.10.2.md +48 -0
- package/engines/_template_http.yaml +2 -0
- package/engines/specs/ncpssd.yaml +3 -0
- package/engines/specs/sciverse.yaml +1 -0
- package/package.json +4 -2
- package/packages/dsh-plugin/dsh/diagnostics.js +8 -3
- package/packages/dsh-plugin/dsh/index.js +7 -7
- package/packages/dsh-plugin/dsh/runner.js +72 -46
- package/packages/dsh-plugin/package.json +1 -1
- package/packages/dsh-plugin/test/index.test.js +43 -0
- package/scripts/argo_engine_registry.py +30 -4
- package/scripts/argo_paths.py +7 -1
- package/scripts/build_concept_table.py +612 -0
- package/scripts/build_route_labels.py +285 -0
- package/scripts/caliber_dedupe.py +66 -0
- package/scripts/caliber_isolation.py +4 -2
- package/scripts/ci_drift_gate.py +47 -24
- package/scripts/circuit_breaker.py +25 -3
- package/scripts/concept_lookup.py +212 -0
- package/scripts/engine_dispatch.py +6 -8
- package/scripts/engine_status.py +12 -5
- package/scripts/engines.py +29 -7
- package/scripts/engines_base.py +48 -17
- package/scripts/engines_builders_data.py +10 -3
- package/scripts/engines_builders_skill.py +87 -10
- package/scripts/evidence.py +26 -5
- package/scripts/extend_route_labels.py +239 -0
- package/scripts/extend_route_labels_by_capability.py +344 -0
- package/scripts/gen_routing_snapshot.py +22 -3
- package/scripts/lang_detect.py +12 -3
- package/scripts/local_seek.py +66 -14
- package/scripts/mcp_transport.py +1 -1
- package/scripts/numeric_verify.py +330 -0
- package/scripts/plan.py +25 -4
- package/scripts/pre-commit +2 -2
- package/scripts/rank_signals.py +48 -4
- package/scripts/ranking_eval.py +23 -1
- package/scripts/regression_p0p1.py +7 -2
- package/scripts/release.py +398 -0
- package/scripts/route.py +24 -3
- package/scripts/route_accuracy_eval.py +191 -0
- package/scripts/route_combo.py +32 -1
- package/scripts/route_domains.py +258 -5
- package/scripts/route_primary.py +101 -0
- package/scripts/search.py +5 -2
- package/scripts/search_cli.py +111 -7
- package/scripts/search_output.py +73 -1
- package/scripts/search_pipeline.py +9 -2
- package/scripts/search_rank.py +3 -1
- package/scripts/serp_guard.py +11 -0
- package/scripts/snippet_clean.py +60 -0
- package/scripts/social_engines/twitter_engine.py +127 -43
- package/scripts/social_engines/xiaohongshu_engine.py +11 -1
- package/scripts/tfidf_router.py +52 -2
- package/scripts/train.py +15 -0
- package/scripts/url_canon.py +2 -1
- package/scripts/verify_with.py +124 -0
- package/scripts/video_route.py +3 -3
- package/sub-skills/local-search/SKILL.md +3 -2
- package/sub-skills/local-search/bm25.py +89 -8
- package/sub-skills/local-search/config.yaml +12 -0
- package/sub-skills/local-search/parse_maps.yaml +8 -0
- package/sub-skills/local-search/parsers.py +5 -2
- package/sub-skills/local-search/search_v3.py +87 -1
- package/sub-skills/local-search/smart_router.py +1 -1
- package/sub-skills/local-seek/SKILL.md +6 -5
- package/sub-skills/local-seek/scripts/eval_rank.py +1 -1
- package/sub-skills/local-seek/scripts/seek.py +171 -40
- package/sub-skills/local-seek/scripts/seek_rank.py +191 -11
- package/engines/specs/_cisa_kev.yaml +0 -54
- package/engines/specs/_osv.yaml +0 -63
- package/scripts/image_vision/vision_probe +0 -0
|
@@ -52,6 +52,8 @@ import time
|
|
|
52
52
|
from datetime import datetime
|
|
53
53
|
from pathlib import Path
|
|
54
54
|
|
|
55
|
+
from seek_rank import _ZH_EN_ALIASES # 中英工程词对齐(词源单点在 seek_rank)
|
|
56
|
+
|
|
55
57
|
CONFIG_DIR = Path(__file__).resolve().parent.parent / "config"
|
|
56
58
|
DOMAINS_FILE = CONFIG_DIR / "domains.yaml"
|
|
57
59
|
|
|
@@ -77,8 +79,9 @@ DEFAULT_EXCLUDES = [
|
|
|
77
79
|
# 「明明有却搜不到」这种更糟的失败模式。
|
|
78
80
|
NOISE_TIER = [
|
|
79
81
|
"repos", "repo", "third_party", "thirdparty", "vendors",
|
|
80
|
-
"__tests__", "__test__", "
|
|
81
|
-
"
|
|
82
|
+
"__tests__", "__test__", "tests", "test", "testdata", "test_data",
|
|
83
|
+
"fixtures", "fixture", "__mocks__", "__snapshots__", "e2e",
|
|
84
|
+
"benchmark", "benchmarks",
|
|
82
85
|
"tmp", "temp", ".tmp", "tmpdir", "archive", "archives", ".trash",
|
|
83
86
|
"2026-*", # 本工作区的日期归档目录:研究产物,非源码
|
|
84
87
|
]
|
|
@@ -311,7 +314,7 @@ _ENV_FALSY = ("0", "off", "no", "false", "disable", "disabled")
|
|
|
311
314
|
|
|
312
315
|
# 重排开启时的池子上限:评分几百行在毫秒级(seek_rank 单遍计数),而浅池
|
|
313
316
|
# 会让「每文件只轮到 1 行」、文件内最相关的深行进不了评分视野。
|
|
314
|
-
_POOL_CAP_MAX =
|
|
317
|
+
_POOL_CAP_MAX = 800
|
|
315
318
|
|
|
316
319
|
|
|
317
320
|
def _rerank_wanted(raw_query: str, context: int, count: bool,
|
|
@@ -354,35 +357,114 @@ def _rerank_content(rows, raw_query: str, context: int, count: bool,
|
|
|
354
357
|
return rows
|
|
355
358
|
|
|
356
359
|
|
|
357
|
-
|
|
358
|
-
"""
|
|
360
|
+
_POOL_ZH_EN: dict[str, str] = {
|
|
361
|
+
"\u672c\u5730": "local", "\u641c\u7d22": "search", "\u68c0\u7d22": "seek", "\u7f13\u5b58": "cache",
|
|
362
|
+
"\u8def\u7531": "route", "\u6392\u5e8f": "rank", "\u91cd\u6392": "rerank", "\u566a\u58f0": "noise",
|
|
363
|
+
"\u62fc\u97f3": "pinyin", "\u8bc1\u636e": "evidence", "\u6293\u53d6": "fetch", "\u7194\u65ad": "breaker",
|
|
364
|
+
"\u805a\u5408": "search_engines", "\u5e76\u53d1": "concurrency", "\u9650\u6d41": "ratelimit",
|
|
365
|
+
"\u8d85\u65f6": "timeout", "\u91cd\u8bd5": "retry", "\u5f02\u6b65": "async", "\u961f\u5217": "queue",
|
|
366
|
+
"\u7d22\u5f15": "index", "\u5411\u91cf": "vector", "\u6743\u91cd": "weight", "\u9608\u503c": "threshold",
|
|
367
|
+
"\u5ef6\u8fdf": "latency", "\u541e\u5410": "throughput", "\u6743\u9650": "permission", "\u8ba4\u8bc1": "auth",
|
|
368
|
+
"\u52a0\u5bc6": "crypto", "\u89e3\u6790": "parse", "\u5e8f\u5217": "serialize", "\u8fdb\u7a0b": "process",
|
|
369
|
+
"\u7ebf\u7a0b": "thread", "\u9501": "lock", "\u8c03\u5ea6": "dispatch", "\u964d\u7ea7": "fallback",
|
|
370
|
+
"\u6062\u590d": "recovery", "\u53bb\u91cd": "dedup", "\u65f6\u6548": "freshness", "\u6743\u5a01": "authority",
|
|
371
|
+
"\u914d\u989d": "quota", "\u95e8\u7981": "gate", "\u6570\u636e": "data", "\u5b9a\u65f6": "schedule",
|
|
372
|
+
"\u7b56\u7565": "policy", "\u6307\u6807": "metrics", "\u7ec8\u7aef": "cli", "\u63a5\u53e3": "api",
|
|
373
|
+
"\u6e32\u67d3": "render", "\u89c6\u9891": "video", "\u5b57\u5e55": "subtitle", "\u7ec4\u4ef6": "component",
|
|
374
|
+
"\u5185\u5b58": "memory", "\u65e5\u5fd7": "log", "\u90e8\u7f72": "deploy", "\u7f51\u7edc": "network",
|
|
375
|
+
"\u4ee3\u7406": "proxy", "\u6570\u636e\u5e93": "db",
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
_DEF_LINE_RE = re.compile(
|
|
379
|
+
r"^\s*(?:(?:async|pub|export|public|private|protected|static|inline|const)\s+)*"
|
|
380
|
+
r"(?:def|class|fn|func|struct|interface|enum|type|trait|mod)\s+[A-Za-z_]"
|
|
381
|
+
)
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
def _line_buf_key(item: tuple[int, str]) -> tuple[int, int, str]:
|
|
385
|
+
ln, txt = item
|
|
386
|
+
if _DEF_LINE_RE.match(txt):
|
|
387
|
+
pri = 0
|
|
388
|
+
elif txt.lstrip().startswith(("#", "//", "/*", "*")):
|
|
389
|
+
pri = 2
|
|
390
|
+
else:
|
|
391
|
+
pri = 1
|
|
392
|
+
return pri, ln, txt
|
|
359
393
|
|
|
360
|
-
旧口径 = (路径,行号,内容) 最小的 cap 条:单文件命中几百行的高频词查询
|
|
361
|
-
会把池位全吃掉,而路径序在后的文件(sub-skills/ 排在 docs/ 之后)一行
|
|
362
|
-
都进不了池——BM25F 重排只能排池内的东西,池子本身偏了排序再好也白搭。
|
|
363
394
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
395
|
+
def _select_pool(candidates, cap: int, per_file: int = 8,
|
|
396
|
+
raw_query: str = "") -> list:
|
|
397
|
+
"""有界池的**按文件轮转配额 + 词覆盖度优先**选择(2026-10-07 方案甲,2026-10-30 升级)。
|
|
398
|
+
|
|
399
|
+
流式阶段按文件收集候选(单文件有界缓冲 32 行,零字符串转换开销);
|
|
400
|
+
仅当总候选超 cap 或单文件超 per_file 时,按「行内词元覆盖数 + 路径互补词元数」
|
|
401
|
+
精选每文件代表行并按文件覆盖度轮转入池。
|
|
369
402
|
"""
|
|
370
|
-
|
|
403
|
+
raw_by_file: dict[str, list[tuple[int, str]]] = {}
|
|
404
|
+
buf_limit = max(per_file * 4, 32)
|
|
405
|
+
total_cands = 0
|
|
371
406
|
for fp, ln, txt in candidates:
|
|
372
|
-
|
|
373
|
-
|
|
407
|
+
total_cands += 1
|
|
408
|
+
rows = raw_by_file.setdefault(fp, [])
|
|
409
|
+
if len(rows) < buf_limit:
|
|
374
410
|
rows.append((ln, txt))
|
|
375
|
-
elif
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
411
|
+
elif buf_limit > 1:
|
|
412
|
+
worst = max(rows, key=_line_buf_key)
|
|
413
|
+
if _line_buf_key((ln, txt)) < _line_buf_key(worst):
|
|
414
|
+
rows[rows.index(worst)] = (ln, txt)
|
|
415
|
+
|
|
416
|
+
if not raw_by_file:
|
|
417
|
+
return []
|
|
418
|
+
|
|
419
|
+
# 快路:总候选未超池上限且每文件均未超配额时,直接按基准序返回(零分词开销)
|
|
420
|
+
if total_cands <= cap and all(len(v) <= per_file for v in raw_by_file.values()):
|
|
421
|
+
return [(fp, ln, txt) for fp in sorted(raw_by_file) for ln, txt in sorted(raw_by_file[fp])]
|
|
422
|
+
|
|
423
|
+
q_terms: list[str] = []
|
|
424
|
+
if raw_query:
|
|
425
|
+
pats, _ = build_patterns(raw_query, exact=False)
|
|
426
|
+
for p in pats:
|
|
427
|
+
pl = p.lower()
|
|
428
|
+
if len(pl) >= 2 and pl not in q_terms:
|
|
429
|
+
q_terms.append(pl)
|
|
430
|
+
en = _POOL_ZH_EN.get(pl)
|
|
431
|
+
if en and en not in q_terms:
|
|
432
|
+
q_terms.append(en)
|
|
433
|
+
q_terms = q_terms[:8]
|
|
434
|
+
|
|
435
|
+
by_file: dict[str, list[tuple[int, str]]] = {}
|
|
436
|
+
file_cov: dict[str, int] = {}
|
|
437
|
+
for fp, rows in raw_by_file.items():
|
|
438
|
+
if not q_terms:
|
|
439
|
+
rows.sort()
|
|
440
|
+
by_file[fp] = rows[:per_file]
|
|
441
|
+
file_cov[fp] = 0
|
|
442
|
+
continue
|
|
443
|
+
fp_low = fp.lower()
|
|
444
|
+
p_mask = 0
|
|
445
|
+
for idx, qt in enumerate(q_terms):
|
|
446
|
+
if qt in fp_low:
|
|
447
|
+
p_mask |= 1 << idx
|
|
448
|
+
f_mask = p_mask
|
|
449
|
+
scored: list[tuple[int, int, int, str]] = []
|
|
450
|
+
for ln, txt in rows:
|
|
451
|
+
txt_low = (txt or "").lower()
|
|
452
|
+
l_mask = 0
|
|
453
|
+
for idx, qt in enumerate(q_terms):
|
|
454
|
+
if qt in txt_low:
|
|
455
|
+
l_mask |= 1 << idx
|
|
456
|
+
f_mask |= l_mask
|
|
457
|
+
scored.append((-(p_mask | l_mask).bit_count(), -(l_mask & ~p_mask).bit_count(), ln, txt))
|
|
458
|
+
scored.sort()
|
|
459
|
+
by_file[fp] = [(ln, txt) for _, _, ln, txt in scored[:per_file]]
|
|
460
|
+
file_cov[fp] = f_mask.bit_count()
|
|
461
|
+
|
|
462
|
+
ordered_files = sorted(by_file, key=lambda fp: (-file_cov[fp], fp))
|
|
380
463
|
out: list = []
|
|
381
|
-
# 文件按路径序轮转,各出 1 行填池——池内文件多样性优先于单文件深度
|
|
382
464
|
consumed: dict[str, int] = {fp: 0 for fp in by_file}
|
|
383
465
|
while len(out) < cap:
|
|
384
466
|
progressed = False
|
|
385
|
-
for fp in
|
|
467
|
+
for fp in ordered_files:
|
|
386
468
|
i = consumed[fp]
|
|
387
469
|
if i < len(by_file[fp]):
|
|
388
470
|
ln, txt = by_file[fp][i]
|
|
@@ -404,9 +486,10 @@ def _finish_content(candidates, raw_query, context, count, fixed,
|
|
|
404
486
|
排序口径,输出 schema 才能逐位一致。
|
|
405
487
|
"""
|
|
406
488
|
cap = max(max_results, min(max_results * 4, 400))
|
|
407
|
-
|
|
489
|
+
want_rerank = _rerank_wanted(raw_query, context, count, fixed)
|
|
490
|
+
if want_rerank:
|
|
408
491
|
cap = max(cap, _POOL_CAP_MAX) # 重排开启:池子放宽,深行进得了评分视野
|
|
409
|
-
out = _select_pool(candidates, cap)
|
|
492
|
+
out = _select_pool(candidates, cap, raw_query=raw_query if want_rerank else "")
|
|
410
493
|
out.sort() # 基准序 = (路径,行号,内容):重排关闭时与 2026-10-06 口径逐位一致
|
|
411
494
|
# BM25F 相关度重排(2026-10-07,方案甲):池子的**选择**口径不变(与发射序
|
|
412
495
|
# 无关),变的只是池内**呈现次序**——基线实测多词查询的 top5 常被配置/
|
|
@@ -421,7 +504,7 @@ def _finish_content(candidates, raw_query, context, count, fixed,
|
|
|
421
504
|
|
|
422
505
|
def rg_search(patterns, path, excludes, exts, context, count, max_results,
|
|
423
506
|
fixed, raw_query="", dots=False, drop_noise=True, timeout=None,
|
|
424
|
-
since_ts=None, until_ts=None, fts_ok=True):
|
|
507
|
+
since_ts=None, until_ts=None, fts_ok=True, symbol=False):
|
|
425
508
|
timeout = _RUN_DEFAULT_TIMEOUT_S if timeout is None else timeout
|
|
426
509
|
|
|
427
510
|
# FTS5 持久索引快路(opt-in,ARGO_LOCAL_FTS=1,2026-10-10 方案乙):只在
|
|
@@ -463,6 +546,8 @@ def rg_search(patterns, path, excludes, exts, context, count, max_results,
|
|
|
463
546
|
else:
|
|
464
547
|
return None, ("本机 rg 未编译 PCRE2,不支持 look-around/反向引用语法,"
|
|
465
548
|
"请简化查询(如去掉 (?=、(?! 等结构)")
|
|
549
|
+
if symbol:
|
|
550
|
+
cmd.append("-w")
|
|
466
551
|
if count:
|
|
467
552
|
cmd.append("--count-matches")
|
|
468
553
|
elif context > 0:
|
|
@@ -491,9 +576,15 @@ def rg_search(patterns, path, excludes, exts, context, count, max_results,
|
|
|
491
576
|
if proc.returncode == 1:
|
|
492
577
|
return [], None # 无匹配,正常
|
|
493
578
|
if proc.returncode == 2:
|
|
494
|
-
#
|
|
495
|
-
|
|
496
|
-
|
|
579
|
+
# 返回码 2 =「有结果,但过程中报了错」(悬空软链 os error 2、权限
|
|
580
|
+
# 不足等):rg 跳过出错路径继续搜,stdout 里其余文件的匹配照常有效
|
|
581
|
+
# ——与 _structural_search 同口径,有结果就放行下方正常解析,不再
|
|
582
|
+
# 整个放弃(2026-10-31 实测:--dot 搜含悬空软链的 ~/.agents/skills,
|
|
583
|
+
# 一条「No such file or directory」让整个查询空手而归)。stderr 的
|
|
584
|
+
# 路径级警告由 rg 自行打印,不进 err——上层 err 非 None 即判失败。
|
|
585
|
+
if not (proc.stdout or "").strip():
|
|
586
|
+
err = (proc.stderr or "").strip()
|
|
587
|
+
return [], f"rg 错误: {err[:200]}" if err else "rg 执行错误"
|
|
497
588
|
if count:
|
|
498
589
|
# 全量收集后按命中数降序取前 N:rg --count-matches 的输出顺序是
|
|
499
590
|
# 目录遍历序,直接截断会让「哪些文件命中最多」系统性答错——
|
|
@@ -769,7 +860,11 @@ def fd_search(query, path, exts, max_results, dots=False, timeout=None,
|
|
|
769
860
|
cmd += ["-e", e]
|
|
770
861
|
cmd += [query, str(path)]
|
|
771
862
|
proc = run(cmd, timeout=timeout)
|
|
772
|
-
if proc is None
|
|
863
|
+
if proc is None:
|
|
864
|
+
return [], "fd 执行失败"
|
|
865
|
+
# fd 对个别路径出错(悬空软链等)退出码落到 0/1 之外,但 stdout 里其余
|
|
866
|
+
# 匹配照常有效——有结果就解析,与 rg_search 同口径(2026-10-31)。
|
|
867
|
+
if proc.returncode not in (0, 1) and not (proc.stdout or "").strip():
|
|
773
868
|
return [], "fd 执行失败"
|
|
774
869
|
# 时间窗在截断前过滤(先截后滤会漏报,与 rg 路径同理)
|
|
775
870
|
lines = [p for p in proc.stdout.splitlines()
|
|
@@ -1172,15 +1267,30 @@ def git_blame(path, line, timeout=None):
|
|
|
1172
1267
|
|
|
1173
1268
|
def _run_grep_fallback(args, patterns, fixed, path, excludes, exts, max_results,
|
|
1174
1269
|
timeout=None, since_ts=None, until_ts=None):
|
|
1175
|
-
"""rg 缺失时的 grep 保底(目录内/全盘共用)。
|
|
1270
|
+
"""rg 缺失时的 FTS5 / grep 保底(目录内/全盘共用)。
|
|
1176
1271
|
|
|
1177
|
-
返回 (results, err, mode);
|
|
1178
|
-
|
|
1272
|
+
返回 (results, err, mode);FTS5 索引命中时优先走标准库 sqlite3(免外部工具),
|
|
1273
|
+
rg 与 grep 都不可用且无 FTS5 索引时 results=None 且 err 说明缺什么——
|
|
1274
|
+
调用方必须把「工具缺失」与「未找到匹配」区分开。
|
|
1179
1275
|
"""
|
|
1276
|
+
dots = getattr(args, "dot", False)
|
|
1277
|
+
if not exts and not getattr(args, "exclude", None) and not args.count and args.context == 0:
|
|
1278
|
+
try:
|
|
1279
|
+
import seek_fts
|
|
1280
|
+
except ImportError:
|
|
1281
|
+
seek_fts = None
|
|
1282
|
+
if seek_fts is not None and seek_fts.query_suitable(args.query):
|
|
1283
|
+
rows = seek_fts.content_candidates(
|
|
1284
|
+
args.query, path, dots=dots,
|
|
1285
|
+
since_ts=since_ts, until_ts=until_ts)
|
|
1286
|
+
if rows is not None:
|
|
1287
|
+
return _finish_content(
|
|
1288
|
+
iter(rows), args.query, args.context, args.count,
|
|
1289
|
+
fixed, path, max_results, not args.include_noise
|
|
1290
|
+
), None, "fts"
|
|
1180
1291
|
grep_exe = resolve_grep()
|
|
1181
1292
|
if not grep_exe:
|
|
1182
1293
|
return None, "本机无 rg 与 grep 可用,请安装 ripgrep", ""
|
|
1183
|
-
dots = getattr(args, "dot", False)
|
|
1184
1294
|
mode = "fast"
|
|
1185
1295
|
if not args.exact and len(patterns) > 1:
|
|
1186
1296
|
results, err = grep_search(grep_exe, [args.query], path, excludes, exts,
|
|
@@ -1230,6 +1340,8 @@ def run_query(argv=None, time_budget=None) -> tuple[str, int]:
|
|
|
1230
1340
|
ap.add_argument("--json", action="store_true", help="JSON 输出")
|
|
1231
1341
|
ap.add_argument("--max", type=int, default=0, help="最大结果数(默认读配置)")
|
|
1232
1342
|
ap.add_argument("--exact", action="store_true", help="关闭中文扩展(精确匹配)")
|
|
1343
|
+
ap.add_argument("--symbol", action="store_true",
|
|
1344
|
+
help="符号/词边界精确匹配(rg -w,过滤子串噪音)")
|
|
1233
1345
|
ap.add_argument("--exclude", action="append", default=[], metavar="GLOB",
|
|
1234
1346
|
help="额外排除 glob(可重复指定,如 --exclude eval_seek.py)")
|
|
1235
1347
|
ap.add_argument("--since", default=None,
|
|
@@ -1323,6 +1435,8 @@ def run_query(argv=None, time_budget=None) -> tuple[str, int]:
|
|
|
1323
1435
|
start = time.time()
|
|
1324
1436
|
results, err = [], None
|
|
1325
1437
|
patterns, fixed = build_patterns(args.query, args.exact)
|
|
1438
|
+
if args.symbol:
|
|
1439
|
+
patterns, fixed = [args.query], is_literal(args.query)
|
|
1326
1440
|
# 时间窗时间戳只解析一次,下传各搜索器在**截断前**过滤
|
|
1327
1441
|
since_ts, until_ts = parse_time(args.since), parse_time(args.until)
|
|
1328
1442
|
|
|
@@ -1382,9 +1496,8 @@ def run_query(argv=None, time_budget=None) -> tuple[str, int]:
|
|
|
1382
1496
|
err = "fd 未安装:按文件名搜索需要 fd(内容搜索走 rg/grep)"
|
|
1383
1497
|
else:
|
|
1384
1498
|
mode = "deep" if (args.context > 0 or args.count) else "fast"
|
|
1385
|
-
# FTS
|
|
1386
|
-
|
|
1387
|
-
fts_ok = not exts and not args.exclude
|
|
1499
|
+
# FTS 快路资格:带扩展名过滤、自定义排除或符号搜索时关闭(快路不做 rg 侧 glob 与 -w 过滤)。
|
|
1500
|
+
fts_ok = not exts and not args.exclude and not args.symbol
|
|
1388
1501
|
if not args.exact and len(patterns) > 1:
|
|
1389
1502
|
# 中文扩展遵循「先窄后宽」:先精确匹配,命中不足才放宽到扩展词
|
|
1390
1503
|
_dn = not args.include_noise
|
|
@@ -1393,14 +1506,14 @@ def run_query(argv=None, time_budget=None) -> tuple[str, int]:
|
|
|
1393
1506
|
is_literal(args.query), args.query, args.dot,
|
|
1394
1507
|
drop_noise=_dn, timeout=time_budget,
|
|
1395
1508
|
since_ts=since_ts, until_ts=until_ts,
|
|
1396
|
-
fts_ok=fts_ok)
|
|
1509
|
+
fts_ok=fts_ok, symbol=args.symbol)
|
|
1397
1510
|
if not results and not err:
|
|
1398
1511
|
results, err = rg_search(patterns, path, excludes, exts,
|
|
1399
1512
|
args.context, args.count, max_results,
|
|
1400
1513
|
fixed, args.query, args.dot, drop_noise=_dn,
|
|
1401
1514
|
timeout=time_budget,
|
|
1402
1515
|
since_ts=since_ts, until_ts=until_ts,
|
|
1403
|
-
fts_ok=fts_ok)
|
|
1516
|
+
fts_ok=fts_ok, symbol=args.symbol)
|
|
1404
1517
|
if results:
|
|
1405
1518
|
mode += "+扩展"
|
|
1406
1519
|
else:
|
|
@@ -1410,7 +1523,25 @@ def run_query(argv=None, time_budget=None) -> tuple[str, int]:
|
|
|
1410
1523
|
drop_noise=not args.include_noise,
|
|
1411
1524
|
timeout=time_budget,
|
|
1412
1525
|
since_ts=since_ts, until_ts=until_ts,
|
|
1413
|
-
fts_ok=fts_ok)
|
|
1526
|
+
fts_ok=fts_ok, symbol=args.symbol)
|
|
1527
|
+
# 中英对齐回落(2026-10-31):alias 只进打分层时纯英文语料连候选池
|
|
1528
|
+
# 都进不了(rg 字面零命中,打分无从发力);无条件注入检索层又会用
|
|
1529
|
+
# 对齐噪音挤掉既有命中(eval_rank 0.8258→0.7857 实测回退)。折中取
|
|
1530
|
+
# 「先窄后宽」同款语义:原 patterns 空手时才带对齐词元重搜一次。
|
|
1531
|
+
if not results and not err:
|
|
1532
|
+
alias_pats = list(patterns) + [
|
|
1533
|
+
en for p in patterns for en in _ZH_EN_ALIASES.get(p, ())
|
|
1534
|
+
if en not in patterns]
|
|
1535
|
+
if alias_pats != patterns:
|
|
1536
|
+
results, err = rg_search(alias_pats, path, excludes, exts,
|
|
1537
|
+
args.context, args.count, max_results,
|
|
1538
|
+
fixed, args.query, args.dot,
|
|
1539
|
+
drop_noise=not args.include_noise,
|
|
1540
|
+
timeout=time_budget,
|
|
1541
|
+
since_ts=since_ts, until_ts=until_ts,
|
|
1542
|
+
fts_ok=fts_ok, symbol=args.symbol)
|
|
1543
|
+
if results:
|
|
1544
|
+
mode += "+中英"
|
|
1414
1545
|
|
|
1415
1546
|
# 注:噪声档**只降权不排除**(见 _apply_noise_floor),所以这里没有
|
|
1416
1547
|
# 「搜不到就回落重搜」的分支——噪声内容始终在结果池里,只是排在真源之后。
|
|
@@ -51,8 +51,8 @@ from collections import Counter
|
|
|
51
51
|
_CJK_RUN = r"[\u3400-\u4dbf\u4e00-\u9fff\u3040-\u30ff\uac00-\ud7af]+"
|
|
52
52
|
# T1 主切词:字母数字连续串(不含 _ . 等分隔符)+ CJK 连续串
|
|
53
53
|
_RUN_RE = re.compile(r"[A-Za-z0-9]+|" + _CJK_RUN)
|
|
54
|
-
# camelCase
|
|
55
|
-
_CAMEL_RE = re.compile(r"[a-
|
|
54
|
+
# camelCase 与字母数字边界细分:小写段、数字段、驼峰大写段
|
|
55
|
+
_CAMEL_RE = re.compile(r"[a-z]+|[0-9]+|[A-Z](?=[a-z])[a-z]*|[A-Z]+(?![a-z])")
|
|
56
56
|
_CJK_ONLY_RE = re.compile("^" + _CJK_RUN + "$")
|
|
57
57
|
|
|
58
58
|
# BM25 常数(与 local-search/bm25.py 同口径:Okapi k1=1.5 b=0.75)
|
|
@@ -84,12 +84,129 @@ _PHRASE_BONUS = 3.0
|
|
|
84
84
|
_PHRASE_BONUS_CAP = 6.0
|
|
85
85
|
_NAME_PHRASE_BONUS = 4.0 # 文件名直接命中查询短语时的定位加成
|
|
86
86
|
|
|
87
|
+
# Markdown 标题行(#、##、### 等)主题加成:仅对 Markdown 文档生效(避免把 Python/Shell/YAML
|
|
88
|
+
# 的顶层 # 注释行误判为章节标题)。
|
|
89
|
+
_HEADING_RE = re.compile(r"^\s{0,3}#{1,6}\s+.*$")
|
|
90
|
+
_HEADING_BONUS = 3.5
|
|
91
|
+
_MD_EXTS = (".md", ".mdx", ".markdown")
|
|
92
|
+
|
|
93
|
+
# 代码符号定义行先验(Zoekt / Blackbird 思路,零 AST 依赖):函数/类/结构体定义或模块常量赋值
|
|
94
|
+
# 命中查询词时显著优先于普通调用行与注释顺带提及。
|
|
95
|
+
_DEF_RE = re.compile(
|
|
96
|
+
r"^\s*(?:(?:async|pub|export|public|private|protected|static|inline|const)\s+)*"
|
|
97
|
+
r"(?:def|class|fn|func|struct|interface|enum|type|trait|mod)\s+([A-Za-z_]\w*)"
|
|
98
|
+
r"|^\s*([A-Za-z_][A-Za-z0-9_]{1,})\s*(?::\s*[^=]+)?=\s*[^=]"
|
|
99
|
+
)
|
|
100
|
+
_DEF_BONUS = 4.5
|
|
101
|
+
_DEF_SYM_BONUS = 3.0
|
|
102
|
+
|
|
103
|
+
# 轻量中英工程核心概念对齐:中文词元同时匹配英文路径与文件名段(用 unicode 转义避免本文件被 rg 字面扫中自污染)
|
|
104
|
+
_ZH_EN_ALIASES: dict[str, tuple[str, ...]] = {
|
|
105
|
+
"\u672c\u5730": ("local",),
|
|
106
|
+
"\u641c\u7d22": ("search", "seek"),
|
|
107
|
+
"\u68c0\u7d22": ("search", "seek"),
|
|
108
|
+
"\u805a\u5408": ("search", "v3", "merge"),
|
|
109
|
+
"\u7f13\u5b58": ("cache",),
|
|
110
|
+
"\u8bed\u4e49": ("similarity", "semantic"),
|
|
111
|
+
"\u8def\u7531": ("route", "router"),
|
|
112
|
+
"\u6392\u5e8f": ("rank", "sort"),
|
|
113
|
+
"\u91cd\u6392": ("rerank", "rank"),
|
|
114
|
+
"\u566a\u58f0": ("noise",),
|
|
115
|
+
"\u62fc\u97f3": ("pinyin",),
|
|
116
|
+
"\u8bc1\u636e": ("evidence",),
|
|
117
|
+
"\u6293\u53d6": ("fetch", "crawl"),
|
|
118
|
+
"\u7194\u65ad": ("breaker", "circuit"),
|
|
119
|
+
"\u914d\u7f6e": ("config",),
|
|
120
|
+
"\u56fe\u7247": ("image",),
|
|
121
|
+
"\u95e8\u7981": ("gate",),
|
|
122
|
+
# 通用工程高频(2026-10-31 补:实测「视频字幕」查 remotion 系列全 miss,
|
|
123
|
+
# 原表偏 argo 仓工程词,通用词是盲区)
|
|
124
|
+
"\u6e32\u67d3": ("render",),
|
|
125
|
+
"\u89c6\u9891": ("video",),
|
|
126
|
+
"\u5b57\u5e55": ("subtitle", "caption"),
|
|
127
|
+
"\u7ec4\u4ef6": ("component",),
|
|
128
|
+
"\u63a5\u53e3": ("interface", "api"),
|
|
129
|
+
"\u7ebf\u7a0b": ("thread",),
|
|
130
|
+
"\u5185\u5b58": ("memory",),
|
|
131
|
+
"\u65e5\u5fd7": ("log", "logging"),
|
|
132
|
+
"\u90e8\u7f72": ("deploy",),
|
|
133
|
+
"\u7f51\u7edc": ("network",),
|
|
134
|
+
"\u4ee3\u7406": ("proxy",),
|
|
135
|
+
"\u8ba4\u8bc1": ("auth", "token"),
|
|
136
|
+
"\u6570\u636e\u5e93": ("database", "db"),
|
|
137
|
+
# 高频软件工程概念扩展
|
|
138
|
+
"\u5e76\u53d1": ("concurrency", "parallel", "concurrent"),
|
|
139
|
+
"\u9650\u6d41": ("ratelimit", "throttle", "rate_limit"),
|
|
140
|
+
"\u8d85\u65f6": ("timeout", "deadline"),
|
|
141
|
+
"\u91cd\u8bd5": ("retry", "backoff"),
|
|
142
|
+
"\u5f02\u6b65": ("async", "await", "future"),
|
|
143
|
+
"\u961f\u5217": ("queue", "mq"),
|
|
144
|
+
"\u7d22\u5f15": ("index", "fts", "indexing"),
|
|
145
|
+
"\u5411\u91cf": ("vector", "embedding"),
|
|
146
|
+
"\u6743\u91cd": ("weight", "priority"),
|
|
147
|
+
"\u9608\u503c": ("threshold", "limit"),
|
|
148
|
+
"\u5ef6\u8fdf": ("latency", "delay"),
|
|
149
|
+
"\u541e\u5410": ("throughput", "tps"),
|
|
150
|
+
"\u6743\u9650": ("permission", "auth", "rbac"),
|
|
151
|
+
"\u52a0\u5bc6": ("encrypt", "crypto", "cipher"),
|
|
152
|
+
"\u89e3\u6790": ("parse", "parser"),
|
|
153
|
+
"\u5e8f\u5217": ("serialize", "json"),
|
|
154
|
+
"\u8fdb\u7a0b": ("process", "daemon", "worker"),
|
|
155
|
+
"\u9501": ("lock", "mutex"),
|
|
156
|
+
"\u8c03\u5ea6": ("dispatch", "schedule", "scheduler"),
|
|
157
|
+
"\u964d\u7ea7": ("fallback", "degrade"),
|
|
158
|
+
"\u6062\u590d": ("recovery", "heal", "reclaim"),
|
|
159
|
+
"\u53bb\u91cd": ("dedup", "dedupe"),
|
|
160
|
+
"\u65f6\u6548": ("freshness", "timestamp"),
|
|
161
|
+
"\u6743\u5a01": ("authority", "trust"),
|
|
162
|
+
"\u914d\u989d": ("quota", "limit"),
|
|
163
|
+
"\u6570\u636e": ("data", "storage"),
|
|
164
|
+
"\u5b9a\u65f6": ("cron", "timer", "schedule"),
|
|
165
|
+
"\u7b56\u7565": ("policy", "strategy"),
|
|
166
|
+
"\u6307\u6807": ("metrics", "metric"),
|
|
167
|
+
"\u7ec8\u7aef": ("terminal", "cli"),
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
_LOOKUP_INSTANCE = None
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
def _get_concept_lookup():
|
|
174
|
+
"""按需延迟加载 concept_lookup(零依赖 fail-open)。"""
|
|
175
|
+
global _LOOKUP_INSTANCE
|
|
176
|
+
if _LOOKUP_INSTANCE is None:
|
|
177
|
+
try:
|
|
178
|
+
import sys
|
|
179
|
+
from pathlib import Path
|
|
180
|
+
cur_file = Path(__file__).resolve()
|
|
181
|
+
argo_root = cur_file.parents[3]
|
|
182
|
+
scripts_dir = str(argo_root / "scripts")
|
|
183
|
+
if scripts_dir not in sys.path:
|
|
184
|
+
sys.path.insert(0, scripts_dir)
|
|
185
|
+
from concept_lookup import get_concept_lookup
|
|
186
|
+
_LOOKUP_INSTANCE = get_concept_lookup()
|
|
187
|
+
except Exception:
|
|
188
|
+
_LOOKUP_INSTANCE = False
|
|
189
|
+
return _LOOKUP_INSTANCE if _LOOKUP_INSTANCE is not False else None
|
|
190
|
+
|
|
191
|
+
# 跨字段协同加成(Minimal Span / Coordination Level):单条结果的 (name ∪ dir ∪ line) 覆盖越多不同查询词元越优先
|
|
192
|
+
_ROW_COORD_WEIGHT = 5.0
|
|
193
|
+
|
|
87
194
|
|
|
88
195
|
def _split_camel(run: str) -> list[str]:
|
|
89
|
-
"""
|
|
90
|
-
if run.islower() or run.isdigit():
|
|
196
|
+
"""驼峰与字母数字细分:BM25Okapi → bm / 25 / bm25 / okapi;bm25 → bm / 25。"""
|
|
197
|
+
if (run.isalpha() and run.islower()) or run.isdigit():
|
|
91
198
|
return []
|
|
92
|
-
|
|
199
|
+
parts = [m.group(0).lower() for m in _CAMEL_RE.finditer(run)]
|
|
200
|
+
if len(parts) <= 1:
|
|
201
|
+
return []
|
|
202
|
+
out = list(parts)
|
|
203
|
+
# 相邻「字母段 + 数字段」合并(如 BM25Okapi 产出 bm25,对齐文件名 bm25.py)
|
|
204
|
+
for i in range(len(parts) - 1):
|
|
205
|
+
if parts[i].isalpha() and parts[i + 1].isdigit():
|
|
206
|
+
merged = parts[i] + parts[i + 1]
|
|
207
|
+
if merged != run.lower():
|
|
208
|
+
out.append(merged)
|
|
209
|
+
return out
|
|
93
210
|
|
|
94
211
|
|
|
95
212
|
def _tokens(text: str, *, camel: bool = False) -> list[str]:
|
|
@@ -111,11 +228,11 @@ def _tokens(text: str, *, camel: bool = False) -> list[str]:
|
|
|
111
228
|
def _row_fields(fp: str, text: str) -> dict[str, Counter]:
|
|
112
229
|
"""一行命中在三字段下的词频表。fp 无目录段时 dir 为空表。"""
|
|
113
230
|
fp = fp.rstrip("/")
|
|
114
|
-
|
|
231
|
+
dirpart, _, name = fp.rpartition("/")
|
|
115
232
|
fields = {
|
|
116
233
|
"name": Counter(_tokens(name, camel=True)),
|
|
117
234
|
"dir": Counter(_tokens(dirpart, camel=True)),
|
|
118
|
-
"line": Counter(_tokens(text or "")),
|
|
235
|
+
"line": Counter(_tokens(text or "", camel=True)),
|
|
119
236
|
}
|
|
120
237
|
return fields
|
|
121
238
|
|
|
@@ -135,6 +252,13 @@ def rank_rows(rows: list[tuple[str, int, str]], raw_query: str,
|
|
|
135
252
|
if not q_tf or not rows:
|
|
136
253
|
return rows
|
|
137
254
|
|
|
255
|
+
# 跨语言标识符对齐词元(降权权重 0.65,辅助中文查询命中英文代码路径/符号)
|
|
256
|
+
q_eff: dict[str, float] = {k: float(v) for k, v in q_tf.items()}
|
|
257
|
+
for qt in list(q_tf):
|
|
258
|
+
for en in _ZH_EN_ALIASES.get(qt, ()):
|
|
259
|
+
if en not in q_eff:
|
|
260
|
+
q_eff[en] = 0.65
|
|
261
|
+
|
|
138
262
|
# 逐字短语表:完整 CJK 连续串 + 较长 ASCII 连续串(行文本做子串检查用)
|
|
139
263
|
phrases = [m.group(0).lower()
|
|
140
264
|
for m in re.finditer(r"[A-Za-z0-9_\-+#.]{3,}|" + _CJK_RUN,
|
|
@@ -159,7 +283,28 @@ def rank_rows(rows: list[tuple[str, int, str]], raw_query: str,
|
|
|
159
283
|
for term in f_tf[f]:
|
|
160
284
|
f_df[term] += 1
|
|
161
285
|
|
|
286
|
+
# 概念向量对齐扩展:从候选项路径高频词元中,寻找与查询词元高度语义对齐的词(余弦 >= 0.75)
|
|
287
|
+
concept_expanded: dict[str, set[str]] = {}
|
|
288
|
+
lookup = _get_concept_lookup()
|
|
289
|
+
if lookup and lookup.is_available:
|
|
290
|
+
for qt in list(q_tf):
|
|
291
|
+
vq = lookup.get_vector(qt)
|
|
292
|
+
if vq is None:
|
|
293
|
+
continue
|
|
294
|
+
matched = set()
|
|
295
|
+
cand_vocab = set(df["name"]) | set(df["dir"])
|
|
296
|
+
for cand in cand_vocab:
|
|
297
|
+
if cand in q_eff:
|
|
298
|
+
continue
|
|
299
|
+
vt = lookup.get_vector(cand)
|
|
300
|
+
if vt is not None and lookup.vector_cosine(vq, vt) >= 0.75:
|
|
301
|
+
q_eff[cand] = 0.60
|
|
302
|
+
matched.add(cand)
|
|
303
|
+
if matched:
|
|
304
|
+
concept_expanded[qt] = matched
|
|
305
|
+
|
|
162
306
|
scores: list[float] = []
|
|
307
|
+
n_q_primary = max(len(q_tf), 1)
|
|
163
308
|
for i, f_tf in enumerate(row_fields):
|
|
164
309
|
total = 0.0
|
|
165
310
|
for f, w, b in _FIELDS:
|
|
@@ -169,7 +314,7 @@ def rank_rows(rows: list[tuple[str, int, str]], raw_query: str,
|
|
|
169
314
|
dl = sum(tf_map.values())
|
|
170
315
|
norm = _K1 * (1.0 - b + b * dl / avgdl[f])
|
|
171
316
|
f_df = df[f]
|
|
172
|
-
for qt, qtf in
|
|
317
|
+
for qt, qtf in q_eff.items():
|
|
173
318
|
tf = tf_map.get(qt)
|
|
174
319
|
if not tf:
|
|
175
320
|
continue
|
|
@@ -177,21 +322,56 @@ def rank_rows(rows: list[tuple[str, int, str]], raw_query: str,
|
|
|
177
322
|
# BM25+:饱和项加下界 δ(只对命中的词,未命中不送底分)
|
|
178
323
|
sat = (tf * (_K1 + 1.0)) / (tf + norm)
|
|
179
324
|
total += w * qtf * (sat + _DELTA) * idf
|
|
180
|
-
|
|
325
|
+
fp = rows[i][0]
|
|
326
|
+
total += _TOPIC_PRIOR_WEIGHT * math.log1p(file_hits[fp])
|
|
327
|
+
# 单行三字段协同覆盖度(name ∪ dir ∪ line 覆盖了多少查询词/跨语言映射词)
|
|
328
|
+
row_voc = set(f_tf["name"]) | set(f_tf["dir"]) | set(f_tf["line"])
|
|
329
|
+
covered = sum(1.0 for qt in q_tf if qt in row_voc or any(
|
|
330
|
+
en in row_voc for en in _ZH_EN_ALIASES.get(qt, ())) or any(
|
|
331
|
+
ce in row_voc for ce in concept_expanded.get(qt, ())))
|
|
332
|
+
if covered > 1.0:
|
|
333
|
+
total += _ROW_COORD_WEIGHT * (covered / n_q_primary)
|
|
181
334
|
if phrases:
|
|
182
335
|
low_line = (rows[i][2] or "").lower()
|
|
183
|
-
fp_low = (
|
|
336
|
+
fp_low = (fp or "").lower()
|
|
184
337
|
name_low = fp_low.rpartition("/")[2] or fp_low
|
|
185
338
|
name_hits = sum(1 for ph in phrases if ph in name_low)
|
|
186
339
|
line_hits = sum(1 for ph in phrases if ph in low_line)
|
|
187
340
|
total += min(name_hits, 2) * _NAME_PHRASE_BONUS + min(line_hits, 2) * _PHRASE_BONUS
|
|
341
|
+
if line_hits >= 2:
|
|
342
|
+
hit_pos = [low_line.find(ph) for ph in phrases if ph in low_line]
|
|
343
|
+
if max(hit_pos) - min(hit_pos) <= 10:
|
|
344
|
+
total += 2.5 # 多词紧邻跨度加成(Min-Span Proximity)
|
|
345
|
+
raw_line = rows[i][2] or ""
|
|
346
|
+
fp_low = (fp or "").lower()
|
|
347
|
+
# 文档标题感知:仅对 Markdown 文件生效,避免误奖代码注释
|
|
348
|
+
if fp_low.endswith(_MD_EXTS) and _HEADING_RE.match(raw_line) and f_tf["line"]:
|
|
349
|
+
if any(qt in f_tf["line"] for qt in q_eff):
|
|
350
|
+
total += _HEADING_BONUS
|
|
351
|
+
# 代码定义行感知:函数/类/常量定义行优先于普通调用与注释
|
|
352
|
+
m_def = _DEF_RE.match(raw_line)
|
|
353
|
+
if m_def and f_tf["line"] and any(qt in f_tf["line"] for qt in q_eff):
|
|
354
|
+
total += _DEF_BONUS
|
|
355
|
+
sym = (m_def.group(1) or m_def.group(2) or "").lower()
|
|
356
|
+
if sym and any(qt in sym for qt in q_eff):
|
|
357
|
+
total += _DEF_SYM_BONUS
|
|
188
358
|
if boost_fn is not None:
|
|
189
359
|
try:
|
|
190
|
-
total += boost_fn(
|
|
360
|
+
total += boost_fn(fp)
|
|
191
361
|
except Exception:
|
|
192
362
|
pass # 注入的加成失败不拖累打分本体
|
|
193
363
|
scores.append(total)
|
|
194
364
|
|
|
365
|
+
# 同文件多行命中边际递减(第 3 条起温和衰减,防单文件 8 行霸屏 Top-5)
|
|
366
|
+
by_fp: dict[str, list[int]] = {}
|
|
367
|
+
for idx, (fp, _ln, _txt) in enumerate(rows):
|
|
368
|
+
by_fp.setdefault(fp, []).append(idx)
|
|
369
|
+
for idxs in by_fp.values():
|
|
370
|
+
if len(idxs) > 2:
|
|
371
|
+
idxs.sort(key=lambda idx: (-scores[idx], rows[idx][1]))
|
|
372
|
+
for rank_in_file, idx in enumerate(idxs[2:], start=2):
|
|
373
|
+
scores[idx] /= (1.0 + 0.35 * (rank_in_file - 1))
|
|
374
|
+
|
|
195
375
|
order = sorted(range(n_rows),
|
|
196
376
|
key=lambda i: (-scores[i], rows[i][0], rows[i][1]))
|
|
197
377
|
return [rows[i] for i in order]
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
# 【已停用·留档】本文件原为 engines/specs/cisa_kev.yaml。7ca2f22 移除
|
|
2
|
-
# OSV/CISA KEV 引擎代码(规避启发式杀毒误报)后,声明文件成了孤儿:加载器照常
|
|
3
|
-
# 读入,但 _BUILDERS 里没有对应 builder,每次启动固定刷一行「未知引擎类型」
|
|
4
|
-
# warning(对把 stderr 当错误日志采集的调用方是误报级噪音)。故加 _ 前缀改名,
|
|
5
|
-
# _load_external_engine_specs 跳过 _ 前缀文件,公开仓恢复干净启动。
|
|
6
|
-
# 本机仍可用:builder 由 scripts/local_engines.py(gitignored,不随公开仓提交)
|
|
7
|
-
# 注册,引擎元数据已完整并入该文件的 _LOCAL_ENGINE_SPECS。
|
|
8
|
-
# 公开仓若重新接回:拷回 engines/specs/ 并去掉下划线,同时提供 builder。
|
|
9
|
-
# ─── 以下为原始声明,未改动 ───
|
|
10
|
-
|
|
11
|
-
# CISA KEV — 已知被在野利用漏洞目录(免 key、免注册)
|
|
12
|
-
#
|
|
13
|
-
# 补的盲区:**「这个漏洞是不是正在被真实攻击利用」**。这是修复优先级里权重最高
|
|
14
|
-
# 的一档信息——NVD 给 CVSS 分数(理论严重度),OSV 给影响版本,而 KEV 给的是
|
|
15
|
-
# 官方确认「已被实际利用」的名单。三者互补,构成安全域的完整判断链。
|
|
16
|
-
#
|
|
17
|
-
# 数据形态(实测 2026-09-16):**单个 JSON 全量文件**,约 1.35MB、1710 条。
|
|
18
|
-
# https://www.cisa.gov/sites/default/files/feeds/known_exploited_vulnerabilities.json
|
|
19
|
-
# {"catalogVersion":"2026.09.14","vulnerabilities":[{cveID, vendorProject,
|
|
20
|
-
# product, vulnerabilityName, dateAdded, shortDescription, dueDate, ...}]}
|
|
21
|
-
# 上游**不支持查询参数**(实测 ?q= 无效,仍返回全量),因此必须本地过滤:
|
|
22
|
-
# 按查询词匹配 cveID / vendor / product / name / description。
|
|
23
|
-
#
|
|
24
|
-
# 约束与取舍:每次查询下载 1.35MB。为避免把带宽与延迟花在无关查询上,
|
|
25
|
-
# 本引擎声明 explicit_only + 低 priority,只在用户明确要「在野利用/KEV」类
|
|
26
|
-
# 信息时被选中,不参与通用路由。
|
|
27
|
-
#
|
|
28
|
-
# 验证:
|
|
29
|
-
# python3 scripts/engine_validate.py --engine cisa_kev --stage health --admit
|
|
30
|
-
# python3 scripts/search.py "chrome" --engine cisa_kev --json
|
|
31
|
-
|
|
32
|
-
engine_id: cisa_kev
|
|
33
|
-
type: cisa_kev
|
|
34
|
-
enabled: true
|
|
35
|
-
explicit_only: true
|
|
36
|
-
cost_tier: free
|
|
37
|
-
label: CISA KEV 在野利用漏洞
|
|
38
|
-
family: security
|
|
39
|
-
priority: 47
|
|
40
|
-
qps: 1
|
|
41
|
-
period: second
|
|
42
|
-
cost_per_call: 0.0
|
|
43
|
-
cost_unit: free
|
|
44
|
-
timeout: 30
|
|
45
|
-
canary_query: "chrome"
|
|
46
|
-
coverage:
|
|
47
|
-
- security
|
|
48
|
-
desc: "CISA 已知被在野利用漏洞目录(官方确认已被实际攻击利用的 CVE;全量 1.35MB 本地过滤)"
|
|
49
|
-
recommended: false
|
|
50
|
-
latency_ms: 4000
|
|
51
|
-
|
|
52
|
-
quality_queries:
|
|
53
|
-
- query: "chrome"
|
|
54
|
-
- query: "CVE-2021-44228"
|