argo-search 2.14.1 → 2.16.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 +57 -813
- package/README.ja.md +56 -814
- package/README.ko.md +56 -812
- package/README.md +160 -754
- package/README.zh.md +152 -872
- package/SKILL.md +22 -23
- 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 +149 -6
- package/backends/engine_concept_vectors.json +1525 -1525
- package/backends/engine_registry.yaml +139 -30
- package/backends/quota_profiles.json +83 -3
- package/bin/argo +33 -17
- package/config.yaml +189 -33
- package/docs/ADDING_NEW_ENGINE.md +10 -0
- package/docs/ARGO_INTRO.md +1 -1
- package/docs/CHANGELOG.md +38 -0
- package/docs/ENGINE_CATALOG.md +102 -89
- package/docs/MCP_SETUP.md +10 -1
- package/docs/RELEASE_NOTES_v2.14.1.md +4 -4
- package/docs/RELEASE_NOTES_v2.15.0.md +50 -0
- package/docs/RELEASE_NOTES_v2.16.0.md +58 -0
- package/docs/RELEASING.md +1 -1
- package/engines/specs/ai_labs.yaml +89 -0
- package/engines/specs/archive_org.yaml +1 -1
- package/engines/specs/bilibili_hot.yaml +11 -1
- package/engines/specs/brave.yaml +3 -3
- package/engines/specs/carbon_intensity.yaml +1 -1
- package/engines/specs/cisa_alerts.yaml +40 -0
- package/engines/specs/cn_ai_news.yaml +10 -8
- package/engines/specs/crates.yaml +1 -1
- package/engines/specs/crossref.yaml +4 -2
- package/engines/specs/crt_sh.yaml +1 -1
- package/engines/specs/dblp.yaml +1 -1
- package/engines/specs/devto.yaml +1 -1
- package/engines/specs/digup.yaml +11 -6
- package/engines/specs/docker_hub.yaml +1 -1
- package/engines/specs/douyin_hot.yaml +11 -1
- package/engines/specs/dw_news.yaml +4 -2
- package/engines/specs/eng_blogs.yaml +63 -0
- package/engines/specs/europeana.yaml +3 -4
- package/engines/specs/europepmc.yaml +1 -1
- package/engines/specs/felo.yaml +3 -3
- 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 +30 -7
- package/engines/specs/gbfs_nyc.yaml +1 -1
- package/engines/specs/gleif.yaml +1 -1
- package/engines/specs/gov_regulations.yaml +1 -1
- package/engines/specs/grepapp_mcp.yaml +62 -0
- package/engines/specs/guardian_rss.yaml +6 -4
- package/engines/specs/hf_datasets.yaml +1 -1
- package/engines/specs/huggingface.yaml +1 -1
- package/engines/specs/itotii.yaml +13 -1
- package/engines/specs/keenable.yaml +7 -1
- package/engines/specs/linux_do.yaml +63 -0
- package/engines/specs/lobsters.yaml +41 -0
- package/engines/specs/local_crossref.yaml +3 -1
- package/engines/specs/local_github.yaml +1 -1
- package/engines/specs/local_npm.yaml +6 -0
- package/engines/specs/local_openstreetmap.yaml +1 -1
- package/engines/specs/local_seek.yaml +6 -0
- package/engines/specs/maven.yaml +1 -1
- package/engines/specs/mdn.yaml +1 -1
- package/engines/specs/musicbrainz.yaml +1 -1
- package/engines/specs/nasa_images.yaml +1 -1
- package/engines/specs/nhtsa_vpic.yaml +6 -3
- package/engines/specs/npm.yaml +1 -1
- package/engines/specs/nuget.yaml +1 -1
- package/engines/specs/nvd.yaml +1 -1
- package/engines/specs/open_meteo.yaml +1 -1
- package/engines/specs/openalex.yaml +4 -2
- package/engines/specs/openreview.yaml +1 -1
- package/engines/specs/polymarket.yaml +1 -1
- package/engines/specs/redskill.yaml +2 -0
- package/engines/specs/searxng.yaml +4 -2
- package/engines/specs/sec_edgar.yaml +9 -4
- package/engines/specs/steam.yaml +1 -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/twitter.yaml +4 -0
- package/engines/specs/unpaywall.yaml +6 -0
- package/engines/specs/vam.yaml +17 -3
- package/engines/specs/weibo_hot.yaml +11 -1
- package/engines/specs/wikidata.yaml +1 -1
- package/engines/specs/wikipedia.yaml +1 -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_hot_app.yaml +1 -1
- 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 +481 -1037
- package/packages/dsh-plugin/dsh/diagnostics.js +71 -20
- package/packages/dsh-plugin/dsh/index.js +6 -0
- package/packages/dsh-plugin/dsh/runner.js +3 -1
- package/packages/dsh-plugin/dsh/workbench-client.js +796 -0
- package/packages/dsh-plugin/dsh/workbench-md.js +386 -0
- package/packages/dsh-plugin/dsh/workbench-suggestions.js +148 -0
- package/packages/dsh-plugin/dsh/workbench.js +966 -0
- package/packages/dsh-plugin/icon.svg +23 -0
- package/packages/dsh-plugin/package.json +10 -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/packages/dsh-plugin/test/workbench.test.js +92 -0
- package/scripts/adaptive.py +7 -1
- package/scripts/archive_run.py +112 -53
- package/scripts/argo_paths.py +42 -5
- package/scripts/badcase_ledger.py +117 -9
- package/scripts/build_concept_table.py +112 -55
- package/scripts/cache.py +6 -2
- package/scripts/caliber_isolation.py +60 -23
- package/scripts/circuit_breaker.py +72 -11
- package/scripts/cli_io.py +20 -2
- package/scripts/config_cache.py +44 -1
- package/scripts/daemon.py +151 -51
- package/scripts/dormant_ledger.py +23 -9
- package/scripts/engine_dispatch.py +8 -5
- package/scripts/engine_env.py +191 -1
- package/scripts/engine_families.py +50 -7
- package/scripts/engine_states.py +3 -50
- package/scripts/engine_validate.py +13 -45
- package/scripts/engines.py +15 -31
- package/scripts/engines_base.py +66 -61
- package/scripts/engines_builders.py +0 -15
- package/scripts/engines_builders_archive.py +4 -3
- package/scripts/engines_builders_batch10.py +346 -100
- package/scripts/engines_builders_batch11.py +4 -76
- package/scripts/engines_builders_batch13.py +4 -3
- package/scripts/engines_builders_batch14.py +2 -1
- package/scripts/engines_builders_batch15.py +2 -1
- package/scripts/engines_builders_batch9.py +16 -25
- package/scripts/engines_builders_cn.py +7 -201
- package/scripts/engines_builders_data.py +12 -11
- package/scripts/engines_builders_data_macro.py +5 -4
- package/scripts/engines_builders_dsh.py +2 -1
- package/scripts/engines_builders_feeds.py +76 -11
- package/scripts/engines_builders_finance.py +2 -1
- package/scripts/engines_builders_intl.py +18 -117
- package/scripts/engines_builders_media.py +59 -12
- package/scripts/engines_builders_pixiv.py +2 -16
- package/scripts/engines_builders_science.py +8 -7
- package/scripts/engines_builders_search.py +7 -14
- package/scripts/engines_builders_skill.py +2 -1
- package/scripts/engines_builders_tech.py +8 -17
- package/scripts/engines_builders_weather.py +241 -0
- package/scripts/engines_fields.py +91 -0
- package/scripts/engines_http.py +184 -0
- package/scripts/engines_mcp.py +405 -0
- package/scripts/engines_parsers.py +13 -369
- package/scripts/engines_schema_drift.py +260 -0
- package/scripts/evidence.py +13 -0
- package/scripts/evidence_loop.py +19 -4
- package/scripts/extend_route_labels.py +6 -0
- package/scripts/fetch_jina.py +98 -0
- package/scripts/fetch_jsrun.py +15 -11
- package/scripts/fetch_v3.py +79 -120
- package/scripts/fulltext_store.py +42 -1
- package/scripts/fxtwitter_api.py +8 -7
- package/scripts/gen_engine_catalog.py +2 -2
- package/scripts/general_pool.py +15 -4
- package/scripts/health_check.py +1 -1
- package/scripts/image_vision/vision_probe +0 -0
- package/scripts/install.sh +2 -0
- package/scripts/link_source.py +65 -24
- package/scripts/local_seek_adapter.py +57 -17
- package/scripts/matrix_search_eval.py +8 -10
- package/scripts/mcp_handlers.py +53 -31
- package/scripts/mcp_handlers_surface.py +6 -18
- package/scripts/mcp_transport.py +10 -5
- package/scripts/min_version_scan.py +7 -3
- package/scripts/network_aware.py +7 -13
- package/scripts/numeric_verify.py +3 -2
- package/scripts/output_transparency.py +3 -0
- package/scripts/pre-commit +45 -43
- package/scripts/query_understanding.py +30 -6
- package/scripts/quota.py +36 -30
- package/scripts/rank_signals.py +9 -0
- package/scripts/recompute.py +15 -5
- package/scripts/recovery.py +38 -29
- package/scripts/recovery_runner.py +29 -10
- package/scripts/redskill/redskill_engine.py +2 -1
- package/scripts/release.py +14 -26
- package/scripts/release_check.py +5 -25
- 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 +40 -70
- package/scripts/route_audit.py +259 -0
- package/scripts/route_combo.py +21 -6
- 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 +85 -6
- 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 +53 -10
- package/scripts/search_entry.py +32 -1
- package/scripts/search_output.py +23 -11
- package/scripts/search_pipeline.py +15 -3
- package/scripts/search_rank.py +21 -11
- package/scripts/semantic_evidence.py +394 -178
- package/scripts/serp_guard.py +13 -1
- package/scripts/settings_page.py +4 -3
- package/scripts/single_flight.py +1 -1
- package/scripts/social_engines/hackernews_engine.py +2 -1
- package/scripts/social_engines/reddit_engine.py +2 -1
- package/scripts/social_engines/xiaohongshu_engine.py +2 -1
- package/scripts/social_engines/zhihu_engine.py +252 -43
- package/scripts/sogou_weixin_browser.py +5 -6
- package/scripts/source_audit.py +44 -9
- 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 +17 -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 +50 -10
- package/scripts/watch.py +3 -3
- package/scripts/zhihu_quota.py +2 -1
- package/sub-skills/argo-wide-research/SKILL.md +70 -0
- package/sub-skills/ego-search/{SKILL.md → README.md} +15 -47
- package/sub-skills/ego-search/scripts/ego_search.py +13 -4
- package/sub-skills/js-run/{SKILL.md → README.md} +3 -20
- package/sub-skills/local-search/{SKILL.md → README.md} +3 -8
- package/sub-skills/local-search/engine_registry.py +32 -7
- package/sub-skills/local-seek/SKILL.md +20 -22
- package/sub-skills/local-seek/scripts/seek_fts.py +58 -3
- package/scripts/caliber_dedupe.py +0 -66
- package/scripts/engines_builders_batch16.py +0 -13
- package/scripts/health_probe.py +0 -253
- package/scripts/social_engines/twitter_engine.py +0 -514
- package/scripts/sync_installs.py +0 -29
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @taxueseek/argo-dsh — 工作台样式与安全 Markdown 渲染器
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export const CSS = `
|
|
6
|
+
.aw-root {
|
|
7
|
+
--aw-brand: #2563eb;
|
|
8
|
+
--aw-brand-strong: #1d4ed8;
|
|
9
|
+
--aw-brand-soft: rgba(37, 99, 235, 0.10);
|
|
10
|
+
--aw-brand-ring: rgba(37, 99, 235, 0.25);
|
|
11
|
+
--aw-grad: linear-gradient(135deg, #0ea5e9, #2563eb 52%, #4f46e5);
|
|
12
|
+
--aw-bg: var(--dsw-alias-bg-base, #f8fafc);
|
|
13
|
+
--aw-layer: var(--dsw-alias-bg-layer-1, #ffffff);
|
|
14
|
+
--aw-sunken: var(--dsw-alias-bg-module-platform, #f1f5f9);
|
|
15
|
+
--aw-text: var(--dsw-alias-label-primary, #0f172a);
|
|
16
|
+
--aw-text-2: var(--dsw-alias-label-secondary, #475569);
|
|
17
|
+
--aw-text-3: var(--dsw-alias-label-tertiary, #64748b);
|
|
18
|
+
--aw-border: var(--dsw-alias-border-l1, rgba(15, 23, 42, 0.10));
|
|
19
|
+
--aw-border-2: var(--dsw-alias-border-l2, rgba(15, 23, 42, 0.16));
|
|
20
|
+
--aw-shadow: var(--dsw-elevation-panel, 0 2px 10px rgba(15, 23, 42, 0.05));
|
|
21
|
+
--aw-shadow-hi: var(--dsw-elevation-prominent, 0 10px 28px rgba(15, 23, 42, 0.10));
|
|
22
|
+
--aw-ok: var(--dsw-alias-state-success-primary, #16a34a);
|
|
23
|
+
--aw-warn: var(--dsw-alias-state-warn-primary, #d97706);
|
|
24
|
+
--aw-err: var(--dsw-alias-state-error-primary, #dc2626);
|
|
25
|
+
position: relative;
|
|
26
|
+
height: 100%;
|
|
27
|
+
width: 100%;
|
|
28
|
+
overflow-y: auto;
|
|
29
|
+
background: var(--aw-bg);
|
|
30
|
+
color: var(--aw-text);
|
|
31
|
+
font-family: var(--dsw-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);
|
|
32
|
+
}
|
|
33
|
+
body[data-ds-dark-theme] .aw-root {
|
|
34
|
+
--aw-brand: #60a5fa;
|
|
35
|
+
--aw-brand-strong: #93c5fd;
|
|
36
|
+
--aw-brand-soft: rgba(96, 165, 250, 0.15);
|
|
37
|
+
--aw-brand-ring: rgba(96, 165, 250, 0.32);
|
|
38
|
+
}
|
|
39
|
+
.aw-hero {
|
|
40
|
+
min-height: 100%;
|
|
41
|
+
display: flex;
|
|
42
|
+
flex-direction: column;
|
|
43
|
+
align-items: center;
|
|
44
|
+
justify-content: center;
|
|
45
|
+
padding: 40px 24px 56px;
|
|
46
|
+
background-image: radial-gradient(58% 38% at 50% 0%, rgba(234, 88, 12, 0.06), transparent 72%);
|
|
47
|
+
}
|
|
48
|
+
.aw-hero-top {
|
|
49
|
+
position: absolute; top: 14px; right: 18px; display: flex; gap: 8px; align-items: center;
|
|
50
|
+
}
|
|
51
|
+
.aw-hero-inner { width: 100%; max-width: 780px; display: flex; flex-direction: column; align-items: center; }
|
|
52
|
+
.aw-slogan {
|
|
53
|
+
font-size: 30px; font-weight: 600; letter-spacing: 0.20em; margin: 0 0 10px;
|
|
54
|
+
text-align: center; color: var(--aw-text);
|
|
55
|
+
}
|
|
56
|
+
.aw-sub { font-size: 13px; color: var(--aw-text-3); margin: 0 0 24px; text-align: center; }
|
|
57
|
+
.aw-box {
|
|
58
|
+
width: 100%; background: var(--aw-layer); border: 1px solid var(--aw-border-2);
|
|
59
|
+
border-radius: 20px; padding: 14px 16px 12px; box-shadow: var(--aw-shadow);
|
|
60
|
+
transition: border-color .18s, box-shadow .18s;
|
|
61
|
+
}
|
|
62
|
+
.aw-box:focus-within { border-color: var(--aw-brand); box-shadow: 0 0 0 3px var(--aw-brand-ring), var(--aw-shadow); }
|
|
63
|
+
.aw-textarea {
|
|
64
|
+
width: 100%; border: none; outline: none; resize: none; background: transparent;
|
|
65
|
+
color: var(--aw-text); font-size: 15px; line-height: 1.6; min-height: 54px; font-family: inherit;
|
|
66
|
+
}
|
|
67
|
+
.aw-box-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
|
|
68
|
+
.aw-modes { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
|
|
69
|
+
.aw-mode-btn {
|
|
70
|
+
border: 1px solid var(--aw-border); background: var(--aw-sunken); color: var(--aw-text-2);
|
|
71
|
+
border-radius: 999px; padding: 5px 13px; font-size: 12px; cursor: pointer; transition: all .15s;
|
|
72
|
+
}
|
|
73
|
+
.aw-mode-btn:hover { border-color: var(--aw-brand); color: var(--aw-text); }
|
|
74
|
+
.aw-mode-btn.active {
|
|
75
|
+
background: var(--aw-brand-soft); border-color: var(--aw-brand); color: var(--aw-brand); font-weight: 600;
|
|
76
|
+
}
|
|
77
|
+
.aw-topic-chip {
|
|
78
|
+
display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
|
|
79
|
+
background: rgba(79, 70, 229, 0.12); border: 1px solid rgba(79, 70, 229, 0.35);
|
|
80
|
+
color: var(--aw-brand); font-size: 12px; font-weight: 600;
|
|
81
|
+
}
|
|
82
|
+
.aw-topic-chip button {
|
|
83
|
+
border: none; background: transparent; color: inherit; cursor: pointer; font-size: 13px; padding: 0 2px; line-height: 1;
|
|
84
|
+
}
|
|
85
|
+
.aw-send {
|
|
86
|
+
width: 34px; height: 34px; border-radius: 999px; border: none; cursor: pointer;
|
|
87
|
+
background: var(--aw-grad); color: #fff; display: inline-flex; align-items: center; justify-content: center;
|
|
88
|
+
flex-shrink: 0; transition: transform .15s, opacity .15s;
|
|
89
|
+
}
|
|
90
|
+
.aw-send:disabled { opacity: 0.45; cursor: not-allowed; }
|
|
91
|
+
.aw-send:not(:disabled):hover { transform: translateY(-1px); }
|
|
92
|
+
|
|
93
|
+
.aw-sec-head {
|
|
94
|
+
width: 100%; display: flex; align-items: center; justify-content: space-between;
|
|
95
|
+
margin: 26px 0 10px; font-size: 12px; font-weight: 600; color: var(--aw-text-3);
|
|
96
|
+
}
|
|
97
|
+
.aw-presets { width: 100%; display: grid; grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); gap: 10px; }
|
|
98
|
+
.aw-preset {
|
|
99
|
+
display: flex; flex-direction: column; justify-content: space-between; gap: 8px;
|
|
100
|
+
text-align: left; background: var(--aw-layer); border: 1px solid var(--aw-border); border-radius: 14px;
|
|
101
|
+
padding: 13px 14px; cursor: pointer; transition: transform .15s, border-color .15s, box-shadow .15s;
|
|
102
|
+
}
|
|
103
|
+
.aw-preset:hover { transform: translateY(-2px); border-color: var(--aw-brand); box-shadow: var(--aw-shadow); }
|
|
104
|
+
.aw-preset.selected { border-color: var(--aw-brand); background: var(--aw-brand-soft); }
|
|
105
|
+
.aw-preset-tag { font-size: 13px; color: var(--aw-text); font-weight: 600; }
|
|
106
|
+
.aw-preset-desc { font-size: 12px; color: var(--aw-text-2); line-height: 1.45; }
|
|
107
|
+
.aw-preset-try {
|
|
108
|
+
align-self: flex-start; font-size: 11px; color: var(--aw-brand); background: transparent;
|
|
109
|
+
border: none; padding: 0; cursor: pointer; font-weight: 600;
|
|
110
|
+
}
|
|
111
|
+
.aw-preset-try:hover { text-decoration: underline; }
|
|
112
|
+
|
|
113
|
+
.aw-topbar {
|
|
114
|
+
position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 8px;
|
|
115
|
+
padding: 10px 18px; background: var(--aw-bg); border-bottom: 1px solid var(--aw-border);
|
|
116
|
+
backdrop-filter: blur(10px); flex-wrap: wrap;
|
|
117
|
+
}
|
|
118
|
+
.aw-icon-btn {
|
|
119
|
+
height: 32px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--aw-border);
|
|
120
|
+
background: var(--aw-layer); color: var(--aw-text-2); font-size: 12px; cursor: pointer;
|
|
121
|
+
display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
|
|
122
|
+
}
|
|
123
|
+
.aw-icon-btn:hover { border-color: var(--aw-brand); color: var(--aw-text); }
|
|
124
|
+
.aw-select {
|
|
125
|
+
height: 32px; padding: 0 8px; border-radius: 10px; border: 1px solid var(--aw-border);
|
|
126
|
+
background: var(--aw-layer); color: var(--aw-text); font-size: 12px; outline: none; cursor: pointer;
|
|
127
|
+
}
|
|
128
|
+
.aw-top-form {
|
|
129
|
+
flex: 1; min-width: 220px; max-width: 560px; display: flex; align-items: center; gap: 8px;
|
|
130
|
+
background: var(--aw-layer); border: 1px solid var(--aw-border-2); border-radius: 14px; padding: 4px 6px 4px 12px;
|
|
131
|
+
}
|
|
132
|
+
.aw-top-input { flex: 1; border: none; outline: none; background: transparent; color: var(--aw-text); font-size: 13px; min-width: 0; }
|
|
133
|
+
.aw-stat-pill {
|
|
134
|
+
font-size: 12px; color: var(--aw-text-2); background: var(--aw-sunken); border: 1px solid var(--aw-border);
|
|
135
|
+
border-radius: 999px; padding: 4px 11px; white-space: nowrap; font-variant-numeric: tabular-nums;
|
|
136
|
+
}
|
|
137
|
+
.aw-main {
|
|
138
|
+
max-width: 1260px; margin: 0 auto; padding: 20px 22px 48px;
|
|
139
|
+
display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(300px, 1fr); gap: 24px; align-items: start;
|
|
140
|
+
}
|
|
141
|
+
@media (max-width: 920px) { .aw-main { grid-template-columns: 1fr; } }
|
|
142
|
+
.aw-q-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
|
|
143
|
+
.aw-q-title { font-size: 21px; font-weight: 600; margin: 0; line-height: 1.35; }
|
|
144
|
+
.aw-badge {
|
|
145
|
+
font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
|
|
146
|
+
background: var(--aw-brand-soft); color: var(--aw-brand);
|
|
147
|
+
}
|
|
148
|
+
.aw-progress {
|
|
149
|
+
display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 12px;
|
|
150
|
+
background: var(--aw-sunken); border: 1px solid var(--aw-border); font-size: 12px; color: var(--aw-text-2);
|
|
151
|
+
margin-bottom: 16px;
|
|
152
|
+
}
|
|
153
|
+
.aw-dot { width: 8px; height: 8px; border-radius: 999px; background: var(--aw-brand); animation: awPulse 1.3s infinite; }
|
|
154
|
+
@keyframes awPulse { 0%,100% { opacity: .35; transform: scale(.85); } 50% { opacity: 1; transform: scale(1.1); } }
|
|
155
|
+
.aw-turn { margin-bottom: 22px; }
|
|
156
|
+
.aw-turn-q {
|
|
157
|
+
font-size: 14px; font-weight: 600; padding: 9px 14px; border-radius: 12px;
|
|
158
|
+
background: var(--aw-brand-soft); color: var(--aw-text); margin: 16px 0 12px;
|
|
159
|
+
}
|
|
160
|
+
.aw-md { font-size: 15px; line-height: 1.82; color: var(--aw-text); }
|
|
161
|
+
.aw-md h1, .aw-md h2, .aw-md h3 { margin: 18px 0 8px; font-weight: 600; line-height: 1.4; }
|
|
162
|
+
.aw-md h2 { font-size: 17px; padding-left: 10px; border-left: 3px solid var(--aw-brand); }
|
|
163
|
+
.aw-md h3 { font-size: 15px; }
|
|
164
|
+
.aw-md p { margin: 0 0 10px; }
|
|
165
|
+
.aw-md ul, .aw-md ol { margin: 0 0 10px; padding-left: 20px; }
|
|
166
|
+
.aw-md li { margin-bottom: 4px; }
|
|
167
|
+
.aw-md blockquote {
|
|
168
|
+
margin: 10px 0; padding: 6px 12px; border-left: 3px solid var(--aw-border-2);
|
|
169
|
+
background: var(--aw-sunken); border-radius: 0 8px 8px 0; color: var(--aw-text-2);
|
|
170
|
+
}
|
|
171
|
+
.aw-md table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 13px; }
|
|
172
|
+
.aw-md th, .aw-md td { border: 1px solid var(--aw-border); padding: 7px 10px; text-align: left; }
|
|
173
|
+
.aw-md th { background: var(--aw-sunken); font-weight: 600; }
|
|
174
|
+
.aw-md code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; background: var(--aw-sunken); padding: 1px 5px; border-radius: 5px; }
|
|
175
|
+
.aw-codebox { margin: 10px 0; border: 1px solid var(--aw-border); border-radius: 12px; overflow: hidden; background: var(--aw-sunken); }
|
|
176
|
+
.aw-codehead { display: flex; justify-content: space-between; align-items: center; padding: 5px 10px; font-size: 11px; color: var(--aw-text-3); border-bottom: 1px solid var(--aw-border); }
|
|
177
|
+
.aw-codepre { margin: 0; padding: 10px 12px; overflow-x: auto; font-size: 13px; line-height: 1.55; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
|
|
178
|
+
.aw-cite {
|
|
179
|
+
display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px;
|
|
180
|
+
padding: 0 5px; margin: 0 2px; border-radius: 6px; font-size: 11px; font-weight: 600;
|
|
181
|
+
vertical-align: 1px; border: none; font-variant-numeric: tabular-nums;
|
|
182
|
+
}
|
|
183
|
+
.aw-cite.ok { background: var(--aw-brand-soft); color: var(--aw-brand); cursor: pointer; }
|
|
184
|
+
.aw-cite.ok:hover { background: var(--aw-brand); color: #fff; }
|
|
185
|
+
.aw-cite.miss { background: var(--aw-sunken); color: var(--aw-text-3); cursor: default; }
|
|
186
|
+
|
|
187
|
+
.aw-followup {
|
|
188
|
+
margin-top: 20px; display: flex; gap: 8px; align-items: center;
|
|
189
|
+
background: var(--aw-layer); border: 1px solid var(--aw-border-2); border-radius: 16px; padding: 6px 8px 6px 14px;
|
|
190
|
+
box-shadow: var(--aw-shadow);
|
|
191
|
+
}
|
|
192
|
+
.aw-followup input { flex: 1; border: none; outline: none; background: transparent; color: var(--aw-text); font-size: 14px; }
|
|
193
|
+
|
|
194
|
+
.aw-right-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
|
|
195
|
+
.aw-filters { display: flex; gap: 6px; flex-wrap: wrap; }
|
|
196
|
+
.aw-filter {
|
|
197
|
+
font-size: 11px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--aw-border);
|
|
198
|
+
background: var(--aw-layer); color: var(--aw-text-2); cursor: pointer;
|
|
199
|
+
}
|
|
200
|
+
.aw-filter.active { background: var(--aw-brand-soft); border-color: var(--aw-brand); color: var(--aw-brand); font-weight: 600; }
|
|
201
|
+
.aw-cards { display: flex; flex-direction: column; gap: 10px; }
|
|
202
|
+
.aw-card {
|
|
203
|
+
background: var(--aw-layer); border: 1px solid var(--aw-border); border-radius: 14px; padding: 13px 14px;
|
|
204
|
+
box-shadow: var(--aw-shadow); transition: transform .15s, border-color .2s, box-shadow .2s;
|
|
205
|
+
}
|
|
206
|
+
.aw-card:hover { transform: translateY(-1px); box-shadow: var(--aw-shadow-hi); }
|
|
207
|
+
.aw-card.flash { border-color: var(--aw-brand); box-shadow: 0 0 0 3px var(--aw-brand-ring); }
|
|
208
|
+
.aw-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; font-size: 11px; color: var(--aw-text-3); }
|
|
209
|
+
.aw-card-src { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
|
|
210
|
+
.aw-idx {
|
|
211
|
+
display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px;
|
|
212
|
+
border-radius: 5px; background: var(--aw-brand-soft); color: var(--aw-brand); font-weight: 600; flex-shrink: 0;
|
|
213
|
+
}
|
|
214
|
+
.aw-verified {
|
|
215
|
+
font-size: 10px; padding: 1px 6px; border-radius: 999px; background: rgba(22, 163, 74, 0.12);
|
|
216
|
+
color: var(--aw-ok); font-weight: 600; flex-shrink: 0;
|
|
217
|
+
}
|
|
218
|
+
.aw-card-quote {
|
|
219
|
+
font-size: 13px; line-height: 1.65; color: var(--aw-text-2); margin: 0 0 8px;
|
|
220
|
+
padding-left: 9px; border-left: 2px solid var(--aw-border-2);
|
|
221
|
+
}
|
|
222
|
+
.aw-card-link {
|
|
223
|
+
display: flex; align-items: center; justify-content: space-between; gap: 8px;
|
|
224
|
+
font-size: 13px; font-weight: 600; color: var(--aw-text); text-decoration: none;
|
|
225
|
+
}
|
|
226
|
+
.aw-card-link:hover { color: var(--aw-brand); }
|
|
227
|
+
.aw-popover {
|
|
228
|
+
position: fixed; top: 54px; right: 18px; z-index: 60; width: 380px; max-height: 74vh; overflow-y: auto;
|
|
229
|
+
background: var(--aw-layer); border: 1px solid var(--aw-border-2); border-radius: 14px;
|
|
230
|
+
padding: 14px; box-shadow: var(--aw-shadow-hi); font-size: 12px;
|
|
231
|
+
}
|
|
232
|
+
.aw-watch-row {
|
|
233
|
+
padding: 10px 0; border-bottom: 1px solid var(--aw-border); display: flex; flex-direction: column; gap: 5px;
|
|
234
|
+
}
|
|
235
|
+
.aw-watch-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
|
|
236
|
+
.aw-sel-pill {
|
|
237
|
+
position: fixed; z-index: 90; display: inline-flex; align-items: center; gap: 6px;
|
|
238
|
+
padding: 6px 12px; border-radius: 999px; border: 1px solid var(--aw-border-2);
|
|
239
|
+
background: var(--aw-layer); color: var(--aw-text); box-shadow: var(--aw-shadow-hi);
|
|
240
|
+
font-size: 12px; font-weight: 600; cursor: pointer;
|
|
241
|
+
}
|
|
242
|
+
.aw-sel-pill:hover { border-color: #2563eb; color: #2563eb; }
|
|
243
|
+
`
|
|
244
|
+
|
|
245
|
+
function renderInline(h, text, cards, onCite) {
|
|
246
|
+
const parts = []
|
|
247
|
+
const tokenRe = /(\[\d+\]|`[^`]+`|\*\*[^*]+\*\*|\[[^\]]+\]\(https?:\/\/[^)]+\))/g
|
|
248
|
+
let last = 0
|
|
249
|
+
let m
|
|
250
|
+
let k = 0
|
|
251
|
+
while ((m = tokenRe.exec(text)) !== null) {
|
|
252
|
+
if (m.index > last) parts.push(text.slice(last, m.index))
|
|
253
|
+
const tok = m[0]
|
|
254
|
+
if (tok.startsWith('[') && /^\[(\d+)\]$/.test(tok)) {
|
|
255
|
+
const idx = Number(tok.slice(1, -1))
|
|
256
|
+
const card = cards.find(c => c.index === idx)
|
|
257
|
+
parts.push(h('button', {
|
|
258
|
+
key: `c-${k++}`,
|
|
259
|
+
type: 'button',
|
|
260
|
+
className: `aw-cite ${card ? 'ok' : 'miss'}`,
|
|
261
|
+
title: card ? card.title : '未匹配到对应证据卡',
|
|
262
|
+
onClick: card ? () => onCite(card.id) : undefined,
|
|
263
|
+
}, String(idx)))
|
|
264
|
+
} else if (tok.startsWith('`')) {
|
|
265
|
+
parts.push(h('code', { key: `cd-${k++}` }, tok.slice(1, -1)))
|
|
266
|
+
} else if (tok.startsWith('**')) {
|
|
267
|
+
parts.push(h('strong', { key: `b-${k++}` }, tok.slice(2, -2)))
|
|
268
|
+
} else {
|
|
269
|
+
const lm = tok.match(/^\[([^\]]+)\]\((https?:\/\/[^)]+)\)$/)
|
|
270
|
+
if (lm) {
|
|
271
|
+
parts.push(h('a', {
|
|
272
|
+
key: `a-${k++}`,
|
|
273
|
+
href: lm[2],
|
|
274
|
+
target: '_blank',
|
|
275
|
+
rel: 'noopener noreferrer',
|
|
276
|
+
style: { color: 'var(--aw-brand)' },
|
|
277
|
+
}, lm[1]))
|
|
278
|
+
} else {
|
|
279
|
+
parts.push(tok)
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
last = m.index + tok.length
|
|
283
|
+
}
|
|
284
|
+
if (last < text.length) parts.push(text.slice(last))
|
|
285
|
+
return parts
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
export function renderMarkdown(h, markdown, cards, onCite) {
|
|
289
|
+
const lines = String(markdown || '').split('\n')
|
|
290
|
+
const blocks = []
|
|
291
|
+
let i = 0
|
|
292
|
+
let key = 0
|
|
293
|
+
|
|
294
|
+
while (i < lines.length) {
|
|
295
|
+
const line = lines[i]
|
|
296
|
+
if (line.trim().startsWith('```')) {
|
|
297
|
+
const lang = line.trim().slice(3).trim() || 'text'
|
|
298
|
+
const codeLines = []
|
|
299
|
+
i++
|
|
300
|
+
while (i < lines.length && !lines[i].trim().startsWith('```')) {
|
|
301
|
+
codeLines.push(lines[i])
|
|
302
|
+
i++
|
|
303
|
+
}
|
|
304
|
+
i++
|
|
305
|
+
const codeText = codeLines.join('\n')
|
|
306
|
+
blocks.push(h('div', { key: `cb-${key++}`, className: 'aw-codebox' },
|
|
307
|
+
h('div', { className: 'aw-codehead' },
|
|
308
|
+
h('span', null, lang),
|
|
309
|
+
h('button', {
|
|
310
|
+
type: 'button',
|
|
311
|
+
className: 'aw-filter',
|
|
312
|
+
onClick: () => navigator.clipboard?.writeText?.(codeText),
|
|
313
|
+
}, '复制')),
|
|
314
|
+
h('pre', { className: 'aw-codepre' }, codeText)))
|
|
315
|
+
continue
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
if (line.includes('|') && i + 1 < lines.length && /^\s*\|?[\s:-]+\|/.test(lines[i + 1])) {
|
|
319
|
+
const parseRow = r => r.trim().replace(/^\|/, '').replace(/\|$/, '').split('|').map(s => s.trim())
|
|
320
|
+
const headers = parseRow(line)
|
|
321
|
+
i += 2
|
|
322
|
+
const rows = []
|
|
323
|
+
while (i < lines.length && lines[i].includes('|') && lines[i].trim() !== '') {
|
|
324
|
+
rows.push(parseRow(lines[i]))
|
|
325
|
+
i++
|
|
326
|
+
}
|
|
327
|
+
blocks.push(h('table', { key: `tb-${key++}` },
|
|
328
|
+
h('thead', null, h('tr', null, headers.map((hd, idx) => h('th', { key: idx }, renderInline(h, hd, cards, onCite))))),
|
|
329
|
+
h('tbody', null, rows.map((r, rIdx) => h('tr', { key: rIdx }, r.map((cell, cIdx) => h('td', { key: cIdx }, renderInline(h, cell, cards, onCite))))))))
|
|
330
|
+
continue
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
const hm = line.match(/^(#{1,3})\s+(.+)$/)
|
|
334
|
+
if (hm) {
|
|
335
|
+
const tag = `h${hm[1].length}`
|
|
336
|
+
blocks.push(h(tag, { key: `h-${key++}` }, renderInline(h, hm[2], cards, onCite)))
|
|
337
|
+
i++
|
|
338
|
+
continue
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
if (line.trim().startsWith('> ')) {
|
|
342
|
+
const qLines = []
|
|
343
|
+
while (i < lines.length && lines[i].trim().startsWith('> ')) {
|
|
344
|
+
qLines.push(lines[i].trim().slice(2))
|
|
345
|
+
i++
|
|
346
|
+
}
|
|
347
|
+
blocks.push(h('blockquote', { key: `bq-${key++}` }, renderInline(h, qLines.join(' '), cards, onCite)))
|
|
348
|
+
continue
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
if (/^\s*[-*]\s+/.test(line)) {
|
|
352
|
+
const items = []
|
|
353
|
+
while (i < lines.length && /^\s*[-*]\s+/.test(lines[i])) {
|
|
354
|
+
items.push(lines[i].replace(/^\s*[-*]\s+/, ''))
|
|
355
|
+
i++
|
|
356
|
+
}
|
|
357
|
+
blocks.push(h('ul', { key: `ul-${key++}` }, items.map((it, idx) => h('li', { key: idx }, renderInline(h, it, cards, onCite)))))
|
|
358
|
+
continue
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
if (/^\s*\d+\.\s+/.test(line)) {
|
|
362
|
+
const items = []
|
|
363
|
+
while (i < lines.length && /^\s*\d+\.\s+/.test(lines[i])) {
|
|
364
|
+
items.push(lines[i].replace(/^\s*\d+\.\s+/, ''))
|
|
365
|
+
i++
|
|
366
|
+
}
|
|
367
|
+
blocks.push(h('ol', { key: `ol-${key++}` }, items.map((it, idx) => h('li', { key: idx }, renderInline(h, it, cards, onCite)))))
|
|
368
|
+
continue
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
if (line.trim() === '') {
|
|
372
|
+
i++
|
|
373
|
+
continue
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
const pLines = [line]
|
|
377
|
+
i++
|
|
378
|
+
while (i < lines.length && lines[i].trim() !== '' && !/^(#{1,3}\s|```|>\s|\s*[-*]\s|\s*\d+\.\s)/.test(lines[i])) {
|
|
379
|
+
pLines.push(lines[i])
|
|
380
|
+
i++
|
|
381
|
+
}
|
|
382
|
+
blocks.push(h('p', { key: `p-${key++}` }, renderInline(h, pLines.join(' '), cards, onCite)))
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
return blocks
|
|
386
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @taxueseek/argo-dsh — 工作台默认推荐引擎(热点 + DSH 语言自适应 + 分模式模板 + 近期检索)
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { readFileSync } from 'node:fs'
|
|
6
|
+
import { homedir } from 'node:os'
|
|
7
|
+
import { join } from 'node:path'
|
|
8
|
+
|
|
9
|
+
const FEED_CACHE_FILE = join(homedir(), '.cache', 'unified-search', 'feed_cache.json')
|
|
10
|
+
const QUERY_LOG_FILE = join(homedir(), '.cache', 'unified-search', 'usage_log', 'query.jsonl')
|
|
11
|
+
const SUGGESTION_CACHE_TTL_MS = 15 * 60 * 1000
|
|
12
|
+
const CJK_RE = /[\u4e00-\u9fff]/
|
|
13
|
+
|
|
14
|
+
const MODE_SUGGESTIONS = {
|
|
15
|
+
general: {
|
|
16
|
+
zh: ['AI 编程助手最新工程实践', '2026 主流开源模型推理成本对比', 'Mac 本地知识库与全文检索工具推荐'],
|
|
17
|
+
en: ['Best open-source local RAG architectures 2026', 'LLM inference latency optimization techniques', 'Agentic coding benchmarks and real-world reviews'],
|
|
18
|
+
},
|
|
19
|
+
hotspot: {
|
|
20
|
+
zh: ['最近一周 AI 行业重大发布与社区争议', '近期大模型价格战与开源生态动态', '本周开发者社区高热技术议题汇总'],
|
|
21
|
+
en: ['Top AI engineering discussions this week', 'Recent open-weight model releases and community reaction', 'Major cloud & devtool announcements this week'],
|
|
22
|
+
},
|
|
23
|
+
verify: {
|
|
24
|
+
zh: ['核验某项行业数据的原始官方报告出处', '核实近期热门开源协议变更公告时间线', '查证某 AI 基准测试成绩的官方复现口径'],
|
|
25
|
+
en: ['Verify official benchmark methodology for latest reasoning models', 'Fact-check recent open-source license change announcements', 'Trace primary source for reported developer productivity stats'],
|
|
26
|
+
},
|
|
27
|
+
research: {
|
|
28
|
+
zh: ['端侧模型量化与低延迟推理技术全景调研', '多智能体协作框架的可靠性与评测体系研究', '本地优先软件架构与同步引擎深度对比'],
|
|
29
|
+
en: ['Comprehensive survey of local-first sync engines', 'Multi-agent orchestration reliability and evaluation gates', 'On-device LLM quantization trade-offs and benchmarks'],
|
|
30
|
+
},
|
|
31
|
+
compare: {
|
|
32
|
+
zh: ['SQLite FTS5 与 Tantivy / Meilisearch 选型对比', '主流终端 AI Agent 工具能力与成本对比', '向量数据库与混合检索方案优缺点对比'],
|
|
33
|
+
en: ['SQLite FTS5 vs Tantivy vs Meilisearch comparison', 'Local vector search vs hybrid BM25 trade-offs', 'Self-hosted search engines benchmark comparison'],
|
|
34
|
+
},
|
|
35
|
+
academic: {
|
|
36
|
+
zh: ['推理时计算扩展(Test-time Compute)最新综述', '检索增强生成(RAG)幻觉抑制与引用溯源论文', '长上下文注意力机制高效实现研究进展'],
|
|
37
|
+
en: ['Test-time compute scaling laws recent papers', 'Citation-grounded RAG and faithfulness verification', 'Efficient long-context attention mechanisms survey'],
|
|
38
|
+
},
|
|
39
|
+
plugin: {
|
|
40
|
+
zh: ['dsh-zsearch 与 argo-dsh 插件功能对比与评价', '常用代码编辑器 AI 扩展真实口碑与避坑', '浏览器自动化与网页提取插件安全性评估'],
|
|
41
|
+
en: ['Compare DSH search plugins capabilities and reliability', 'Top developer productivity extensions security audit', 'Open-source browser automation plugins comparison'],
|
|
42
|
+
},
|
|
43
|
+
local: {
|
|
44
|
+
zh: ['circuit_breaker', 'engine_states', 'workbench'],
|
|
45
|
+
en: ['circuit_breaker', 'engine_states', 'wide-research'],
|
|
46
|
+
},
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const feedCache = { ts: 0, zh: [], en: [] }
|
|
50
|
+
|
|
51
|
+
function cleanTitle(raw) {
|
|
52
|
+
return String(raw || '')
|
|
53
|
+
.replace(/https?:\/\/\S+/g, '')
|
|
54
|
+
.replace(/\s+/g, ' ')
|
|
55
|
+
.trim()
|
|
56
|
+
.slice(0, 44)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function readFeedHotspots(lang, limit = 4) {
|
|
60
|
+
const now = Date.now()
|
|
61
|
+
if (now - feedCache.ts < SUGGESTION_CACHE_TTL_MS && (feedCache.zh.length || feedCache.en.length)) {
|
|
62
|
+
return (lang === 'en' ? feedCache.en : feedCache.zh).slice(0, limit)
|
|
63
|
+
}
|
|
64
|
+
const zh = []
|
|
65
|
+
const en = []
|
|
66
|
+
const seen = new Set()
|
|
67
|
+
try {
|
|
68
|
+
const raw = JSON.parse(readFileSync(FEED_CACHE_FILE, 'utf8'))
|
|
69
|
+
const entries = Object.entries(raw && typeof raw === 'object' ? raw : {})
|
|
70
|
+
.sort((a, b) => (b[1]?.ts || 0) - (a[1]?.ts || 0))
|
|
71
|
+
for (const [, feed] of entries) {
|
|
72
|
+
const items = Array.isArray(feed?.items) ? feed.items : []
|
|
73
|
+
for (const item of items.slice(0, 8)) {
|
|
74
|
+
const title = cleanTitle(item?.title)
|
|
75
|
+
if (title.length < 6 || seen.has(title)) continue
|
|
76
|
+
seen.add(title)
|
|
77
|
+
if (CJK_RE.test(title)) {
|
|
78
|
+
if (zh.length < 12) zh.push(title)
|
|
79
|
+
} else if (en.length < 12) {
|
|
80
|
+
en.push(title)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (zh.length >= 12 && en.length >= 12) break
|
|
84
|
+
}
|
|
85
|
+
} catch { /* ignore */ }
|
|
86
|
+
feedCache.ts = now
|
|
87
|
+
feedCache.zh = zh
|
|
88
|
+
feedCache.en = en
|
|
89
|
+
return (lang === 'en' ? en : zh).slice(0, limit)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function readRecentQueries(lang, limit = 3) {
|
|
93
|
+
const out = []
|
|
94
|
+
const seen = new Set()
|
|
95
|
+
try {
|
|
96
|
+
const raw = readFileSync(QUERY_LOG_FILE, 'utf8')
|
|
97
|
+
const lines = raw.slice(-24576).split('\n').reverse()
|
|
98
|
+
for (const line of lines) {
|
|
99
|
+
if (!line.trim()) continue
|
|
100
|
+
try {
|
|
101
|
+
const row = JSON.parse(line)
|
|
102
|
+
const q = cleanTitle(row?.query)
|
|
103
|
+
if (q.length < 4 || q.length > 40 || (row?.count || 0) <= 0 || seen.has(q)) continue
|
|
104
|
+
const isCjk = CJK_RE.test(q)
|
|
105
|
+
if ((lang === 'en' && isCjk) || (lang === 'zh' && !isCjk)) continue
|
|
106
|
+
seen.add(q)
|
|
107
|
+
out.push(q)
|
|
108
|
+
if (out.length >= limit) break
|
|
109
|
+
} catch { /* ignore malformed tail line */ }
|
|
110
|
+
}
|
|
111
|
+
} catch { /* ignore */ }
|
|
112
|
+
return out
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function buildSuggestions(mode = 'general', rawLang = 'zh', shuffle = false) {
|
|
116
|
+
const lang = String(rawLang || '').toLowerCase().startsWith('en') ? 'en' : 'zh'
|
|
117
|
+
const specPool = MODE_SUGGESTIONS[mode] || MODE_SUGGESTIONS.general
|
|
118
|
+
const baseList = [...(specPool[lang] || specPool.zh)]
|
|
119
|
+
if (shuffle) baseList.sort(() => Math.random() - 0.5)
|
|
120
|
+
|
|
121
|
+
const hotspots = mode === 'local' ? [] : readFeedHotspots(lang, 4)
|
|
122
|
+
const recent = mode === 'local' ? [] : readRecentQueries(lang, 3)
|
|
123
|
+
|
|
124
|
+
const items = []
|
|
125
|
+
const seen = new Set()
|
|
126
|
+
const push = (query, tag, source) => {
|
|
127
|
+
const q = String(query || '').trim()
|
|
128
|
+
if (!q || seen.has(q)) return
|
|
129
|
+
seen.add(q)
|
|
130
|
+
items.push({ query: q, tag, source })
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const hotTag = lang === 'en' ? 'Hot' : '热点'
|
|
134
|
+
const modeTag = lang === 'en' ? 'Mode' : '推荐'
|
|
135
|
+
const recentTag = lang === 'en' ? 'Recent' : '近期'
|
|
136
|
+
|
|
137
|
+
if (mode === 'hotspot' || mode === 'general' || mode === 'verify') {
|
|
138
|
+
for (const q of hotspots.slice(0, 3)) push(q, hotTag, 'feed')
|
|
139
|
+
for (const q of baseList) push(q, modeTag, 'template')
|
|
140
|
+
for (const q of recent) push(q, recentTag, 'history')
|
|
141
|
+
} else {
|
|
142
|
+
for (const q of baseList) push(q, modeTag, 'template')
|
|
143
|
+
for (const q of hotspots.slice(0, 2)) push(q, hotTag, 'feed')
|
|
144
|
+
for (const q of recent.slice(0, 2)) push(q, recentTag, 'history')
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return { ok: true, mode, lang, items: items.slice(0, 7) }
|
|
148
|
+
}
|