open-context-engine-skill

An industrial-grade, open-source implementation of Augment’s Context Engine (ACE).

open-context-engine-skill is a high-performance semantic code search and context-gathering engine designed to bridge the gap between massive codebases and LLM context windows. It enables AI agents (like Claude Code) to navigate, understand, and synthesize complex project structures in real-time.


🚀 Key Features

  • Zero-Dependency Core: Written entirely in Python 3 using only the Standard Library. No pip install required—maximum portability for any environment.
  • Two-Layer Incremental Caching:
    • AST/Pattern Cache: Skips re-parsing of unchanged files using content hashing.
    • Semantic Score Cache: Persistent SQLite-based storage (.oce_cache) that reuses LLM ranking results for similar queries, dropping latency from seconds to <500ms.
  • Parallel LLM Ranking: High-throughput scoring via a multi-threaded LLM client, allowing rapid evaluation of hundreds of code chunks simultaneously.
  • Multi-Language Intelligence:
    • Python: Deep AST-based extraction.
    • Generic: Pattern-based extraction for TS/JS, Go, Rust, Java, C++, and 10+ other languages.
  • Git-Aware Filtering: Automatically respects .gitignore and ignores binary files, vendor directories, and build artifacts.
  • Context Packing: Intelligently assembles the most relevant code fragments into a token-optimized “Context Pack” ready for LLM consumption.

🛠 Installation

  1. Clone the repository:

    git clone https://github.com/your-username/open-context-engine-skill.git
    cd open-context-engine-skill
    
  2. Configure API Access:
    Create a config file at open-context-engine-skill/.config/open-context-engine/config.json:

    {
      "api_url": "https://api.openai.com/v1",
      "api_key": "your-api-key",
      "model": "gpt-oss-120b",
      "max_tokens": 8000
    }
    

📖 Usage

Command Line Interface

Run a semantic search against any project:

python scripts/search_context.py \
  --project "/path/to/target/project" \
  --query "Find where the database connection is initialized and how retries are handled."

Integration with AI Tools (Claude Code)

This engine is designed to be used as a Skill. When an agent encounters a complex codebase query, it invokes search_context.py to retrieve the most relevant logic:

  1. [search-mode]: Exhaustive search across the codebase using parallel agents and AST-aware tools.
  2. [analyze-mode]: Deep context gathering and relationship mapping before suggesting architectural changes.

🏗 Architecture

The engine follows a strictly optimized pipeline:

  1. File Collector: Scans the project, applying Git rules and detecting binary files.
  2. Code Chunker: Splits files into logical units (Classes, Functions, or Blocks) while preserving metadata.
  3. Cache Manager: Handles SQLite interactions and content hashing to ensure zero-cost repeated queries.
  4. Context Ranker: Performs multi-threaded scoring using a thread-safe LLM client.
  5. Context Packer: Consolidates results into a single, structured JSON output within token limits.

🛡 Performance

Project Size Cold Search (Initial) Hot Search (Cached)
Small (<100 files) ~20-40ms ~15ms
Medium (~500 files) ~80-120ms ~35ms
Large (>1000 files) ~1s+ ~35ms

Logo

小龙虾开发者社区是 CSDN 旗下专注 OpenClaw 生态的官方阵地,聚焦技能开发、插件实践与部署教程,为开发者提供可直接落地的方案、工具与交流平台,助力高效构建与落地 AI 应用

更多推荐