一键导入
bookstrap-research
Execute research tasks autonomously by searching for sources, evaluating reliability, ingesting content, and resolving knowledge gaps
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Execute research tasks autonomously by searching for sources, evaluating reliability, ingesting content, and resolving knowledge gaps
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Outline creation patterns for fiction and nonfiction book structures, including chapter breakdowns, scene planning, and narrative arc mapping.
Grounded prose composition workflow including pre-write queries, consistency checks, and post-write entity extraction for database-backed writing.
Run editing passes over completed sections for voice consistency, timeline verification, contradiction flagging, and citation coverage
Load research corpus into the database by processing files, directories, or URLs through semantic chunking, embedding generation, entity extraction, and relationship building
Analyze BRD and existing corpus to identify knowledge gaps, then generate prioritized research tasks for filling those gaps
Generate writing tasks from BRD structure and corpus, creating chapter/section tasks with dependencies, pre-write queries, and consistency checks
| name | bookstrap-research |
| description | Execute research tasks autonomously by searching for sources, evaluating reliability, ingesting content, and resolving knowledge gaps |
| disable-model-invocation | true |
| allowed-tools | Bash, Read, Write, WebFetch, WebSearch, TaskGet, TaskUpdate |
Execute research tasks autonomously to fill knowledge gaps identified during planning. Search the web for sources, evaluate their reliability, ingest relevant content, extract entities and relationships, and mark gaps as resolved.
Fill knowledge gaps by conducting autonomous web research. This command loads pending research tasks from the database, searches for high-quality sources, ingests them into the corpus, and resolves the associated knowledge gaps.
This command delegates the research work to the researcher agent, which operates in research mode with full web access.
None. This command reads pending research tasks from the database:
Query the database to retrieve unresolved knowledge gaps:
# Query pending research tasks
surreal sql --conn http://localhost:2665 \
--user root --pass root \
--ns bookstrap --db <database-name> \
--query "SELECT * FROM knowledge_gap WHERE resolved = false ORDER BY priority DESC, created_at ASC;"
Filter and prioritize:
Execute research tasks one at a time, committing progress after each successful ingestion.
Use configured search provider (Tavily, Brave, Serper, Google) to find relevant sources:
# Perform web search based on research question
# Apply domain filters from bookstrap.config.json
# Respect rate limits
# Target max_sources_per_task from config (default: 5)
Search strategy:
For each search result, assess reliability:
| Source Type | Reliability | Use Case |
|---|---|---|
| Academic/peer-reviewed journals | High | Factual claims, scholarly arguments |
| Primary sources (archives, documents) | High | Historical facts, original evidence |
| Reputable journalism (NYT, BBC, etc.) | Medium-High | Recent events, context |
| Government/institutional sites | Medium-High | Official data, statistics |
| Expert blogs/substacks | Medium | Opinion, analysis, niche expertise |
| Wikipedia | Low (for leads only) | Starting point, bibliography mining |
| Random blogs/forums | Very Low | Avoid unless unique perspective needed |
Check reliability indicators:
For approved sources, ingest into the database:
# Use ingest-file.py for web content
python ./scripts/ingest-file.py \
--url <source-url> \
--source-type <primary|secondary|web> \
--reliability <high|medium|low> \
--context "ingested_during:research" \
--gap-id <knowledge-gap-id>
Ingestion performs:
The ingestion script uses extract-entities.py with LLM-based extraction:
# Extract entities from ingested content
python ./scripts/extract-entities.py \
--source-id <source-id> \
--content <chunk-content> \
--context <surrounding-context>
Extracts:
Creates relationships:
-- Link source to extracted entities
RELATE source:<id>->supports->concept:<id>;
RELATE event:<id>->precedes->event:<next-id>;
RELATE character:<id>->knows->character:<other-id>;
RELATE location:<id>->contains->location:<sub-id>;
After successful ingestion, update the knowledge gap:
UPDATE knowledge_gap:<gap-id> SET
resolved = true,
resolved_by = source:<source-id>,
resolved_at = time::now()
;
After each successfully resolved gap:
git add .
git commit -m "[bookstrap] Research: Resolved gap '<gap-question>' with <N> sources
Sources ingested:
- <source-1-title> (<reliability>)
- <source-2-title> (<reliability>)
...
Entities extracted: <count>
Relationships created: <count>
Co-Authored-By: Claude <noreply@anthropic.com>"
Invoke the researcher agent to perform the detailed research work:
# Load researcher agent with context
# Agent will:
# 1. Load next pending research task
# 2. Search web for sources
# 3. Evaluate source reliability
# 4. Ingest approved sources
# 5. Extract entities and relationships
# 6. Mark gap resolved
# 7. Commit progress
# 8. Continue to next task or exit if blocked
The researcher agent has read+write database access, web search capabilities, and uses the research and surrealdb skills.
The researcher agent continues processing tasks until:
Report research progress to the user:
RESEARCH EXECUTION
==================
Configuration:
- Search provider: Tavily
- Max sources per task: 5
- Rate limit: 10 requests/min
- Database: bookstrap/my_book
TASK 1/12: High Priority
-------------------------
Question: "SOE wireless operator training protocols 1942-1943"
Context: Core to protagonist's role, zero sources
Blocks: Chapters 2, 4, 6
Web search: 15 results found
Evaluating sources...
✓ [HIGH] "SOE Training at Beaulieu" - Historical Society Journal
✓ [HIGH] "Wireless Operator Manual 1943" - National Archives
✓ [MEDIUM] "Special Operations Executive Training" - Imperial War Museum
✗ [LOW] Wikipedia article (using for bibliography only)
Ingesting 3 sources...
→ Source 1: 2,340 words, 4 chunks, 15 entities extracted
→ Source 2: 1,850 words, 3 chunks, 8 entities extracted
→ Source 3: 3,120 words, 5 chunks, 12 entities extracted
Entities extracted:
- Characters: 5 (trainers, notable agents)
- Locations: 3 (Beaulieu, training facilities)
- Events: 12 (training procedures, protocols)
- Concepts: 10 (wireless techniques, codes)
- Dates: 8 (timeline entries)
Relationships created: 24 graph edges
Gap resolved ✓
Committed: [abc1234]
---
TASK 2/12: High Priority
-------------------------
Question: "Lyon Resistance network structure and key figures"
Context: Primary setting, only 2 tangential sources
Blocks: Chapters 3, 5, 7
Web search: 22 results found
Evaluating sources...
✓ [HIGH] "Combat: Resistance Movements in Lyon" - French Archives
✓ [MEDIUM] "The Lyon Resistance 1940-1944" - BBC History
✓ [MEDIUM] "Jean Moulin and Lyon Networks" - Resistance Museum
✗ [LOW] Blog post (insufficient citations)
Ingesting 3 sources...
[...]
---
PROGRESS SUMMARY
================
Tasks completed: 2/12
Tasks remaining: 10 (8 high priority, 2 medium priority)
Sources ingested: 6
Entities extracted: 35
Relationships created: 48
Knowledge gaps resolved: 2
Commits: 2
Time elapsed: 8 minutes
Rate limit status: 18/60 requests used this hour
NEXT STEPS
----------
Continue research: /bookstrap-research (auto-resumes)
Check progress: /bookstrap-status
View corpus: /bookstrap-query "What sources do we have about wireless training?"
This command operates in research mode:
Runs fully autonomously:
Prioritizes source quality:
Handles rate limits gracefully:
{
"research": {
"provider": "tavily",
"rate_limit": {
"requests_per_minute": 10,
"retry_after_seconds": 60,
"max_retries": 3
}
}
}
If rate limited:
Re-running /bookstrap-research after interruption:
Research behavior configured in bookstrap.config.json:
{
"research": {
"provider": "tavily",
"api_key_env": "TAVILY_API_KEY",
"rate_limit": {
"requests_per_minute": 10
},
"blocked_domains": ["example-spam-site.com"],
"allowed_domains": [],
"max_sources_per_task": 5,
"min_reliability": "medium",
"auto_commit": true,
"max_retries_per_task": 3
}
}
Settings:
provider: Search API (tavily, brave, serper, google)max_sources_per_task: Limit sources per research question (prevents over-research)min_reliability: Minimum acceptable source quality (low, medium, high)blocked_domains: Never fetch from these domainsallowed_domains: If set, only fetch from these domainsauto_commit: Commit after each gap resolved (recommended)max_retries_per_task: Abandon task after N failed attempts| Error | Recovery |
|---|---|
| Search API unavailable | Skip to next task, flag for manual research |
| Rate limit exceeded | Pause, wait for reset, resume |
| No sources found | Flag gap as "no sources available", continue |
| All sources rejected (low quality) | Flag gap as "needs human review", continue |
| Ingestion failure | Log error, skip source, try next source |
| Database write failure | Abort, report error, preserve uncommitted work |
| Network timeout | Retry up to max_retries, then skip |
Before running /bookstrap-research:
/bookstrap-init must have been run/bookstrap-plan-research must have identified gaps/bookstrap-plan-research - Generate research tasks (run this first)/bookstrap-ingest - Ingest user-provided sources (manual alternative)/bookstrap-status - Monitor research progress and gap resolution/bookstrap-query - Query ingested sources/bookstrap-plan-write - Generate writing tasks (run after research complete)| Agent | Role |
|---|---|
researcher | Executes web research, evaluates sources, ingests content |
| Skill | Purpose |
|---|---|
research/ | Source evaluation, web search strategies, entity extraction patterns |
surrealdb/ | Database query patterns for gap tracking and entity storage |
| Script | Purpose |
|---|---|
ingest-file.py | Ingest content from URLs or files |
generate-embedding.py | Generate embeddings via configured provider |
extract-entities.py | LLM-based entity extraction |
chunk.py | Semantic chunking strategies |
# After identifying gaps, execute research
/bookstrap-plan-research
/bookstrap-research
# Research interrupted? Resume where you left off
/bookstrap-research
# Check progress
/bookstrap-status
# Continue research if new gaps found during writing
/bookstrap-write
# (discovers gaps)
/bookstrap-plan-research
/bookstrap-research
/bookstrap-write
This command is part of the research-write cycle:
init → ingest → plan-research → research
↑ │
│ ▼
│ plan-write → write → edit
│ │
└──── gaps ────┘
When writing discovers knowledge gaps:
/bookstrap-plan-research to generate research tasks/bookstrap-research to fill gaps/bookstrap-write to resume writing (now unblocked)Calculate and report:
Detailed logging for transparency:
[2024-01-15 14:23:45] [RESEARCH] Task 1/12 started: "SOE wireless protocols"
[2024-01-15 14:23:47] [SEARCH] Query: "SOE wireless operator training 1942-1943"
[2024-01-15 14:23:49] [SEARCH] Found 15 results
[2024-01-15 14:23:50] [EVAL] Source 1: "SOE Training at Beaulieu" - HIGH (academic journal)
[2024-01-15 14:23:51] [EVAL] Source 2: "Wireless Manual 1943" - HIGH (primary source)
[2024-01-15 14:23:52] [EVAL] Source 3: "Random blog post" - REJECTED (insufficient citations)
[2024-01-15 14:23:55] [INGEST] Source 1: 2,340 words, 4 chunks, 15 entities
[2024-01-15 14:24:12] [INGEST] Source 2: 1,850 words, 3 chunks, 8 entities
[2024-01-15 14:24:28] [GRAPH] Created 24 relationships
[2024-01-15 14:24:30] [DB] Gap resolved: knowledge_gap:gap-001
[2024-01-15 14:24:32] [GIT] Committed: abc1234
[2024-01-15 14:24:33] [RESEARCH] Task 1/12 complete (8m 48s)
This command is a thin wrapper that:
researcher agentThe actual research logic lives in the researcher agent to keep concerns separated.
Re-running /bookstrap-research is safe:
Research mode vs. Write mode:
This command operates exclusively in research mode and is never invoked during writing. Writing discovers gaps but never fills them.
When ingesting academic sources:
For complex topics:
Validate facts across sources:
Gap: "Obscure technical detail from 1943"
Status: No sources found after 3 searches
Action: Flagged for human review
Possible solutions:
/bookstrap-ingestGap: "Controversial historical claim"
Status: 8 sources found, all rejected (reliability too low)
Action: Flagged for human review
Possible solutions:
min_reliability threshold in config/bookstrap-ingestStatus: Rate limit hit (60/60 requests this hour)
Action: Paused, resuming at 15:00
Automatic recovery:
Use blocked_domains to prevent fetching from:
Never log or display API keys:
Before ingesting web content: