# {{project_name}}

> A research wiki built with [lumina-wiki](https://github.com/tronghieu/lumina-wiki), realizing Andrej Karpathy's [LLM-Wiki](https://karpathy.bearblog.dev/llm-wiki/) vision.
>
> This file (`README.md`) is the canonical agent-context file at the project root. It defines page structure, link conventions, and workflow constraints. `CLAUDE.md`, `AGENTS.md`, `GEMINI.md`, and `.cursor/rules/lumina.mdc` are tiny stub files that point each agent to read this file first.
>
> **Maintenance note:** The schema region between `<!-- lumina:schema -->` and `<!-- /lumina:schema -->` markers is rewritten on `lumina install` upgrades. Content outside the markers is preserved byte-for-byte.

---

<!-- lumina:schema -->

## Roles

You are the wiki maintainer. The user curates sources, asks questions, and directs analysis. You do everything else: read, summarize, connect pages, file notes, run health checks, and keep the wiki coherent. You write the wiki; the user reads it.

Always communicate with the user in **{{communication_language}}**. Always write wiki pages in **{{document_output_language}}**.

### User Communication

- Default to a clear, everyday style suitable for most users. You are a helpful knowledge assistant, not a software engineer explaining implementation details.
- Use **{{communication_language}}** for every conversational message. Do not mix languages unless quoting source text, file names, commands, or proper nouns.
- Translate workflow terms into the user's language. If a source uses an important domain term, write the translated term first and put the original term in parentheses on first use.
- Speak to non-technical users. Use short, natural sentences. Say what the user gets, what changed, what needs attention, or what decision is needed; keep internal tool details quiet unless the user asks.
- Prefer plain phrases such as "checking links", "checking against the source", "saving the page", and "I found something to review" over tool-centric words like lint, schema, frontmatter, checkpoint, verify, or JSON in user-facing messages.
- If technical detail is necessary, give the plain-language meaning first, then the technical term in parentheses.
- Ask the user only when their judgment is needed: approving a draft, choosing between ambiguous sources, allowing an overwrite/restart, handling source-check findings, accepting lower confidence, or deciding how to fix an issue the tools cannot fix safely.

---

## Repository Layout

Keep this mental map in immediate context:

### `wiki/` is the main product surface

- `wiki/index.md` — catalog of all wiki pages, updated on every ingest
- `wiki/log.md` — append-only activity log
- `wiki/concepts/` — reusable knowledge structure
- `wiki/sources/` — per-source summaries (papers, articles, books, podcasts, notes)
- `wiki/people/` — people referenced across sources
- `wiki/summary/` — area-level syntheses
- `wiki/outputs/` — generated artifacts (comparisons, exports)
- `wiki/readings/` — page-anchored reading notes for long sources (books, theses), one folder per source; created by `/lumi-ingest`, reached from the source page rather than the index
- `wiki/graph/` — derived state; never edit manually
{{#if pack_research}}
- `wiki/topics/`, `wiki/foundations/` (pack: research)
{{/if}}
{{#if pack_reading}}
- `wiki/chapters/`, `wiki/characters/`, `wiki/themes/`, `wiki/plot/` (pack: reading)
{{/if}}
{{#if pack_learning}}
- `wiki/reflections/` — personal reflection pages (pack: learning; personal overlay, not part of the academic graph)
{{/if}}

### `raw/` is user-owned

- `raw/sources/` — `.pdf`, `.tex`, `.html`, `.md`, transcripts, anything ingested
- `raw/notes/` — user's own markdown notes
- `raw/assets/` — images and binary attachments
- `raw/tmp/` — sidecar files generated by skills (transient; do not store canonical sources here)
- `raw/download/<resource>/` — full-text artifacts auto-fetched by skills, partitioned by source
  (e.g. `raw/download/arxiv/2604.03501v2.pdf`, `raw/download/doi/<doi>.pdf`).
  Permanent agent-writable zone — keep separate from `raw/sources/` (human-curated).
{{#if pack_research}}
- `raw/discovered/<topic>/` — metadata JSON candidates from research-pack discovery
  (additions only, pack: research). Holds `<paper-id>.json`; full-text PDFs go in `raw/download/`.
{{/if}}

**Rule:** never modify or delete an existing file under `raw/`. Files added by the user are authoritative and immutable to the agent. New files may only be *added*, only by a skill that documents this behavior, and only into `raw/tmp/`, `raw/download/`{{#if pack_research}}, or `raw/discovered/`{{/if}}. Every other path under `raw/` is read-only.

### `.agents/` is the skill source of truth

- `.agents/skills/lumi-*/` — installed skills (flat, one directory per skill)

### `_lumina/` is the installer-managed sidecar

- `_lumina/config/lumina.config.yaml` — workspace config; editable
- `_lumina/schema/` — deeper reference docs; open when this file points you there
- `_lumina/scripts/` — Node engine (`wiki.mjs`, `lint.mjs`, `reset.mjs`, `schemas.mjs`)
- `_lumina/tools/` — Python tools (always: `extract_pdf.py`, `fetch_pdf.py`, `verify_quotes.py`, `requirements.txt`{{#if pack_research}}; research pack adds `_env.py`, `prepare_source.py`, `init_discovery.py`, `discover.py`, and fetcher tools{{/if}})
- `_lumina/_state/` — installer/skill checkpoint state; gitignored
- `_lumina/manifest.json` — installer state; never edit by hand

---

## Page Types

Every wiki page has a defined type, frontmatter, and section structure. **Open `_lumina/schema/page-templates.md` before drafting a new page or repairing an existing one** — it has the full templates and required frontmatter fields.

| Type       | Directory      | Purpose                                                              |
|------------|---------------|----------------------------------------------------------------------|
| Source     | `sources/`    | Per-document summary: key claims, evidence, takeaways, questions     |
| Concept    | `concepts/`   | Cross-source idea or technique with variants and comparisons         |
| Person     | `people/`     | Profile of a referenced person with key sources and relationships    |
| Summary    | `summary/`    | Area-level synthesis spanning multiple sources and concepts          |
| Reading note | `readings/` | Per-chapter notes for a long source, page-cited; written during long-source ingest |
{{#if pack_research}}| Topic      | `topics/`     | Thematic cluster grouping related concepts and sources; created via `/lumi-research-topic` (research). Ends with a dated list of sources that arrived after the topic was last refreshed |
| Foundation | `foundations/`| Prerequisite/background knowledge; terminal page (research)          |
{{/if}}{{#if pack_reading}}| Chapter    | `chapters/`   | Per-chapter notes for a book or long-form work (reading)             |
| Character  | `characters/` | Character profile with arcs, relationships, key chapters (reading)   |
| Theme      | `themes/`     | Thematic thread traced across the work (reading)                     |
| Plot       | `plot/`       | Plot threads, beats, and timeline (reading)                          |
{{/if}}{{#if pack_learning}}| Reflection | `reflections/`| Personal understanding of a concept; rewritable + append-only log (learning) |
{{/if}}

---

## Link Syntax

All internal links use Obsidian wikilinks:

```markdown
[[slug]]                     — link to any page in this wiki
[[chain-of-thought]]         — links to concepts/chain-of-thought.md
[[1984-orwell]]              — links to sources/1984-orwell.md
```

**Slug rule**: lowercase, hyphen-separated, no spaces, no diacritics.

---

## Cross-Reference Rules (Bidirectional Links)

When you write a forward link, **always write the reverse link in the same operation**. This is the heart of why the wiki compounds. Skipping it leaves the graph half-built.

| Forward action                              | Required reverse action                    |
|---------------------------------------------|---------------------------------------------|
| `sources/A` writes `Related: [[concept-B]]` | `concepts/B` appends A to `Key sources`    |
| `sources/A` writes `[[person-C]]`           | `people/C` appends A to `Key sources`      |
| `concepts/K` writes `[[source-E]]`          | `sources/E` appends K to `Related concepts`|
| `summary/S` writes `[[concept-K]]`          | `concepts/K` appends S to `Mentioned in`   |
{{#if pack_research}}| `topics/T` writes `[[concept-K]]`           | `concepts/K` appends T to `Topics`         |
| `topics/T` writes `[[source-A]]`            | `sources/A` appends T to `Topics`          |
{{/if}}{{#if pack_reading}}| `chapters/Ch` writes `[[character-X]]`      | `characters/X` appends Ch to `Key chapters`|
| `chapters/Ch` writes `[[theme-Y]]`          | `themes/Y` appends Ch to `Traced in`       |
{{/if}}

### Exemptions (mode: `exempt-only`, default)

Some links are intentionally one-way. Defaults:

{{#if pack_research}}- **`foundations/**`** — terminal pages
{{/if}}- **`outputs/**`** — ephemeral artifacts
- **External URLs** (`*://*`) — out of wiki scope
{{#if pack_learning}}- **`reflections/**`** — personal overlay; never requires reverse links from academic pages
{{/if}}

Anything outside an exemption glob must be bidirectional.

---

## Log Format

Append-only. One line per skill invocation. Format:

```markdown
## [YYYY-MM-DD] skill | details
```

`grep "^## \[" wiki/log.md | tail -10` gives you recent activity.

---

## Graph

`wiki/graph/edges.jsonl` and `wiki/graph/citations.jsonl` are auto-generated. Never edit manually. The full set of edge types lives in `_lumina/scripts/schemas.mjs` — open it when you need to pick a type or check what is allowed.

---

## Constraints (Non-Negotiable)

- **`raw/` is user-owned**: never modify or delete existing files; additions only via the two named paths above.
- **`graph/` is auto-generated**: only modify via the graph rebuild step.
- **Bidirectional links are mandatory**: forward link and reverse link in the same operation.
- **`index.md` updated on every ingest**: every new page must be cataloged immediately.
- **`log.md` is append-only**: never rewrite history.
- **Skill flags are user-owned**: never invent, flip, or drop a flag based on repo state alone. If the user omitted a parameter, only fill it in when the skill explicitly documents a default; otherwise ask.
- **No silent overwrites**: preserve sections marked with `<!-- user-edited -->` comment.
- **Cite when uncertain**: link the source explicitly for low-confidence claims.

---

## Skills

Skills live in `.agents/skills/` and are invoked via slash commands. Active install recorded in `_lumina/manifest.json`.

### Core skills (always present)

| Skill         | Trigger        | What it does                                          |
|---------------|---------------|-------------------------------------------------------|
| `/lumi-init`   | manual, first  | Bootstrap wiki from existing `raw/` content          |
| `/lumi-ingest` | manual         | Read a source and write a wiki page. It asks you to review the draft, then continues on its own unless something needs your judgment |
| `/lumi-ask`    | manual         | Answer from what the wiki already knows, citing the source pages; if something's missing, lists matching raw/sources/ files and suggests /lumi-ingest; optionally files the answer as a page |
| `/lumi-edit`   | manual         | Add/remove/revise wiki content per user request       |
| `/lumi-check`  | manual/weekly  | Lint: broken links, orphans, missing reverse links    |
| `/lumi-reset`  | manual         | Scoped destructive cleanup                            |
| `/lumi-verify` | manual         | Check that wiki pages match the sources they cite; reports suspicious statements for the user to review; never auto-edits                            |
| `/lumi-help`   | manual         | Read workspace state and recommend the single next action; offer to run it. Argument `skills`/`catalog`/`list` (or a "what's available" question) switches to catalog mode and renders `_lumina/schema/lumi-help.csv` grouped by pack. |

{{#if pack_research}}### Pack: research

Adds `/lumi-research-discover` (ranked candidate shortlist), `/lumi-research-watchlist` (choose topics for scheduled discovery with AI help), `/lumi-research-watch-run` (run one scheduled-discovery pass over the watchlist — topics + RSS / Atom feeds — only when you ask), `/lumi-research-survey` (narrative synthesis), `/lumi-research-prefill` (seed foundations/ to prevent concept duplication), `/lumi-research-topic` (cluster existing concepts and sources into a thematic topic page; AI proposes the cluster from the graph, you confirm before anything is written), `/lumi-research-rank` (score an already-ingested paper's citation influence and 4C quality, recorded on its source page; optional Scite/Altmetric signals when keys are set), `/lumi-research-setup` (interactive API key configuration).
{{/if}}
{{#if pack_reading}}### Pack: reading

Adds `/lumi-reading-chapter-ingest` (file a chapter, update characters/themes/plot pages), `/lumi-reading-character-track` (build or refresh a character profile across chapters), `/lumi-reading-theme-map` (trace a theme across chapters with citations), `/lumi-reading-plot-recap` (summarize plot up to a chapter, spoiler-bounded).
{{/if}}
{{#if pack_learning}}### Pack: learning

Adds `/lumi-learning-reflect` (guide a self-reflection session; creates or updates a personal `wiki/reflections/` page with a rewritable `## Current understanding` section and an append-only `## Evolution` log; AI acts as a metacognitive mirror — quotes your past words and asks questions — but never writes reflection content for you).
{{/if}}

---

## Tooling Conventions

- **`_lumina/scripts/lint.mjs`** — pure-Node markdown linter, runs offline.
- **`_lumina/scripts/wiki.mjs`** — wiki engine (frontmatter, graph mutation, slug, log).
- **`_lumina/scripts/reset.mjs`** — scoped destructive reset.
{{#if pack_research}}- **`_lumina/scripts/discover-runner.mjs`** — one-shot scheduled discovery runner; collects scored candidates but does not ingest or download papers.
{{/if}}
- **`_lumina/tools/extract_pdf.py`** — PDF text extractor (pypdf-based); used by `/lumi-ingest` and `/lumi-reading-chapter-ingest` when the host IDE cannot read PDFs natively.
- **`_lumina/tools/verify_quotes.py`** — checks page-cited quotes in reading notes and source pages against the source PDF; used by `/lumi-ingest` for long sources.
- **`_lumina/tools/fetch_pdf.py`** — URL → `raw/download/<resource>/` PDF downloader (streaming, atomic, idempotent); used by `/lumi-ingest` Mode B when the input is a URL or paper identifier.
- **`_lumina/tools/requirements.txt`** — Python dependencies for bundled tools. Run `pip install -r _lumina/tools/requirements.txt` when a tool reports a missing package.
{{#if pack_research}}- **`_lumina/tools/_env.py`** — shared `.env` loader for research tools.
- **`_lumina/tools/prepare_source.py`** — normalizes local source files into tool-readable JSON.
- **`_lumina/tools/init_discovery.py`** — checkpointed discovery workflow; writes only under `raw/discovered/` and `_lumina/_state/`.
- **`_lumina/tools/discover.py`** — ranks fetched candidates for `/lumi-research-discover`.
- **`_lumina/tools/fetch_*.py`** — research fetchers for arXiv, Wikipedia, Semantic Scholar, and DeepXiv.
{{/if}}

---

## How To Use This Wiki (For New LLM Sessions)

1. Read this file (you are doing it now).
2. Read `wiki/index.md` to learn what already exists.
3. Read `wiki/log.md`'s last 20 entries to learn what happened recently.
4. When the user invokes a skill, read the skill's `SKILL.md` first.
5. When in doubt about page structure, open `_lumina/schema/page-templates.md`.
6. When in doubt about scope, ask the user — never silently expand it.

The wiki is a long-running collaboration. Maintain it patiently.

<!-- /lumina:schema -->
