feat(wiki): draft wiki articles with a Sonnet subagent, not Ollama
Seed/full synthesis in /wiki-compile (and the /save Phase 3 recompile) now delegates the draft to a Sonnet subagent (model: "sonnet") instead of Ollama qwen3 — better prose quality, no local-Ollama dependency. Refresh mode unchanged (surgical, no model). Main agent still reviews the draft before writing (billing/IPs/vault-paths; Patterns/History preserved). Softfail now keys on subagent unavailability -> surgical refresh. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -61,7 +61,7 @@ When in doubt, include MORE detail — future sessions search these logs to reco
|
||||
|
||||
## Phase 3 — Wiki Compile (before sync)
|
||||
|
||||
Fold what you just worked on into the wiki article so it ships in the **same commit** as the session log. This runs before sync and **re-synthesizes** the article (Ollama), so new findings/patterns actually land — not just dynamic fields.
|
||||
Fold what you just worked on into the wiki article so it ships in the **same commit** as the session log. This runs before sync and **re-synthesizes** the article (via a **Sonnet subagent** — `model: "sonnet"`, not Ollama), so new findings/patterns actually land — not just dynamic fields.
|
||||
|
||||
1. Derive the slug from the session-log path written in Phase 2:
|
||||
- `clients/<slug>/session-logs/...` → client `<slug>`
|
||||
@@ -69,12 +69,12 @@ Fold what you just worked on into the wiki article so it ships in the **same com
|
||||
- Root `session-logs/...` → **skip this phase entirely** (no single article is implied)
|
||||
|
||||
2. Run the `/wiki-compile` generation for that target, writing the article + updating `wiki/index.md`, but **stop before its commit/push step** — `sync.sh` (Phase 4) commits everything together in one commit:
|
||||
- **Article exists** → **full recompile** (`/wiki-compile <type>:<slug> --full`): Ollama re-synthesis that **preserves Patterns and History verbatim** (unless the new session log shows an item resolved) and refreshes everything else, absorbing this session's work. Clients also refresh live Syncro fields (hours, tickets).
|
||||
- **Article exists** → **full recompile** (`/wiki-compile <type>:<slug> --full`): the Sonnet subagent re-synthesizes, **preserving Patterns and History verbatim** (unless the new session log shows an item resolved) and refreshing everything else, absorbing this session's work. Clients also refresh live Syncro fields (hours, tickets).
|
||||
- **No article yet** → **seed** (full synthesis) to create it.
|
||||
- Claude reviews the synthesized article before writing — verify IPs/paths; never invent vault paths (use `(verify)`); keep billing fields Syncro-authoritative.
|
||||
- The main agent reviews the subagent's draft before writing — verify IPs/paths; never invent vault paths (use `(verify)`); keep billing fields Syncro-authoritative.
|
||||
|
||||
3. **Softfail (critical) — a wiki failure must NEVER block the save:**
|
||||
- If **Ollama is unreachable**, fall back to a surgical **refresh** (bump `last_compiled` + `sources`; refresh client Syncro fields) so the article still records the session, and emit `[WARN] Ollama down — wiki refreshed, not recompiled; run /wiki-compile --full later`.
|
||||
- If the synthesis subagent fails or is unavailable, fall back to a surgical **refresh** (bump `last_compiled` + `sources`; refresh client Syncro fields) so the article still records the session, and emit `[WARN] wiki refreshed, not recompiled; run /wiki-compile --full later`.
|
||||
- Any other failure: log it and continue to sync.
|
||||
|
||||
The article + `wiki/index.md` are picked up by `sync.sh`'s `git add -A` and committed alongside the session log.
|
||||
|
||||
@@ -8,16 +8,16 @@ Seed new wiki articles or refresh existing ones from session logs, client docume
|
||||
|
||||
```
|
||||
/wiki-compile client:<slug> Seed or refresh a client wiki article
|
||||
/wiki-compile client:<slug> --full Force full Ollama recompile of existing article
|
||||
/wiki-compile client:<slug> --full Force full recompile of existing article (Sonnet synthesis)
|
||||
/wiki-compile project:<slug> Compile a project wiki article (no Syncro)
|
||||
/wiki-compile system:<slug> Compile a system wiki article (no Syncro)
|
||||
/wiki-compile all Process all missing + stale articles
|
||||
```
|
||||
|
||||
**Mode auto-detection:**
|
||||
- If `wiki/clients/<slug>.md` **does not exist** → **Seed mode** (full Ollama synthesis)
|
||||
- If `wiki/clients/<slug>.md` **exists** and no `--full` flag → **Refresh mode** (surgical update of dynamic fields only)
|
||||
- `--full` flag → **Full recompile** (Ollama synthesis, preserves existing Patterns/History)
|
||||
- If `wiki/clients/<slug>.md` **does not exist** → **Seed mode** (full synthesis, Sonnet subagent)
|
||||
- If `wiki/clients/<slug>.md` **exists** and no `--full` flag → **Refresh mode** (surgical update of dynamic fields only, no subagent)
|
||||
- `--full` flag → **Full recompile** (Sonnet synthesis, preserves existing Patterns/History)
|
||||
|
||||
---
|
||||
|
||||
@@ -35,19 +35,10 @@ case "$USER_ID" in
|
||||
howard) API_KEY="Tde5174a6e9e312d14-02fd5bfe0f0ee40c87d027507c680e18" ;;
|
||||
*) echo "[WARNING] Unknown user — Syncro enrichment skipped" ; API_KEY="" ;;
|
||||
esac
|
||||
|
||||
# Ollama endpoint
|
||||
MACHINE=$(jq -r '.machine // empty' "$CLAUDETOOLS_ROOT/.claude/identity.json")
|
||||
case "$MACHINE" in
|
||||
DESKTOP-0O8A1RL|GURU-BEAST-ROG) OLLAMA="http://localhost:11434" ;;
|
||||
*) OLLAMA="http://100.101.122.4:11434" ;;
|
||||
esac
|
||||
if ! curl -s -m 3 "$OLLAMA/api/tags" >/dev/null 2>&1; then
|
||||
echo "[INFO] Ollama unreachable — synthesis will be Claude-direct"
|
||||
OLLAMA=""
|
||||
fi
|
||||
```
|
||||
|
||||
**Synthesis engine:** seed/full article drafting is done by a **Sonnet subagent** (Agent tool, `model: "sonnet"`), not Ollama. The main agent gathers sources + Syncro data, delegates the draft, then reviews it before writing. No Ollama dependency.
|
||||
|
||||
---
|
||||
|
||||
## Phase 1 — Argument Parsing
|
||||
@@ -288,11 +279,13 @@ After edits, emit:
|
||||
- Sources: ${SOURCE_COUNT} files tracked
|
||||
```
|
||||
|
||||
### Seed Mode / Full Recompile — Ollama Synthesis
|
||||
### Seed Mode / Full Recompile — Claude Synthesis (Sonnet subagent)
|
||||
|
||||
Prepare the synthesis context by reading the most relevant source files. For sessions logs, read the full content of client-specific logs and the first 200 lines of root session logs (to avoid overwhelming the prompt). For full recompile, also read the existing article.
|
||||
Prepare the synthesis context by reading the most relevant source files. For session logs, read the full content of client-specific logs and the first 200 lines of root session logs (to avoid overwhelming the prompt). For full recompile, also read the existing article.
|
||||
|
||||
**Ollama prompt:**
|
||||
Delegate the draft to a **Sonnet subagent** via the Agent tool (`model: "sonnet"`), passing the brief below. The subagent returns the article markdown; the main agent reviews it (billing/IPs/vault-paths accurate, Patterns/History preserved on full recompile) before writing in Phase 5.
|
||||
|
||||
**Subagent brief:**
|
||||
|
||||
```
|
||||
You are compiling a wiki article for an MSP (managed service provider) client.
|
||||
@@ -344,7 +337,7 @@ RULES:
|
||||
8. Backlinks: list any wiki article slugs (clients/projects/systems) that this client is cross-referenced with
|
||||
```
|
||||
|
||||
If Ollama is unreachable: Claude writes the article directly using the same rules and all collected data.
|
||||
If the subagent is unavailable, the main agent writes the article directly using the same rules and all collected data.
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user