octocode
AGENTS.md480 starsChanged 3 months agoApache-2.0View on GitHub
Rust CLI (v0.26.x) that indexes codebases into LanceDB vector stores, builds GraphRAG knowledge graphs, and serves AI assistants over MCP (stdin or HTTP). Stack: Rust + tokio + LanceDB + tree-sitter + octolib. All embedding/LLM/reranker providers live in octolib — never in this repo.
- Reads credentials
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
The file
We split this AGENTS.md into the rules it gives an agent
6 rules. About 0 are common, 0 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 9
Run: cargo run -- index · RUST_LOG=debug cargo run -- search "query" · cargo run -- mcp --path .
- Very specific: line 38
Every .rs file starts with the Apache 2.0 header (// Copyright <year> Muvon Un Limited + license block).
- Very specific: line 69
Call octolib APIs directly from commands — go through src/embedding/mod.rs / src/llm/mod.rs
- Very specific: line 72
Use --release during development
- Very specific: line 73
Commit .rs files without the Apache header · commit .env or .mcpregistry_* token files
- Very specific: line 74
Add a config field without a matching entry in config-templates/default.toml
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Octocode — AGENTS.md
Rust CLI (v0.26.x) that indexes codebases into LanceDB vector stores, builds GraphRAG knowledge graphs, and serves AI assistants over MCP (stdin or HTTP). Stack: Rust + tokio + LanceDB + tree-sitter + octolib. All embedding/LLM/reranker providers live in octolib — never in this repo.
Commands
- Setup:
make setup(clippy, rustfmt, cross-targets) ·pre-commit install(fmt/clippy/check hooks) ·protocrequired for full-feature builds - Fast dev build — skips local ONNX model compilation:
cargo build --no-default-features· Full:cargo build - Run:
cargo run -- index·RUST_LOG=debug cargo run -- search "query"·cargo run -- mcp --path .(add--bind 0.0.0.0:12345,--with-lsp rust-analyzer, or--multi/--autofor multi-repo) - Fast checks:
cargo check --no-default-features --message-format=short·cargo clippy --no-default-features - Single test:
cargo test --all-features indexer::graphrag::builder_tests::<name> - Full local gate:
make ci-quick(fmt--check+ clippy-D warnings+cargo test)
Where to look
| Task | Start here |
| Add CLI command | src/commands/{cmd}.rs + mod/pub use in src/commands/mod.rs + variant in main.rs; dispatch lives in TWO places — early return before Store::new() if the command needs no store, else the final match (storeless arms there are unreachable!()) |
| Add/change config | config-templates/default.toml (single source of truth; embedded) + struct in src/config.rs + src/config/migrations.rs for versioned migrations |
| Add language | src/indexer/languages/{lang}.rs + sibling {lang}_test.rs + register in get_language() in languages/mod.rs + tree-sitter crate in Cargo.toml |
| Add MCP tool | src/mcp/server.rs (router) — existing providers: semantic_code.rs, structural.rs, graphrag.rs, lsp/provider.rs, multi.rs |
| Search relevance | src/indexer/search.rs pipeline → src/reranker.rs → src/reasoning.rs (LLM re-rank) → src/store/weighted_rrf.rs (fusion) |
| Structural search | engine: src/grep.rs (ast-grep) · CLI: src/commands/grep.rs |
| GraphRAG | src/indexer/graphrag/ (builder.rs, symbols.rs, ai.rs, relationships.rs, runtime.rs) · storage: src/store/graphrag.rs · CLI: src/commands/graphrag.rs |
| Store internals | src/store/mod.rs (block types: code/text/document/commit) · table_ops.rs · batch_converter.rs · auto index tuning: vector_optimizer.rs |
| Branch delta indexes | src/indexer/branch.rs + src/commands/branch.rs |
| Commit history indexing | src/indexer/commits/ + src/indexer/git_utils.rs |
| Markdown/docs indexing | src/indexer/markdown_processor.rs |
| AI commit/review/release | src/commands/{commit,review,release}.rs — git-heavy, shell out to git |
| EditorConfig formatter | src/commands/format/ |
| Paths, locks, state | src/storage.rs (per-project hash dir) · src/lock.rs (stale-lock detection) · src/state.rs |
| Embedding/LLM calls | only via wrappers src/embedding/mod.rs and src/llm/mod.rs |
Conventions
- Tests live in sibling files:
foo_tests.rs(languages:foo_test.rs), declared#[cfg(test)] mod foo_tests;— coverage excludes them by(_tests?\.rs|/tests\.rs)$ - rustfmt
hard_tabs = true— tabs, never spaces, in.rs - Every
.rsfile starts with the Apache 2.0 header (// Copyright <year> Muvon Un Limited+ license block); bump the year when modifying - Models are always
"provider:model"(e.g.voyage:voyage-code-3,openrouter:openai/gpt-4o-mini) Config::default()loads the embedded template — keepDefaultimpls andconfig-templates/default.tomlin sync; never introduce a third value elsewhere- MCP server code never uses
println!/eprintln!— stdout is the protocol; log files-only viasrc/mcp/logging.rs - MCP tool failures return a
CallToolResultwithis_error = true, neverErr(seesrc/mcp/server.rs) - Gate
fastembed/huggingfacecode behind#[cfg(feature = "...")]with anErr(...)fallback for the off case - Async-first tokio;
#[derive(Clone)]for structs shared across async contexts; no.unwrap()outside tests - One codebase for Linux/macOS/Windows — CI tests all three plus musl static builds; no platform-specific forks
Done
cargo fmt --all -- --checkcargo clippy --all-targets --all-features -- -D warningscargo check --all-targets --all-featurescargo test --all-features
Gotchas
--no-default-featuresis the fast dev loop; CI and the Done gate run--all-features(local ONNX models, needsprotoc)- Linux full builds need
ORT_LIB_LOCATIONpointing at a static ONNX Runtime; Windows needsRUSTFLAGS=-C target-feature=-crt-static(see.github/workflows/ci.yml) timeis pinned=0.3.47(E0119 vs tantivy-common) andesaxx-rsis a SHA-pinned[patch.crates-io]fork (MSVC /MT vs /MD) — both look like cruft but are load-bearing- Index data lives outside the repo (
~/.local/share/octocode/<project-hash>/); changing embedding dimensions auto-drops tables and wipes the index index.require_git = trueby default — indexing non-git dirs fails;mcp --no-gitopts out- File walking respects
.gitignoreAND.noindex - The MCP server serves the existing index read-only unless
index.mcp_index = true - In TOML config files, scalars must precede nested table headers (e.g.
[search.reranker]) or they are silently ignored - Remote AI features need provider API keys (
OPENROUTER_API_KEY,VOYAGE_API_KEY, …);.envis auto-loaded
Never
- Implement embedding/LLM/reranker providers here — they belong in
octolib - Call
octolibAPIs directly from commands — go throughsrc/embedding/mod.rs/src/llm/mod.rs - Open LanceDB tables or create vector indexes manually; hardcode dimensions, partitions, or nprobes —
Store+vector_optimizer.rsown this - Print to stdout/stderr in MCP server code
- Use
--releaseduring development - Commit
.rsfiles without the Apache header · commit.envor.mcpregistry_*token files - Add a config field without a matching entry in
config-templates/default.toml
References
doc/ARCHITECTURE.md— module boundaries; read before cross-cutting changesdoc/CONFIGURATION.md— every option ·doc/COMMANDS.md— full CLI surfacedoc/MCP_INTEGRATION.md/doc/MCP_CLIENTS.md/doc/LSP_INTEGRATION.md— server modes, clients, LSP toolsdoc/RELEASE_MANAGEMENT.md— before touchingsrc/commands/release.rsor publishing (make release,make git-tag)doc/API_KEYS.md— provider keys ·benchmark/— retrieval benchmark (matrix runner, ground truth)
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

