Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,16 @@ on:
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .
- name: Test codesight cli
- name: Test installation
run: |
python -m codesight --help
python -m codesight --version
python -m codesight --help
93 changes: 73 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,92 @@
# CodeSight

A tool for generating token-efficient codebase overviews.
[![PyPI version](https://badge.fury.io/py/codesight.svg)](https://badge.fury.io/py/codesight)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Python Version](https://img.shields.io/pypi/pyversions/codesight.svg)](https://pypi.org/project/codesight/)

## Usage
**CodeSight** is a utility that helps you extract your entire codebase into a single text file. This makes it easy to share your code with Large Language Models (LLMs) like GPT-4 or Claude for comprehensive code reviews, analysis, and suggestions.

## Why CodeSight?

- **Complete Codebase Context**: Give LLMs the full picture of your code for more accurate assistance
- **Smart Token Optimization**: CodeSight intelligently truncates files to ensure you stay within token limits
- **Flexible Configuration**: Easily include or exclude specific files, directories, or file types
- **Works with Any Project**: Language-agnostic - works with Python, JavaScript, Go, or any text-based code

From the `.codesight` directory, run:
## Installation

```bash
./run_codesight.sh [options]
pip install codesight
```

### Options
## Usage

### Quick Start

- `--dir PATH`: Root directory of the project (default: parent directory)
- `--extensions EXT [EXT ...]`: File extensions to include (default: .ts, .toml, .css, .js, .json, .md)
- `--output FILE`: Output file name (default: codebase_overview.txt)
- `--max-lines N`: Maximum lines per file before truncation (default: 500)
- `--model MODEL`: Model to use for token counting (default: gpt-4)
```bash
# Initialize CodeSight in your project
cd your-project
codesight init

# Generate a codebase overview file
codesight analyze
```

### Examples
This will create a `.codesight` directory in your project with configuration files and a `codebase_overview.txt` file containing your entire codebase.

Analyze Python files in the parent directory:
### Command-line Options

```bash
./run_codesight.sh --extensions .py
# Analyze a specific directory
codesight analyze /path/to/project

# Only include specific file extensions
codesight analyze --extensions .py .js .ts

# Custom output file
codesight analyze --output my-overview.txt

# Customize token optimization settings
codesight analyze --max-lines 100 --max-files 200 --max-file-size 100000
```

Analyze JavaScript and TypeScript files in a specific directory:
## Configuration

```bash
./run_codesight.sh --dir /path/to/project --extensions .js .ts
After running `codesight init`, you'll have a `.codesight/codesight.config.json` file with settings like:

```json
{
"ignore_patterns": ["*.pyc", "__pycache__", "venv", ".git"],
"file_extensions": [".py", ".js", ".ts", ".jsx", ".tsx"],
"token_optimization": {
"max_lines_per_file": 500,
"max_files": 1000,
"max_file_size": 500000
}
}
```

## Installation
## Using with Language Models

1. Generate your codebase overview file:
```bash
codesight analyze
```

2. Open the created file at `.codesight/codebase_overview.txt`

3. Copy the contents and paste into an LLM conversation

4. Ask for code review, architecture suggestions, improvements, etc.

## Requirements

- Python 3.8+

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## License

1. Install uv: `curl -LsSf https://astral.sh/uv/install.sh | sh`
2. Run `./install.sh` in the `.codesight` directory
3. Or manually: `uv venv .venv && uv pip install -r requirements.txt`
This project is licensed under the MIT License.
22 changes: 22 additions & 0 deletions codesight/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env python3
"""
Main entry point for CodeSight.
When run directly as a script, this file provides CLI functionality.
For proper package use, use 'codesight' command after installation.
"""
import sys
from codesight import cli
from codesight import __version__

def main():
"""Main entry point for the CodeSight tool"""
# Handle --version flag specifically
if len(sys.argv) > 1 and sys.argv[1] == "--version":
print(f"codesight version {__version__}")
return

# Use the CLI from the codesight package
cli.main()

if __name__ == "__main__":
main()
1 change: 1 addition & 0 deletions codesight/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from . import core

@click.group()
@click.version_option()
def main():
"""CodeSight: Code analysis and visualization tool."""
pass
Expand Down