@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,387 +0,0 @@
1
- ---
2
- name: smart-search-cli
3
- description: CLI-first web research and source retrieval through the local smart-search command. Use when Codex needs current web search, source-backed fact checking, URL fetching, site mapping, official/API/documentation search, or reproducible search evidence via Skill + CLI instead of MCP tools.
4
- ---
5
-
6
- # Smart Search CLI
7
-
8
- Use the local `smart-search` command as the default execution layer for web research. The skill decides routing; the CLI performs the work; JSON or saved files provide evidence.
9
-
10
- ## Default workflow
11
-
12
- 1. Run `smart-search doctor --format json` when configuration or availability is uncertain.
13
- 2. If `doctor` reports missing configuration, use `smart-search setup` or `smart-search config set KEY VALUE` when the user provides keys. Do not ask users to edit global environment variables by default.
14
- 3. If OpenAI-compatible `search` hangs or times out after `doctor` succeeds, run `smart-search diagnose openai-compatible --format markdown` and use its summary/recommendation. This one command tests quick chat plus real search-shape `stream=false` and `stream=true`.
15
- 4. If `doctor` returns `ok: true`, use only `smart-search` CLI subcommands for web research. Do not call Codex native web search in the same task.
16
- 5. For every research question, run a bilingual `smart-search search` pair: one Chinese-source query and one English-source query. Save both JSON outputs.
17
- 6. Use `smart-search search` as the first hop for realtime, broad exploration, community signals, multi-source summaries, and routing metadata. The default broad pass is bilingual, not Zhipu-backed.
18
- 7. Do not use `smart-search zhipu-search` in normal workflows. Zhipu is deprecated and not used by default routing because quota may be unavailable; the command remains only for manual legacy compatibility when the user explicitly asks for it.
19
- 8. Use `smart-search context7-library` / `context7-docs` first for library, SDK, API, framework, or documentation intent.
20
- 9. Use `smart-search exa-search` for official domains, papers, product pages, trusted sites, and low-noise discovery. Do not treat Exa as the universal second hop for every high-risk or verification task.
21
- 10. Use `smart-search search --extra-sources N` for Tavily/Firecrawl horizontal candidates, and `smart-search fetch` for page text that can support final claims.
22
- 11. Use `smart-search exa-similar` when the user gives a representative URL and wants related pages or neighboring sources.
23
- 12. Use `smart-search fetch` when the user gives a URL or a claim depends on page content.
24
- 13. Use `smart-search map` when a documentation site or domain structure matters.
25
- 14. To change the main-search model, use `smart-search config set OPENAI_COMPATIBLE_MODEL ...`.
26
- 15. For current-news, policy, finance, health, or other high-risk facts, do not answer from broad `search.content` alone. Use the bilingual search pair plus intent-specific sources: Context7 for docs/API, Exa for official/trusted domains or papers, then `fetch` key pages and summarize only what fetched text supports.
27
- 16. Use `smart-search research "question" --format json` when the user wants the CLI to run live Deep Research end to end instead of only planning. It executes plan -> discover -> fetch/read -> gap check -> evidence-only synthesis.
28
- 17. Preserve command lines and source URLs in your answer. Prefer citing fetched pages or `primary_sources`; treat `extra_sources` as follow-up candidates, not verified evidence for generated claims.
29
-
30
- ## Deep Research Mode
31
-
32
- Use Deep Research Mode when the user asks for `深度搜索`, `深度调研`, `深入搜索`, `deep search`, `deep research`, multi-source verification, cross-checking, serious review, or selection/comparison research. This is a capability-based orchestration workflow. The live executor route calls `smart-search research "question" --format json` and lets the CLI execute plan -> discover -> fetch/read -> gap check -> evidence-only synthesis. `smart-search research` builds the `research_plan` internally before discovery; there is no separate offline planner command. This does not change default `smart-search search`, and it does not depend on an MCP session.
33
-
34
- Do not select a fixed topic recipe. Market, product, technical docs, news, policy, claim-checking, and URL-first prompts are examples of user language, not schema modes. Decide from intent dimensions and capability needs.
35
-
36
- When `smart-search research` runs, it builds an internal `research_plan` as its planning artifact before discovery. The plan uses this shape:
37
-
38
- ```json
39
- {
40
- "mode": "deep_research",
41
- "query_mode": "research",
42
- "question": "user question",
43
- "trigger_source": "explicit_cli",
44
- "difficulty": "standard|high",
45
- "intent_signals": {
46
- "recency_requirement": "none|recent|current",
47
- "docs_api_intent": false,
48
- "locale_domain_scope": "global|china|known_domains|mixed",
49
- "known_url": false,
50
- "source_authority_need": "normal|high",
51
- "claim_risk": "low|medium|high",
52
- "cross_validation_need": "normal|high",
53
- "breadth_depth_budget": "quick|standard|deep"
54
- },
55
- "decomposition": [
56
- {
57
- "id": "sq1",
58
- "question": "subquestion",
59
- "reason": "why this subquestion is needed",
60
- "required_capabilities": ["broad_discovery"]
61
- }
62
- ],
63
- "capability_plan": [
64
- {
65
- "capability": "broad_discovery",
66
- "tools": ["search"],
67
- "reason": "Find the initial answer shape and candidate sources."
68
- }
69
- ],
70
- "preflight": {
71
- "tool": "doctor",
72
- "command": "smart-search doctor --format json",
73
- "when": "configuration or availability is uncertain",
74
- "executed_during_planning": false
75
- },
76
- "evidence_policy": "fetch_before_claim",
77
- "steps": [
78
- {
79
- "id": "s1",
80
- "subquestion_id": "sq1",
81
- "tool": "search",
82
- "purpose": "broad discovery",
83
- "command": "smart-search search \"query\" --validation balanced --extra-sources 1 --format json --output <resolved_evidence_dir>\\YYYYMMDD-HHMM-topic\\01-search.json",
84
- "output_path": "<resolved_evidence_dir>\\YYYYMMDD-HHMM-topic\\01-search.json"
85
- }
86
- ],
87
- "gap_check": {
88
- "required": true,
89
- "rule": "fetch missing evidence for key claims or downgrade them to unverified candidates"
90
- },
91
- "final_answer_policy": "cite fetched evidence, list unverified candidates, and include key commands",
92
- "usage_boundary": {
93
- "search": "smart-search search runs live fast/broad search immediately.",
94
- "execution": "smart-search research executes the listed steps with existing CLI building blocks, then performs gap_check."
95
- }
96
- }
97
- ```
98
-
99
- Allowed `steps[].tool` values are `search`, `exa-search`, `exa-similar`, `context7-library`, `context7-docs`, `fetch`, and `map`. Each step must include `id`, `subquestion_id`, `purpose`, `command`, and `output_path`. `doctor` is preflight and must not appear in `steps[]`. Simple plans may have one subquestion; complex plans should use 2-6 subquestions unless the user explicitly asks for exhaustive coverage.
100
-
101
- Capability boundaries:
102
-
103
- - `search`: broad bilingual discovery and synthesis through `main_search`; inspect `routing_decision`, `provider_attempts`, `fallback_used`, and `source_warning`. Do not treat broad answers as proof for high-risk claims.
104
- - `zhipu-search`: deprecated manual compatibility command. Do not include it in default plans or workflows unless the user explicitly requests Zhipu.
105
- - `context7-library` / `context7-docs`: library, SDK, API, framework, and documentation intent. Prefer Context7 before Exa for docs/API questions.
106
- - `exa-search`: low-noise discovery for official domains, papers, product pages, known domains, and trusted pages. Use it when that boundary fits; it is not the default second hop for every verification task.
107
- - `exa-similar`: adjacent-source discovery when a known reliable URL is available.
108
- - `search --extra-sources N`: Tavily/Firecrawl horizontal candidate collection for breadth. Treat those candidates as discovery until fetched.
109
- - `fetch`: page-content evidence. Use it before claim-level conclusions.
110
- - `map`: site structure exploration before many fetches from one site; not claim evidence by itself.
111
-
112
- Default Deep Research orchestration:
113
-
114
- 1. Run `smart-search doctor --format json` as preflight when configuration is uncertain.
115
- 2. `smart-search research` builds an internal `research_plan` with `intent_signals`, `decomposition`, and `capability_plan`; do not choose fixed topic recipe ids.
116
- 3. Execute planned bilingual `search --validation balanced --extra-sources 1..3` steps for Chinese-source and English-source broad discovery, then read routing metadata.
117
- 4. Execute planned `exa-search`, `exa-similar`, `context7-library`, `context7-docs`, or `map` only when their capability boundary matches the intent.
118
- 5. Use `fetch` on key URLs before making claim-level statements.
119
- 6. Run `gap_check`: if an important claim lacks fetched evidence, fetch another source or mark the claim/source as unverified.
120
-
121
- Default evidence policy is `fetch_before_claim`: key claims in the final answer must be supported by fetched page text. Treat `primary_sources` and `extra_sources` as discovery candidates until the relevant URL has been fetched. The final answer should include fetched evidence, unverified candidate sources, and key commands used.
122
-
123
- Live Deep Research executor:
124
-
125
- - `smart-search research QUERY [--budget quick|standard|deep] [--evidence-dir PATH] [--fallback auto|off] [--format json|markdown|content] [--output PATH]` runs the staged workflow directly.
126
- - Default `--fallback auto` permits same-capability fallback inside selected routes. Use `--fallback off` only for debugging or deterministic provider checks.
127
- - Research output includes `final_answer`, `citations`, `evidence_items`, `gap_check`, `provider_attempts`, `fallback_used`, `degraded`, `route_policy_version`, and `evidence_dir`.
128
- - The synthesis is evidence-only. It may cite fetched/read evidence, but it must not cite unfetched discovery candidates as proof.
129
- - If providers are exhausted or evidence cannot close, return the degraded gaps rather than inventing missing claims.
130
-
131
- Research provider advantage routing:
132
-
133
- - Context7: library/API/framework docs resolution and docs retrieval.
134
- - Exa: official domains, papers, product/company pages, date/domain-filtered low-noise discovery, and adjacent-source discovery.
135
- - Tavily: broad bilingual source discovery and site map.
136
- - Jina: known public URL, PDF, and arXiv clean extraction; ReaderLM-v2 requires `JINA_API_KEY`.
137
- - Firecrawl: robust fetch fallback, JS-heavy/dynamic pages, browser-like extraction, OCR/PDF/structured extraction.
138
-
139
- Safe research overrides are `SMART_SEARCH_RESEARCH_PREFERRED_PROVIDERS` and `SMART_SEARCH_RESEARCH_DISABLED_PROVIDERS`. They may reorder or disable providers only within capabilities the provider already supports; they must not move a provider across capability boundaries.
140
-
141
- Deep Research test coverage for workflow maintenance should verify trigger phrases, normal search requests that should not trigger Deep Research, required `research_plan` fields, allowed tool whitelist, bilingual search steps, `fetch_before_claim`, evidence output paths, capability boundaries, `intent_signals`, `capability_plan`, `gap_check`, simple current prompts such as `深度搜索一下最近的比特币行情`, docs/API prompts, claim-verification prompts, user-provided URL fetch-first flows, missing-provider failure guidance, and the rule that fixed topic recipe ids are not required schema. When real keys are available and the user expects live checks, a small live pass can run `doctor`, two broad `search` commands (Chinese and English), one `exa-search`, and one `fetch`.
142
-
143
- Standard user-facing Deep Research tests:
144
-
145
- ```powershell
146
- smart-search research "深度搜索一下最近的比特币行情" --format json
147
- smart-search research "OpenAI Responses API web_search 和 Chat Completions 联网搜索怎么选" --budget deep --format json
148
- smart-search research "帮我核验这个说法是真是假:某某工具已经完全替代 Tavily 做 AI 搜索了" --format json
149
- smart-search research "https://example.com/source" --format json
150
- ```
151
-
152
- ## Provider Routing
153
-
154
- - `search` builds `main_search` from `OPENAI_COMPATIBLE_API_URL` + `OPENAI_COMPATIBLE_API_KEY`, which registers OpenAI-compatible Chat Completions.
155
- - `search` is the default first hop for broad exploration, current synthesis, and routing metadata.
156
- - OpenAI-compatible relays/gateways use Chat Completions `/chat/completions` through `OPENAI_COMPATIBLE_*`.
157
- - `OPENAI_COMPATIBLE_STREAM=true` or `search --stream` sets `stream=true` only for OpenAI-compatible `search` and provider-side `fetch`; it is a relay compatibility switch and does not affect URL description or source ranking.
158
- - Legacy `SMART_SEARCH_API_URL`, `SMART_SEARCH_API_KEY`, `SMART_SEARCH_API_MODE`, and `SMART_SEARCH_MODEL` are unsupported config keys.
159
- - The standard minimum profile requires one configured provider in each of `main_search`, `docs_search`, and fetch capability. Missing required capabilities should be treated as a hard configuration failure.
160
- - Jina Reader is `web_fetch` only, not a general search provider. `JINA_API_KEY` is required before Jina satisfies the standard minimum profile; anonymous `r.jina.ai` is explicit/experimental fetch behavior.
161
- - `search` exposes `--validation fast|balanced|strict`, `--fallback auto|off`, and `--providers auto|CSV`. Default validation is `balanced`; fallback only happens within the same capability.
162
- - `search --validation strict` uses the same bilingual web_search policy as balanced mode when source discovery providers are configured. Strict queries without primary, docs, fetch, or explicit source evidence can still fail with `evidence_error`; use `--extra-sources N`, source-first commands such as `exa-search`, or `fetch` when citable evidence is required.
163
- - `search` runs bilingual web_search source discovery through Tavily / Firecrawl when configured. Zhipu is deprecated from default routing and is not the first hop for Chinese/current/domestic searches.
164
- - Docs/API/library routing stays explicit keyword intent-based and should prefer Context7 first. Exa is for official-domain or low-noise supplemental discovery, not the default docs answer route.
165
- - `search` calls Tavily and/or Firecrawl for `extra_sources` only when `--extra-sources N` is greater than 0.
166
- - With both Tavily and Firecrawl configured, `search --extra-sources N` splits extra sources between them, with Tavily receiving about 60% and Firecrawl the rest.
167
- - Search JSON separates `primary_sources`, `extra_sources`, and backward-compatible merged `sources`.
168
- - `primary_sources` are extracted from the primary model answer. `extra_sources` are parallel Tavily / Firecrawl candidates and are not automatically used to verify `content`.
169
- - `fetch` tries Tavily first, then Jina with `JINA_API_KEY`, then Firecrawl.
170
- - `map` currently uses Tavily only.
171
- - `exa-search` and `exa-similar` use Exa only.
172
- - `context7-library` and `context7-docs` use Context7 only.
173
- - `zhipu-search` uses Zhipu only and is retained as a deprecated manual compatibility command.
174
- - `zhipu-search` corresponds to the official Zhipu Web Search API route, using `ZHIPU_API_URL` plus `ZHIPU_SEARCH_ENGINE`; it is not Zhipu Chat Completions `tools=[web_search]`, not Search Agent, and not the MCP Server.
175
- - `ZHIPU_SEARCH_ENGINE` defaults to `search_std`. Official Web Search API service values include `search_std`, `search_pro`, `search_pro_sogou`, and `search_pro_quark`; keep custom values possible because official services may change.
176
- - `TAVILY_API_URL` only affects Tavily REST calls and does not proxy Zhipu. Zhipu defaults to `https://open.bigmodel.cn/api` unless `ZHIPU_API_URL` is set.
177
- - `doctor` tests configured main-search providers, Exa, Tavily, Jina, Zhipu Web Search API, and Context7 connectivity. Firecrawl status currently means the key is configured, not that a live Firecrawl request succeeded.
178
-
179
- ## Evidence Files
180
-
181
- For multi-source research, use `smart-search config path --format json` and save evidence under `resolved_evidence_dir` with a descriptive timestamped filename. Stdout should still contain the full JSON result unless markdown or content output was explicitly chosen for human reading.
182
-
183
- For claim-level evidence, prefer this order:
184
-
185
- 1. Discover candidate URLs with a bilingual source-focused `search` pair, Context7 for docs/API/library topics, or `exa-search` for official/trusted domains and papers.
186
- 2. Fetch the exact pages that matter.
187
- 3. Use broad `search` only as synthesis or discovery, and mark claims as unverified when only `extra_sources` are available.
188
-
189
- Prefer shorter, source-directed commands:
190
-
191
- ```powershell
192
- $Config = smart-search config path --format json | ConvertFrom-Json
193
- $EvidenceDir = Join-Path $Config.resolved_evidence_dir "YYYYMMDD-HHMM-topic"
194
- New-Item -ItemType Directory -Force -Path $EvidenceDir | Out-Null
195
- smart-search exa-search "Reuters Iran Hormuz latest" --num-results 5 --include-highlights --format json --output (Join-Path $EvidenceDir "01-iran-hormuz-exa.json")
196
- smart-search exa-search "OpenAI Responses API documentation" --include-domains platform.openai.com developers.openai.com --num-results 5 --include-text --format json
197
- smart-search exa-similar "https://example.com/source" --num-results 5 --format json
198
- smart-search fetch "https://example.com/source" --format json --output (Join-Path $EvidenceDir "02-source-fetch.json")
199
- smart-search search "Iran Hormuz latest military talks" --extra-sources 3 --timeout 90 --format json --output (Join-Path $EvidenceDir "03-iran-hormuz-search.json")
200
- ```
201
-
202
- ## Workflows
203
-
204
- Use these recipes when the user asks for evidence, citations, repeated searches, or an archiveable research trail. Keep `--output` paths under one timestamped evidence directory so later answers can cite saved files and rerun commands.
205
-
206
- ### Lightweight Evidence Gathering
207
-
208
- Use this when the user needs a source-backed answer but not full Deep Research.
209
-
210
- 1. Create an evidence directory under the system-aware Smart Search evidence root reported by `smart-search config path --format json`.
211
- 2. Discover candidate sources by intent:
212
- - Always run the bilingual broad pair:
213
- - `smart-search search "中文搜索,优先检索中文来源,并回答原问题:query" --validation balanced --extra-sources 1 --format json --output "$EvidenceDir\01-search-zh.json"`
214
- - `smart-search search "Search English-language sources and answer the original question: query" --validation balanced --extra-sources 1 --format json --output "$EvidenceDir\02-search-en.json"`
215
- - Docs/API/library/framework intent: `smart-search context7-library "library" "topic" --format json --output "$EvidenceDir\01-context7-library.json"`
216
- - Official domains, papers, product pages, or trusted sites: `smart-search exa-search "query" --num-results 5 --include-text --include-highlights --format json --output "$EvidenceDir\01-exa.json"`
217
- 3. Fetch the one or two URLs that support the answer: `smart-search fetch "https://example.com/source" --format markdown --output "$EvidenceDir\02-fetch-source.md"`.
218
- 4. Write the final answer only from fetched page text or clearly label unfetched items as candidates.
219
-
220
- See `examples/evidence-gathering.md` for a complete command sequence.
221
-
222
- ### Deep Research With Citations
223
-
224
- Use this when the user asks for deep research, cross-checking, serious comparison, or a multi-source investigation.
225
-
226
- 1. Run the live executor: `smart-search research "question" --budget standard --format json --output "$EvidenceDir\research.json"`.
227
- 2. Read `research_plan`, `evidence_items`, `gap_check`, `citations`, and `final_answer`.
228
- 3. If `degraded` is true or `gap_check` lists open gaps, either fetch more sources or report the remaining gaps instead of filling them from memory.
229
-
230
- Keep the detailed Deep Research rules in `## Deep Research Mode`; this workflow is only the quick selection recipe.
231
-
232
- ### Batch Search And Fetch
233
-
234
- Use this when the user gives multiple queries, companies, tools, documents, URLs, or comparison targets.
235
-
236
- 1. Create one evidence directory for the batch.
237
- 2. Run one CLI command per query or URL, using numbered outputs such as `01-search-react.json`, `02-search-vue.json`, or `03-fetch-docs.md`.
238
- 3. Keep each command narrow:
239
- - Use the bilingual `search --extra-sources 1` pair for quick broad discovery.
240
- - Use `context7-library` / `context7-docs` for docs/API/library items.
241
- - Use `exa-search` for official/trusted-domain discovery.
242
- - Use `fetch` for each URL that will support a claim.
243
- 4. After the loop, summarize across saved files. Cite fetched files or fetched URLs for claims; list unfetched discovery results only as candidates.
244
-
245
- See `examples/batch-search.md` for PowerShell loop patterns and output naming.
246
-
247
- ### Evidence Archiving
248
-
249
- Use this when the user wants work that can be inspected, resumed, or audited.
250
-
251
- 1. Save every non-trivial command with `--output`.
252
- 2. Use stable numbered filenames: `01-search.json`, `02-exa-official.json`, `03-fetch-source.md`, `04-summary.json`.
253
- 3. Keep command lines in the final answer or notes.
254
- 4. Prefer JSON for machine-readable discovery and Markdown for fetched page text intended for reading.
255
- 5. Do not treat `primary_sources` or `extra_sources` as claim proof until the relevant URL has been fetched.
256
-
257
- ## Local wrapper contract
258
-
259
- - Expect `smart-search` to resolve from the user's PATH.
260
- - This bundled skill is maintained with the `smartsearch` repository.
261
- - Prefer the CLI's local config file managed by `smart-search setup` / `smart-search config`.
262
- - Environment variables remain supported for CI and advanced users, and override the local config file.
263
- - Do not ask users to set Windows global API-key environment variables by default.
264
- - If keys are changed with `smart-search config set`, rerun the CLI; no Codex restart is needed.
265
- - If PATH is changed, a new terminal or Codex restart may be needed.
266
- - On Windows, the default local config file is `%LOCALAPPDATA%\smart-search\config.json`. Linux/macOS default to `~/.config/smart-search/config.json`.
267
- - In sandboxed runtimes (Codex CLI, containers, CI) where the default config directory is not writable or must be pinned, set `SMART_SEARCH_CONFIG_DIR` to an absolute writable path. The CLI uses it for both config and relative logs and skips default-directory selection.
268
- - The default research evidence root is `evidence` under the active config directory. Set `SMART_SEARCH_EVIDENCE_DIR` only when evidence needs a separate absolute location; `config path` and `doctor` report both the configured and resolved evidence paths.
269
- - Earlier Windows source defaults used `~\.config\smart-search\config.json`, while some installs were already pinned to `%LOCALAPPDATA%\smart-search` through `SMART_SEARCH_CONFIG_DIR`. If the new default file is missing but the old file exists, `doctor` reports `legacy_windows_home` as the active source so upgrades do not silently lose configuration. It also reports the override value and whether it matches the current default.
270
- - Use `smart-search doctor --format json` for agent/script parsing and `smart-search doctor --format markdown` when a human wants a detailed diagnostic report.
271
- - If `smart-search doctor --format json` returns `ok: false`, follow the `error` field's guidance (`smart-search setup` or `smart-search config set KEY VALUE`); do not silently fall back to native web search.
272
- - Use `smart-search diagnose openai-compatible --format markdown` when `doctor` succeeds but OpenAI-compatible `search` appears to hang, returns a timeout, or differs between `--stream` and `--no-stream`. It is the beginner-facing one-command report for upstream/relay compatibility.
273
- - Interactive `smart-search setup` is a language-selecting grouped wizard with arrow-key / Space / Enter provider selection. It guides users through required `main_search`, `docs_search`, and fetch capability. Zhipu is no longer recommended or prompted in the default setup flow.
274
- - The setup wizard prints beginner filling examples for official-service and relay/pooled-endpoint minimum profiles. Keep that guidance on stderr so stdout remains parseable JSON/Markdown/content output.
275
- - Use `smart-search setup --lang en` for an English wizard and `smart-search setup --advanced` only when low-level config keys must be shown one by one.
276
- - Use `smart-search config set ZHIPU_API_KEY ...` only for explicit legacy Zhipu compatibility. Do not set it up for default workflows.
277
- - Use `smart-search setup --non-interactive --jina-key "key"` to let Jina satisfy `web_fetch`; `JINA_RESPOND_WITH=readerlm-v2` also requires `JINA_API_KEY`.
278
- - Use `smart-search setup --non-interactive --openai-compatible-stream true` only when an OpenAI-compatible relay benefits from SSE streaming for long requests. Default is true.
279
- - Interactive setup does not ask for Zhipu by default.
280
- - Use `TAVILY_API_URL=https://<host>/api/tavily` for Tavily Hikari / pooled endpoints. Root host and `/mcp` inputs are normalized by setup; `/mcp` itself is not the REST base Smart Search should call.
281
- - `TAVILY_TIMEOUT_SECONDS` controls the Tavily `doctor` connectivity timeout and defaults to `30`. Raise it for slower pooled/community Tavily endpoints before judging the provider unhealthy.
282
- - Use `FIRECRAWL_API_URL` only for a Firecrawl-compatible REST base. Official default is `https://api.firecrawl.dev/v2`.
283
-
284
- ## Command Patterns
285
-
286
- ```powershell
287
- smart-search search "query" --extra-sources 5 --timeout 90 --format json --output result.json
288
- smart-search search "query" --stream --format json
289
- smart-search diagnose openai-compatible --format markdown
290
- smart-search search "query" --platform "Reuters" --model "model-id" --extra-sources 3 --timeout 90 --format json
291
- smart-search search "nba战报" --format content
292
- smart-search search "query" --validation strict --fallback auto --providers auto --format json
293
- smart-search exa-search "query" --num-results 5 --search-type neural --include-text --include-highlights --include-domains docs.example.com developer.mozilla.org --format json
294
- smart-search exa-similar "https://example.com/article" --num-results 5 --format json
295
- smart-search context7-library "react" "hooks" --format json
296
- smart-search context7-docs "/facebook/react" "useEffect cleanup" --format json
297
- smart-search fetch "https://example.com" --format markdown --output page.md
298
- smart-search map "https://docs.example.com" --instructions "Find API reference pages" --max-depth 1 --max-breadth 20 --limit 50 --format json
299
- smart-search research "OpenAI Responses API web_search vs Chat Completions search" --budget deep --fallback auto --format json
300
- smart-search rs "https://example.com/source" --fallback off --format markdown
301
- smart-search setup
302
- smart-search setup --lang en
303
- smart-search setup --advanced
304
- smart-search setup --non-interactive --openai-compatible-stream true
305
- smart-search setup --non-interactive --tavily-api-url "https://api.tavily.com" --tavily-key "key"
306
- smart-search --version
307
- smart-search config path --format json
308
- smart-search config list --format json
309
- smart-search config list --format markdown
310
- smart-search config set OPENAI_COMPATIBLE_API_URL "https://api.openai.com/v1" --format json
311
- smart-search config set OPENAI_COMPATIBLE_API_KEY "key" --format json
312
- smart-search config set OPENAI_COMPATIBLE_MODEL "model-id" --format json
313
- smart-search config set OPENAI_COMPATIBLE_STREAM "true" --format json
314
- smart-search config set EXA_API_KEY "key" --format json
315
- smart-search config set CONTEXT7_API_KEY "key" --format json
316
- smart-search config set ZHIPU_API_KEY "key" --format json
317
- smart-search config set ZHIPU_API_URL "https://open.bigmodel.cn/api" --format json
318
- smart-search config set ZHIPU_SEARCH_ENGINE "search_pro" --format json
319
- smart-search config set TAVILY_API_URL "https://api.tavily.com" --format json
320
- smart-search config set TAVILY_TIMEOUT_SECONDS "45" --format json
321
- smart-search config set FIRECRAWL_API_URL "https://api.firecrawl.dev/v2" --format json
322
- smart-search doctor --format json
323
- smart-search doctor --format markdown
324
- smart-search diagnose openai-compatible --format markdown
325
- ```
326
-
327
- Short aliases are supported for interactive use:
328
-
329
- ```powershell
330
- smart-search --v
331
- smart-search s "query" --format json
332
- smart-search s "nba战报" --format content
333
- smart-search rs "query" --format json
334
- smart-search f "https://example.com" --format markdown
335
- smart-search exa "OpenAI Responses API documentation" --format json
336
- smart-search z "today China AI news" --format json
337
- smart-search c7 "react" "hooks" --format json
338
- smart-search c7docs "/facebook/react" "useEffect cleanup" --format json
339
- smart-search cfg ls --format json
340
- smart-search d --format markdown
341
- ```
342
-
343
- ## Timeout Retry Policy
344
-
345
- When `smart-search search` returns `ok: false` with `error_type: "network_error"` and an error message containing `timed out`, treat it as a retryable CLI-level timeout, not as a terminal research failure.
346
-
347
- 1. Retry up to 3 total attempts with `--timeout 180`, waiting about 5 seconds between attempts.
348
- 2. Use `--format json` and `--output PATH` for each attempt; after each attempt, inspect the saved JSON and stop on the first `"ok": true`.
349
- 3. Use `--extra-sources 1` during retry attempts to keep Tavily/Firecrawl overhead small.
350
- 4. Always use the CLI's `--timeout` option. Do not wrap `smart-search` in a shell-level `timeout` command because shell termination can prevent the CLI from writing structured failure JSON.
351
- 5. Do not rely on `SMART_SEARCH_RETRY_*` settings for this path; search command timeouts are surfaced by the CLI result contract and should be handled by the agent workflow.
352
- 6. If all attempts time out, fall back to source-first evidence:
353
- - Run `exa-search` with the original query for broad source discovery.
354
- - Run `exa-search --include-domains` when likely official domains are known.
355
- - `fetch` the top 1-2 relevant URLs before making claim-level statements.
356
- - Mark the final answer as `source_mode: "fallback"` or clearly state that the answer was assembled from fetched sources rather than generated by `search`.
357
-
358
- Example retry flow:
359
-
360
- ```powershell
361
- smart-search search "query" --validation balanced --extra-sources 1 --timeout 180 --format json --output result-attempt-1.json
362
- smart-search search "query" --validation balanced --extra-sources 1 --timeout 180 --format json --output result-attempt-2.json
363
- smart-search search "query" --validation balanced --extra-sources 1 --timeout 180 --format json --output result-attempt-3.json
364
- smart-search exa-search "query" --num-results 5 --include-text --format json --output exa.json
365
- smart-search exa-search "query" --include-domains platform.openai.com developers.openai.com --num-results 3 --include-text --format json --output exa-official.json
366
- smart-search fetch "https://example.com/source" --format markdown --output fetch.md
367
- ```
368
-
369
- ## Guardrails
370
-
371
- - Prefer JSON for agent parsing and markdown for fetched page text intended for reading.
372
- - Use `--output` for multi-source work, long pages, or anything the answer may need to cite later.
373
- - Keep `--extra-sources` small (`1` to `3`) unless the user asks for broad coverage. Large values are slower and can add noise.
374
- - Do not cite `extra_sources` as proof for a sentence in `content`; fetch the URL first or cite it only as a candidate source.
375
- - Prefer `exa-search --include-domains` for official documentation when likely domains are known.
376
- - Do not expose API keys. Treat `doctor` output as safe only because it is expected to mask secrets.
377
- - In this CLI-first workflow, native `web_search` is disabled unless the user explicitly configures another approved route.
378
- - If `doctor` or a command fails, report the failure and recovery steps; do not silently fall back to another web-search route.
379
- - If the user explicitly asks to bypass smart-search, state that another approved web-search route must be configured first.
380
- - Do not use legacy MCP tool names in prompts, notes, or generated instructions for this workflow.
381
- - Treat key rotation as a hard safety gate when previous key values were pasted into chat or logs.
382
- - For provider architecture maintenance, verify the distributable contract rather than the current developer machine's wrappers or local config. Keep fallback same-capability only.
383
- - `main_search` is OpenAI-compatible Chat Completions configured through `OPENAI_COMPATIBLE_*`. Do not fabricate a second `main_search` provider or reuse another capability's URL/key as a `main_search` fallback.
384
-
385
- ## Supporting Reference
386
-
387
- Read `references/cli-contract.md` when you need command details, output fields, exit codes, or contract expectations.
@@ -1,3 +0,0 @@
1
- display_name: Smart Search CLI
2
- short_description: Source-backed web research via CLI
3
- default_prompt: Use $smart-search-cli to research this current web question.
@@ -1,98 +0,0 @@
1
- # Batch Search Workflow
2
-
3
- Use this workflow when the user gives multiple queries, tools, companies, documents, URLs, or comparison targets. The model should run repeated narrow CLI commands, save each output, and summarize only after reading the saved files.
4
-
5
- ## Goal
6
-
7
- Keep batch work reproducible:
8
-
9
- - one evidence directory
10
- - one numbered output per query or URL
11
- - narrow commands selected by intent
12
- - fetched evidence before claim-level conclusions
13
-
14
- ## Batch Query Discovery
15
-
16
- Use a PowerShell loop when several independent queries need the same source-discovery treatment.
17
-
18
- ```powershell
19
- $Config = smart-search config path --format json | ConvertFrom-Json
20
- $EvidenceDir = Join-Path $Config.resolved_evidence_dir "YYYYMMDD-HHMM-batch"
21
- New-Item -ItemType Directory -Force -Path $EvidenceDir | Out-Null
22
-
23
- $Queries = @(
24
- @{ Name = "openai"; Query = "OpenAI Responses API web_search documentation" },
25
- @{ Name = "anthropic"; Query = "Anthropic tool use web search documentation" },
26
- @{ Name = "google"; Query = "Google Gemini grounding search documentation" }
27
- )
28
-
29
- $Index = 1
30
- foreach ($Item in $Queries) {
31
- $OutputPath = Join-Path $EvidenceDir ("{0:D2}-exa-{1}.json" -f $Index, $Item["Name"])
32
- smart-search exa-search ($Item["Query"]) --num-results 5 --include-text --include-highlights --format json --output $OutputPath
33
- $Index += 1
34
- }
35
- ```
36
-
37
- After the loop:
38
-
39
- 1. Read each saved JSON.
40
- 2. Select the top URL or official result for each item.
41
- 3. Fetch pages that will support final claims.
42
- 4. Compare only what fetched text supports.
43
-
44
- ## Batch Fetch Known URLs
45
-
46
- Use this when the user already provided URLs or when discovery produced a short URL list.
47
-
48
- ```powershell
49
- $Config = smart-search config path --format json | ConvertFrom-Json
50
- $EvidenceDir = Join-Path $Config.resolved_evidence_dir "YYYYMMDD-HHMM-url-batch"
51
- New-Item -ItemType Directory -Force -Path $EvidenceDir | Out-Null
52
-
53
- $Urls = @(
54
- "https://example.com/source-a",
55
- "https://example.com/source-b",
56
- "https://example.com/source-c"
57
- )
58
-
59
- $Index = 1
60
- foreach ($Url in $Urls) {
61
- $OutputPath = Join-Path $EvidenceDir ("{0:D2}-fetch.md" -f $Index)
62
- smart-search fetch $Url --format markdown --output $OutputPath
63
- $Index += 1
64
- }
65
- ```
66
-
67
- ## Mixed Intent Batches
68
-
69
- Pick the command per item instead of forcing every item through one provider:
70
-
71
- - Broad/current/domestic item: run the bilingual `smart-search search` pair and save separate `*-zh.json` / `*-en.json` outputs.
72
- - Docs/API/library item: `smart-search context7-library "library" "topic" --format json --output PATH`, then `context7-docs` for the selected library id.
73
- - Official/trusted-domain item: `smart-search exa-search "query" --num-results 5 --include-text --include-highlights --format json --output PATH`
74
- - Broad first pass: `smart-search search "中文搜索,优先检索中文来源,并回答原问题:query" --validation balanced --extra-sources 1 --format json --output PATH`, then `smart-search search "Search English-language sources and answer the original question: query" --validation balanced --extra-sources 1 --format json --output PATH`
75
- - Known URL: `smart-search fetch "https://example.com/source" --format markdown --output PATH`
76
-
77
- ## Summarize The Batch
78
-
79
- Before answering:
80
-
81
- 1. Confirm every claim maps to a fetched file or fetched URL.
82
- 2. Separate fetched evidence from unfetched candidates.
83
- 3. Keep per-item gaps visible instead of smoothing them over.
84
- 4. Include the evidence directory and important command lines when useful.
85
-
86
- Use a compact summary table:
87
-
88
- | Item | Evidence file | Supported conclusion | Gaps |
89
- | --- | --- | --- | --- |
90
- | item-a | `03-fetch-a.md` | supported claim | none |
91
- | item-b | `04-fetch-b.md` | partial claim | missing official source |
92
-
93
- ## Guardrails
94
-
95
- - Keep `--extra-sources` small, usually `1` to `3`.
96
- - Do not use broad `search.content` as proof for a comparison row.
97
- - Do not cite `extra_sources` as verified evidence until fetched.
98
- - Do not silently switch to native web search if a command fails; report the failure and recovery path.
@@ -1,89 +0,0 @@
1
- # Evidence Gathering Workflow
2
-
3
- Use this workflow when the user wants a source-backed answer, citation trail, or audit-friendly notes, but does not need full `smart-search research`.
4
-
5
- ## Goal
6
-
7
- Answer from fetched evidence, not from broad generated `search.content` alone.
8
-
9
- ## When To Use
10
-
11
- - The user asks for sources, citations, verification, or a defensible short answer.
12
- - The task can be answered with a small number of discovery and fetch commands.
13
- - Full Deep Research would be more work than the user asked for.
14
-
15
- Use `smart-search research` instead when the user asks for deep research, cross-checking, serious comparison, or a multi-stage investigation.
16
-
17
- ## Evidence Directory
18
-
19
- Create one directory per user question. Keep command outputs numbered so the trail is easy to inspect.
20
-
21
- ```powershell
22
- $Config = smart-search config path --format json | ConvertFrom-Json
23
- $EvidenceDir = Join-Path $Config.resolved_evidence_dir "YYYYMMDD-HHMM-topic"
24
- New-Item -ItemType Directory -Force -Path $EvidenceDir | Out-Null
25
- ```
26
-
27
- ## Step 1: Discover Candidate Sources
28
-
29
- Run the bilingual broad-search pair first, then add intent-specific discovery only when needed.
30
-
31
- Chinese-source broad pass:
32
-
33
- ```powershell
34
- smart-search search "中文搜索,优先检索中文来源,并回答原问题:query" --validation balanced --extra-sources 1 --format json --output "$EvidenceDir\01-search-zh.json"
35
- ```
36
-
37
- English-source broad pass:
38
-
39
- ```powershell
40
- smart-search search "Search English-language sources and answer the original question: query" --validation balanced --extra-sources 1 --format json --output "$EvidenceDir\02-search-en.json"
41
- ```
42
-
43
- Official domains, papers, product pages, or trusted sites:
44
-
45
- ```powershell
46
- smart-search exa-search "query" --num-results 5 --include-text --include-highlights --format json --output "$EvidenceDir\01-exa.json"
47
- ```
48
-
49
- Docs/API/library/framework intent:
50
-
51
- ```powershell
52
- smart-search context7-library "react" "useEffect cleanup" --format json --output "$EvidenceDir\01-context7-library.json"
53
- smart-search context7-docs "/facebook/react" "useEffect cleanup" --format json --output "$EvidenceDir\02-context7-docs.json"
54
- ```
55
-
56
- ## Step 2: Fetch The Pages That Matter
57
-
58
- Pick the one or two URLs that directly support the answer. Fetch exact pages before making claim-level statements.
59
-
60
- ```powershell
61
- smart-search fetch "https://example.com/source" --format markdown --output "$EvidenceDir\03-fetch-source.md"
62
- smart-search fetch "https://example.com/second-source" --format markdown --output "$EvidenceDir\04-fetch-second-source.md"
63
- ```
64
-
65
- ## Step 3: Write The Answer
66
-
67
- Use this evidence policy:
68
-
69
- - Cite fetched page text or fetched URLs for claims.
70
- - Treat `primary_sources` and `extra_sources` as discovery candidates until fetched.
71
- - If a useful candidate was not fetched, label it as an unfetched candidate.
72
- - Include the key command lines or the evidence directory path when the user may need to audit the work.
73
-
74
- ## Minimal Final-Answer Shape
75
-
76
- ```text
77
- Evidence used:
78
- - 03-fetch-source.md: <what it supports>
79
- - 04-fetch-second-source.md: <what it supports>
80
-
81
- Answer:
82
- <short answer grounded in fetched text>
83
-
84
- Unverified candidates:
85
- - <candidate URL or source from search/exa output, if relevant>
86
-
87
- Commands:
88
- - smart-search ...
89
- ```