v0.12: stabilize search routing and profile-driven phase4 pipeline
This commit is contained in:
@@ -17,6 +17,8 @@ permission:
|
||||
"*": deny
|
||||
"wc *": allow
|
||||
"python3 *": allow
|
||||
"uv run python scripts/search.py *": allow
|
||||
"uv run python scripts/ground.py *": allow
|
||||
"mkdir *": allow
|
||||
"grep *": allow
|
||||
"cat *": allow
|
||||
@@ -66,6 +68,15 @@ Read `projects/<slug>/phase1/framework.md` to understand the chapter's positioni
|
||||
- Round 3: Counter-evidence (search for limitations, failures, controversies)
|
||||
- Round 4: Tavily/Exa/Brave for gap-filling, trace back to Tier 1-2 originals
|
||||
|
||||
Mandatory project search gateway:
|
||||
- Literature / reviews: `uv run python scripts/search.py "<query>" --route scholar --num-results 10 --year-low 2023`
|
||||
- Patents / FTO: `uv run python scripts/search.py "<query>" --route patents --num-results 10`
|
||||
- News / transactions: `uv run python scripts/search.py "<query>" --route news --num-results 10 --time-range m`
|
||||
- Generic gap-fill: `uv run python scripts/search.py "<query>" --route general --num-results 10`
|
||||
- Fast grounded fact-check (native model web search): `uv run python scripts/ground.py "<query>" --json`
|
||||
|
||||
Record the routes used in the evidence file. Do not use Tavily / Exa / Brave MCP as the primary path for literature or patent searches.
|
||||
|
||||
Search in **both English and Chinese** for each direction (Chinese sources critical for China market / NMPA / CSRC disclosures).
|
||||
|
||||
### Step 3: Source Scoring
|
||||
|
||||
@@ -7,10 +7,14 @@ temperature: 0.1
|
||||
tools:
|
||||
read: true
|
||||
webfetch: true
|
||||
bash: true
|
||||
skill: true
|
||||
permission:
|
||||
bash:
|
||||
"*": deny
|
||||
"uv run python scripts/search.py *": allow
|
||||
"uv run python scripts/ground.py *": allow
|
||||
"python3 scripts/search.py *": allow
|
||||
edit: deny
|
||||
webfetch: allow
|
||||
task:
|
||||
@@ -25,10 +29,13 @@ permission:
|
||||
|
||||
1. 加载 `skill:search-strategy` 了解信源优先级与检索规则
|
||||
2. 加载 `skill:source-quality` 了解评分标准与黑名单
|
||||
3. 按调用方给定的关键词方向,执行 **3 轮检索**:
|
||||
- 第 1 轮:英文关键词,优先 Tavily advanced 模式,锁定 Tier 1 域名
|
||||
- 第 2 轮:中文关键词,查中文专业来源
|
||||
- 第 3 轮:反方/限制性关键词(如 `limitations`, `adverse`, `failed`)
|
||||
3. 按调用方给定的关键词方向,执行 **3 轮检索**,必须优先使用项目搜索网关:
|
||||
- 文献:`uv run python scripts/search.py "<query>" --route scholar --num-results 10 --year-low 2023`
|
||||
- 专利:`uv run python scripts/search.py "<query>" --route patents --num-results 10`
|
||||
- 新闻/行业动态:`uv run python scripts/search.py "<query>" --route news --num-results 10 --time-range m`
|
||||
- 通用补漏:`uv run python scripts/search.py "<query>" --route general --num-results 10`
|
||||
- 快速 grounding:`uv run python scripts/ground.py "<query>" --json`
|
||||
- Tavily / Brave / Exa MCP 只能作为 gap-fill 或脚本不可用时的兜底
|
||||
4. 对每条候选信源按 source-quality 评分,过滤掉评分 < 5 及黑名单
|
||||
5. 整理输出,直接返回给调用方(不写文件)
|
||||
|
||||
@@ -43,6 +50,7 @@ permission:
|
||||
- 英文:...
|
||||
- 中文:...
|
||||
- 反方:...
|
||||
- Routes used: scholar / patents / news / general
|
||||
|
||||
### 信源列表(共 N 条,Tier 1-2)
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
description: Cross-model verification agent (English). Uses non-Claude model (GPT-5.4) to do counter-evidence searching and fact-check on completed chapters, avoiding same-source bias. Scheduled by dr-pm after dr-analyst finishes each chapter.
|
||||
mode: subagent
|
||||
hidden: true
|
||||
model: zenmux/openai/gpt-5.4
|
||||
model: zenmux/openai/gpt-5.4-mini
|
||||
temperature: 0.2
|
||||
tools:
|
||||
read: true
|
||||
@@ -10,12 +10,16 @@ tools:
|
||||
edit: false
|
||||
apply_patch: false
|
||||
webfetch: true
|
||||
bash: true
|
||||
skill: true
|
||||
permission:
|
||||
edit: allow
|
||||
webfetch: allow
|
||||
bash:
|
||||
"*": deny
|
||||
"uv run python scripts/search.py *": allow
|
||||
"uv run python scripts/ground.py *": allow
|
||||
"python3 scripts/search.py *": allow
|
||||
task:
|
||||
"*": deny
|
||||
---
|
||||
@@ -74,6 +78,12 @@ For each core claim, search:
|
||||
|
||||
Run 3-5 webfetch queries per claim, prioritizing Tier 1-2 sources.
|
||||
|
||||
Use the project search gateway before generic webfetch:
|
||||
- `uv run python scripts/search.py "<claim keyword> limitations failed controversy" --route scholar --num-results 10 --year-low 2023`
|
||||
- For patent/IP claims: `uv run python scripts/search.py "<claim keyword>" --route patents --num-results 10`
|
||||
- For news or transaction claims: `uv run python scripts/search.py "<claim keyword>" --route news --num-results 10 --time-range y`
|
||||
- For rapid independent spot checks: `uv run python scripts/ground.py "<claim keyword>" --json`
|
||||
|
||||
### Step 3: Data Sanity Check
|
||||
|
||||
Verify all numbers in the chapter:
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
---
|
||||
description: 将模型预设应用到 agent 文件。用法:/dr-apply-models <profile>
|
||||
agent: dr-pm
|
||||
---
|
||||
|
||||
你是 dr-pm。把模型预设应用到 agent 配置文件。
|
||||
|
||||
## 执行步骤
|
||||
|
||||
1. 如果 `$ARGUMENTS` 为空,先列出可用 profile:
|
||||
|
||||
```bash
|
||||
uv run python scripts/dr.py models --list
|
||||
```
|
||||
|
||||
并提示用户至少选择 `simple / medium / premium` 之一。
|
||||
|
||||
2. 如果 `$ARGUMENTS` 非空,执行 dry-run:
|
||||
|
||||
```bash
|
||||
uv run python scripts/dr.py apply-models --profile "$ARGUMENTS" --target both --dry-run
|
||||
```
|
||||
|
||||
3. 将 dry-run 结果展示给用户确认影响范围后,再执行实际应用:
|
||||
|
||||
```bash
|
||||
uv run python scripts/dr.py apply-models --profile "$ARGUMENTS" --target both
|
||||
```
|
||||
|
||||
4. 最后输出:
|
||||
- 采用的 profile
|
||||
- 更新的文件数与路径
|
||||
- 下一步建议(如需同步到本机 `.codex/**`,运行 `uv run python scripts/install_codex_adapter.py --force`)
|
||||
@@ -1,11 +1,11 @@
|
||||
---
|
||||
description: Phase 4 - 成稿(v0.6)。dr-editor-in-chief 写 ES/Abstract/Glossary,然后调 Python 脚本链路:translate → build_glossary → apply_glossary → polish → build_report。用法:/dr-finalize [slug]
|
||||
description: Phase 4 - 成稿(v0.12)。dr-editor-in-chief 写 ES/Abstract/Glossary,然后调统一 Python pipeline(phase4_pipeline.py)。用法:/dr-finalize [slug]
|
||||
agent: dr-editor-in-chief
|
||||
---
|
||||
|
||||
你是 dr-editor-in-chief。用户执行了 `/dr-finalize $ARGUMENTS`,进入 Phase 4 成稿链路(v0.6 架构)。
|
||||
你是 dr-editor-in-chief。用户执行了 `/dr-finalize $ARGUMENTS`,进入 Phase 4 成稿链路(v0.12 架构)。
|
||||
|
||||
## 架构变更说明(v0.6)
|
||||
## 架构变更说明(v0.12)
|
||||
|
||||
**Phase 4 的翻译/润色/出稿已从 LLM agent 改为 Python 脚本**。原因:
|
||||
- LLM agent 一次性处理整篇报告(19k+ 词)会超 Sonnet output token 上限(~32k),不稳定
|
||||
@@ -40,57 +40,40 @@ agent: dr-editor-in-chief
|
||||
- 给每章强加 SCQA 或小节标题
|
||||
- 保留调度元数据(字数配额/研究员/quota 等)
|
||||
|
||||
## Step 3: 翻译(Python 脚本)
|
||||
## Step 3: 执行统一 Phase 4 pipeline(Python 脚本)
|
||||
|
||||
```bash
|
||||
uv run python scripts/translate.py <slug>
|
||||
uv run python scripts/phase4_pipeline.py <slug>
|
||||
```
|
||||
|
||||
完成条件:`phase4/final_zh.md` 生成且字数 ≥ 目标字数的 90%。如未达标,`--force` 强制重跑。
|
||||
默认行为:
|
||||
- 自动估算 translate / polish 并发
|
||||
- glossary 仅核查低置信度术语(`--glossary-mode low-confidence`)
|
||||
- 统一串联 translate → glossary(optional) → apply_glossary → polish → build_report
|
||||
|
||||
## Step 4: 术语表核查(强烈推荐)
|
||||
可选参数示例:
|
||||
|
||||
```bash
|
||||
uv run python scripts/build_glossary.py <slug> --workers 4
|
||||
uv run python scripts/phase4_pipeline.py <slug> --glossary-mode full
|
||||
uv run python scripts/phase4_pipeline.py <slug> --glossary-mode off
|
||||
```
|
||||
|
||||
完成后查看 `phase4/glossary.json`:
|
||||
- `confidence == "high"` 且 `issue` 非空的条目:说明发现了错误,需要回塑到正文
|
||||
- 关注公司名 / 机构名 / 产品名类,它们最容易有拼写错误
|
||||
完成条件:`phase4/final_zh_polished.md`、PDF、DOCX 全部生成,且无致命报错。
|
||||
|
||||
## Step 5: 应用术语修正(Python 脚本)
|
||||
## Step 4: (可选)分步重跑
|
||||
|
||||
```bash
|
||||
# 先预览
|
||||
uv run python scripts/apply_glossary.py <slug> --input phase4/final_zh.md --dry-run
|
||||
|
||||
# 确认无误后应用
|
||||
uv run python scripts/apply_glossary.py <slug> --input phase4/final_zh.md
|
||||
```
|
||||
|
||||
这会把 glossary 中发现的拼写错误 / 错译直接替换进 `final_zh.md`。
|
||||
如润色后仍需二次复核,可手动对 `final_zh_polished.md` 再运行一次:
|
||||
`uv run python scripts/apply_glossary.py <slug> --input phase4/final_zh_polished.md --dry-run`。
|
||||
|
||||
## Step 6: 润色(Python 脚本)
|
||||
|
||||
```bash
|
||||
uv run python scripts/polish.py <slug>
|
||||
```
|
||||
|
||||
输出:`phase4/final_zh_polished.md`。查看 `phase4/polish_notes.jsonl` 了解模型标记的异常点。
|
||||
|
||||
## Step 7: 出稿(Python 脚本)
|
||||
|
||||
```bash
|
||||
uv run python scripts/build_report.py <slug>
|
||||
```
|
||||
当你只想重跑单环节时,仍可手动调用:
|
||||
- `translate.py`
|
||||
- `build_glossary.py`
|
||||
- `apply_glossary.py`
|
||||
- `polish.py`
|
||||
- `build_report.py`
|
||||
|
||||
自动:
|
||||
- 按 `manifest.report_title` 命名输出(`<Title>.pdf` + `<Title>.docx`)
|
||||
- PDF 自动插 TOC + 从 `phase2/sources.jsonl` 生成参考文献
|
||||
|
||||
## Step 8: 更新 manifest
|
||||
## Step 5: 更新 manifest
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -115,7 +98,7 @@ uv run python scripts/build_report.py <slug>
|
||||
}
|
||||
```
|
||||
|
||||
## Step 9: 汇报
|
||||
## Step 6: 汇报
|
||||
|
||||
向用户展示:
|
||||
- 各阶段耗时和成本
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
---
|
||||
description: 查看或解析模型预设。用法:/dr-models [profile]
|
||||
agent: dr-pm
|
||||
---
|
||||
|
||||
你是 dr-pm。目标是把当前模型预设解析成清晰结果,并给出可执行命令。
|
||||
|
||||
## 执行步骤
|
||||
|
||||
1. 如果 `$ARGUMENTS` 为空:运行
|
||||
|
||||
```bash
|
||||
uv run python scripts/dr.py models
|
||||
```
|
||||
|
||||
2. 如果 `$ARGUMENTS` 非空:把它当作 profile,运行
|
||||
|
||||
```bash
|
||||
uv run python scripts/dr.py models --profile "$ARGUMENTS"
|
||||
```
|
||||
|
||||
3. 输出结果时必须包含:
|
||||
- 当前 profile 名称
|
||||
- 各角色模型映射(至少 dr_plan / dr_pm / dr_analyst / dr_verifier / translate / polish / glossary)
|
||||
- 一条可复制命令,用于 Phase 4 指定该 profile:
|
||||
|
||||
```bash
|
||||
uv run python scripts/dr.py finalize <slug> --model-profile <profile>
|
||||
```
|
||||
|
||||
4. 如果 profile 不存在,提示可用 profile 并建议 `simple / medium / premium` 三档。
|
||||
@@ -113,7 +113,7 @@
|
||||
"environment": {
|
||||
"TAVILY_API_KEY": "{env:TAVILY_API_KEY}"
|
||||
},
|
||||
"enabled": true
|
||||
"enabled": false
|
||||
},
|
||||
"brave-search": {
|
||||
"type": "local",
|
||||
@@ -121,7 +121,7 @@
|
||||
"environment": {
|
||||
"BRAVE_API_KEY": "{env:BRAVE_API_KEY}"
|
||||
},
|
||||
"enabled": true
|
||||
"enabled": false
|
||||
},
|
||||
"exa": {
|
||||
"type": "local",
|
||||
@@ -129,7 +129,7 @@
|
||||
"environment": {
|
||||
"EXA_API_KEY": "{env:EXA_API_KEY}"
|
||||
},
|
||||
"enabled": true
|
||||
"enabled": false
|
||||
}
|
||||
},
|
||||
"permission": {
|
||||
|
||||
@@ -82,7 +82,46 @@ description: 生物医药深度研究的统一检索策略。规定信源优先
|
||||
|
||||
---
|
||||
|
||||
## 三、API 调用顺序(技术栈,v0.8 更新)
|
||||
## 三、强制工具入口(v0.12)
|
||||
|
||||
所有 agent 做联网检索时,**优先调用项目内 Python 网关**,不要直接把 Tavily / Brave / Exa MCP 当成主路径:
|
||||
|
||||
```bash
|
||||
uv run python scripts/search.py "<query>" --route scholar --num-results 10 --year-low 2023
|
||||
uv run python scripts/search.py "<query>" --route patents --num-results 10
|
||||
uv run python scripts/search.py "<query>" --route news --num-results 10 --time-range m
|
||||
uv run python scripts/search.py "<query>" --route general --num-results 10
|
||||
uv run python scripts/search.py "<query>" --profile china_market --num-results 10 --trace
|
||||
uv run python scripts/ground.py "<query>" --model google/gemini-3.1-flash-lite-preview --json
|
||||
```
|
||||
|
||||
也可以按研究场景跑 profile:
|
||||
|
||||
```bash
|
||||
uv run python scripts/search.py "<query>" --profile biomed_literature --num-results 10 --year-low 2023
|
||||
uv run python scripts/search.py "<query>" --profile patent_heavy --num-results 10
|
||||
```
|
||||
|
||||
**原因**:
|
||||
- Python 网关在 repo 内,可被 OpenCode / Codex / Gemini CLI / Claude Code 共同复用。
|
||||
- `--route patents` 固定优先 Serper + Google Patents,避免专利检索被 Tavily 普通网页结果替代。
|
||||
- `--route scholar` 固定优先 Serper Scholar,避免论文检索只停留在通用网页摘要。
|
||||
- 专用 route(scholar/patents/news)默认 `--strict-specialized`,Serper 异常时应显式失败,不允许静默降级。
|
||||
- Tavily / Exa / Brave 只作为 gap-fill 或 MCP 兜底,不作为文献/专利主路径。
|
||||
|
||||
每个检索小结必须写明实际使用过的 route,例如:
|
||||
|
||||
```text
|
||||
Routes used: scholar, patents, general
|
||||
```
|
||||
|
||||
如果由于缺 key 或 API 错误无法调用 Serper,必须在输出中明确写(且建议重新执行,不直接进入正文证据):
|
||||
|
||||
```text
|
||||
Serper unavailable: <原因>; fallback used: general site:patents.google.com
|
||||
```
|
||||
|
||||
## 四、API 调用顺序(技术栈,v0.11 更新)
|
||||
|
||||
**按"查询类型"路由到最合适的 API**,而不是一律走通用搜索。
|
||||
|
||||
@@ -114,24 +153,23 @@ description: 生物医药深度研究的统一检索策略。规定信源优先
|
||||
### Serper(google.serper.dev)使用模板
|
||||
|
||||
**专利检索**:
|
||||
```python
|
||||
from scripts.lib.search_client import SearchClient
|
||||
with SearchClient() as c:
|
||||
hits = c.patents("dual-target siRNA GalNAc", num_results=10)
|
||||
```bash
|
||||
uv run python scripts/search.py "dual-target siRNA GalNAc" --route patents --num-results 10
|
||||
```
|
||||
|
||||
**学术论文**:
|
||||
```python
|
||||
hits = c.scholar("dual-target RNAi 2024", num_results=10, year_low=2023)
|
||||
# hits[i].snippet 里包含引用数和期刊信息
|
||||
```bash
|
||||
uv run python scripts/search.py "dual-target RNAi 2024" --route scholar --num-results 10 --year-low 2023
|
||||
```
|
||||
|
||||
**新闻(时效性)**:
|
||||
```python
|
||||
hits = c.news("Arrowhead ARO-DIMER-PA clinical trial", time_range="w") # 最近一周
|
||||
```bash
|
||||
uv run python scripts/search.py "Arrowhead ARO-DIMER-PA clinical trial" --route news --num-results 10 --time-range w
|
||||
```
|
||||
|
||||
### Tavily MCP 调用模板(通用网页 - Phase 1 初扫)
|
||||
### Tavily MCP 调用模板(兜底,不作为主路径)
|
||||
|
||||
仅当 `scripts/search.py` 不可用,或需要 MCP 特有能力时使用。通用网页结果必须回溯到 Tier 1-2 原始来源。
|
||||
```
|
||||
工具名:tavily_search
|
||||
参数:
|
||||
@@ -171,7 +209,7 @@ curl -s "https://api.fda.gov/drug/event.json?search=patient.drug.medicinalproduc
|
||||
|
||||
---
|
||||
|
||||
## 四、关键词策略
|
||||
## 五、关键词策略
|
||||
|
||||
### 中英双语必备
|
||||
- 任何生物医药主题**必须同时用中英文检索**
|
||||
@@ -195,7 +233,7 @@ curl -s "https://api.fda.gov/drug/event.json?search=patient.drug.medicinalproduc
|
||||
|
||||
---
|
||||
|
||||
## 五、每条信源的提取字段(标准化)
|
||||
## 六、每条信源的提取字段(标准化)
|
||||
|
||||
任何信源进 `sources.jsonl` 必须有以下字段:
|
||||
|
||||
@@ -225,7 +263,7 @@ curl -s "https://api.fda.gov/drug/event.json?search=patient.drug.medicinalproduc
|
||||
|
||||
---
|
||||
|
||||
## 六、失败兜底
|
||||
## 七、失败兜底
|
||||
|
||||
- 某个 API 限流/超时:**等 5s 重试 3 次**,仍失败则跳过并在日志标注
|
||||
- 某个信源 404:在 sources.jsonl 标 `"dead_link": true`,不删除(审计用)
|
||||
@@ -233,7 +271,7 @@ curl -s "https://api.fda.gov/drug/event.json?search=patient.drug.medicinalproduc
|
||||
|
||||
---
|
||||
|
||||
## 七、硬规则总结
|
||||
## 八、硬规则总结
|
||||
|
||||
1. ✅ 每 section 至少 4 轮检索
|
||||
2. ✅ 中英双语必查
|
||||
@@ -241,6 +279,8 @@ curl -s "https://api.fda.gov/drug/event.json?search=patient.drug.medicinalproduc
|
||||
4. ✅ 反方关键词必查
|
||||
5. ✅ Tier 4 结果只做发现,不做佐证
|
||||
6. ✅ 所有信源写入 sources.jsonl 并评分
|
||||
7. ❌ 不得引用 Wikipedia 做结论
|
||||
8. ❌ 不得编造数据、URL、DOI
|
||||
9. ❌ 不得使用黑名单信源
|
||||
7. ✅ 文献检索必须优先 `scripts/search.py --route scholar`
|
||||
8. ✅ 专利检索必须优先 `scripts/search.py --route patents`
|
||||
9. ❌ 不得引用 Wikipedia 做结论
|
||||
10. ❌ 不得编造数据、URL、DOI
|
||||
11. ❌ 不得使用黑名单信源
|
||||
|
||||
Reference in New Issue
Block a user