SuperAPI AI Directory

pipeline-persistence

Writing & research

View repository

Updated 10-16 09:13

About this skill

Pipeline persistence — structured search plan management

Description

Save complex search workflows as reusable Pipeline YAML configurations. Supports:

  • Quick creation from templates (PICO, comprehensive, exploration, gene_drug)
  • Custom DAG (directed acyclic graph) multi-step pipelines
  • Two-tier storage (workspace + global)
  • Automatic validation + aggressive auto-correction (21 rules)

Trigger Conditions

  • "Save this search", "Create a search plan"
  • "Run this search once a week", "Save this pipeline"
  • "List my pipelines", "Can the last search be run again"
  • "Convert the search just now into a search plan"

🌟 Quick Start

Method 1: Use a template (simplest)

# 保存一個 PICO 模板 pipeline
save_pipeline(
    name="icu_remimazolam_vs_propofol",
    config="""
template: pico
params:
  P: ICU patients requiring sedation
  I: remimazolam
  C: propofol
  O: delirium incidence, sedation quality
""",
    tags="anesthesia,sedation,ICU",
    description="Weekly monitoring: remimazolam vs propofol ICU sedation"
)

# 執行已保存的 pipeline
unified_search(pipeline="saved:icu_remimazolam_vs_propofol")

Method 2: Custom DAG (full control)

save_pipeline(
    name="brca1_comprehensive",
    config="""
steps:
  - id: expand
    action: expand
    params:
      topic: BRCA1 breast cancer
  - id: pubmed
    action: search
    params:
      query: BRCA1 breast cancer
      sources: pubmed
      limit: 50
  - id: expanded
    action: search
    inputs: [expand]
    params:
      strategy: mesh
      sources: pubmed,openalex
      limit: 50
  - id: merged
    action: merge
    inputs: [pubmed, expanded]
    params:
      method: rrf
  - id: enriched
    action: metrics
    inputs: [merged]
output:
  format: markdown
  limit: 30
  ranking: quality
""",
    tags="genetics,oncology",
    description="BRCA1 breast cancer comprehensive search with MeSH expansion"
)

6 MCP tools

save_pipeline — save a pipeline

save_pipeline(
    name="weekly_remimazolam",     # 唯一名稱 (英數 + _ -, max 64)
    config="<YAML or JSON>",       # Pipeline 配置
    tags="tag1,tag2",              # 逗號分隔標籤
    description="...",             # 人類可讀描述
    scope="auto"                   # "workspace" | "global" | "auto"
)

Auto-correction examples:

  • action: "find" → auto-corrected to action: "search"(alias resolution)
  • action: "serach" → auto-corrected to action: "search"(fuzzy matching)
  • Missing step ID → auto-generate step_1, step_2...
  • Duplicate step ID → auto-rename s1 → s1_2
  • Circular dependency → auto-remove problematic references

list_pipelines — list pipelines

list_pipelines()                    # 列出所有
list_pipelines(tag="ICU")           # 按標籤過濾
list_pipelines(scope="workspace")   # 只看工作區

load_pipeline — load a pipeline

load_pipeline(source="weekly_remimazolam")            # 從已保存
load_pipeline(source="file:path/to/pipeline.yaml")    # 從檔案

delete_pipeline — delete a pipeline

delete_pipeline(name="old_search")  # 刪除配置 + 歷史

get_pipeline_history — view execution history

get_pipeline_history(name="weekly_remimazolam", limit=5)
# 顯示:日期、文章數、新增/移除文章、狀態

schedule_pipeline — schedule (Phase 4 not yet implemented)

schedule_pipeline(name="weekly_remimazolam", cron="0 9 * * 1")
# ⚠️ 目前返回使用說明,建議手動執行或使用 OS 排程

4 built-in templates

pico — PICO clinical question

template: pico
params:
  P: ICU patients requiring sedation
  I: remimazolam
  C: propofol
  O: delirium incidence
  sources: pubmed        # 可選,預設 pubmed
  limit: 20              # 可選

Auto-generated DAG:

pico → search_p  ──┐
     → search_i  ──┤
     → search_c  ──┼→ merged → enriched

comprehensive — multiple databases + MeSH expansion

template: comprehensive
params:
  query: CRISPR gene therapy safety
  sources: pubmed,openalex,europe_pmc  # 可選
  limit: 30                             # 可選
  min_year: 2020                        # 可選

Auto-generated DAG:

expand → search_expanded  ──┐
         search_original  ──┼→ merged → enriched

exploration — seed paper exploration

template: exploration
params:
  pmid: "33475315"
  limit: 20        # 每個方向的限制

Auto-generated DAG:

related  ──┐
citing   ──┼→ merged → enriched
refs     ──┘

gene_drug — gene/drug search

template: gene_drug
params:
  term: BRCA1
  sources: pubmed,openalex  # 可選
  limit: 20                  # 可選
  min_year: 2020             # 可選

10 available Actions

Action Description Main parameters
search Literature search query, sources, limit, min_year, max_year
pico Agent-provided PICO handoff search P, I, optional C, recommended O
expand MeSH/synonym expansion topic
details Get article details pmids
related Related articles pmid, limit
citing Citing articles pmid, limit
references References pmid, limit
metrics iCite citation metrics (obtained from inputs)
merge Merge results method: union / intersection / rrf
filter Filter results min_year, max_year, article_types, min_citations, has_abstract

Two-tier storage model

Workspace scope (.pubmed-search/pipelines/)
├── 每個專案獨立
├── 可納入 git 追蹤
└── 團隊共享

Global scope (~/.pubmed-search-mcp/pipelines/)
├── 跨專案共用
├── 個人偏好
└── 通用模板

Resolution order: workspace first → global fallback


Production-grade examples

Example 1: Weekly report search — anesthesia drug monitoring

name: weekly_anesthesia_monitoring
steps:
  - id: search_remimazolam
    action: search
    params:
      query: remimazolam
      sources: pubmed,europe_pmc
      limit: 50
      min_year: 2024
  - id: search_dex
    action: search
    params:
      query: dexmedetomidine ICU sedation
      sources: pubmed
      limit: 50
      min_year: 2024
  - id: merged
    action: merge
    inputs: [search_remimazolam, search_dex]
    params:
      method: union
  - id: filtered
    action: filter
    inputs: [merged]
    params:
      has_abstract: true
      article_types: "Journal Article,Clinical Trial,Randomized Controlled Trial"
  - id: enriched
    action: metrics
    inputs: [filtered]
output:
  format: markdown
  limit: 30
  ranking: recency

Example 2: Seed paper deep exploration

name: explore_landmark_paper
steps:
  - id: seed_details
    action: details
    params:
      pmids: "33475315"
  - id: related
    action: related
    params:
      pmid: "33475315"
      limit: 30
  - id: citing
    action: citing
    params:
      pmid: "33475315"
      limit: 30
  - id: refs
    action: references
    params:
      pmid: "33475315"
      limit: 30
  - id: merged
    action: merge
    inputs: [related, citing, refs]
    params:
      method: rrf
  - id: enriched
    action: metrics
    inputs: [merged]
output:
  format: markdown
  limit: 25
  ranking: impact

Example 3: Systematic literature review — SGLT2 + heart failure

name: sglt2_heart_failure_review
steps:
  - id: pico
    action: pico
    params:
      P: Type 2 diabetes with heart failure
      I: SGLT2 inhibitors
      C: standard care
      O: hospitalization, mortality
  - id: mesh_expand
    action: expand
    params:
      topic: SGLT2 inhibitors heart failure outcomes
  - id: search_pico_p
    action: search
    inputs: [pico]
    params:
      element: P
      sources: pubmed,europe_pmc
      limit: 100
  - id: search_pico_i
    action: search
    inputs: [pico]
    params:
      element: I
      sources: pubmed,europe_pmc
      limit: 100
  - id: search_expanded
    action: search
    inputs: [mesh_expand]
    params:
      strategy: mesh
      sources: pubmed,openalex
      limit: 100
  - id: merged
    action: merge
    inputs: [search_pico_p, search_pico_i, search_expanded]
    params:
      method: rrf
  - id: filtered
    action: filter
    inputs: [merged]
    params:
      min_year: 2018
      has_abstract: true
  - id: enriched
    action: metrics
    inputs: [filtered]
output:
  format: markdown
  limit: 50
  ranking: quality

Best practices for Agents generating Pipelines

Converting conversation searches into Pipelines

After completing a successful search, the Agent can:

# 1. 回顧剛才的搜尋策略
# 2. 轉化為 Pipeline YAML
save_pipeline(
    name="auto_from_session",
    config="""
steps:
  - id: main_search
    action: search
    params:
      query: "<剛才的查詢>"
      sources: pubmed,openalex
      limit: 50
  - id: enriched
    action: metrics
    inputs: [main_search]
output:
  limit: 20
  ranking: balanced
""",
    description="Auto-generated from search session"
)

# 3. 下次直接重複
# unified_search(pipeline="saved:auto_from_session")

Common patterns

Scenario Recommended template Description
Clinical question A vs B pico Agent provides P/I/C/O; the backend executes a precision/recall search containing O
Topic comprehensive search comprehensive Multi-source + MeSH expansion
Known important papers exploration Three-direction exploration (related/citing/refs)
Gene/drug research gene_drug Vocabulary expansion + multi-source
Complex workflow Custom DAG Full control over each step