# Knowledge sources

Drafts are grounded in a local index built from material you choose. The
index lives at `~/.inboxminder/index/` and never leaves your Mac; at
indexing time the text is sent once to your embedding provider to be
turned into vectors (a local embedding model keeps even that on the Mac).

## Sources

| Source | What it indexes | Where to set it up |
|---|---|---|
| **Sent mail** | Your own past replies, as the style corpus. Always on with the assistant | Automatic |
| **Folders** | Markdown, text and docs in local folders | Wizard, **Sources** editor, `[connectors.files]` |
| **Docs site** | An `llms.txt` or `llms-full.txt` your docs publish | Wizard, `[connectors.llmstxt]` |
| **GitHub** | Repositories, cloned shallowly with your own git credentials, so private repos work | `[connectors.github]` |
| **Notion** | Pages your integration token can read | **Sources** editor, `inboxminder set-key notion` |
| **Linear** | Issues your API key can read | **Sources** editor, `inboxminder set-key linear` |
| **Slack** | Channels you list, with a user token that has `channels:history` | **Sources** editor, `inboxminder set-key slack` |
| **Notes** | What you write in the window's **Your notes** | Automatic |
| **Canonical answers** | Q&A snippets in a folder, ranked above everything else | `[answers]`, see [Drafting](drafting.md#canonical-answers) |

![The sources editor in the menu bar](images/sources-editor.png)

Notion, Linear and Slack tokens are read-only uses; the only write the
app ever makes to any of these is filing a Linear issue when you ask for
one with a label.

## Indexing

The index is built when you go live, refreshed at agent startup, and
every `indexRefreshHours` (default 24) while watching. It is incremental:
each source keeps a cursor, each document a content hash, so only changed
documents are re-embedded. Notes are indexed the moment you save them.

Sent mail comes in batches of `sentBackfillLimit` (default 200) per run,
newest first, with older history backfilled one batch per run until the
mailbox is exhausted. On a large mailbox the voice corpus fills over a few
days.

Run it by hand:

```bash
inboxminder index                      # everything, incremental
inboxminder index --source files       # one connector
inboxminder index --full               # refetch everything (unchanged text is still not re-embedded)
```

Changing the embedding provider, model or dimensions needs `--full`; the
content hashes include the embedding config, so everything re-embeds.

## Excluding a document

**Knowledge** in the window, **Stop using in drafts**, or:

```bash
inboxminder knowledge docs             # find the docKey
inboxminder knowledge exclude <docKey>
inboxminder knowledge include <docKey>
```

An excluded document stays excluded through re-indexing; an included one
returns on its next pull. The same works for a single sent email from
**Voice**.

## Seeing what a draft would find

```bash
echo "how long do refunds take?" | inboxminder knowledge search --stdin
```

![The Knowledge section's look-up](images/window-knowledge-search.png)

or the search box in **Knowledge**. If the right passage does not come up,
the fix is usually a note, a canonical answer, or a better-structured
document, not a prompt change.

## Docs-gap drafting

With `[docs]` on, a customer question your indexed docs cannot answer
produces a new page or a surgical edit drafted into a local docs
repository's working tree. Nothing is committed, and files with
uncommitted changes are never touched. The question is anonymized before
the writer sees it; sender identity never reaches the page.

```toml
[docs]
enabled = true
repoPath = "~/code/docs"
sources = ["llmstxt"]     # which indexed sources count as "your docs"
instructions = "Use our MDX components; second person; never document internal tooling."
```

`docs.instructions` (**Preferences → Features → Docs**) steers voice,
structure and topics to leave out; it cannot make a page invent facts, and
gaps still get a `[TODO: …]`. Drafted pages appear in **Written for you**
with an open-in-Finder link, and in `inboxminder written list`.
