Skip to main content

Civyk Repo Index - Codebase indexing service for AI coding agents

Project description

Civyk Repo Index

Python 3.11+ License: MIT MCP Compatible

Semantic code intelligence for AI coding agents — Give your AI assistant deep understanding of your codebase through the Model Context Protocol (MCP).

If you find this useful, please consider giving it a star on GitHub! It helps others discover the project.


Local-First, Private, Secure

Your code never leaves your machine. Civyk Repo Index is a fully local MCP server:

  • 100% offline — No cloud services, no API calls, no telemetry
  • Your data stays yours — All indexes and caches stored locally in SQLite
  • Works air-gapped — Perfect for proprietary codebases and enterprise environments
  • Open source — Audit the code yourself, MIT licensed

Why Civyk Repo Index?

AI coding assistants have limited context windows. They can't read entire codebases. Civyk Repo Index provides token-budgeted semantic code intelligence:

  • 🔍 Symbol-aware search — Find functions, classes, and types instantly
  • 📦 Smart context packs — Auto-select relevant code within token budgets
  • 🔗 Relationship tracking — Understand calls, imports, and inheritance
  • Real-time indexing — Always up-to-date with your code changes
  • 🌳 Multi-language — Python, TypeScript, JavaScript, Java, Go, C#, Rust, Ruby, PHP
  • 🔀 Branch-aware — Separate indexes per git branch
  • 🧠 AI Context Cache — Persist code understanding across sessions, save 80-90% tokens

Quick Start

Installation

pip install civyk-repoix

Setup for Your AI Agent

cd /path/to/your/project

# Interactive setup
civyk-repoix setup

# Or configure specific agent
civyk-repoix setup --ai claude        # Claude Code
civyk-repoix setup --ai cursor-agent  # Cursor
civyk-repoix setup --ai windsurf      # Windsurf
civyk-repoix setup --ai copilot       # GitHub Copilot

Verify

civyk-repoix query index-status

MCP Tools

36 tools for code intelligence. Full reference →

Category Tools
Core index_status, build_context_pack, search_symbols, get_symbol, get_references, get_components, get_api_endpoints, get_dependencies, force_reindex
Navigation get_file_symbols, get_definition, get_callers
Discovery list_files, get_file_imports, search_code
Git get_recent_changes, get_hotspots, get_branch_diff
Analysis get_dead_code, find_circular_dependencies, analyze_impact, get_tests_for, get_code_for_test, get_duplicate_code, get_tool_performance_stats
Advanced get_type_hierarchy, get_related_files, find_similar
AI Cache store_understanding, recall_understanding, get_understanding_stats, invalidate_understanding
Context build_delta_context_pack, map_trace_to_symbols, get_recommended_tests, build_doc_pack

Tip: Use recall_understanding before reading files — cached analysis saves 80-90% of tokens.


AI Context Cache — Your AI Remembers

The killer feature: Your AI assistant remembers what it learned about your code.

Traditional AI coding assistants forget everything when you start a new chat or session. With Civyk Repo Index's AI Context Cache, understanding persists:

Monday:    AI reads auth.py → analyzes → stores understanding
Tuesday:   New chat → AI recalls cached understanding → no file read needed!
Wednesday: You modify auth.py → cache auto-invalidates → AI re-analyzes

Why This Matters

Without Cache With Cache
AI re-reads files every session AI recalls previous analysis instantly
Wastes tokens on repeated reads 80-90% token savings
Slow context building Sub-millisecond recall
Understanding lost on chat restart Persists across sessions and chats

How It Works

  1. First encounter: AI reads a file, analyzes it, calls store_understanding
  2. Future sessions: AI calls recall_understanding first — gets cached analysis
  3. File changes: Cache auto-invalidates via content hash — AI re-analyzes
  4. Per-repository: Each repo has its own persistent cache

Cache Tools

Tool Purpose
recall_understanding Call FIRST before reading any file — retrieves cached analysis
store_understanding Persist AI's analyzed understanding after reading files
get_understanding_stats Session start: List cached targets, filter by path/scope, sort, check freshness
invalidate_understanding Manually clear cached entries when needed

store_understanding supports structured fields (purpose, key_points, gotchas) plus a free-form analysis field for complex business logic, state machines, and workflows.

Pro tip: The AI Context Cache is stored locally in SQLite alongside your code index. Your analysis never leaves your machine.


Language Support

Tier Languages
Full Python, TypeScript, JavaScript
Standard Java, Go, C#, Rust, Ruby, PHP
SQL T-SQL, PL/SQL, Standard SQL
Docs Markdown

Architecture

Daemon-based architecture for multi-repository support. Full details →

graph LR
    IDE[IDE] --> Shim[stdio Shim] --> Daemon[Daemon Manager] --> Workers[Repository Workers] --> DB[(SQLite)]

Key Components:

  • Daemon Manager — Coordinates worker lifecycle
  • Repository Worker — One per repo, handles indexing and queries
  • Indexer — Tree-sitter parsing, symbol extraction
  • Context Builder — Token-budgeted context generation

CLI Mode

Use without MCP protocol:

civyk-repoix query search-symbols --query "%User%" --kind class
civyk-repoix query build-context-pack --task "implement auth" --token-budget 1000
civyk-repoix query --schema  # Get JSON schema of all tools

Configuration

Location: ~/.config/civyk-repoix/config.yaml

index:
  max_file_size_mb: 10
  debounce_ms: 500

daemon:
  max_workers: 10
  idle_worker_timeout_s: 3600

context:
  default_token_budget: 800
  max_token_budget: 4000

Environment Variables:

Variable Default Description
CIVYK_LOG_LEVEL INFO Log level
REPOIX_PARSE_WORKERS CPU count Parallel parsing workers
REPOIX_CACHE_TTL 60 Query cache TTL (seconds)

Performance

Operation Performance
Symbol search < 1ms
Build context pack < 10ms
Full index (1K files) 5-10s
Delta index < 1s

Documentation


Code Structure

The project follows a modular architecture with clear separation of concerns:

src/civyk_repoix/
├── cli.py              # Command-line interface entry point
├── cli_tools.py        # CLI tool implementations for query subcommands
├── config.py           # Configuration dataclasses and loading
├── service.py          # Standalone service lifecycle management
├── mcp_server.py       # MCP protocol server (standalone mode)
├── mcp_responses.py    # Response builders (single source of truth)
├── tool_handlers.py    # Shared MCP tool handler implementations
├── tool_schemas.py     # Tool parameter schemas for CLI/MCP
├── tool_descriptions.py# AI-agent-friendly tool descriptions
├── exceptions.py       # Custom exceptions
├── logging_setup.py    # Logging configuration
│
├── daemon/             # Daemon architecture for multi-repo support
│   ├── manager.py      # DaemonManager - coordinates worker pool
│   ├── worker.py       # RepoWorker - per-repository handler
│   └── shim.py         # stdio-to-socket bridge for MCP
│
├── workers/            # Core processing workers
│   ├── indexer.py      # File indexer with Tree-sitter parsing
│   └── context_builder.py # Token-budgeted context generation
│
├── storage/            # Data persistence layer
│   ├── database.py     # SQLite wrapper with WAL mode
│   ├── repository.py   # High-level data access pattern
│   └── cache.py        # Query and context pack caching
│
├── engines/            # Language parsing
│   ├── treesitter.py   # Tree-sitter parsing engine
│   └── languages.py    # Language detection and grammar loading
│
├── models/             # Domain entities (immutable dataclasses)
│   ├── symbol.py       # Code symbols (classes, functions, etc.)
│   ├── file.py         # Source files with metadata
│   ├── edge.py         # Symbol relationships
│   ├── component.py    # Architectural components
│   ├── status.py       # Health status
│   └── ai_understanding.py # AI analysis cache
│
├── monitors/           # Change detection
│   ├── file_watcher.py # File system monitoring
│   ├── git_watcher.py  # Git branch detection
│   └── parent_watcher.py # IDE process monitoring
│
├── transport/          # Communication layer
│   ├── protocol.py     # Framed JSON-RPC protocol
│   └── socket.py       # Socket server/client
│
├── security/           # Security utilities
│   └── scanner.py      # Secret detection and redaction
│
├── setup/              # Agent configuration
│   ├── config.py       # Agent registry
│   └── mcp_setup.py    # MCP server setup
│
└── utils/              # Shared utilities
    ├── git_utils.py    # Git operations
    ├── path_filter.py  # Path filtering for indexer
    ├── language_filter.py # Source code detection
    └── timing.py       # Performance metrics

Key Patterns

  • Response Builders: All MCP responses defined in mcp_responses.py
  • Handler Delegation: Tool logic in tool_handlers.py, called by both daemon and standalone modes
  • Immutable Models: Domain entities use @dataclass(frozen=True, slots=True)
  • Async Architecture: Core operations use asyncio with thread pools for CPU-bound work
  • Single Source of Truth: Tool schemas, descriptions, and responses each in one module

Contributing

git clone https://github.com/civyk/civyk-repoix.git
cd civyk-repoix
pip install -e ".[dev]"
pytest -n auto

Guidelines: Use ruff format, add type hints, maintain >80% test coverage.


License

MIT — see LICENSE

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

civyk_repoix-0.3.0-cp312-cp312-win_amd64.whl (6.3 MB view details)

Uploaded CPython 3.12Windows x86-64

civyk_repoix-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl (7.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

civyk_repoix-0.3.0-cp312-cp312-macosx_11_0_arm64.whl (6.2 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

civyk_repoix-0.3.0-cp311-cp311-win_amd64.whl (6.1 MB view details)

Uploaded CPython 3.11Windows x86-64

civyk_repoix-0.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl (7.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

civyk_repoix-0.3.0-cp311-cp311-macosx_11_0_arm64.whl (6.1 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

civyk_repoix-0.3.0-cp310-cp310-win_amd64.whl (5.9 MB view details)

Uploaded CPython 3.10Windows x86-64

civyk_repoix-0.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl (7.0 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

civyk_repoix-0.3.0-cp310-cp310-macosx_11_0_arm64.whl (5.9 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file civyk_repoix-0.3.0-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for civyk_repoix-0.3.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 a8a76776b76f54509749a56ac8677b750a0a4d8bba24b22068929d2bfe69c03b
MD5 6062dfeb45348da7f4394b31eb381019
BLAKE2b-256 ac908fcd4280ca424f21c7dcc71ee3e0f8c4911ac5e460f38f5c97c841239ebf

See more details on using hashes here.

File details

Details for the file civyk_repoix-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for civyk_repoix-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 513e5a271341ef91213b7c4553703cc50fefc4a69b6a0750bffa00e082c06cbb
MD5 ccbc8701acbb581e0b457487efbabc42
BLAKE2b-256 314a8cd143f6861913511e4e6d885d9065ecaa0d6b13f40a6d3eb6dd871ca67d

See more details on using hashes here.

File details

Details for the file civyk_repoix-0.3.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for civyk_repoix-0.3.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5730e83e38e341e183181595dccb462d4bc8ec74da25056c1ca56a6e17734e8b
MD5 c80d70ca5d2ce6b2289845478830fea7
BLAKE2b-256 1e619d251db8a297b0ab505f856280495a04e1acdad9d7ab8f1fc6f07053442e

See more details on using hashes here.

File details

Details for the file civyk_repoix-0.3.0-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for civyk_repoix-0.3.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 eceb68effaeadcf6ff000ba28999e6a2d14617d479818492bd4386d4246cf83f
MD5 d1af8c1059cefa74d9ce0877269102f6
BLAKE2b-256 719c4bf946b8a32470693daba2027bd7baa47797b01de01cf0a7b72ffe777985

See more details on using hashes here.

File details

Details for the file civyk_repoix-0.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for civyk_repoix-0.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7a83e3a513f73828464ba199bdf3eb7c5a1989093730abaa93b61ed435829f29
MD5 5a6ff69dbc14edbbbf9e03da736c1384
BLAKE2b-256 798764d0870e0bd72af74aec7d30c5ef4ef8131cc9517feaaf3580b290eb9a32

See more details on using hashes here.

File details

Details for the file civyk_repoix-0.3.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for civyk_repoix-0.3.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9b2bda4b041ef96aa03615d29d4278213acab4c1a590f610d4c935caceb3bad7
MD5 3987614bf4002fb4e7cc6c462c82dbd1
BLAKE2b-256 556cdcfc6a3a2487c881a51a34dfb44acd3f1ac76b04c400cd6c090cc1f0d7b1

See more details on using hashes here.

File details

Details for the file civyk_repoix-0.3.0-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for civyk_repoix-0.3.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 bd7a9fca0ddab3e557c2c777188edce95fcadb5271e8012987b949ba722ee9f3
MD5 95fa62aef5dad1d9c2fc7ae32dd0f43c
BLAKE2b-256 5c623b613ddc9f0afbb2af7ce379802259b7ce1a351a6c030bac9de2868ffd25

See more details on using hashes here.

File details

Details for the file civyk_repoix-0.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for civyk_repoix-0.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fb3007b17834e5644c92569077d5a03d182248f52bcfcbf702517fe5ea9b3d2b
MD5 ab66f3e9e7dc643e56890475e6be30a6
BLAKE2b-256 6f7891b3620c5a1e38e7c3eaf897105282153d1456584d026d8a0ca2d30b5d59

See more details on using hashes here.

File details

Details for the file civyk_repoix-0.3.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for civyk_repoix-0.3.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c442ee2959c6cfaea26777996b4303f465cb26e7db2fa104055fe14c7d1312af
MD5 cded16cafef2278242c96c54b12ab869
BLAKE2b-256 c62cbbf7b9ff0f698abb2698d993922dfa7037307519f2b7b0a9254a3cee8ba1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page