| name | knowledge-compile |
| description | Compile raw session logs, feedback, and inbox items into structured wiki articles. Orchestrated in this session — MCP returns work items, Claude synthesizes, MCP confirms. |
| disable-model-invocation | true |
| allowed-tools | mcp__plugin_agent-kevin_kevin__compile_status, mcp__plugin_agent-kevin_kevin__compile_next, mcp__plugin_agent-kevin_kevin__compile_write, Read, Write, Edit, Glob, Grep |
Compile
Compile raw inputs from <HOME>/knowledge/raw/ into structured wiki articles. The orchestration loop runs in this session — the MCP server is pure I/O, no LLM calls.
Loop
- Call
mcp__plugin_agent-kevin_kevin__compile_status to see what's pending.
- Call
mcp__plugin_agent-kevin_kevin__compile_next:
- If
done: true, you're finished. Stop.
- Otherwise, item is
{ itemId, kind, fileName, prompt, meta }. kind is session | feedback | inbox.
- Read the
prompt field carefully. It contains:
- The CLAUDE.md operating manual (how to organise the wiki)
- The current
USER.md (who the user is)
- The current knowledge/index.md
- Every existing wiki article (markdown-fenced for grounding)
- The raw source content (session log, feedback log, or spec)
- Paths to write to
- Perform the work the prompt instructs — using Read to inspect existing articles, Write/Edit to update them. Common outputs:
- New entries in
<HOME>/knowledge/memory/YYYY-MM-DD.md (daily memory; 14-day retention)
- Updates to
<HOME>/knowledge/memory/index.md (active threads, recent decisions, learnings)
- New or updated
<HOME>/knowledge/concepts/<slug>.md (cross-cutting patterns)
- Updates to
<HOME>/USER.md (durable facts about you)
- After all edits land, call
mcp__plugin_agent-kevin_kevin__compile_write with the itemId. State is updated: session items advance chunk counter (or promote on last chunk); feedback marks hash; inbox items archive the source file.
- Goto step 2.
Gap pass (on completion)
When the loop ends (compile_next returns done: true) and at least one item was compiled this run, do one editorial pass over the wiki you just updated and refresh the knowledge-gap list. Synthesis is only half the job — naming the holes is the other half. (This is the "what the brain doesn't know yet" idea: surface gaps so the operator can fill them.)
- Re-read
<HOME>/knowledge/index.md and <HOME>/knowledge/memory/index.md (both current after this run).
- Judge the wiki as a whole and surface up to 7 items across three kinds:
- stale — a dated/status-bearing fact that current context has outrun (a "pending" since resolved, a deadline now past, a "target X" that already happened).
- contradiction — two articles asserting incompatible facts.
- missing — a fact strongly implied across the corpus but never recorded (a decision referenced everywhere with no source, a project with threads but no README fact).
- Overwrite the
## Open Questions section of <HOME>/knowledge/memory/index.md with the result (create it directly above ## Daily Memory if absent). Overwrite, never append — this is derived state, regenerated each compile so filled gaps drop off and unfilled ones persist. Hard cap 7. If nothing qualifies, write _None — wiki is internally consistent as of <date>._.
Format each as one line: - **[stale|contradiction|missing]** <the gap — and where it shows up>.
Do not invent gaps to hit a quota. Most runs surface 0–3. This is a judgment pass, not a checklist. Because memory/index.md is auto-loaded every session, the list becomes ambient context — no briefing wiring needed.
Boundaries
- Do not modify the raw source file. The session log, feedback log, or inbox item under
raw/ is the input; never edit it. Compilation produces new or updated wiki articles and (for inbox items) archives the source via compile_write.
- One itemId at a time. Sessions may chunk:
meta.totalChunks > 1 means multiple compile_next calls for the same file. The prompt already contains only the current chunk's content — synthesize only what's in this chunk.
- Idempotency is enforced by hash. If the source hasn't changed since the last successful compile,
compile_next won't return it again.
Stop conditions
compile_next returns { done: true } — work complete.
- Three consecutive errors from any MCP call — stop and surface the error.
- The user interrupts.
Why this shape
If the synthesis were called inside the MCP server (via the Anthropic SDK), it would bill against API quota. By returning the prompt to the calling Claude Code session, the synthesis runs as a turn in your TUI — billing against your subscription pool. The MCP server is pure I/O + state; no LLM call ever happens inside MCP tool handlers.