Every Attachment Is Now Indexed, Once
Attachments were always on disk, sealed inside their emails. Now each one is listed by type, size, and hash, with every message it arrived on, and an agent can ask for the file.
Why Care?
"Find the deck Acme sent in March" used to mean searching for a filename and hoping. Now kay-os knows every attachment as a thing of its own: what it is, how big, which messages carried it, and where to get the file. This is Phase 1 of Attachments-as-First-Class-Mail, and the base for reading what's inside them next.
What's New?
An attachment index inside the existing
index.sqlite: one row per unique file (by SHA-256 of its bytes) and one row per message it arrived on. A deck forwarded ten times is one file seen on ten messages.Five kinds: document, calendar, image, archive, other. Calendar invites get their own kind because they're structured meeting data, not prose.
Noise sorted out. Signature logos, icons, and tracking pixels are marked and left out of listings unless asked for.
New commands:
kaymail.py attachmentsto list and filter (by sender, type, kind, date, or message),--backfillto index mail synced before today, andkaymail.py attachment <id>to see where a file came from, save it, or get a local copy's path.Two new MCP tools,
list_attachmentsandget_attachment, andread_messagenow returns a message's attachments as a list.The index file is owner-only now. It was readable by other users on the machine, which the README already said it shouldn't be.
How it Works
Sync indexes each new message's attachments as it stores it. The backfill does
the same for older mail, reading each .eml from disk with no network. It
remembers which messages it has scanned, so it can be stopped and rerun.
No file is copied anywhere. The original email stays the only copy, and a file is decoded from it on request into a local cache that's safe to delete. The decoded bytes are checked against the stored hash every time.
Filenames come from senders, so saving a file reduces its name to a plain name
inside the chosen folder. A name like ../../etc/x.pdf can't write outside
it.
Measured on michael@humain.vc
The backfill scanned all 713 messages in about 2.5 seconds and found 287 attachment parts: 71 documents (89 MB), 71 calendar invites, 15 images, 2 archives, and 18 noise images. Decoding a 4 MB PDF back out of its email matched its hash.
What's Next
Run the backfill over the two large archives (about 440,000 messages). Then Phase 2: Docling extraction to Markdown, the calendar parser, and Ghostscript reading copies.