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.1.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.1-py3-none-any.whl (41.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pycodesage-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 3be633893875f29fe4a2395dd13e35841cc3d3e28d9c8478ea0a6ca4bb6c99c3
MD5 599f2665abbcd2290aea277235645afe
BLAKE2b-256 cc287c25356187b4cb91693e45d1e3c97996ea45188755f29df42ab245a0cc01

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycodesage-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fceebf9b9a0408f81dbe4f5ba9f12516628d82e378549dbf1c1e7bb7e2e9d680
MD5 0f67c5874c9a8955849179f3bcad64f6
BLAKE2b-256 7b299788c6340c5f9469fef9c8ab6a6a02fee9e4580361e5d699541e731cefa4

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