refactor: rework wiki skill to use Karpathy's original text as reference

Remove pre-written container skill. Instead, include llm-wiki.md
(Karpathy's gist) as the reference material and have the setup skill
guide the user through collaboratively building their own wiki schema,
container skill, and directory structure based on the pattern.

Add NanoClaw-specific notes: image vision, PDF reader, voice
transcription, curl for full document fetch, file attachment handling.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
gavrielc
2026-04-05 10:07:48 +03:00
parent 36943fbcfd
commit 54bf4543f2
3 changed files with 144 additions and 159 deletions

View File

@@ -1,114 +1,91 @@
---
name: add-wiki
description: Add a persistent wiki knowledge base to a NanoClaw group. The agent ingests sources (URLs, files, attachments), builds interlinked wiki pages, answers questions from accumulated knowledge, and runs periodic health checks. Based on the LLM Wiki pattern. Triggers on "add wiki", "wiki", "knowledge base", "llm wiki".
description: Add a persistent wiki knowledge base to a NanoClaw group. Based on Karpathy's LLM Wiki pattern. Triggers on "add wiki", "wiki", "knowledge base", "llm wiki".
---
# Add Wiki
Adds a persistent wiki knowledge base to a NanoClaw group. The agent builds and maintains structured, interlinked markdown pages from sources you provide. Knowledge compounds over time rather than being re-derived on every question.
Set up a persistent wiki knowledge base on NanoClaw, based on Karpathy's LLM Wiki pattern.
Based on the [LLM Wiki pattern](https://gist.github.com/karpathy/442a6bf555914893e9891c11519de94f).
## Step 1: Read the pattern
## Phase 1: Pre-flight
Read `${CLAUDE_SKILL_DIR}/llm-wiki.md` — this is the full LLM Wiki idea as written by Karpathy. Understand it thoroughly before proceeding. Summarize the core idea to the user briefly, then discuss what they want to build.
Check if `container/skills/wiki/SKILL.md` exists. If it does, skip to Phase 3.
## Step 2: Choose a group
## Phase 2: Apply Code Changes
AskUserQuestion: "Which group should have the wiki?"
1. **Main group** — add to your existing main chat
2. **Dedicated group** — create a new group just for the wiki
3. **Other** — pick an existing group
If dedicated: ask which channel and chat, then register with `npx tsx setup/index.ts --step register`.
## Step 3: Design collaboratively
Discuss with the user based on the pattern:
- What's the wiki's domain or topic?
- What kinds of sources will they add? (URLs, PDFs, images, voice notes, books, transcripts)
- Do they want the full three-layer architecture or a lighter version?
- Any specific conventions they care about? (The pattern intentionally leaves this open.)
Based on this discussion, create three things:
### 3a. Directory structure
Create `wiki/` and `sources/` directories in the group folder. Create initial `index.md` and `log.md` per the pattern's Indexing and Logging section. Adapt to the user's domain.
### 3b. Container skill
Create a `container/skills/wiki/SKILL.md` tailored to this user's wiki. This is the schema layer from the pattern — it tells the agent how to maintain the wiki. Base it on the pattern's Operations section (ingest, query, lint) and the conventions you agreed on with the user. Don't over-prescribe — the pattern says "your LLM figures out the rest."
### 3c. Group CLAUDE.md
Add a wiki section to the group's CLAUDE.md that activates the wiki behavior and points to the container skill.
## Step 4: Source handling skills
Check which source-handling capabilities are installed and offer to add missing ones based on what the user plans to ingest:
| Source type | Skill needed | Check |
|---|---|---|
| Images | `/add-image-vision` | `src/channels/image-vision.ts` or similar exists |
| PDFs | `/add-pdf-reader` | `container/skills/pdf-reader/` exists |
| Voice notes | `/add-voice-transcription` | `container/skills/voice-transcription/` exists |
For each missing skill the user needs, invoke it.
### URL handling note
The agent has built-in `WebFetch`, but it returns a summary, not the full document. For wiki ingestion where the full text matters, the container skill should instruct the agent to use `curl` piped through an HTML-to-text conversion instead:
```bash
git fetch origin skill/wiki
git merge origin/skill/wiki
curl -sL "<url>" | sed 's/<[^>]*>//g'
```
If merge conflicts, resolve them. Then:
Or better, use `agent-browser` to open the page and extract full text if available. The container skill should note this so the agent gets full content for sources rather than summaries.
### File attachments
If the user's channel supports file attachments (WhatsApp documents, Telegram files, Slack uploads), these arrive in the container's workspace. The container skill should note that attached files can be read directly and saved to `sources/`.
## Step 5: Optional lint schedule
AskUserQuestion: "Want periodic wiki health checks?"
1. **Weekly**
2. **Monthly**
3. **Skip** — lint manually
If yes, schedule via `mcp__nanoclaw__schedule_task` with a prompt based on the pattern's Lint operation.
## Step 6: Build and restart
```bash
npm run build
./container/build.sh
```
## Phase 3: Setup
### Choose target group
AskUserQuestion: "Which group should have the wiki?"
1. **Main group** — add wiki to your existing main chat
2. **Dedicated wiki group** — create a new group just for the wiki (recommended for focused research)
3. **Other** — pick an existing group
If dedicated: ask which channel and chat to use, then register with `npx tsx setup/index.ts --step register`.
### Wiki topic
Ask the user: "What's this wiki for?" (e.g. AI research, health tracking, competitive analysis, trip planning, book companion, general knowledge base)
This shapes the initial index categories and the CLAUDE.md additions.
### Create directory structure
In the target group folder:
```bash
mkdir -p groups/<folder>/wiki groups/<folder>/sources
```
Create initial `wiki/index.md`:
```markdown
# Index
_Last updated: <today>_
(Pages will appear here as sources are added.)
```
Create initial `wiki/log.md`:
```markdown
# Log
## [<today>] setup | Wiki initialized
Wiki created. Topic: <topic>.
```
### Update group CLAUDE.md
Add a wiki section to the group's CLAUDE.md. Keep it brief — the container skill has the full workflow:
```markdown
## Wiki
You maintain a persistent wiki on <topic>. When sources arrive (URLs, files, attachments), ingest them into the wiki — don't just answer and move on. The `/wiki` container skill has the full ingest/query/lint workflow.
- Wiki pages: `wiki/` (start with `wiki/index.md`)
- Raw sources: `sources/` (immutable — never modify)
```
### Optional: Schedule lint
AskUserQuestion: "Want periodic wiki health checks?"
1. **Weekly** — every Sunday at 10am
2. **Monthly** — first of each month
3. **Skip** — lint manually when needed
If yes, use `mcp__nanoclaw__schedule_task`:
- prompt: "Run a wiki lint. Check for contradictions, orphan pages, stale content, missing cross-references, and gaps. Report findings."
- schedule_type: "cron"
- schedule_value: `"0 10 * * 0"` (weekly) or `"0 10 1 * *"` (monthly)
### Optional: Obsidian
If the user uses Obsidian, mention they can point a vault at `groups/<folder>/` for graph view, backlinks, and visual browsing. The wiki is just markdown files on disk.
## Phase 4: Verify
Restart the service to pick up the new container skill:
```bash
launchctl kickstart -k gui/$(id -u)/com.nanoclaw # macOS
# Linux: systemctl --user restart nanoclaw
```
Tell the user to test: send a URL to the wiki group. The agent should ingest it, create wiki pages, and update the index.
Tell the user to test by sending a source to the wiki group.