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.2.tar.gz (34.6 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.2-py3-none-any.whl (41.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pycodesage-0.1.2.tar.gz
  • Upload date:
  • Size: 34.6 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.2.tar.gz
Algorithm Hash digest
SHA256 079e5848dd497631e61a77e4f7274c7ccc9c482f6d392ce9fb3554e8a77a6423
MD5 8b0948975fe580bdfcc9065a482dff20
BLAKE2b-256 548a7eb695a6e5c59acd7e97bed2bcde0fb7192a513e9f741bedea4dfb02b74b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycodesage-0.1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1c6c092ed40626fce762a8780b15dadb4e22cd6d726f4b6997556a694a935d6d
MD5 08b7daef8bea83eb57dd49ad8bf21819
BLAKE2b-256 befcc3daf5fb9c06e1b0bd30b57fd9364833b23e4f2430891927bee953ec68f8

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