moca-index
Builds sidecar indexes in the portable
moca-jsonl-v1 format, bound to a package’s digest.
moca-index build <package> -o <out> [--zip] [--chunk node|headings] [--max-chars n [--overlap n]] [--force] [--model name [--models folder]] [--embedder module]moca-index check <sidecar> --package <package>-
--chunk nodeindexes each node representation whole;--chunk headingssplits at level 1-3 headings. Every chunk records UTF-8 byte offsets into its node file. -
--max-chars <n>then splits any chunk longer thanncharacters, in its second half at the best break: a blank line, a line end, a sentence end or a space.--overlap <n>starts each windowncharacters before the last one ended, at a word boundary (at most half of--max-chars). Use it with an embedder: a model reads only so many tokens (about 4 characters each in English), and ignores the rest of a longer chunk.index.jsonrecords the limit inchunking. -
The builder checks its own output with the Reader before finishing.
-
Keep sidecars outside the package directory.
-
--modeladds vectors with one of MOCA’s standard embedding models:bge-small-en-v1.5,nomic-embed-text-v1.5,all-MiniLM-L6-v2ormultilingual-e5-small. The index is then searched by meaning, as well as by words, by any tool that runs the same model, such as the MOCA MCP server. The model’s files are read from a store folder (--models, elseMOCA_MODELS, else~/.moca/models) and checked against their pinned SHA-256; install them withnpx @openmoca/moca-embed models add <model>(ormoca-mcp models add). The models are run by@openmoca/moca-embed. -
--embedder(experimental) loads a module whose default export is an embedder (name,version?,dimensions,queryPrefix?,documentPrefix?,embed(texts, { role })). Chunks are embedded with the roledocument, and any declared prefixes are recorded inmodelfor Readers to compare. The vectors go inpayload/vectors.f32(little-endian float32, one row per item), andindex.jsonrecords the embedder as itsmodel(indexType: hybrid). A Reader searches the vectors only with an embedder for the same model.
Without --embedder, the sidecar is lexical: text and offsets, no vectors.