# 📚 Pi-Wiki

**LLM Wiki** — a compounding knowledge base for pi + Obsidian.

Based on [Karpathy's LLM Wiki pattern](https://gist.github.com/karpathy/442a6bf555914893e9891c11519de94f) + [Ar9av/obsidian-wiki](https://github.com/Ar9av/obsidian-wiki) framework.

> "Obsidian is the IDE, the LLM is the programmer, the wiki is the codebase."

## Quick Start

```bash
pi install npm:pi-wiki
```

Then in pi:
```
/wiki-status          # Check wiki health
/wiki-ingest <url>     # Add a source
/wiki-query <question> # Ask the wiki
/wiki-lint             # Health check
```

## Core Commands

| Command | Description |
|---------|-------------|
| `/wiki-status` | Wiki health: pages, sources, activity |
| `/wiki-ingest <path\|url>` | Add source (MD, HTML, JSON, PDF, URL) |
| `/wiki-query <question>` | Search wiki with keyword + semantic |
| `/wiki-lint` | Health check: orphans, broken links, stale |
| `/wiki-list` | All wiki pages |
| `/wiki-read <title>` | Read specific page |
| `/wiki-append <note>` | Quick note for later review |

## Maintenance Commands

| Command | Description |
|---------|-------------|
| `/wiki-crosslink` | Auto-discover unlinked mentions, add wikilinks |
| `/wiki-taxonomy` | Audit + normalize tags across vault |
| `/wiki-export` | Export graph (JSON, HTML, GraphML) |
| `/wiki-sync` | Sync with Obsidian vault (if configured) |

## Obsidian Integration

Pi-wiki can use your **existing Obsidian vault** OR its own built-in vault.

### Config

```json
// ~/.pi-wiki/config
{
  "vault_path": "~/pi-wiki",                    // pi-wiki's own vault
  "obsidian_vault": "~/Obsidian/my-vault",      // OR existing Obsidian vault
  "link_format": "wikilink"
}
```

### Features

- **Read** from Obsidian vault
- **Write** to Obsidian vault (bi-directional)
- **Obsidian graph view** support (export graph.json)
- **Obsidian CLI** integration (`obsidian read`, `obsidian search`)
- **Web Clipper** support (auto-ingest from browser)
- **Frontmatter** schema matches Obsidian conventions

### Obsidian Web Clipper

1. Install [Obsidian Web Clipper](https://obsidian.md/clipper)
2. Clip articles → saved to `sources/web-clips/`
3. `/wiki-lint` auto-ingests clips

## Directory Structure

```
pi-wiki/
├── CLAUDE.md           ← Schema (pi-wiki pattern)
├── index.md            ← Catalog of all pages
├── log.md              ← Chronological activity
├── .manifest.json      ← Tracked sources + hashes
├── sources/            ← Raw documents (immutable)
├── wiki/               ← LLM-generated pages
│   ├── entities/       ← People, places, things
│   ├── concepts/      ← Ideas, theories
│   └── summaries/     ← Source summaries
├── _raw/               ← Draft staging
├── _drafts/            ← Append notes
├── _meta/
│   └── taxonomy.md     ← Canonical tags
└── .obsidian/          ← Obsidian config (if linked)
```

## Page Schema

```yaml
---
title: Page Title
type: entity|concept|summary|synthesis
tags: [tag1, tag2]
sources: [source-slug]
created: 2026-01-15
updated: 2026-01-20
provenance: ^[extracted]
aliases: [Alternate Title]
---

# Page Title

## Key Points

## See Also
- [[Related Page]]
- [[Another Page]]
```

## Supported Formats

| Format | Extension | Parser |
|--------|-----------|--------|
| **Markdown** | `.md` | Native |
| **HTML** | `.html`, `.htm` | Strip tags → MD |
| **JSON** | `.json` | Pretty print |
| **PDF** | `.pdf` | `npm i pdf-parse` (optional) |
| **DOCX** | `.docx` | `npm i mammoth` (optional) |
| **URL** | `https://...` | Fetch + HTML strip |

## Comparison

| Feature | Karpathy | obsidian-wiki | AgentWiki | **pi-wiki** |
|---------|----------|---------------|-----------|-------------|
| Pattern | LLM Wiki | LLM Wiki | LLM Wiki | LLM Wiki ✅ |
| Personal | ✅ | ✅ | ❌ | ✅ |
| Multi-agent | ❌ | 15+ agents | All agents | **pi only** |
| Obsidian link | ❌ | ✅ | ❌ | **✅** |
| Cross-linker | ❌ | ✅ | ✅ | **Planned** |
| Tag taxonomy | ❌ | ✅ | ❌ | **Planned** |
| QMD search | ❌ | ✅ | ✅ | **Planned** |
| History mining | ❌ | 5 agents | ❌ | **Planned** |
| Install | Copy/paste | `npx skills add` | Web only | `pi install npm:pi-wiki` ✅ |

## Why Pi-Wiki?

- **Single install** — `pi install npm:pi-wiki`
- **Works inside pi** — `/wiki-*` commands in TUI
- **Obsidian compatible** — use existing vault or create new
- **Compounds over time** — every source makes wiki smarter

## Install

```bash
pi install npm:pi-wiki
```

Or from source:
```bash
cd ~/Projects/pi-wiki
node ~/Projects/gh-repo/pub-hotlin.cjs pi-wiki
pi install npm:pi-wiki
```

## Optional Dependencies

```bash
# For PDF support
npm i -g pdf-parse

# For DOCX support
npm i -g mammoth

# For semantic search
npm i -g qmd
qmd index --name wiki ~/pi-wiki/wiki
```

## See Also

- [Karpathy's LLM Wiki](https://gist.github.com/karpathy/442a6bf555914893e9891c11519de94f)
- [Ar9av/obsidian-wiki](https://github.com/Ar9av/obsidian-wiki) — 36 skills framework
- [AgentWiki.org](https://agentwiki.org/) — shared agent knowledge base
- [Wyndo's Substack](https://aimaker.substack.com/p/llm-wiki-obsidian-knowledge-base-andrej-karphaty) — case study
- [ΩmegaWiki](https://github.com/OmegaWiki/omega-wiki) — 23 Claude Code skills
- [llmbase](https://github.com/Hosuke/llmbase) — React web UI version