| name | add-to-corpus |
| description | Add new knowledge to the twin. Use when the user says "/add-to-corpus", "teach my twin about X", "add this to my corpus", "index this file/url", or hands you a document, link, or block of text they want the AI portfolio to know. Places the material into content/ and re-indexes it for the configured retrieval backend (local vectors by default, or Gemini File Search). |
| allowed-tools | Read Write Edit Bash(npm run ingest *) Bash(npm run embed) Bash(git status) |
Add to corpus
The twin answers from a RAG corpus stored as files in content/ and indexed
by the configured backend — local vectors by default (content/.vectors.json,
embedded via the OpenRouter key) or Gemini File Search. Your job: take
whatever the user gives you, land it as a clean file under content/, and
re-index it.
1. Identify the source
The user will provide one of:
- A file path (markdown, pdf, txt) — already on disk somewhere.
- A URL — a blog post, about page, LinkedIn export, etc.
- Raw text — pasted bio, project notes, a talk transcript.
Confirm Read twinfolio.json to learn rag.contentDir (default content) and
rag.backend. If the backend's key is missing (local needs OPENROUTER_API_KEY;
filesearch needs a Gemini key) or rag.backend is "none", tell the user the
file will be saved but not indexed until RAG is enabled (run /setup-twin
to add a key). Saving is still useful — it's there for later.
2. Land it in content/
- File already in
content/: nothing to move; note its path.
- File elsewhere: copy/convert its text into a new
content/<slug>.md (prefer markdown). For PDFs, keep the original in content/ if it's clean text; otherwise transcribe key content into a .md.
- URL: fetch/summarize the substantive content into
content/<topic>.md as first-person prose where appropriate. Keep it factual — this is grounding truth, not marketing.
- Raw text: write it to
content/<topic>.md with a short # heading.
Use a kebab-case filename that says what it is (content/2024-keynote.md,
content/side-projects.md). Keep each file focused on one subject — retrieval
works better with coherent chunks.
3. Re-index
The command depends on rag.backend:
-
local (default) — rebuild the vectors index (embeds via the OpenRouter
key):
npm run embed
-
filesearch — ingest the new/changed path into the File Search store
(the script is idempotent — it skips unchanged files by hash):
npm run ingest content/<the-file-or-dir>.md
npm run ingest content
If the command reports a missing key / store, that's the degraded path — the
file is saved and will be picked up the next time the index is built.
4. Confirm what the twin now knows
Summarize back to the user: the filename you created, a one-line description of
what's in it, and whether it was successfully indexed. Suggest they open the
chat at / (or /admin/corpus in the Studio) and ask a question that the new
material should answer, to verify grounding.