@blxzer/cursor-trellis 0.1.2 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/README.md +45 -21
  3. package/dist/configurators/workflow.d.ts +1 -1
  4. package/dist/configurators/workflow.d.ts.map +1 -1
  5. package/dist/configurators/workflow.js +20 -9
  6. package/dist/configurators/workflow.js.map +1 -1
  7. package/dist/migrations/manifests/0.1.3.json +9 -0
  8. package/dist/migrations/manifests/0.1.4.json +9 -0
  9. package/dist/templates/cursor/rules/retrieval-routing.mdc +9 -7
  10. package/dist/templates/markdown/agents.md +1 -1
  11. package/dist/templates/markdown/index.d.ts +1 -0
  12. package/dist/templates/markdown/index.d.ts.map +1 -1
  13. package/dist/templates/markdown/index.js +1 -0
  14. package/dist/templates/markdown/index.js.map +1 -1
  15. package/dist/templates/markdown/prompts/run-semantic-slice-12.md.txt +13 -29
  16. package/dist/templates/markdown/spec/guides/code-reuse-thinking-guide.md.txt +0 -49
  17. package/dist/templates/markdown/spec/guides/cross-layer-thinking-guide.md.txt +0 -85
  18. package/dist/templates/markdown/spec/guides/cursor-semantic-compliance.md.txt +7 -21
  19. package/dist/templates/markdown/spec/guides/cursor-subagent-policy.md.txt +6 -10
  20. package/dist/templates/markdown/spec/guides/retrieval-daily-guide.md.txt +17 -18
  21. package/dist/templates/shared-hooks/inject-retrieval-plan.py +42 -23
  22. package/dist/templates/shared-hooks/inject-subagent-context.py +6 -2
  23. package/dist/templates/shared-hooks/session-start.py +17 -9
  24. package/dist/templates/trellis/index.d.ts +8 -4
  25. package/dist/templates/trellis/index.d.ts.map +1 -1
  26. package/dist/templates/trellis/index.js +13 -7
  27. package/dist/templates/trellis/index.js.map +1 -1
  28. package/dist/templates/trellis/scripts/common/codebase_retrieval_router.py +80 -31
  29. package/dist/templates/trellis/scripts/common/config.py +1 -1
  30. package/dist/templates/trellis/scripts/common/cursor_retrieval_env.py +92 -0
  31. package/dist/templates/trellis/scripts/common/parent_orchestration.py +27 -15
  32. package/dist/templates/trellis/scripts/common/retrieval_adapter_metadata.py +100 -9
  33. package/dist/templates/trellis/scripts/common/retrieval_agent_instructions.py +76 -31
  34. package/dist/templates/trellis/scripts/common/retrieval_tool_classification.py +18 -3
  35. package/dist/templates/trellis/scripts/common/semantic_plan_gate.py +19 -0
  36. package/dist/templates/trellis/scripts/common/smart_search_evidence.py +5 -2
  37. package/dist/templates/trellis/scripts/common/smart_search_resolve.py +28 -3
  38. package/dist/templates/trellis/scripts/common/task_gates.py +372 -73
  39. package/dist/templates/trellis/scripts/common/task_map.py +29 -1
  40. package/dist/templates/trellis/scripts/cursor_retrieval_probe.py +396 -0
  41. package/dist/templates/trellis/scripts/cursor_retrieval_probe_prompt.md +300 -0
  42. package/dist/templates/trellis/scripts/retrieval_probe_matrix_template.json +126 -0
  43. package/dist/templates/trellis/workflow.md +9 -53
  44. package/dist/utils/codebase-retrieval-router.d.ts +5 -0
  45. package/dist/utils/codebase-retrieval-router.d.ts.map +1 -1
  46. package/dist/utils/codebase-retrieval-router.js +48 -28
  47. package/dist/utils/codebase-retrieval-router.js.map +1 -1
  48. package/dist/utils/cursor-retrieval-env.d.ts +28 -0
  49. package/dist/utils/cursor-retrieval-env.d.ts.map +1 -0
  50. package/dist/utils/cursor-retrieval-env.js +89 -0
  51. package/dist/utils/cursor-retrieval-env.js.map +1 -0
  52. package/dist/utils/project-capabilities.d.ts.map +1 -1
  53. package/dist/utils/project-capabilities.js +22 -15
  54. package/dist/utils/project-capabilities.js.map +1 -1
  55. package/dist/utils/retrieval-agent-instructions.d.ts.map +1 -1
  56. package/dist/utils/retrieval-agent-instructions.js +37 -21
  57. package/dist/utils/retrieval-agent-instructions.js.map +1 -1
  58. package/dist/utils/retrieval-tool-classification.d.ts +2 -0
  59. package/dist/utils/retrieval-tool-classification.d.ts.map +1 -1
  60. package/dist/utils/retrieval-tool-classification.js +10 -2
  61. package/dist/utils/retrieval-tool-classification.js.map +1 -1
  62. package/dist/utils/semantic-plan-gate.d.ts +8 -0
  63. package/dist/utils/semantic-plan-gate.d.ts.map +1 -0
  64. package/dist/utils/semantic-plan-gate.js +42 -0
  65. package/dist/utils/semantic-plan-gate.js.map +1 -0
  66. package/package.json +5 -43
  67. package/bin/smart-search.js +0 -79
  68. package/dist/templates/trellis/scripts/aggregate_retrieval_telemetry.py +0 -342
  69. package/dist/templates/trellis/scripts/batch_plan_envelope.py +0 -105
  70. package/vendor/smart-search/LICENSE +0 -21
  71. package/vendor/smart-search/README.md +0 -412
  72. package/vendor/smart-search/README.zh-CN.md +0 -430
  73. package/vendor/smart-search/npm/bin/smart-search.js +0 -63
  74. package/vendor/smart-search/npm/scripts/postinstall.js +0 -87
  75. package/vendor/smart-search/npm/scripts/resolve-prerelease-version.js +0 -108
  76. package/vendor/smart-search/npm/scripts/set-package-version.js +0 -35
  77. package/vendor/smart-search/npm/scripts/sync-python-version.js +0 -22
  78. package/vendor/smart-search/npm/scripts/test-wrapper-repair.js +0 -99
  79. package/vendor/smart-search/npm/scripts/test.js +0 -85
  80. package/vendor/smart-search/package.json +0 -42
  81. package/vendor/smart-search/pyproject.toml +0 -37
  82. package/vendor/smart-search/skills/smart-search-cli/SKILL.md +0 -387
  83. package/vendor/smart-search/skills/smart-search-cli/agents/openai.yaml +0 -3
  84. package/vendor/smart-search/skills/smart-search-cli/examples/batch-search.md +0 -98
  85. package/vendor/smart-search/skills/smart-search-cli/examples/evidence-gathering.md +0 -89
  86. package/vendor/smart-search/skills/smart-search-cli/references/cli-contract.md +0 -337
  87. package/vendor/smart-search/src/smart_search/__init__.py +0 -1
  88. package/vendor/smart-search/src/smart_search/assets/skills/smart-search-cli/SKILL.md +0 -387
  89. package/vendor/smart-search/src/smart_search/assets/skills/smart-search-cli/agents/openai.yaml +0 -3
  90. package/vendor/smart-search/src/smart_search/assets/skills/smart-search-cli/examples/batch-search.md +0 -98
  91. package/vendor/smart-search/src/smart_search/assets/skills/smart-search-cli/examples/evidence-gathering.md +0 -89
  92. package/vendor/smart-search/src/smart_search/assets/skills/smart-search-cli/references/cli-contract.md +0 -337
  93. package/vendor/smart-search/src/smart_search/cli.py +0 -2003
  94. package/vendor/smart-search/src/smart_search/config.py +0 -580
  95. package/vendor/smart-search/src/smart_search/logger.py +0 -43
  96. package/vendor/smart-search/src/smart_search/providers/__init__.py +0 -16
  97. package/vendor/smart-search/src/smart_search/providers/base.py +0 -41
  98. package/vendor/smart-search/src/smart_search/providers/context7.py +0 -141
  99. package/vendor/smart-search/src/smart_search/providers/exa.py +0 -206
  100. package/vendor/smart-search/src/smart_search/providers/jina.py +0 -136
  101. package/vendor/smart-search/src/smart_search/providers/openai_compatible.py +0 -370
  102. package/vendor/smart-search/src/smart_search/providers/zhipu.py +0 -143
  103. package/vendor/smart-search/src/smart_search/service.py +0 -2865
  104. package/vendor/smart-search/src/smart_search/sources.py +0 -429
  105. package/vendor/smart-search/src/smart_search/utils.py +0 -220
@@ -1,430 +0,0 @@
1
- # smart-search
2
-
3
- 简体中文 | [English](README.md)
4
-
5
- `smart-search` 是一个给 AI 助手和命令行用户使用的 CLI-first 网页研究工具。它把普通联网搜索、来源发现、网页正文抓取、站点 map、配置检查和 live Deep Research 执行统一成一个可复现的命令层。
6
-
7
- <p>
8
- <a href="https://www.npmjs.com/package/@konbakuyomu/smart-search">
9
- <img src="https://img.shields.io/npm/v/@konbakuyomu/smart-search?label=npm%20latest" alt="npm latest">
10
- </a>
11
- </p>
12
-
13
- ![Star History Chart](https://api.star-history.com/svg?repos=konbakuyomu/smartsearch&type=Date)
14
-
15
- ## 它到底是什么
16
-
17
- 它不是 MCP Server,而是一个普通命令行工具。AI 工具通过 `smart-search-cli` skill 调它,脚本和终端用户也可以直接调它:
18
-
19
- ```powershell
20
- smart-search search "今天 OpenAI Responses API 有什么新变化" --format json
21
- smart-search fetch "https://example.com/article" --format markdown
22
- smart-search research "OpenAI Responses API web_search 和 Chat Completions 联网搜索怎么选" --format markdown
23
- ```
24
-
25
- 当前架构分两层:
26
-
27
- | 层 | 负责什么 |
28
- | --- | --- |
29
- | CLI 执行层 | 稳定执行命令、provider 路由、同能力兜底、JSON/Markdown 输出、本机配置 |
30
- | Skill / AI 编排层 | 判断用户意图,决定普通搜索还是 Deep Research,按计划执行 CLI 积木,最后写出有来源支撑的回答 |
31
-
32
- `smart-search search` 保持快速、直接联网。`smart-search research` 是 live Deep Research 执行器:它会先在内部生成计划,再按 plan -> discover -> fetch/read -> gap check -> evidence-only synthesis 执行。
33
-
34
- ## 安装
35
-
36
- 稳定版:
37
-
38
- ```powershell
39
- npm install -g @konbakuyomu/smart-search@latest
40
- smart-search --version
41
- smart-search setup
42
- ```
43
-
44
- 测试版:
45
-
46
- ```powershell
47
- npm install -g @konbakuyomu/smart-search@next
48
- smart-search --version
49
- ```
50
-
51
- npm 包安装时会自动创建隔离的 Python 运行环境。你平时只需要使用 `smart-search` 这个命令。
52
-
53
- 前置条件:
54
-
55
- - 已安装 Node.js / npm。
56
- - 已安装 Python 3.10 或更新版本,并且终端里能运行 `python`、`python3` 或 Windows 的 `py -3`。
57
-
58
- ## 快速开始
59
-
60
- 1. 配置 provider:
61
-
62
- ```powershell
63
- smart-search setup
64
- smart-search doctor --format json
65
- ```
66
-
67
- 2. 普通快速搜索:
68
-
69
- ```powershell
70
- smart-search search "今天有什么值得关注的 AI 新闻?" --validation balanced --extra-sources 2 --format json
71
- ```
72
-
73
- 3. 抓取关键网页正文:
74
-
75
- ```powershell
76
- smart-search fetch "https://example.com/source" --format markdown --output evidence.md
77
- ```
78
-
79
- 4. 让 CLI 直接执行 live Deep Research:
80
-
81
- ```powershell
82
- smart-search research "深度搜索一下最近的比特币行情" --budget deep --format markdown
83
- ```
84
-
85
- ## 当前架构
86
-
87
- | 能力 | 主要命令 | Provider | 负责什么 |
88
- | --- | --- | --- | --- |
89
- | `main_search` | `search` | OpenAI-compatible Chat Completions | 综合回答、快速搜索、初步总结 |
90
- | `docs_search` | `context7-library`、`context7-docs`、`exa-search` | Context7、Exa | 官方文档、SDK、API、框架/库文档 |
91
- | `web_search` | `search` 内部中英双语来源发现;`zhipu-search` 仅作 deprecated 手动兼容 | Tavily、Firecrawl;智谱 Web Search API 仅在显式请求时使用 | 每个常规研究问题都做中文和英文网页来源发现 |
92
- | `web_fetch` | `fetch` | Tavily、Jina Reader、Firecrawl | 已知 URL 正文抓取、证据提取 |
93
- | `site_map` | `map` | Tavily | 文档站、产品站、目录型站点结构 |
94
- | `research_executor` | `research` / `rs` | 按 capability 注册的 provider | live 深度研究执行:规划、发现、抓取/读取、gap check、仅基于证据综合 |
95
-
96
- 同能力兜底关系:
97
-
98
- | 能力 | 兜底链 |
99
- | --- | --- |
100
- | `main_search` | OpenAI-compatible |
101
- | `docs_search` | Context7 处理库/API/文档意图;Exa 处理官方域名、论文、产品页、可信站点发现 |
102
- | `web_search` | Tavily -> Firecrawl;智谱仅在显式选择 deprecated legacy 命令时使用 |
103
- | `web_fetch` | Tavily -> 带 `JINA_API_KEY` 的 Jina Reader -> Firecrawl |
104
-
105
- Jina Reader 只属于 `web_fetch`,不是通用搜索 provider。只有配置 `JINA_API_KEY` 后,它才可以满足 `SMART_SEARCH_MINIMUM_PROFILE=standard`;匿名 `r.jina.ai` 只能当显式/实验抓取能力,不能让最低配置检查放松。
106
-
107
- 这里有一个重要边界:兜底只在同一类能力里发生。不会用 Context7 去查普通新闻,也不会用 Firecrawl 假装做文档语义检索。
108
-
109
- 输出里会保留可观测字段:
110
-
111
- | 字段 | 作用 |
112
- | --- | --- |
113
- | `routing_decision` | 为什么触发了某些补强路径 |
114
- | `provider_attempts` | 每个 provider 的尝试结果 |
115
- | `providers_used` | 最终用到哪些 provider |
116
- | `fallback_used` | 是否触发同能力兜底 |
117
- | `primary_sources` | 主搜索回答里带出的来源 |
118
- | `extra_sources` | Tavily / Firecrawl 等额外发现的候选来源 |
119
- | `source_warning` | 来源和回答之间可能存在的证据边界提醒 |
120
-
121
- `balanced` 和 `strict` 的 `search` 默认通过 Tavily / Firecrawl 执行中英双语 `web_search` 来源发现:同一个用户问题会生成一个中文来源查询和一个英文来源查询。`--validation fast` 跳过补强。没有主回答来源、docs、fetch 或显式来源证据的 strict 查询仍可能返回 `evidence_error`;需要可引用证据时,用 `--extra-sources N`、`exa-search` 这类 source-first 命令,或直接 `fetch` 关键 URL。docs 补强继续保持显式 docs/API/库/框架关键词触发。
122
-
123
- `extra_sources` 是通过 `--extra-sources N` 显式请求的候选来源,默认是 `0`,不等于自动事实校验。新闻、政策、财经、医疗、严肃评测、工具选型等高风险问题,建议先发现来源,再 `fetch` 关键网页正文,最后只基于抓到的正文写结论。
124
-
125
- 搜索引擎选择速记:先用 `search` 做中英双语宽泛探索和综合;想让 CLI 执行完整证据流时用 `research`;库/API/框架文档优先用 Context7;官方域名、论文、产品页、可信站点和低噪声发现再用 Exa;Tavily/Firecrawl 负责双语网页发现和 URL/页面证据;Jina 用于已知 URL 正文抓取。智谱只保留为 deprecated 手动兼容命令,不再作为默认路径。
126
-
127
- ## Deep Research 深度搜索
128
-
129
- 普通问题用:
130
-
131
- ```powershell
132
- smart-search search "React useEffect cleanup 文档" --format json
133
- ```
134
-
135
- 如果你希望 CLI 直接执行完整 live Deep Research,用:
136
-
137
- ```powershell
138
- smart-search research "OpenAI Responses API web_search 和 Chat Completions 联网搜索怎么选" --budget deep --fallback auto --format json
139
- smart-search rs "https://example.com/source" --fallback off --format markdown
140
- ```
141
-
142
- `research` 会先在内部生成 Deep Research 计划,再执行 plan -> discover -> fetch/read -> gap check -> evidence-only synthesis。规划阶段会产出:
143
-
144
- - `intent_signals`:是否强时效、是否 docs/API、是否给 URL、是否高风险、是否需要权威来源、是否需要交叉验证;
145
- - `decomposition`:复杂问题拆成 1-6 个子问题;
146
- - `capability_plan`:选择需要的能力;
147
- - `steps[]`:每一步的 `tool`、`purpose`、`command`、`output_path`、`subquestion_id`;
148
- - `evidence_policy="fetch_before_claim"`;
149
- - `gap_check`:关键结论没有正文证据就继续抓,或者降级成未验证候选。
150
-
151
- Deep Research 不是固定题材配方。行情、选型、技术文档、新闻政策、真假核验、用户给 URL 这些只是用户语言示例,不是 schema 枚举。
152
-
153
- 规划只允许组合现有 CLI 积木:
154
-
155
- ```text
156
- search, exa-search, exa-similar, context7-library, context7-docs, fetch, map
157
- ```
158
-
159
- `doctor` 是 preflight 配置预检,不是 research step;它帮助 AI 判断当前 provider 是否可用,但不算 Deep Research 的取证步骤。
160
-
161
- 默认 `--fallback auto`,会在同一 capability 内兜底;`--fallback off` 只尝试每个 capability 选中的第一个 provider,适合手动调试某个 provider。
162
-
163
- `research` JSON 会包含 `final_answer`、`citations`、`evidence_items`、`gap_check`、`provider_attempts`、`fallback_used`、`degraded`、`route_policy_version` 和 `evidence_dir`。发现阶段的 snippet 只是候选,不会直接变成 citation;只有 fetch/read 到正文的来源才会被引用。兜底仍然补不齐证据时,`research` 会降级输出 gap,不会编造结论。
164
-
165
- `research` 的路由是 capability-first 加 provider 优势:
166
-
167
- - Context7 优先处理库/API/框架文档,Exa 用于官方域名、论文、产品页、可信站点和低噪声发现。
168
- - Tavily / Firecrawl 负责中英双语宽泛来源发现。智谱已从默认路由弃用,除非显式请求 legacy 命令,否则不会用于中文、时效、国内搜索。
169
- - Jina 优先用于已知公开 URL、PDF、arXiv 正文抽取;ReaderLM-v2 仍要求 `JINA_API_KEY`。
170
- - Firecrawl 优先用于 JS-heavy、动态页面、浏览器式抽取、OCR/PDF 或强兜底抓取。
171
-
172
- 高级路由覆盖项是 `SMART_SEARCH_RESEARCH_PREFERRED_PROVIDERS` 和 `SMART_SEARCH_RESEARCH_DISABLED_PROVIDERS`。它们只能在 provider 已支持的 capability 内调整顺序或禁用,不能把 provider 移到另一个 capability。
173
-
174
- 可以用这些标准问题测试 live Deep Research:
175
-
176
- ```powershell
177
- smart-search research "深度搜索一下最近的比特币行情" --format json
178
- smart-search research "OpenAI Responses API web_search 和 Chat Completions 联网搜索怎么选" --budget deep --format json
179
- smart-search research "帮我核验这个说法是真是假:某某工具已经完全替代 Tavily 做 AI 搜索了" --format json
180
- smart-search research "https://example.com/source" --format json
181
- ```
182
-
183
- 看到输出里有 `mode=deep_research_execution`、`citations`、`evidence_items`、`gap_check`,就说明已经进入 Deep Research 执行模式。
184
-
185
- ## API 和 Key 申请入口
186
-
187
- 普通用户优先用 `smart-search setup` 配置。环境变量仍然支持 CI 和高级用户。
188
-
189
- | Provider / 路线 | 用途 | 主要配置项 | 官方文档 | Key / 控制台 |
190
- | --- | --- | --- | --- | --- |
191
- | OpenAI-compatible Chat Completions | 主搜索,适合 OpenAI 官方或兼容中转 | `OPENAI_COMPATIBLE_API_URL`、`OPENAI_COMPATIBLE_API_KEY`、`OPENAI_COMPATIBLE_MODEL`、`OPENAI_COMPATIBLE_STREAM` | [OpenAI platform docs](https://platform.openai.com/docs) | [OpenAI API keys](https://platform.openai.com/api-keys) 或你的兼容服务商 |
192
- | Exa | 官方文档、API、论文、产品页、可信网页的低噪声发现 | `EXA_API_KEY` | [Exa docs](https://docs.exa.ai/) | [Exa API keys](https://dashboard.exa.ai/api-keys) |
193
- | Context7 | SDK、库、框架、API 文档兜底 | `CONTEXT7_API_KEY`、`CONTEXT7_BASE_URL` | [Context7 docs](https://context7.com/docs) | [Context7](https://context7.com/) |
194
- | 智谱 Web Search API | 仅用于 deprecated 手动 `zhipu-search` 兼容;不参与默认路由 | `ZHIPU_API_KEY`、`ZHIPU_API_URL`、`ZHIPU_SEARCH_ENGINE` | [智谱联网搜索文档](https://docs.bigmodel.cn/cn/guide/tools/web-search) | [智谱 API keys](https://open.bigmodel.cn/usercenter/apikeys) |
195
- | Tavily | 额外来源、URL fetch、站点 map | `TAVILY_API_URL`、`TAVILY_API_KEY` | [Tavily docs](https://docs.tavily.com/) | [Tavily app](https://app.tavily.com/home) |
196
- | Jina Reader | 已知 URL 正文抓取;满足 standard 最低配置必须有 key | `JINA_API_KEY`、`JINA_READER_API_URL`、`JINA_RESPOND_WITH`、`JINA_TIMEOUT_SECONDS` | [Jina Reader](https://jina.ai/reader/) | [Jina AI](https://jina.ai/) |
197
- | Firecrawl | fetch 兜底、补充网页来源 | `FIRECRAWL_API_URL`、`FIRECRAWL_API_KEY` | [Firecrawl docs](https://docs.firecrawl.dev/) | [Firecrawl API keys](https://www.firecrawl.dev/app/api-keys) |
198
-
199
- 几个容易混淆的点:
200
-
201
- - OpenAI-compatible 兼容中转/网关走 Chat Completions `/chat/completions`,只通过 `OPENAI_COMPATIBLE_*` 配置。
202
- - `OPENAI_COMPATIBLE_STREAM=true` 或 `smart-search search --stream` 只会给 OpenAI-compatible 的 `search` 和 provider 侧 `fetch` 设置 `stream=true`。它是中转长请求兼容开关,不改变 URL 描述和来源排序行为。
203
- - 旧的 `SMART_SEARCH_API_URL`、`SMART_SEARCH_API_KEY`、`SMART_SEARCH_API_MODE`、`SMART_SEARCH_MODEL` 不再是受支持配置项。请显式使用 `OPENAI_COMPATIBLE_*`。
204
- - 默认网页发现走 Tavily / Firecrawl 的中英双语路径。`zhipu-search` 仅保留为 deprecated 手动兼容命令,不参与普通 `search` 或 `research` 路由。
205
- - `zhipu-search` 对应的是智谱 Web Search API,不是 Chat Completions `tools=[web_search]`,不是 Search Agent,也不是 MCP Server。
206
- - Jina Reader 不是通用搜索 provider。只有配置 `JINA_API_KEY` 后才计入 `standard`;`JINA_RESPOND_WITH=readerlm-v2` 也必须配置 `JINA_API_KEY`。
207
- - `ZHIPU_SEARCH_ENGINE` 默认是 `search_std`。官方值包括 `search_std`、`search_pro`、`search_pro_sogou`、`search_pro_quark`;`config set` 仍允许自定义值,方便官方以后新增服务。
208
- - `TAVILY_API_URL` 只影响 Tavily,不会代理智谱。Tavily Hikari / 号池用 `https://<host>/api/tavily`;setup 会把根域名或 `/mcp` 输入规范化成这个 REST base。
209
- - `FIRECRAWL_API_URL` 默认是 `https://api.firecrawl.dev/v2`。
210
-
211
- 非交互配置示例:
212
-
213
- ```powershell
214
- smart-search setup --non-interactive `
215
- --openai-compatible-api-url "https://api.openai.com/v1" `
216
- --openai-compatible-api-key "your-openai-or-relay-key" `
217
- --openai-compatible-model "gpt-4.1" `
218
- --openai-compatible-stream "false" `
219
- --validation-level "balanced" `
220
- --fallback-mode "auto" `
221
- --minimum-profile "standard" `
222
- --exa-key "your-exa-key" `
223
- --context7-key "your-context7-key" `
224
- --jina-key "your-jina-key" `
225
- --tavily-api-url "https://api.tavily.com" `
226
- --tavily-key "your-tavily-key" `
227
- --firecrawl-api-url "https://api.firecrawl.dev/v2" `
228
- --firecrawl-key "your-firecrawl-key"
229
- ```
230
-
231
- 仅在显式需要 legacy 智谱兼容时,`smart-search setup --non-interactive --zhipu-key "your-zhipu-key" --zhipu-api-url "https://open.bigmodel.cn/api" --zhipu-search-engine "search_pro_sogou"` 仍会保存这条 deprecated 手动路径。
232
-
233
- 默认最低配置是 `SMART_SEARCH_MINIMUM_PROFILE=standard`,至少需要:
234
-
235
- - `main_search`:OpenAI-compatible;
236
- - `docs_search`:Exa 或 Context7 二选一;
237
- - `web_fetch`:Tavily、带 `JINA_API_KEY` 的 Jina、Firecrawl 三选一。
238
-
239
- 缺少任一最低能力时,`doctor` 和 `search` 会 fail closed 并返回缺失 capability。`SMART_SEARCH_MINIMUM_PROFILE=off` 只建议本地实验使用。
240
-
241
- 本机配置和证据文件位置:
242
-
243
- - Windows 默认:`%LOCALAPPDATA%\smart-search\config.json`。
244
- - Linux/macOS 默认:`~/.config/smart-search/config.json`。
245
- - `SMART_SEARCH_CONFIG_DIR` 是高级覆盖项,适合 CI、容器、沙箱或便携安装。
246
- - `research` 证据默认保存到当前配置目录下的 `evidence`,例如 Windows 上的 `%LOCALAPPDATA%\smart-search\evidence`。
247
- - `SMART_SEARCH_EVIDENCE_DIR` 可覆盖证据根目录;相对路径会解析到当前配置目录下,绝对路径按原样使用。
248
- - 更早的 Windows 源码默认路径曾是 `~\.config\smart-search\config.json`,但有些安装会通过 `SMART_SEARCH_CONFIG_DIR` 提前固定到 `%LOCALAPPDATA%\smart-search`。如果新版默认位置还没有配置,但旧 home 路径存在配置,Smart Search 会以 `legacy_windows_home` 方式继续读取旧配置,避免升级后配置丢失;`config path` 和 `doctor` 会同时报告当前生效路径、默认路径、旧 home 路径、`SMART_SEARCH_CONFIG_DIR`、`SMART_SEARCH_EVIDENCE_DIR` 和最终解析出的证据根目录。
249
-
250
- 常用环境变量:
251
-
252
- | 变量 | 用途 |
253
- | --- | --- |
254
- | `OPENAI_COMPATIBLE_API_URL` | OpenAI-compatible `/v1` base URL |
255
- | `OPENAI_COMPATIBLE_API_KEY` | OpenAI-compatible key |
256
- | `OPENAI_COMPATIBLE_MODEL` | 兼容模型名,默认 `grok-4.20-multi-agent-xhigh` |
257
- | `OPENAI_COMPATIBLE_STREAM` | OpenAI-compatible 中转兼容开关,接受 `true/1/yes`,默认 `true` |
258
- | `EXA_API_KEY` | Exa key |
259
- | `CONTEXT7_API_KEY` | Context7 key |
260
- | `ZHIPU_API_KEY` | 智谱 Web Search key |
261
- | `ZHIPU_API_URL` | 智谱 API 地址,默认 `https://open.bigmodel.cn/api` |
262
- | `ZHIPU_SEARCH_ENGINE` | 智谱搜索服务,例如 `search_pro_sogou` |
263
- | `JINA_API_KEY` | Jina Reader key;满足 standard 必须配置 |
264
- | `JINA_READER_API_URL` | Jina Reader endpoint,默认 `https://r.jina.ai` |
265
- | `JINA_RESPOND_WITH` | Jina Reader 响应模式,例如 `readerlm-v2`;需要 `JINA_API_KEY` |
266
- | `JINA_TIMEOUT_SECONDS` | Jina Reader 请求超时,默认 `60` |
267
- | `TAVILY_API_URL` | Tavily REST base |
268
- | `TAVILY_API_KEY` | Tavily key |
269
- | `TAVILY_TIMEOUT_SECONDS` | Tavily 连通性检查超时,默认 `60`;公益站/号池较慢时可调大 |
270
- | `FIRECRAWL_API_URL` | Firecrawl REST base |
271
- | `FIRECRAWL_API_KEY` | Firecrawl key |
272
- | `SMART_SEARCH_VALIDATION_LEVEL` | `fast`、`balanced`、`strict` |
273
- | `SMART_SEARCH_FALLBACK_MODE` | `auto` 或 `off` |
274
- | `SMART_SEARCH_RESEARCH_PREFERRED_PROVIDERS` | `research` 路由优先 provider CSV,只能在同 capability 内调整顺序 |
275
- | `SMART_SEARCH_RESEARCH_DISABLED_PROVIDERS` | `research` 禁用 provider CSV,不能改变 provider capability 边界 |
276
- | `SMART_SEARCH_CONFIG_DIR` | 指定本机配置和日志根目录 |
277
- | `SMART_SEARCH_EVIDENCE_DIR` | 指定 `research` 默认证据根目录 |
278
-
279
- ## 常用命令
280
-
281
- | 命令 | 简写 | 用途 |
282
- | --- | --- | --- |
283
- | `search` | `s` | 快速联网搜索和综合回答 |
284
- | `research` | `rs` | live Deep Research 执行 |
285
- | `fetch` | `f` | 抓一个 URL 正文 |
286
- | `map` | `m` | 读取站点结构 |
287
- | `exa-search` | `exa`、`x` | Exa 来源发现 |
288
- | `exa-similar` | `xs` | 从一个 URL 找相似页面 |
289
- | `zhipu-search` | `z`、`zp` | Deprecated legacy 智谱 Web Search API |
290
- | `context7-library` | `c7`、`ctx7` | 查 Context7 库候选 |
291
- | `context7-docs` | `c7d`、`c7docs`、`ctx7-docs` | 抓 Context7 文档 |
292
- | `doctor` | `d` | 配置和连通性检查 |
293
- | `setup` | `init` | 配置向导 |
294
- | `config` | `cfg` | 本机配置读写 |
295
-
296
- 示例:
297
-
298
- ```powershell
299
- smart-search search "query" --validation balanced --extra-sources 3 --timeout 90 --format json --output result.json
300
- smart-search research "query" --budget deep --fallback auto --format json --output research.json
301
- smart-search search "query" --stream --format json
302
- smart-search search "query" --no-stream --format json
303
- smart-search search "nba战报" --format content
304
- smart-search exa-search "OpenAI Responses API documentation" --include-domains platform.openai.com developers.openai.com --num-results 5 --include-text --format json
305
- smart-search context7-library "react" "hooks" --format json
306
- smart-search context7-docs "/facebook/react" "useEffect cleanup" --format json
307
- smart-search exa-similar "https://example.com/source" --num-results 5 --format json
308
- smart-search fetch "https://example.com/source" --format markdown --output page.md
309
- smart-search map "https://docs.example.com" --instructions "Find API reference pages" --max-depth 1 --limit 50 --format json
310
- smart-search doctor --format markdown
311
- ```
312
-
313
- ## 输出和证据策略
314
-
315
- AI 和脚本解析优先用 JSON:
316
-
317
- ```powershell
318
- smart-search search "query" --format json
319
- smart-search doctor --format json
320
- ```
321
-
322
- 给人看连接状态、详细排障报告、来源列表、网页正文时用 Markdown:
323
-
324
- ```powershell
325
- smart-search doctor --format markdown
326
- smart-search exa-search "OpenAI Responses API documentation" --format markdown
327
- smart-search fetch "https://example.com" --format markdown
328
- ```
329
-
330
- 终端快速扫正文或摘要用 content:
331
-
332
- ```powershell
333
- smart-search search "nba战报" --format content
334
- smart-search doctor --format content
335
- ```
336
-
337
- `content` 刻意保持很短,只适合快速看结论。完整排障给人看用 `doctor --format markdown`,给脚本和 AI 解析用 `doctor --format json`。
338
-
339
- 多来源研究建议保存证据文件:
340
-
341
- ```powershell
342
- $Config = smart-search config path --format json | ConvertFrom-Json
343
- $EvidenceDir = Join-Path $Config.resolved_evidence_dir "iran-hormuz"
344
- New-Item -ItemType Directory -Force -Path $EvidenceDir | Out-Null
345
- smart-search exa-search "Reuters Iran Hormuz latest" --format json --output (Join-Path $EvidenceDir "01-exa.json")
346
- smart-search fetch "https://example.com/source" --format markdown --output (Join-Path $EvidenceDir "02-fetch.md")
347
- ```
348
-
349
- 写 claim-level 结论时建议流程:
350
-
351
- 1. 用中英双语 `search`、`exa-search` 或 `exa-similar` 找候选 URL。
352
- 2. 用 `fetch` 抓关键 URL 正文。
353
- 3. 最终回答只引用 fetch 正文能支撑的事实。
354
- 4. 没有 fetch 的来源标为未验证候选。
355
-
356
- ## 排障
357
-
358
- 如果 `doctor` 返回 `config_error`:
359
-
360
- ```powershell
361
- smart-search setup
362
- smart-search config list --format json
363
- smart-search doctor --format markdown
364
- ```
365
-
366
- 如果搜索慢:
367
-
368
- - 降低 `--extra-sources`;
369
- - 把大问题拆成多个小问题;
370
- - 先用中英双语 `search` 或 `exa-search` 找来源,再 `fetch` 关键网页。
371
-
372
- 如果想确认安装是否正常:
373
-
374
- ```powershell
375
- smart-search --help
376
- smart-search --version
377
- smart-search doctor --format json
378
- ```
379
-
380
- Windows npm/mise 安装后建议验证中文 JSON 管道:
381
-
382
- ```powershell
383
- smart-search search "深度搜索一下最近的比特币行情" --format json | ConvertFrom-Json
384
- ```
385
-
386
- ## 开发验证
387
-
388
- ```powershell
389
- .\.venv\Scripts\python.exe -m compileall -q src tests
390
- .\.venv\Scripts\python.exe -m pytest tests -q
391
- npm test
392
- npm pack --dry-run
393
- ```
394
-
395
- ## 最新稳定版说明
396
-
397
- ### v0.1.14
398
-
399
- 这个稳定补丁版把已经验证过的 `0.1.13-beta.4` CLI 和内置 skill contract 推到 npm `latest`。
400
-
401
- - `smart-search diagnose openai-compatible --format markdown` 会生成适合复制给维护者的 OpenAI-compatible 卡住/超时诊断报告。
402
- - 文档/API 路由现在优先用 Context7 处理库/框架文档,Exa 继续负责官方域名、论文、产品页和可信站点发现。
403
- - README、打包 skill 资源、release notes 和测试已经同步说明并验证这次稳定包行为。
404
-
405
- ## 发布通道
406
-
407
- 稳定版走 Git tag 和 npm `latest`:
408
-
409
- ```powershell
410
- git tag v0.1.14
411
- git push origin v0.1.14
412
- ```
413
-
414
- 测试版不移动 `latest`。推送到 `main` 会发布下一个 `<package.json version>-beta.N` 到 npm `next`,并且 `N` 按每个稳定版本重新从 1 开始。例如 `0.1.10-beta.1`、`0.1.10-beta.2` 之后是 `0.1.10-beta.3`。
415
-
416
- 已发布 npm 版本不可变。旧的 `*-dev.*` 包不能原地改名,只能发布新的 `*-beta.N` 替代。
417
-
418
- 稳定版 GitHub Release 会读取 `.github/releases/vX.Y.Z.md` 作为正文,并自动追加 npm package、dist-tag、workflow run 等元数据。打稳定 tag 前先写这个文件,避免 Release 页面只显示包名和 workflow 链接。
419
-
420
- 发布收尾检查:
421
-
422
- 1. 先读 `npm view @konbakuyomu/smart-search versions --json`、`npm view @konbakuyomu/smart-search dist-tags --json`、`gh release list --repo konbakuyomu/smartsearch --limit 100`。
423
- 2. beta 发布必须保持 `latest` 不动,只移动 `next` 或指定的非 latest tag。
424
- 3. 遇到 npm `E409`,先查版本是否已经发布,再串行重跑对应版本。
425
- 4. 最后安装指定版本并运行 `smart-search --version`、`smart-search doctor --format json`。
426
- 5. Windows npm/mise 包装层额外跑中文 JSON 管道:`smart-search search "深度搜索一下最近的比特币行情" --format json | ConvertFrom-Json`。
427
-
428
- ## License
429
-
430
- MIT
@@ -1,63 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const { spawn, spawnSync } = require("node:child_process");
4
- const fs = require("node:fs");
5
- const path = require("node:path");
6
-
7
- const packageRoot = path.resolve(__dirname, "..", "..");
8
- const callerCwd = process.env.INIT_CWD || process.cwd();
9
- const venvDir = path.join(packageRoot, ".smart-search-python");
10
- const pythonPath =
11
- process.platform === "win32"
12
- ? path.join(venvDir, "Scripts", "python.exe")
13
- : path.join(venvDir, "bin", "python");
14
-
15
- if (!fs.existsSync(pythonPath)) {
16
- const postinstall = path.join(packageRoot, "npm", "scripts", "postinstall.js");
17
- console.error("smart-search Python runtime is missing; attempting repair...");
18
- const repaired = spawnSync(process.execPath, [postinstall], {
19
- cwd: packageRoot,
20
- stdio: "inherit",
21
- windowsHide: true
22
- });
23
- if (repaired.error) {
24
- console.error(`smart-search runtime repair failed: ${repaired.error.message}`);
25
- process.exit(5);
26
- }
27
- if (repaired.status !== 0 || !fs.existsSync(pythonPath)) {
28
- console.error("smart-search npm wrapper could not find its Python runtime.");
29
- console.error(`Expected: ${pythonPath}`);
30
- console.error("Repair it by reinstalling the package:");
31
- console.error(" npm install -g @konbakuyomu/smart-search@next");
32
- process.exit(repaired.status || 5);
33
- }
34
- }
35
-
36
- const child = spawn(
37
- pythonPath,
38
- ["-m", "smart_search.cli", ...process.argv.slice(2)],
39
- {
40
- cwd: callerCwd,
41
- stdio: "inherit",
42
- env: {
43
- ...process.env,
44
- SMART_SEARCH_PACKAGE_ROOT: packageRoot,
45
- PYTHONIOENCODING: process.env.PYTHONIOENCODING || "utf-8",
46
- PYTHONUTF8: process.env.PYTHONUTF8 || "1"
47
- },
48
- windowsHide: true
49
- }
50
- );
51
-
52
- child.on("error", (error) => {
53
- console.error(`Failed to start smart-search: ${error.message}`);
54
- process.exit(5);
55
- });
56
-
57
- child.on("close", (code, signal) => {
58
- if (signal) {
59
- process.kill(process.pid, signal);
60
- return;
61
- }
62
- process.exit(code ?? 5);
63
- });
@@ -1,87 +0,0 @@
1
- const { spawnSync } = require("node:child_process");
2
- const fs = require("node:fs");
3
- const path = require("node:path");
4
-
5
- const packageRoot = path.resolve(__dirname, "..", "..");
6
- const venvDir = path.join(packageRoot, ".smart-search-python");
7
-
8
- function run(command, args, options = {}) {
9
- const result = spawnSync(command, args, {
10
- cwd: packageRoot,
11
- stdio: options.stdio || "inherit",
12
- encoding: "utf8",
13
- windowsHide: true
14
- });
15
-
16
- if (result.error) {
17
- return { ok: false, error: result.error };
18
- }
19
- return { ok: result.status === 0, status: result.status, stdout: result.stdout || "" };
20
- }
21
-
22
- function pythonCandidates() {
23
- if (process.platform === "win32") {
24
- return [
25
- { command: "py", args: ["-3"] },
26
- { command: "python", args: [] },
27
- { command: "python3", args: [] }
28
- ];
29
- }
30
- return [
31
- { command: "python3", args: [] },
32
- { command: "python", args: [] }
33
- ];
34
- }
35
-
36
- function findPython() {
37
- const probe = [
38
- "-c",
39
- "import sys; raise SystemExit(0 if sys.version_info >= (3, 10) else 1)"
40
- ];
41
-
42
- for (const candidate of pythonCandidates()) {
43
- const result = run(candidate.command, [...candidate.args, ...probe], { stdio: "pipe" });
44
- if (result.ok) {
45
- return candidate;
46
- }
47
- }
48
- return null;
49
- }
50
-
51
- function venvPython() {
52
- return process.platform === "win32"
53
- ? path.join(venvDir, "Scripts", "python.exe")
54
- : path.join(venvDir, "bin", "python");
55
- }
56
-
57
- const python = findPython();
58
- if (!python) {
59
- console.error("smart-search requires Python 3.10 or newer.");
60
- console.error("Install Python, then run: npm install -g @konbakuyomu/smart-search@latest");
61
- process.exit(1);
62
- }
63
-
64
- if (!fs.existsSync(venvPython())) {
65
- console.log("Creating smart-search Python runtime...");
66
- const created = run(python.command, [...python.args, "-m", "venv", venvDir]);
67
- if (!created.ok) {
68
- console.error("Failed to create the smart-search Python virtual environment.");
69
- process.exit(created.status || 1);
70
- }
71
- }
72
-
73
- const py = venvPython();
74
-
75
- console.log("Installing smart-search Python package...");
76
- const install = run(py, [
77
- "-m",
78
- "pip",
79
- "install",
80
- "--disable-pip-version-check",
81
- packageRoot
82
- ]);
83
-
84
- if (!install.ok) {
85
- console.error("Failed to install the bundled smart-search Python package.");
86
- process.exit(install.status || 1);
87
- }