Skip to content

Project Structure ​

ContextWeaver source code lives in src/, and tests live in tests/.

text
src/
├── index.ts
├── config.ts
├── defaultEnv.ts
├── api/
├── chunking/
├── cli/
├── db/
├── indexer/
├── mcp/
├── scanner/
├── search/
├── stats/
├── utils/
└── vectorStore/

Top-level entrypoints ​

FileDescription
src/index.tsCLI entrypoint and command registration
src/config.tsEnvironment variables, API config, ignore rules
src/defaultEnv.tsDefault .env template generated by contextweaver init

api ​

text
src/api/
├── embedding.ts
└── reranker.ts

Wraps external model APIs. This layer handles request shape, error responses, retries, and compatibility with different provider response formats.

scanner ​

text
src/scanner/
├── crawler.ts
├── filter.ts
├── hash.ts
├── index.ts
├── language.ts
├── processor.ts
└── watcher.ts

Finds files, filters them, reads content, detects language, computes hashes, and coordinates watch-mode incremental scans.

chunking ​

text
src/chunking/
├── LanguageSpec.ts
├── ParserPool.ts
├── SemanticSplitter.ts
├── SourceAdapter.ts
└── types.ts

Handles Tree-sitter AST chunking, language specifications, parser reuse, and offset normalization.

indexer / db / vectorStore ​

text
src/indexer/index.ts
src/db/index.ts
src/db/bootstrap.ts
src/vectorStore/index.ts

This is the indexing write core:

  • indexer orchestrates embeddings and cross-store writes
  • db manages SQLite schema, FTS, metadata, stats, and pending marks
  • bootstrap handles migrations and pending mark replay
  • vectorStore wraps pure LanceDB vector operations
text
src/search/
├── SearchService.ts
├── GraphExpander.ts
├── ContextPacker.ts
├── ChunkContentLoader.ts
├── QueryCache.ts
├── fts.ts
├── config.ts
├── loadConfig.ts
├── resolvers/
└── types.ts

The search layer includes hybrid recall, RRF, rerank, Smart TopK, context expansion, and token-aware packing.

mcp ​

text
src/mcp/
├── server.ts
├── main.ts
└── tools/

MCP tools are implemented in src/mcp/tools/. Each tool usually has an independent handler so CLI mirrors can reuse the same logic.

tests ​

text
tests/
├── chunking/
├── cli/
├── db/
├── indexer/
├── integration/
├── mcp/
├── scanner/
├── search/
├── stats/
└── vectorStore/

The test tree mirrors the source modules. Add new tests under the module-specific directory whenever possible.

Released under the MIT License.