argo-search 2.14.0 → 2.15.0
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/AGENTS.md +8 -6
- package/README.es.md +56 -824
- package/README.ja.md +55 -825
- package/README.ko.md +55 -823
- package/README.md +128 -868
- package/README.zh.md +206 -0
- package/SKILL.md +17 -18
- package/assets/readme/counts.json +1 -1
- package/assets/readme/hero.svg +23 -23
- package/backends/concept_vectors.bin +0 -0
- package/backends/domain_profiles.json +66 -0
- package/backends/engine_concept_vectors.json +1525 -1525
- package/backends/engine_registry.yaml +193 -46
- package/backends/quota_profiles.json +110 -0
- package/bin/argo +30 -17
- package/config.yaml +196 -36
- package/docs/ADDING_NEW_ENGINE.md +10 -0
- package/docs/ARGO_INTRO.md +1 -1
- package/docs/CHANGELOG.md +45 -0
- package/docs/ENGINE_CATALOG.md +128 -112
- package/docs/MCP_SETUP.md +2 -2
- package/docs/RELEASE_NOTES_v2.14.0.md +12 -1
- package/docs/RELEASE_NOTES_v2.14.1.md +80 -0
- package/docs/RELEASE_NOTES_v2.15.0.md +50 -0
- package/docs/RELEASING.md +53 -1
- package/engines/specs/ai_labs.yaml +89 -0
- package/engines/specs/artic.yaml +11 -1
- package/engines/specs/bilibili_hot.yaml +11 -1
- package/engines/specs/brave.yaml +3 -3
- package/engines/specs/cisa_alerts.yaml +40 -0
- package/engines/specs/cleveland.yaml +15 -1
- package/engines/specs/clinicaltrials.yaml +16 -1
- package/engines/specs/cn_ai_news.yaml +10 -8
- package/engines/specs/cnii.yaml +15 -4
- package/engines/specs/deezer.yaml +12 -1
- package/engines/specs/digup.yaml +11 -6
- package/engines/specs/doaj.yaml +14 -1
- package/engines/specs/douyin_hot.yaml +11 -1
- package/engines/specs/dw_news.yaml +4 -2
- package/engines/specs/endoflife.yaml +16 -1
- package/engines/specs/eng_blogs.yaml +63 -0
- package/engines/specs/eu_opendata.yaml +11 -1
- package/engines/specs/europeana.yaml +22 -5
- package/engines/specs/feed.yaml +62 -0
- package/engines/specs/felo.yaml +3 -3
- package/engines/specs/figshare.yaml +12 -1
- package/engines/specs/firecrawl.yaml +3 -0
- package/engines/specs/fourget.yaml +5 -2
- package/engines/specs/france24.yaml +6 -4
- package/engines/specs/fxtwitter.yaml +29 -6
- package/engines/specs/grepapp_mcp.yaml +62 -0
- package/engines/specs/guardian_rss.yaml +6 -4
- package/engines/specs/hackernews.yaml +17 -2
- package/engines/specs/hal.yaml +19 -1
- package/engines/specs/hf_datasets.yaml +59 -0
- package/engines/specs/hf_papers.yaml +17 -1
- package/engines/specs/itotii.yaml +13 -1
- package/engines/specs/jikan.yaml +12 -10
- package/engines/specs/kaggle.yaml +5 -3
- package/engines/specs/lobsters.yaml +41 -0
- package/engines/specs/local_seek.yaml +6 -0
- package/engines/specs/maven.yaml +61 -0
- package/engines/specs/nasa_cmr.yaml +12 -1
- package/engines/specs/nuget.yaml +57 -0
- package/engines/specs/open_meteo.yaml +1 -1
- package/engines/specs/redskill.yaml +2 -0
- package/engines/specs/searxng.yaml +4 -2
- package/engines/specs/sec_edgar.yaml +8 -3
- package/engines/specs/tatoeba.yaml +14 -1
- package/engines/specs/tinyfish.yaml +2 -0
- package/engines/specs/tinyfish_news.yaml +2 -0
- package/engines/specs/tinyfish_paper.yaml +2 -0
- package/engines/specs/toutiao_hot.yaml +11 -1
- package/engines/specs/train.yaml +3 -0
- package/engines/specs/tvmaze.yaml +5 -1
- package/engines/specs/twitter.yaml +4 -0
- package/engines/specs/unpaywall.yaml +6 -0
- package/engines/specs/usda.yaml +14 -1
- package/engines/specs/vam.yaml +17 -3
- package/engines/specs/weibo_hot.yaml +11 -1
- package/engines/specs/wolframalpha.yaml +3 -3
- package/engines/specs/xiaohongshu.yaml +2 -0
- package/engines/specs/zhihu.yaml +3 -18
- package/engines/specs/zhihu_kb.yaml +18 -0
- package/engines/specs/zhihu_questions.yaml +19 -0
- package/package.json +4 -2
- package/packages/dsh-plugin/README.md +9 -14
- package/packages/dsh-plugin/dsh/client.js +467 -1024
- package/packages/dsh-plugin/dsh/diagnostics.js +71 -20
- package/packages/dsh-plugin/dsh/native-tools.mjs +61 -113
- package/packages/dsh-plugin/dsh/runner.js +2 -0
- package/packages/dsh-plugin/dsh/wide-research.js +1 -1
- package/packages/dsh-plugin/package.json +8 -3
- package/packages/dsh-plugin/scripts/sync-local.mjs +87 -0
- package/packages/dsh-plugin/scripts/sync-local.sh +13 -1
- package/packages/dsh-plugin/test/diagnostics.test.js +38 -1
- package/packages/dsh-plugin/test/size-gate.test.js +2 -9
- package/scripts/adaptive.py +7 -1
- package/scripts/archive_run.py +112 -53
- package/scripts/argo_paths.py +40 -3
- package/scripts/badcase_ledger.py +153 -10
- package/scripts/build_concept_table.py +112 -55
- package/scripts/build_release_assets.sh +43 -15
- package/scripts/cache.py +5 -1
- package/scripts/caliber_isolation.py +60 -23
- package/scripts/circuit_breaker.py +56 -8
- package/scripts/cli_io.py +20 -2
- package/scripts/config_cache.py +31 -0
- package/scripts/daemon.py +146 -51
- package/scripts/dormant_ledger.py +239 -0
- package/scripts/engine_dispatch.py +3 -3
- package/scripts/engine_env.py +182 -1
- package/scripts/engine_families.py +50 -7
- package/scripts/engine_states.py +9 -51
- package/scripts/engine_validate.py +150 -6
- package/scripts/engines.py +15 -67
- package/scripts/engines_base.py +68 -124
- package/scripts/engines_builders.py +0 -51
- package/scripts/engines_builders_batch10.py +346 -100
- package/scripts/engines_builders_batch11.py +2 -75
- package/scripts/engines_builders_batch9.py +15 -228
- package/scripts/engines_builders_cn.py +0 -194
- package/scripts/engines_builders_feeds.py +203 -35
- package/scripts/engines_builders_intl.py +15 -443
- package/scripts/engines_builders_pixiv.py +2 -16
- package/scripts/engines_builders_science.py +0 -85
- package/scripts/engines_builders_search.py +7 -14
- package/scripts/engines_builders_tech.py +5 -112
- package/scripts/engines_builders_weather.py +236 -0
- package/scripts/engines_fields.py +91 -0
- package/scripts/engines_http.py +135 -0
- package/scripts/engines_mcp.py +383 -0
- package/scripts/engines_parsers.py +196 -27
- package/scripts/engines_schema_drift.py +260 -0
- package/scripts/evidence.py +13 -0
- package/scripts/evidence_loop.py +93 -5
- package/scripts/fetch_jsrun.py +15 -11
- package/scripts/fetch_v3.py +28 -28
- package/scripts/fulltext_store.py +42 -1
- package/scripts/fxtwitter_api.py +8 -7
- package/scripts/gen_engine_catalog.py +4 -4
- package/scripts/gen_native_tools.py +2 -1
- package/scripts/general_pool.py +15 -4
- package/scripts/health_check.py +1 -1
- package/scripts/link_source.py +65 -24
- package/scripts/local_intent.py +51 -15
- package/scripts/local_seek.py +37 -4
- package/scripts/local_seek_adapter.py +57 -17
- package/scripts/mcp_handlers.py +173 -99
- package/scripts/mcp_handlers_surface.py +6 -18
- package/scripts/mcp_server.py +1 -1
- package/scripts/mcp_tools.py +143 -61
- package/scripts/mcp_transport.py +42 -10
- package/scripts/min_version_scan.py +7 -3
- package/scripts/network_aware.py +7 -13
- package/scripts/pre-commit +57 -31
- package/scripts/query_understanding.py +30 -6
- package/scripts/quota.py +6 -1
- package/scripts/rank_signals.py +9 -0
- package/scripts/recompute.py +15 -5
- package/scripts/recovery.py +21 -15
- package/scripts/release.py +29 -32
- package/scripts/release_check.py +6 -26
- package/scripts/replay_eval.py +2 -2
- package/scripts/research_cli.py +40 -0
- package/scripts/research_notes.py +368 -0
- package/scripts/route.py +32 -70
- package/scripts/route_audit.py +259 -0
- package/scripts/route_combo.py +10 -4
- package/scripts/route_domains.py +150 -23
- package/scripts/route_lang.py +20 -7
- package/scripts/route_log.py +26 -9
- package/scripts/route_policy.py +91 -7
- package/scripts/route_telemetry_export.py +199 -0
- package/scripts/rrf_classic.py +5 -22
- package/scripts/search.py +2 -1
- package/scripts/search_attribution.py +33 -10
- package/scripts/search_cli.py +44 -7
- package/scripts/search_entry.py +5 -1
- package/scripts/search_output.py +5 -4
- package/scripts/search_pipeline.py +12 -0
- package/scripts/search_rank.py +21 -11
- package/scripts/secret_guard.py +106 -0
- package/scripts/semantic_evidence.py +539 -117
- package/scripts/settings_page.py +83 -11
- package/scripts/social_engines/xiaohongshu_engine.py +2 -1
- package/scripts/social_engines/zhihu_engine.py +251 -43
- package/scripts/sogou_weixin_browser.py +5 -6
- package/scripts/source_audit.py +77 -0
- package/scripts/source_ledger.py +2 -15
- package/scripts/source_selection.py +45 -20
- package/scripts/straggler_policy.py +1 -2
- package/scripts/sync_backends.py +24 -0
- package/scripts/tfidf_router.py +23 -11
- package/scripts/time_utils.py +54 -1
- package/scripts/train.py +68 -2
- package/scripts/usage_log.py +26 -1
- package/sub-skills/argo-wide-research/SKILL.md +68 -0
- package/sub-skills/ego-search/SKILL.md +1 -1
- package/sub-skills/local-seek/scripts/seek_fts.py +67 -4
- package/README.en.md +0 -826
- package/scripts/caliber_dedupe.py +0 -66
- package/scripts/engines_builders_batch16.py +0 -186
- package/scripts/health_probe.py +0 -253
- package/scripts/image_vision/vision_probe +0 -0
- package/scripts/social_engines/twitter_engine.py +0 -514
- package/scripts/sync_installs.py +0 -29
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* sync-local.mjs — 跨平台(Windows/macOS/Linux)将本仓 packages/dsh-plugin 同步到本机 DSH profile。
|
|
4
|
+
* 用法:
|
|
5
|
+
* node scripts/sync-local.mjs # 同步 web,desktop(或 DSH_PROFILES)
|
|
6
|
+
* node scripts/sync-local.mjs web # 只同步指定 profile
|
|
7
|
+
* node scripts/sync-local.mjs --check # 只比对不写,有漂移退出 1
|
|
8
|
+
*/
|
|
9
|
+
import fs from 'node:fs';
|
|
10
|
+
import os from 'node:os';
|
|
11
|
+
import path from 'node:path';
|
|
12
|
+
import { fileURLToPath } from 'node:url';
|
|
13
|
+
|
|
14
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
15
|
+
const SRC = path.resolve(__dirname, '..');
|
|
16
|
+
const DSH_HOME = process.env.DSH_HOME || path.join(os.homedir(), '.dsh');
|
|
17
|
+
|
|
18
|
+
let mode = 'sync';
|
|
19
|
+
const profiles = [];
|
|
20
|
+
for (const arg of process.argv.slice(2)) {
|
|
21
|
+
if (arg === '--check') mode = 'check';
|
|
22
|
+
else if (arg === '--restart') {
|
|
23
|
+
console.error('[removed] --restart 已移除:同步产物不等于激活 Host');
|
|
24
|
+
process.exit(2);
|
|
25
|
+
} else if (arg === '-h' || arg === '--help') {
|
|
26
|
+
console.log('Usage: node scripts/sync-local.mjs [--check] [profile...]');
|
|
27
|
+
process.exit(0);
|
|
28
|
+
} else profiles.push(arg);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (profiles.length === 0) {
|
|
32
|
+
const raw = process.env.DSH_PROFILES || 'web,desktop';
|
|
33
|
+
profiles.push(...raw.split(',').map((s) => s.trim()).filter(Boolean));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function filesEqual(a, b) {
|
|
37
|
+
if (!fs.existsSync(a) || !fs.existsSync(b)) return false;
|
|
38
|
+
const sa = fs.statSync(a), sb = fs.statSync(b);
|
|
39
|
+
if (sa.isDirectory() && sb.isDirectory()) {
|
|
40
|
+
const ea = fs.readdirSync(a).sort(), eb = fs.readdirSync(b).sort();
|
|
41
|
+
if (ea.length !== eb.length || ea.some((x, i) => x !== eb[i])) return false;
|
|
42
|
+
return ea.every((name) => filesEqual(path.join(a, name), path.join(b, name)));
|
|
43
|
+
}
|
|
44
|
+
if (sa.isFile() && sb.isFile()) {
|
|
45
|
+
if (sa.size !== sb.size) return false;
|
|
46
|
+
return Buffer.compare(fs.readFileSync(a), fs.readFileSync(b)) === 0;
|
|
47
|
+
}
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const ts = new Date().toISOString().replace(/[-:]/g, '').replace('T', '-').slice(0, 15);
|
|
52
|
+
let drift = 0;
|
|
53
|
+
|
|
54
|
+
for (const p of profiles) {
|
|
55
|
+
const dest = path.join(DSH_HOME, 'profiles', p, 'node_modules', '@taxueseek', 'argo-dsh');
|
|
56
|
+
let lst;
|
|
57
|
+
try { lst = fs.lstatSync(dest); } catch {
|
|
58
|
+
console.log(`[skip] ${p}: 未安装 ${dest}`);
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (lst.isSymbolicLink() && fs.realpathSync(dest) === fs.realpathSync(SRC)) {
|
|
62
|
+
console.log(mode === 'check' ? `[ok] ${p} (symlink)` : `[skip] ${p}: 已是直连 symlink`);
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
if (mode === 'check') {
|
|
66
|
+
const same = filesEqual(path.join(SRC, 'dsh'), path.join(dest, 'dsh'))
|
|
67
|
+
&& filesEqual(path.join(SRC, 'package.json'), path.join(dest, 'package.json'));
|
|
68
|
+
if (same) console.log(`[ok] ${p}`);
|
|
69
|
+
else {
|
|
70
|
+
console.log(`[drift] ${p}: 源码与已安装 bundle 不一致,请运行 npm run sync-local`);
|
|
71
|
+
drift = 1;
|
|
72
|
+
}
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
const bakDir = path.join(DSH_HOME, 'backups', `argo-dsh-sync-${ts}-${p}`);
|
|
76
|
+
fs.mkdirSync(path.dirname(bakDir), { recursive: true });
|
|
77
|
+
fs.cpSync(dest, bakDir, { recursive: true, force: true });
|
|
78
|
+
fs.rmSync(path.join(dest, 'dsh'), { recursive: true, force: true });
|
|
79
|
+
fs.cpSync(path.join(SRC, 'dsh'), path.join(dest, 'dsh'), { recursive: true, force: true });
|
|
80
|
+
for (const f of ['package.json', 'cordis.patch.yml', 'README.md']) {
|
|
81
|
+
fs.copyFileSync(path.join(SRC, f), path.join(dest, f));
|
|
82
|
+
}
|
|
83
|
+
console.log(`[synced] ${p}`);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (mode === 'check') process.exit(drift);
|
|
87
|
+
console.log('[artifact-synced] 产物已同步;请核对 Host 运行态');
|
|
@@ -45,10 +45,22 @@ drift=0
|
|
|
45
45
|
|
|
46
46
|
for p in "${PROFILES[@]}"; do
|
|
47
47
|
DEST="$DSH_HOME/profiles/$p/node_modules/@taxueseek/argo-dsh"
|
|
48
|
-
if [ ! -
|
|
48
|
+
if [ ! -e "$DEST" ] && [ ! -L "$DEST" ]; then
|
|
49
49
|
echo "[skip] $p: 未安装 $DEST"
|
|
50
50
|
continue
|
|
51
51
|
fi
|
|
52
|
+
if [ -L "$DEST" ]; then
|
|
53
|
+
REAL_DEST="$(cd "$DEST" 2>/dev/null && pwd -P || true)"
|
|
54
|
+
REAL_SRC="$(cd "$SRC" && pwd -P)"
|
|
55
|
+
if [ "$REAL_DEST" = "$REAL_SRC" ]; then
|
|
56
|
+
if [ "$MODE" = check ]; then
|
|
57
|
+
echo "[ok] $p (symlink)"
|
|
58
|
+
else
|
|
59
|
+
echo "[skip] $p: 已是直连 symlink,无需拷贝同步"
|
|
60
|
+
fi
|
|
61
|
+
continue
|
|
62
|
+
fi
|
|
63
|
+
fi
|
|
52
64
|
if [ "$MODE" = check ]; then
|
|
53
65
|
if diff -rq "$SRC/dsh" "$DEST/dsh" >/dev/null 2>&1 \
|
|
54
66
|
&& cmp -s "$SRC/package.json" "$DEST/package.json"; then
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { test } from 'node:test'
|
|
2
2
|
import assert from 'node:assert/strict'
|
|
3
|
-
import {
|
|
3
|
+
import { mkdtempSync, mkdirSync, writeFileSync, rmSync } from 'node:fs'
|
|
4
|
+
import { join } from 'node:path'
|
|
5
|
+
import { tmpdir } from 'node:os'
|
|
6
|
+
import { getMcpPoolStats, getRouteHealth, resetMcpPool, resolveStateDir } from '../dsh/diagnostics.js'
|
|
4
7
|
|
|
5
8
|
test('diagnostics: getMcpPoolStats returns pool status and active loads', () => {
|
|
6
9
|
const dummyPool = [
|
|
@@ -26,3 +29,37 @@ test('diagnostics: resetMcpPool evicts connections safely', () => {
|
|
|
26
29
|
assert.equal(result.poolSizeNow, 0)
|
|
27
30
|
assert.equal(closed, 2)
|
|
28
31
|
})
|
|
32
|
+
|
|
33
|
+
test('diagnostics: getRouteHealth reads real route.jsonl fields and summary without query', async () => {
|
|
34
|
+
const dir = mkdtempSync(join(tmpdir(), 'argo-diag-'))
|
|
35
|
+
try {
|
|
36
|
+
mkdirSync(join(dir, 'usage_log'), { recursive: true })
|
|
37
|
+
const rows = [
|
|
38
|
+
JSON.stringify({ domain: 'code_search', engine: 'github', engines: ['github', 'anysearch'], primary_lang: 'en', effective_lang: 'en', confidence: 0.92, mode: 'auto', intents: ['fact'], ts: '2026-11-15T10:00:00Z' }),
|
|
39
|
+
JSON.stringify({ domain: null, engine: 'anysearch', engines: ['anysearch', 'local_bing'], primary_lang: 'en', effective_lang: 'es', confidence: 0.65, mode: 'fast', intents: ['news'], ts: '2026-11-15T10:01:00Z' }),
|
|
40
|
+
]
|
|
41
|
+
writeFileSync(join(dir, 'usage_log', 'route.jsonl'), rows.join('\n') + '\n', 'utf8')
|
|
42
|
+
const health = await getRouteHealth(dir, 5)
|
|
43
|
+
assert.equal(health.samples.length, 2)
|
|
44
|
+
assert.equal(health.samples[0].domain, 'code_search')
|
|
45
|
+
assert.equal(health.samples[1].effective_lang, 'es')
|
|
46
|
+
assert.equal('query' in health.samples[0], false)
|
|
47
|
+
assert.equal(health.summary.total, 2)
|
|
48
|
+
assert.equal(health.summary.fallbackCount, 1)
|
|
49
|
+
assert.equal(health.summary.fallbackRate, 0.5)
|
|
50
|
+
assert.equal(health.summary.langCounts.es, 1)
|
|
51
|
+
} finally {
|
|
52
|
+
rmSync(dir, { recursive: true, force: true })
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
test('diagnostics: resolveStateDir honors ARGO_STATE_DIR env override', () => {
|
|
57
|
+
const prev = process.env.ARGO_STATE_DIR
|
|
58
|
+
process.env.ARGO_STATE_DIR = '/tmp/argo-custom-state-test'
|
|
59
|
+
try {
|
|
60
|
+
assert.equal(resolveStateDir(), '/tmp/argo-custom-state-test')
|
|
61
|
+
} finally {
|
|
62
|
+
if (prev === undefined) delete process.env.ARGO_STATE_DIR
|
|
63
|
+
else process.env.ARGO_STATE_DIR = prev
|
|
64
|
+
}
|
|
65
|
+
})
|
|
@@ -31,15 +31,8 @@ const DSH_DIR = join(PKG_ROOT, 'dsh')
|
|
|
31
31
|
|
|
32
32
|
const HARD_LIMIT = 1000
|
|
33
33
|
|
|
34
|
-
// 路径 → [上限行数, 为什么不拆/拆到哪一步]
|
|
35
|
-
const GRANDFATHERED = new Map(
|
|
36
|
-
['dsh/client.js', [
|
|
37
|
-
1548,
|
|
38
|
-
'web 设置面板单页(接入/工具/密钥/研究/高级五段 UI + 状态机);' +
|
|
39
|
-
'2026-11-09 同步新增独立引擎(mojeek、repology 等)声明密钥至 1,548;' +
|
|
40
|
-
'拆分候选:把各段表单渲染抽成 render-* 模块,状态机留在本文件',
|
|
41
|
-
]],
|
|
42
|
-
])
|
|
34
|
+
// 路径 → [上限行数, 为什么不拆/拆到哪一步](client.js 经 schema 驱动重构已降至千行以内,清单清零)
|
|
35
|
+
const GRANDFATHERED = new Map()
|
|
43
36
|
|
|
44
37
|
function lineCount(file) {
|
|
45
38
|
const text = readFileSync(file, 'utf8')
|
package/scripts/adaptive.py
CHANGED
|
@@ -128,9 +128,15 @@ def scenario_of(decision: dict | None) -> dict[str, str]:
|
|
|
128
128
|
"""
|
|
129
129
|
d = decision or {}
|
|
130
130
|
feats = d.get("features") or {}
|
|
131
|
+
lang = str(
|
|
132
|
+
feats.get("lang_override")
|
|
133
|
+
or feats.get("effective_lang")
|
|
134
|
+
or feats.get("primary_lang")
|
|
135
|
+
or ""
|
|
136
|
+
)
|
|
131
137
|
return {
|
|
132
138
|
"domain": str(d.get("domain") or ""),
|
|
133
|
-
"lang":
|
|
139
|
+
"lang": lang,
|
|
134
140
|
}
|
|
135
141
|
|
|
136
142
|
|
package/scripts/archive_run.py
CHANGED
|
@@ -26,9 +26,8 @@ archive_run.py — 搜索/研究 run 工作区归档
|
|
|
26
26
|
|
|
27
27
|
默认根目录解析顺序:
|
|
28
28
|
1. ARGO_ARCHIVE_ROOT
|
|
29
|
-
2.
|
|
30
|
-
3.
|
|
31
|
-
4. ./argo-search-archive
|
|
29
|
+
2. 兼容既有工作区目录:<workspace>/数据/argo-search-archive(若存在)
|
|
30
|
+
3. 规范化项目标准级惯例:<workspace>/docs/research/archive 或 <workspace>/research/archive
|
|
32
31
|
"""
|
|
33
32
|
|
|
34
33
|
from __future__ import annotations
|
|
@@ -138,17 +137,35 @@ def resolve_archive_root(explicit: str | Path | None = None) -> Path:
|
|
|
138
137
|
if env:
|
|
139
138
|
return Path(env).expanduser().resolve()
|
|
140
139
|
|
|
141
|
-
#
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
root = p / "数据" / "argo-search-archive"
|
|
146
|
-
return root
|
|
147
|
-
if p == p.parent:
|
|
148
|
-
break
|
|
140
|
+
# 与 research_notes 共用同一个基目录,避免「笔记在 research/、归档在
|
|
141
|
+
# docs/research/archive/」的首次使用分叉。
|
|
142
|
+
from research_notes import find_workspace_root, resolve_research_base
|
|
143
|
+
ws = find_workspace_root()
|
|
149
144
|
|
|
150
|
-
|
|
151
|
-
|
|
145
|
+
# 1. 兼容既有特定工作区归档目录(如母仓历史沿用的 数据/argo-search-archive)
|
|
146
|
+
legacy_root = ws / "数据" / "argo-search-archive"
|
|
147
|
+
if legacy_root.is_dir():
|
|
148
|
+
return legacy_root
|
|
149
|
+
|
|
150
|
+
# 2. 笔记基目录下的 archive/(docs/research/archive 或 research/archive)
|
|
151
|
+
base = resolve_research_base(ws)
|
|
152
|
+
try:
|
|
153
|
+
from research_notes import should_anchor_workspace
|
|
154
|
+
anchor = should_anchor_workspace(ws)
|
|
155
|
+
except Exception:
|
|
156
|
+
# 探测不可用不赌工作区:结论进用户级持久区。与 research_notes 的
|
|
157
|
+
# 兜底同一口径(宁落持久区,不落易失区),见 workspace_anchorable。
|
|
158
|
+
anchor = False
|
|
159
|
+
if anchor:
|
|
160
|
+
return base / "archive"
|
|
161
|
+
|
|
162
|
+
# 3. 工作区不可锚定(容器、无持久盘):退回用户级文档目录,随环境销毁
|
|
163
|
+
# 会丢掉全部归档证据。与缓存分开(缓存可清,归档不可丢)。
|
|
164
|
+
try:
|
|
165
|
+
from argo_paths import research_root
|
|
166
|
+
return research_root().expanduser().resolve() / "archive"
|
|
167
|
+
except Exception:
|
|
168
|
+
return base / "archive"
|
|
152
169
|
|
|
153
170
|
|
|
154
171
|
def make_run_id(query: str, when: datetime | None = None) -> str:
|
|
@@ -160,57 +177,99 @@ def make_run_id(query: str, when: datetime | None = None) -> str:
|
|
|
160
177
|
|
|
161
178
|
def search_archive(query: str, root: Path | None = None,
|
|
162
179
|
since: str | None = None, until: str | None = None,
|
|
163
|
-
limit: int = 10
|
|
180
|
+
limit: int = 10,
|
|
181
|
+
include_notes: bool = False) -> list[dict[str, Any]]:
|
|
164
182
|
"""检索归档索引(成果复用):主题词命中的历史研究/搜索 run。
|
|
165
183
|
|
|
166
184
|
- 数据源:{root}/index.jsonl(无索引时返回空)
|
|
167
185
|
- 过滤:query/tag/note 子串命中(query 必需);packed_at 日期窗可选
|
|
186
|
+
- include_notes=True 时并入 research_notes 的 research-index.jsonl,
|
|
187
|
+
让「上次得到的结论」也能被搜到——只搜证据不搜结论,等于每次从零开始
|
|
168
188
|
- 返回:run_id / packed_at / query / tag / source / counts / run_dir
|
|
169
189
|
"""
|
|
170
190
|
archive_root = (root or resolve_archive_root()).expanduser().resolve()
|
|
171
191
|
index_path = archive_root / "index.jsonl"
|
|
172
|
-
if not index_path.exists():
|
|
173
|
-
return []
|
|
174
192
|
kw = (query or "").strip().lower()
|
|
175
193
|
out: list[dict[str, Any]] = []
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
line
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
194
|
+
if index_path.exists():
|
|
195
|
+
try:
|
|
196
|
+
with index_path.open(encoding="utf-8") as f:
|
|
197
|
+
for line in f:
|
|
198
|
+
line = line.strip()
|
|
199
|
+
if not line:
|
|
200
|
+
continue
|
|
201
|
+
try:
|
|
202
|
+
row = json.loads(line)
|
|
203
|
+
except ValueError:
|
|
204
|
+
continue
|
|
205
|
+
hay = " ".join([
|
|
206
|
+
str(row.get("query") or ""),
|
|
207
|
+
str(row.get("tag") or ""),
|
|
208
|
+
str(row.get("note") or ""),
|
|
209
|
+
]).lower()
|
|
210
|
+
if kw and kw not in hay:
|
|
211
|
+
continue
|
|
212
|
+
packed = str(row.get("packed_at") or "")
|
|
213
|
+
day = packed[:10]
|
|
214
|
+
if since and day and day < since:
|
|
215
|
+
continue
|
|
216
|
+
if until and day and day > until:
|
|
217
|
+
continue
|
|
218
|
+
out.append({
|
|
219
|
+
"run_id": row.get("run_id"),
|
|
220
|
+
"packed_at": packed,
|
|
221
|
+
"query": row.get("query"),
|
|
222
|
+
"tag": row.get("tag"),
|
|
223
|
+
"source": row.get("source"),
|
|
224
|
+
"status": row.get("status"),
|
|
225
|
+
"counts": row.get("counts") or {},
|
|
226
|
+
"run_dir": row.get("run_dir"),
|
|
227
|
+
})
|
|
228
|
+
if len(out) >= limit:
|
|
229
|
+
break
|
|
230
|
+
except OSError:
|
|
231
|
+
return out
|
|
232
|
+
|
|
233
|
+
if include_notes and kw:
|
|
234
|
+
try:
|
|
235
|
+
from research_notes import search_index as _search_notes, resolve_root as _resolve_note_root
|
|
236
|
+
# 笔记索引根与归档根**不是同一个目录**:8ec0501 起归档在
|
|
237
|
+
# `<base>/archive/`,笔记在 `<base>/`,索引是 `<base>/research-index.jsonl`。
|
|
238
|
+
# 只传 archive_root 时 `_search_notes` 读不到索引,`--include-notes`
|
|
239
|
+
# 永远空结果(实测:传 archive_root 得 [],传 note root 得命中)。
|
|
240
|
+
# 候选根取「笔记根 + 归档根 + 归档根的父目录」:
|
|
241
|
+
# - 笔记根:ARGO_RESEARCH_ROOT 与 ARGO_ARCHIVE_ROOT 分设时仍然命中
|
|
242
|
+
# - 归档根 / 其父:共用基目录布局(archive 与笔记同基)
|
|
243
|
+
# 三者去重后合并,任一根有索引都能搜到。
|
|
244
|
+
candidates: list[Path] = []
|
|
245
|
+
for cand in (_resolve_note_root(), archive_root, archive_root.parent):
|
|
246
|
+
rc = cand.expanduser().resolve()
|
|
247
|
+
if rc not in candidates:
|
|
248
|
+
candidates.append(rc)
|
|
249
|
+
seen: set[str] = set()
|
|
250
|
+
for cand in candidates:
|
|
251
|
+
if not (cand / "research-index.jsonl").is_file():
|
|
198
252
|
continue
|
|
199
|
-
|
|
200
|
-
"
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
253
|
+
for row in _search_notes(kw, root=cand, limit=limit):
|
|
254
|
+
key = f"{row.get('kind')}:{row.get('slug')}"
|
|
255
|
+
if key in seen:
|
|
256
|
+
continue
|
|
257
|
+
seen.add(key)
|
|
258
|
+
out.append({
|
|
259
|
+
"run_id": f"note:{row.get('kind')}:{row.get('slug')}",
|
|
260
|
+
"packed_at": row.get("created_at"),
|
|
261
|
+
"query": row.get("title"),
|
|
262
|
+
"tag": row.get("kind"),
|
|
263
|
+
"source": "research_note",
|
|
264
|
+
"status": "completed",
|
|
265
|
+
"counts": {},
|
|
266
|
+
"run_dir": str(row.get("note_file")),
|
|
267
|
+
"note_slug": row.get("slug"),
|
|
268
|
+
"note_kind": row.get("kind"),
|
|
269
|
+
})
|
|
270
|
+
except Exception:
|
|
271
|
+
pass
|
|
272
|
+
return out[:limit]
|
|
214
273
|
|
|
215
274
|
|
|
216
275
|
def write_search_archive(
|
package/scripts/argo_paths.py
CHANGED
|
@@ -34,6 +34,8 @@ ENV_STATE_DIR = "ARGO_STATE_DIR"
|
|
|
34
34
|
# 平台惯例变量(只读,不新增 argo 私有名字)
|
|
35
35
|
ENV_XDG_CACHE = "XDG_CACHE_HOME"
|
|
36
36
|
ENV_LOCALAPPDATA = "LOCALAPPDATA"
|
|
37
|
+
# 研究结论归档的独立覆盖名(与缓存分离:缓存可清,结论不可丢)
|
|
38
|
+
ENV_RESEARCH_DIR = "ARGO_RESEARCH_ROOT"
|
|
37
39
|
|
|
38
40
|
# 历史默认目录(也是 config.yaml 中 db_path 的默认前缀)
|
|
39
41
|
_LEGACY_ROOT = "~/.cache/unified-search"
|
|
@@ -112,6 +114,41 @@ def state_root() -> Path:
|
|
|
112
114
|
return platform_cache_default()
|
|
113
115
|
|
|
114
116
|
|
|
117
|
+
def research_root() -> Path:
|
|
118
|
+
"""研究结论归档的**独立**根目录,与缓存分开(缓存可清,结论不可丢)。
|
|
119
|
+
|
|
120
|
+
为什么不复用 state_root:state_root 的语义是「可重建的派生状态」——
|
|
121
|
+
缓存、配额计数、健康度都能删,删了最多重跑。研究笔记是**用户产出**,
|
|
122
|
+
删掉不可恢复。两者放进同一个可清理区,用户清缓存时会连带丢掉全部
|
|
123
|
+
研究结论(第一性原理:保留策略不同的数据不该共享生命周期)。
|
|
124
|
+
|
|
125
|
+
优先级:
|
|
126
|
+
1. ARGO_RESEARCH_ROOT(显式覆盖,容器/多机指向挂载卷时用它)
|
|
127
|
+
2. 平台惯例的**文档**目录(不是缓存目录):
|
|
128
|
+
macOS → ~/Documents/argo-research
|
|
129
|
+
Windows → %USERPROFILE%\\Documents\\argo-research
|
|
130
|
+
POSIX → $XDG_DOCUMENTS_DIR(未设则 ~/Documents/argo-research)
|
|
131
|
+
|
|
132
|
+
注意:工作区内的 docs/research 或 research/ 由 research_notes.resolve_root
|
|
133
|
+
负责,那是**项目级**归档(跟着仓库走、可提交、可共享给协作者);本函数
|
|
134
|
+
是**用户级**兜底,只在没有工作区可锚定时使用,不参与项目内归档。
|
|
135
|
+
"""
|
|
136
|
+
override = os.environ.get(ENV_RESEARCH_DIR, "").strip()
|
|
137
|
+
if override:
|
|
138
|
+
return Path(os.path.expanduser(override))
|
|
139
|
+
|
|
140
|
+
env = os.environ
|
|
141
|
+
platform = sys.platform
|
|
142
|
+
if platform == "darwin":
|
|
143
|
+
base = Path.home() / "Documents"
|
|
144
|
+
elif platform.startswith("win"):
|
|
145
|
+
base = Path(os.path.expanduser(str(env.get("USERPROFILE") or "~"))) / "Documents"
|
|
146
|
+
else:
|
|
147
|
+
xdg_docs = str(env.get("XDG_DOCUMENTS_DIR") or "").strip()
|
|
148
|
+
base = Path(os.path.expanduser(xdg_docs)) if xdg_docs else Path.home() / "Documents"
|
|
149
|
+
return base / "argo-research"
|
|
150
|
+
|
|
151
|
+
|
|
115
152
|
def resolved_paths() -> dict[str, str]:
|
|
116
153
|
"""诊断用:把关键路径的**实际来源**摊开(`python3 scripts/argo_paths.py`)。
|
|
117
154
|
|
|
@@ -130,6 +167,7 @@ def resolved_paths() -> dict[str, str]:
|
|
|
130
167
|
else:
|
|
131
168
|
out["state_source"] = "平台惯例默认"
|
|
132
169
|
out["state_root"] = str(state_root())
|
|
170
|
+
out["research_root"] = str(research_root())
|
|
133
171
|
out["platform_cache_default"] = str(platform_cache_default())
|
|
134
172
|
out["legacy_root"] = str(Path(os.path.expanduser(_LEGACY_ROOT)))
|
|
135
173
|
try:
|
|
@@ -325,8 +363,8 @@ def run_checks(lock_hold_s: float = 0.15) -> list[dict[str, Any]]:
|
|
|
325
363
|
|
|
326
364
|
`lock_hold_s` 是子进程持锁时长,判据是「第二个持有者等待 ≥100 ms」(见
|
|
327
365
|
`_check_lock_roundtrip`),0.15 s 留足一倍余量即可。历史上这里写 0.6 s,
|
|
328
|
-
让每次自检固定空等 600 ms
|
|
329
|
-
|
|
366
|
+
让每次自检固定空等 600 ms;`tests/test_platform_paths_conventions.py` 早已
|
|
367
|
+
用 0.2(原插件桥测试用 0.15,随 2026-11-13 ZCode 插件剥离退出),
|
|
330
368
|
此处对齐同一口径,自检结论不变。
|
|
331
369
|
"""
|
|
332
370
|
checks: list[dict[str, Any]] = []
|
|
@@ -477,7 +515,6 @@ def _config_db_path() -> str | None:
|
|
|
477
515
|
def state_path(*parts: str) -> Path:
|
|
478
516
|
"""返回状态根目录下的路径(不自动创建目录)。
|
|
479
517
|
|
|
480
|
-
state_path("health.db") → <root>/health.db
|
|
481
518
|
state_path("admission", "x.json") → <root>/admission/x.json
|
|
482
519
|
"""
|
|
483
520
|
return state_root().joinpath(*parts)
|