CLI tool to summarize code in a repo.
Project description
👻 repoGhost
repoGhost is a command-line tool to scan a local code repository, split files into chunks, and summarize each chunk using an LLM (e.g., GPT-4). Summaries are stored in summaries.json, and repeated runs skip unchanged files to save cost.
Features
- Hash-based caching: Skips unchanged files (no repeated LLM calls).
- Auto
.gitignore: Automatically adds the cache and summary files to.gitignoreif found. - Clipboard: Copies the last summary to your clipboard for easy reference.
- Configurable chunk size: Choose how many lines per chunk.
Installation
pip install repoGhost
Usage
repoGhost --repo_path /path/to/your/repo --lines_per_chunk 30
Command-Line Arguments
--repo_path: Path to the local repo (default./my_repo).--lines_per_chunk: Lines per chunk for summarizing (default30).
Example
repoGhost --repo_path ./my_project --lines_per_chunk 50
This generates two files in the specified repo path:
hash_cache.json: Contains file hashes and chunk summaries (used to skip unchanged files).summaries.json: Contains all chunk summaries (the final output).
The last chunk’s summary is copied to your clipboard automatically.
Constants
In the code, the following constants can be modified to suit your needs:
EXCLUDED_DIRS = {
"migrations",
"static",
"media",
"__pycache__",
".git",
"venv",
"node_modules",
}
EXCLUDED_EXTENSIONS = {
".pyc", ".css", ".scss", ".png", ".jpg", ".jpeg", ".svg", ".sqlite3"
}
EXCLUDED_FILES = {"manage.py", "wsgi.py", "asgi.py", "package-lock.json"}
VALID_EXTENSIONS = {".py", ".js", ".html", ".json"}
Feel free to add or remove items based on the files you want to skip or process.
Customizing the Prompt & Model
Inside the script, the summarize_chunk function calls an OpenAI model:
openai.ChatCompletion.create(
model="gpt-4o", # or your custom model name
messages=[
{"role": "user", "content": f"Please summarize this code chunk concisely:\n\n{chunk}"}
],
temperature=0.3,
max_tokens=150
)
You can modify:
- The
modelparameter (e.g.,gpt-3.5-turbo,gpt-4,gpt-4o-mini, etc.). - The prompt text (if you want a different style of summary).
- The
temperatureormax_tokensvalues.
OpenAI API Key
You need an OPENAI_API_KEY set in your environment variables for the script to call OpenAI’s API. For instance:
export OPENAI_API_KEY="sk-1234..."
Then run:
repoGhost --repo_path /path/to/repo
Requirements
See requirements.txt. Python 3.7+ recommended.
openaipypercliprich
Development / Local Install
- Clone this repo:
git clone https://github.com/georgestander/repoGhost.git cd repoGhost
- Install in editable mode:
pip install -e .
- Verify the CLI is installed:
repoGhost --help
License
MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file repoghost-0.1.2.post1.dev1.tar.gz.
File metadata
- Download URL: repoghost-0.1.2.post1.dev1.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5cd5da94c39f90d7a62927ca2abc2795c5729df6fb44d522a0d8d03d70be64c4
|
|
| MD5 |
5c3e63889f719c9231d18887e9fc95a5
|
|
| BLAKE2b-256 |
0d72e45853a2226c1178e0c3aa45b1b3e86ad68955c408b68862fe5ae92925a3
|
File details
Details for the file repoGhost-0.1.2.post1.dev1-py3-none-any.whl.
File metadata
- Download URL: repoGhost-0.1.2.post1.dev1-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac6cc4c75795444efa2736137edf99c6736746b9641dc7bd46c808eeca36a7f0
|
|
| MD5 |
ae76446a3e7266333db528aadd8ae7bd
|
|
| BLAKE2b-256 |
a6a6d5930285af5065db7c267e5233627205f7365a744db0f6df124569c192bb
|