https://github.com/samk13/ccprompt
AI Code Context Extractor for Prompts ✨
https://github.com/samk13/ccprompt
ai code context python tooling workflow
Last synced: 12 months ago
JSON representation
AI Code Context Extractor for Prompts ✨
- Host: GitHub
- URL: https://github.com/samk13/ccprompt
- Owner: Samk13
- License: mit
- Created: 2024-10-04T23:01:36.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-09T22:10:25.000Z (over 1 year ago)
- Last Synced: 2025-03-18T18:54:25.674Z (about 1 year ago)
- Topics: ai, code, context, python, tooling, workflow
- Language: Python
- Homepage: https://pypi.org/project/ccprompt
- Size: 41 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.rst
- License: LICENSE
Awesome Lists containing this project
README
# CCprompt
## Code Context Prompt
### The Problem
When working with AI prompts, it is often necessary to provide code context to the model to generate useful responses. This can be a time-consuming task, especially when working with large codebases.
CCprompt is a tool designed to extract code context for AI prompts based on provided function or class names. It supports both Python and JavaScript/TypeScript codebases.
Providing such context can help AI models generate more accurate and relevant responses.
## Features
- Supports Python languages, JavaScript/TypeScript support coming soon.
- Extracts functions or classes and their inheritance chains.
- Configurable via a JSON configuration file or command-line arguments.
- Excludes virtual environment directories if needed.
- zero dependencies if you are using it for python.
## Installation
```bash
pip install ccprompt
```
## Usage
### first time usage
run `ccprompt` it will create a configuration file `ccprompt_config.json` in the current directory.
fill in the configuration file with the required information. Alternatively, you can pass the required information as command-line arguments.
`ccprompt --config CONFIG`. The configuration file should be in the following format:
```json
{
"target_name": ["YourClassName", "your_function_name"],
"project_path": "/full/path/to/project",
"venv_site_packages_path": "/full/path/to/venv/lib/python3.x/site-packages",
"exclude_venv": false,
"output_file": "extracted_code.txt",
"language": "python"
}
```
then run `ccprompt`, it will extract the code context based on the configuration file. and create `extracted_code.txt` that include extracted code context.
the extracted code will include file path, functions or classes and their inheritance chains.
Star and share the repository if you find it useful.
```bash
# Update your configuration file then run
ccprompt
# Also possible to pass the configuration file as arguments
ccprompt --target_names YourClassName your_function_name
# See all available options
ccprompt --help
```
## Development
```bash
pip install -e .["dev"]
```
## Commands
```bash
# installs development dependencies specified in setup.py
make install
# Runs tests
make test
# Check linting issues
make lint-check
# Runs linting and fixes issues
make lint-fix
# Formats code using Ruff
make format
```