|
| 1 | +# AGENTS.md — Thesis Agent Schema |
| 2 | + |
| 3 | +This file is loaded into the main agent's system prompt on every run. It defines how to organise knowledge, write the thesis, and stay grounded. Follow it exactly. |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## Three layers |
| 8 | + |
| 9 | +1. **`research/raw/`** — immutable source material (PDFs, DOCX, EPUB, MD, URLs). Never edit these. The `thesis ingest` CLI command normalises each file to `research/raw/<filename>.md` (same stem as the original) and records it in `research/raw/_index.json` with `status: pending`. |
| 10 | +2. **`research/wiki/`** — LLM-compiled knowledge. **One wiki page per source file**, named `research/wiki/<filename>.md` (matching the raw file's stem). Plus `research/wiki/index.md` which groups pages by topic/tag. |
| 11 | +3. **This file (`AGENTS.md`)** — the schema that turns the raw layer into the wiki layer, and the wiki layer into grounded thesis prose. |
| 12 | + |
| 13 | +The wiki is the index. **There is no vector search, no embeddings, no RAG.** To find information you navigate `research/wiki/index.md` → entity pages → drill into the raw file only if the wiki page is insufficient. Use `read_file`, `glob`, and `grep` — nothing else. |
| 14 | + |
| 15 | +--- |
| 16 | + |
| 17 | +## Wiki page template |
| 18 | + |
| 19 | +Every file under `research/wiki/<name>.md` (except `index.md`) must follow this template exactly. Use the raw source's stem as the filename. |
| 20 | + |
| 21 | +```markdown |
| 22 | +--- |
| 23 | +source: <raw_filename_with_ext> |
| 24 | +title: <best-effort title from the source; filename if unknown> |
| 25 | +authors: [<author1>, <author2>] # empty list if unknown |
| 26 | +date: <YYYY or YYYY-MM-DD if known; "unknown" otherwise> |
| 27 | +tags: [<topic1>, <topic2>, ...] # 3-8 short lowercase tags |
| 28 | +--- |
| 29 | + |
| 30 | +# <title> |
| 31 | + |
| 32 | +## Summary |
| 33 | +3–5 sentences capturing the source's thesis / core contribution / relevance. Every sentence must be supported by the source. Inline-cite with `[src:<raw_filename>]`. |
| 34 | + |
| 35 | +## Key claims |
| 36 | +- Claim 1. [src:<raw_filename>] |
| 37 | +- Claim 2. [src:<raw_filename>] |
| 38 | +- ... |
| 39 | +(5–15 bullet points. Each bullet is a discrete factual claim quotable in the thesis.) |
| 40 | + |
| 41 | +## Methods / datasets |
| 42 | +- <method or dataset name>: <one-line description>. [src:<raw_filename>] |
| 43 | +(Omit this section if the source is not empirical.) |
| 44 | + |
| 45 | +## Key terms |
| 46 | +- <term>: <one-line definition as used in this source>. [src:<raw_filename>] |
| 47 | + |
| 48 | +## See also |
| 49 | +- [[<other_source_stem>]] — <one-line reason for the link> |
| 50 | +(Cross-references to other wiki pages. Add reciprocally on the other page.) |
| 51 | + |
| 52 | +## Conflicts |
| 53 | +- ⚠ conflicts with [[<other_source_stem>]] on <claim topic> |
| 54 | +(Flag only — do NOT quote both sides, do NOT merge. User resolves manually.) |
| 55 | +``` |
| 56 | + |
| 57 | +--- |
| 58 | + |
| 59 | +## Citation format |
| 60 | + |
| 61 | +Any factual claim — in a wiki page, in a thesis chapter, in chat — must carry `[src:<raw_filename>]` where `<raw_filename>` is the name (with extension) of the file in `research/raw/`. Example: `[src:attention-is-all-you-need.pdf]`. |
| 62 | + |
| 63 | +Never invent a citation. If no source supports a claim, reply: **"no grounding in indexed sources — add material or remove claim."** Do not use pretraining knowledge. Do not use web search (you have no web tools anyway). |
| 64 | + |
| 65 | +--- |
| 66 | + |
| 67 | +## Workflows |
| 68 | + |
| 69 | +### Ingest (user-initiated via `thesis ingest`) |
| 70 | +1. The CLI runs `thesis_agent.ingest` — pure Python, no agent involvement. You do not run this. |
| 71 | +2. After it finishes, new entries appear in `research/raw/_index.json` with `status: pending`. |
| 72 | + |
| 73 | +### Curate (agent — triggered by `thesis curate` or user request) |
| 74 | +1. Read `research/raw/_index.json`. Collect entries where `status == "pending"`. |
| 75 | +2. For each pending entry, delegate to the `wiki-curator` subagent with the raw filename. The subagent: |
| 76 | + - Reads `research/raw/<name>.md`. |
| 77 | + - Produces `research/wiki/<name>.md` following the template above. |
| 78 | + - Updates `research/wiki/index.md` to list the new page under the right topic cluster. |
| 79 | + - Flips `status` to `curated` in `_index.json`. |
| 80 | +3. When all pending entries are processed, report a one-line summary: `curated N sources; M conflicts flagged`. |
| 81 | + |
| 82 | +### Write (user-initiated via `thesis write <section>` or chat) |
| 83 | +1. Read `style/STYLE.md`. If missing, stop and tell the user to run `thesis style` first. |
| 84 | +2. Read `research/wiki/index.md`. Identify wiki pages relevant to the requested section. |
| 85 | +3. Read those wiki pages. |
| 86 | +4. For any claim you plan to make, verify it appears in a wiki page's "Key claims" or can be read out of the raw file. Drill into `research/raw/<file>.md` only when the wiki page is insufficient. |
| 87 | +5. Delegate drafting to the `drafter` subagent. The drafter writes to `thesis/chapters/<NN>.md` (matching the outline numbering in `thesis/outline.md`). |
| 88 | +6. Every paragraph must contain at least one `[src:...]` citation. Paragraphs with no citable claim (transitions, meta-prose) are allowed but must not make factual statements. |
| 89 | + |
| 90 | +### Lint (agent — triggered by `thesis lint` or user request) |
| 91 | +1. Read the target chapter file. |
| 92 | +2. For every `[src:<name>]` citation, verify `research/raw/<name>` exists and `research/wiki/<name>.md` exists with `status: curated`. |
| 93 | +3. Flag paragraphs that make factual claims without any citation. |
| 94 | +4. Output a short report: file, line, issue, suggested fix. Do not auto-edit unless asked. |
| 95 | + |
| 96 | +### Style learning (agent — triggered by `thesis style`) |
| 97 | +1. Read every file in `style/samples/`. |
| 98 | +2. Produce/update `style/STYLE.md` with sections: Voice, Sentence rhythm, Lexicon (jargon density, hedging words, favoured transitions), POV and tense, Citation placement habits, Structural patterns (how the user opens/closes sections). |
| 99 | +3. Be specific and prescriptive (e.g., "average sentence length 22–28 words; avoid sentences under 10 words except in conclusions"). The drafter will follow this verbatim. |
| 100 | + |
| 101 | +--- |
| 102 | + |
| 103 | +## Write scopes (enforced by the sandbox middleware — do not attempt violations) |
| 104 | + |
| 105 | +- `researcher` subagent: **read-only**. Cannot write anywhere. |
| 106 | +- `wiki-curator` subagent: may write only to `research/wiki/**` and update `research/raw/_index.json`. |
| 107 | +- `drafter` subagent: may write only to `thesis/**`. |
| 108 | +- The main agent: may write to `research/wiki/index.md`, `style/STYLE.md`, and the user's explicit targets. Never write to `research/raw/` (sources are immutable). Never write to `data/` (reserved for memory databases). |
| 109 | +- No tool can reach outside the project workspace. |
| 110 | + |
| 111 | +--- |
| 112 | + |
| 113 | +## Hard rules (non-negotiable) |
| 114 | + |
| 115 | +1. **Every factual claim** in `research/wiki/**` and `thesis/**` has a `[src:...]` citation. |
| 116 | +2. **Never fabricate** sources, quotes, author names, dates, or statistics. |
| 117 | +3. **Never write** to `research/raw/` or `data/`. |
| 118 | +4. **Always read** `style/STYLE.md` before any `thesis/**` write. |
| 119 | +5. **Contradictions are flagged, not resolved.** Add `⚠ conflicts with [[other]]` on both pages; move on. |
| 120 | +6. When the wiki has no answer, say so. Do not fill the gap from memory. |
0 commit comments