From 0f47b873fd40b6c19a3a0349969e4cb29e119409 Mon Sep 17 00:00:00 2001 From: MS <156176+mattsilv@users.noreply.github.com> Date: Tue, 11 Mar 2025 22:38:46 -0400 Subject: [PATCH 1/3] Update README.md with installation instructions --- README.md | 93 +++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 73 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index df2e1de..6768f97 100644 --- a/README.md +++ b/README.md @@ -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. \ No newline at end of file From e1f23e4490f74e3195ef6d5d0789bdeb7e9ed23e Mon Sep 17 00:00:00 2001 From: MS <156176+mattsilv@users.noreply.github.com> Date: Tue, 11 Mar 2025 22:40:08 -0400 Subject: [PATCH 2/3] Simplify CI workflow to only test on Python 3.12 --- .github/workflows/ci.yml | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 13fd903..77bd266 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 \ No newline at end of file + python -m codesight --help \ No newline at end of file From cb64789898ed94d8ce5da1d09a748315d19ffd94 Mon Sep 17 00:00:00 2001 From: MS <156176+mattsilv@users.noreply.github.com> Date: Tue, 11 Mar 2025 22:41:24 -0400 Subject: [PATCH 3/3] Fix module structure and CLI flags handling --- codesight/__main__.py | 22 ++++++++++++++++++++++ codesight/cli.py | 1 + 2 files changed, 23 insertions(+) create mode 100644 codesight/__main__.py diff --git a/codesight/__main__.py b/codesight/__main__.py new file mode 100644 index 0000000..25a968d --- /dev/null +++ b/codesight/__main__.py @@ -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() \ No newline at end of file diff --git a/codesight/cli.py b/codesight/cli.py index 91593e0..5ee2395 100644 --- a/codesight/cli.py +++ b/codesight/cli.py @@ -12,6 +12,7 @@ from . import core @click.group() +@click.version_option() def main(): """CodeSight: Code analysis and visualization tool.""" pass