ContextWeaver  by hsingjui

Code context engine for AI agents

Created 3 months ago
256 stars

Top 98.5% on SourcePulse

GitHubView on GitHub
Project Summary

ContextWeaver addresses the challenge of providing AI agents with precise, contextually rich code snippets from local repositories. It targets AI code assistants and developers building LLM-powered coding tools, enabling deeper code understanding and more effective AI-driven development through advanced semantic retrieval.

How It Works

ContextWeaver employs a hybrid search engine combining vector (semantic) and lexical (FTS) retrieval, fused via Reciprocal Rank Fusion (RRF). Code is semantically split using Tree-sitter AST parsing for supported languages (TS, JS, Python, Go, Java, Rust), with a fallback for others. A three-stage context expansion strategy (neighbor, breadcrumb, import) enriches retrieved snippets before token-aware packing and truncation.

Quick Start & Requirements

  • Installation: Global installation via npm/pnpm (npm install -g @hsingjui/contextweaver or pnpm add -g @hsingjui/contextweaver).
  • Prerequisites: Node.js >= 20. Requires configuration of external Embedding and Reranker API keys and endpoints in ~/.contextweaver/.env after running contextweaver init.
  • Usage: Indexing is initiated with contextweaver index [/path/to/repo]. Semantic search is performed via cw search --information-request "...". MCP server activation uses contextweaver mcp.

Highlighted Details

  • Hybrid search (vector + FTS) with RRF fusion for robust retrieval.
  • AST-based semantic code splitting via Tree-sitter for 6 primary languages.
  • Multi-stage context expansion (neighbor, breadcrumb, import) for comprehensive context.
  • Native MCP server support for seamless AI agent integration.
  • Smart TopK truncation strategy optimizes context length while ensuring recall.

Maintenance & Community

The provided README does not detail specific contributors, community channels (e.g., Discord/Slack), or roadmap links.

Licensing & Compatibility

Distributed under the permissive MIT License, suitable for commercial use and integration into closed-source projects.

Limitations & Caveats

Relies on external API keys for embedding and reranking, necessitating setup and potential costs. Unsupported languages use a less precise line-based fallback splitting mechanism.

Health Check
Last Commit

1 month ago

Responsiveness

Inactive

Pull Requests (30d)
1
Issues (30d)
2
Star History
56 stars in the last 30 days

Explore Similar Projects

Feedback? Help us improve.