Skip to main content

Local-first CLI code intelligence tool with LangChain-powered RAG

Project description

CodeSage

Local-first CLI code intelligence tool with LangChain-powered RAG

CodeSage indexes your codebase and enables semantic code search using AI. Everything runs locally on your machine with Ollama.

Features

  • Semantic Code Search - Find code using natural language queries
  • AI-Powered Suggestions - Get intelligent code recommendations from your codebase
  • 100% Local - Everything runs on your machine with Ollama, no cloud required
  • Fast Indexing - Incremental updates only re-index changed files
  • Python Support - Full Python AST parsing

Requirements

Setting Up Ollama

# Install Ollama from https://ollama.ai, then pull required models:
ollama pull qwen2.5-coder:7b      # For code analysis (~4.4GB)
ollama pull mxbai-embed-large     # For embeddings (~670MB)

Installation

From PyPI

pip install codesage

From Source (Development)

# Clone the repository
git clone https://github.com/keshavashiya/codesage.git
cd codesage

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install in development mode
pip install -e ".[dev]"

Optional: OpenAI/Anthropic Support

pip install codesage[openai]      # For OpenAI
pip install codesage[anthropic]   # For Anthropic Claude

Quick Start

# Navigate to your project
cd your-project

# Initialize CodeSage
codesage init

# Index the codebase
codesage index

# Search for code
codesage suggest "function to validate email"

Commands

codesage init [PATH]

Initialize CodeSage in a project directory.

codesage init                              # Initialize in current directory
codesage init /path/to/project             # Initialize in specific directory
codesage init --model qwen2.5-coder:7b     # Specify LLM model
codesage init --embedding-model mxbai-embed-large  # Specify embedding model

codesage index [PATH]

Index the codebase for semantic search.

codesage index                # Incremental index (only changed files)
codesage index --full         # Force full reindex
codesage index --clear        # Clear existing index before indexing

codesage suggest QUERY

Search for code using natural language.

codesage suggest "error handling"           # Search with default settings
codesage suggest "database query" -n 10     # Return 10 results (default: 5)
codesage suggest "auth logic" -s 0.5        # Set minimum similarity threshold
codesage suggest "config" --no-explain      # Skip AI explanations (faster)
codesage suggest "utils" -p /path/to/proj   # Search in specific project

codesage stats

Show index statistics.

codesage stats                # Show stats for current directory
codesage stats /path/to/proj  # Show stats for specific project

codesage health

Check system health and dependencies.

codesage health               # Check Ollama, database, disk space

codesage version

Show CodeSage version.

codesage version

Configuration

Configuration is stored in .codesage/config.yaml:

project_name: my-project
language: python

llm:
  provider: ollama
  model: qwen2.5-coder:7b
  embedding_model: mxbai-embed-large
  base_url: http://localhost:11434
  temperature: 0.3
  max_tokens: 500
  request_timeout: 30.0
  max_retries: 3

storage:
  vector_store: chromadb

exclude_dirs:
  - venv
  - node_modules
  - .git
  - __pycache__

Using OpenAI or Anthropic

export CODESAGE_API_KEY="your-api-key"
llm:
  provider: openai           # or anthropic
  model: gpt-4o-mini         # or claude-3-haiku-20240307

Development

# Run tests
pytest tests/ -v

# Format code
black codesage tests

# Lint
ruff check codesage

Troubleshooting

"Ollama connection failed"

ollama serve  # Make sure Ollama is running

"Model not found"

ollama pull qwen2.5-coder:7b
ollama pull mxbai-embed-large

Project details


Download files

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

Source Distribution

pycodesage-0.1.0.tar.gz (34.5 kB view details)

Uploaded Source

Built Distribution

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

pycodesage-0.1.0-py3-none-any.whl (41.4 kB view details)

Uploaded Python 3

File details

Details for the file pycodesage-0.1.0.tar.gz.

File metadata

  • Download URL: pycodesage-0.1.0.tar.gz
  • Upload date:
  • Size: 34.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for pycodesage-0.1.0.tar.gz
Algorithm Hash digest
SHA256 64e3f377e7c6d5ca005aa58636e26ca26619e9d1c966bf3ca7f68e3f1258c711
MD5 d4247f9af9cbe6c5a710fb052ea98d07
BLAKE2b-256 ecc05bd9f9c0cdbee8dc64a4895cae1f6f2054a975d4510ce66eff646e85ef2f

See more details on using hashes here.

File details

Details for the file pycodesage-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pycodesage-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 41.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for pycodesage-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 98ea0db9d3a8c2794da209bd042770524fdc2d0364c0544d90730cf929fc267f
MD5 3f5ad306b111cb7c9aef3e09c70ead7d
BLAKE2b-256 b90fd20119192a69336966afc1e51baeeef0af6e5a25d65cc0570f2e1fe45295

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