-
Notifications
You must be signed in to change notification settings - Fork 0
How it works
Meyverick edited this page Jun 23, 2026
·
2 revisions
When you run omnicode, the entrypoint at src/bin/omnicode.js:
- Verifies
opencode,omnirouteare onPATH. - Resolves the session launch mode from the OpenCode SQLite DB.
- Calls the Node.js runtime module (
src/bin/omnicode-runtime.js).
The runtime then:
- Initializes GrayMatter and OpenSpec quietly (logs to
~/.local/share/omnicode/). - Starts
omniroute --no-openin the background, or reuses an existing instance. - Starts a Qdrant Docker container (
qdrant/qdrant) for vector storage, if Docker is available. - Configures the Qdrant MCP server in
opencode.jsoncwith inline environment variables. - Launches OpenCode with the resolved session argument.
- Begins background indexing of
./references/using an async file walker with per-file read and chunking. - On OpenCode exit, stops the Qdrant container and cleans up OmniRoute if no other sessions remain.
The indexing flow in src/installer/lib.js:
-
walkReferencesAsync()— async generator that recursively walks./references/usingfsPromises.readdir/stat. Skips hidden files andnode_modules. -
chunkFile()/ MinerU / tree-sitter — splits files into chunks. Markdown uses heading-based splitting. PDFs/images use MinerU OCR. Code files use tree-sitter AST-based structural chunking. -
Batch processing — files are processed in batches of 100 to limit memory. Each batch is sent to Qdrant via
callQdrantStore(). -
callQdrantStore()— sends chunks as JSON-RPCtools/callrequests tomcp-server-qdrant, which embeds them via FastEmbed and stores in Qdrant. -
State tracking —
index.jsontracks file mtimes per batch. State is saved atomically (write to.tmp, rename).
- Stale Qdrant
.lockfiles and WAL journals are cleaned before MCP startup. - Ctrl+C during indexing sets a
cancelledflag, stops the MCP server, and saves partial state. -
--force-reindexwipes the.qdrant/directory and all state before re-indexing.
OmniRoute is started as a detached Node.js child process.
- Logs and PID files:
~/.local/share/omnicode/. - If OmniRoute is already running, the existing process is reused.
- Only the process started by
omnicodeis stopped when OpenCode exits and no other sessions remain.
-
-s <id>→ launchesopencode -s <id>directly. -
-cor no args + existing session → reads latest session ID from OpenCode's SQLite DB. - No args + no session → launches
opencodewith no session flag.