# docspack overview

docspack gives AI coding agents the documentation of the dependencies a project
actually installed. Documentation is distributed as npm packages, indexed locally into
SQLite, and served to agents over the Model Context Protocol.

## What problem docspack solves

An agent answering a question about a dependency has three bad options. It can recall the
API from training data, which is frozen at some past date. It can scrape the vendor's
website, which is slow and returns whichever version the vendor publishes today. Or it can
read the library's source, which is expensive and rarely explains intent.

All three fail the same way: the answer does not correspond to the version in
`package.json`. docspack removes that gap by treating documentation as a dependency. The
docs for `acme@1.4.0` live in a package pinned next to `acme@1.4.0`, so an agent reading
them is reading about the code that is actually installed.

## How the pieces fit together

Four moving parts:

- A **docs package** is an npm package named `@vendor/docspack`,
  `@vendor/<name>-docspack` or `@docspack-community/<name>`. It contains Markdown split
  into chunks and a manifest describing them.
- The **indexer** (`docspack sync`) reads every docs package the project depends on and
  writes its chunks into a shared SQLite database.
- The **index** is one database per machine, at `~/.docspack/store.db`. It uses SQLite's
  FTS5 extension for full-text search.
- The **query interface** is `docspack ask`, a command any agent with a shell can run.
  `docspack mcp` serves the same index over the Model Context Protocol for clients that
  prefer a declared tool; both return identical text.

Nothing in that path touches the network. After `docspack sync`, everything works offline.

## Why chunks instead of files

A library's documentation is much larger than a context window. Pointing an agent at a
folder of Markdown means it either reads the wrong file or fills its context with prose
that does not answer the question.

docspack stores documentation pre-split into chunks, each with a token count. A query
returns the few passages that match, ranked, and stops once a token budget is reached. The
default is three chunks and 3,000 tokens. The agent gets an answer, not a library.

## Why the index is global

The index lives in one database per machine rather than one per project, the same way pnpm
keeps one content-addressed store. If five projects depend on `@stripe/docspack@2025.4.1`,
the chunks are read and indexed once.

Different versions coexist. `@stripe/docspack@1.0.0` and `@stripe/docspack@2025.4.1` are
separate rows with separate chunks, and a query from a project is scoped to the versions
that project installed. A project never sees documentation for a version it does not use,
even though the database holds it for a neighbour.
