Contributing to NGPT
Thank you for your interest in contributing to NGPT! This document provides guidelines and instructions for contributing to this project.
Development Setup
- Fork the repository
- Clone your fork:
git clone https://github.com/YOUR_USERNAME/ngpt.git
- Navigate to the project directory:
cd ngpt
- Set up Python environment:
- It’s recommended to use a virtual environment
- Create a virtual environment:
python -m venv .venv
- Activate the virtual environment:
- Windows:
.venv\Scripts\activate
- Unix/MacOS:
source .venv/bin/activate
- Windows:
- Install dependencies:
pip install -e .
- Open the project in your preferred code editor
Code Structure
ngpt/
- Main package directory__init__.py
- Package initialization__main__.py
- Entry point when run as a moduleclient.py
- Client implementation for API interactioncli/
- Command-line interface implementation__init__.py
main.py
- Main CLI application logicargs.py
- Argument parsing setupconfig_manager.py
- CLI configuration handlingformatters.py
- Output formatting logicmodes/
- Different operational modes__init__.py
- Modes initializationchat.py
- Chat mode functionalitycode.py
- Code generation modegitcommsg.py
- Git commit message generationinteractive.py
- Interactive mode implementationrewrite.py
- Text rewriting modeshell.py
- Shell command generationtext.py
- Text generation mode
renderers.py
- Output rendering logic (e.g., markdown)ui.py
- User interface elements (e.g., prompts, spinners)
utils/
- Utility modules__init__.py
config.py
- API endpoint and general configuration managementcli_config.py
- CLI-specific option configuration managementlog.py
- Logging setup and utilities
docs/
- Documentation filesexamples/
- Example usageusage/
- Usage guides and tutorials
.github/
- GitHub workflows and templatespyproject.toml
- Project configuration and dependencies
Code Style Guidelines
- Follow PEP 8 style guidelines for Python code
- Use consistent indentation (4 spaces)
- Write descriptive docstrings for functions and classes
- Add type hints where appropriate
- Add comments for complex logic
Pull Request Guidelines
Before submitting a pull request, please make sure that:
- Your code follows the project’s coding conventions
- You have tested your changes thoroughly
- All existing tests pass (if applicable)
- The commit messages are clear and follow conventional commit guidelines as specified in COMMIT_GUIDELINES.md
- You have provided a detailed explanation of the changes in the pull request description
Submitting Changes
- Create a new branch:
git checkout -b feature/your-feature-name
- Make your changes
- Test thoroughly
- Commit with clear messages:
git commit -m "feat: description"
- Push to your fork:
git push origin feature/your-feature-name
- Open a Pull Request against the main repository
Testing Your Changes
Before submitting your changes, please test:
- Basic CLI functionality
- Any new features you’ve added
- Any components you’ve modified
- Test on different platforms if possible (Windows, Linux, macOS)
- Try various prompts and inputs to ensure robustness
Test your changes with:
# After installing with -e flag
python -m ngpt --version
python -m ngpt "Test prompt"
Issue Reporting
When opening an issue, please:
- Use a clear and descriptive title
- Provide a detailed description of the issue, including the environment and steps to reproduce
- Include any relevant logs or code snippets
- Specify your Python version and operating system
- Search the repository for similar issues before creating a new one
Feature Requests
Feature requests are welcome! To submit a feature request:
- Use a clear and descriptive title
- Provide a detailed description of the proposed feature
- Explain why this feature would be useful to NGPT users
- If possible, suggest how it might be implemented
Questions and Discussions
For questions about the project that aren’t bugs or feature requests, please use GitHub Discussions instead of opening an issue. This helps keep the issue tracker focused on bugs and features.
Common Tasks
Adding a New Mode
If you’re adding a new mode to nGPT, you should:
- Create a new file in
ngpt/cli/modes/
for your mode implementation - Add your mode to the mode selection logic in
ngpt/cli/args.py
- Update help documentation to include your mode
- Add tests for your new mode
- Update documentation in
docs/usage/
to describe your mode
Improving Renderers
For improvements to the output rendering:
- Modify the renderer code in
ngpt/cli/renderers.py
- Ensure backward compatibility if possible
- Test with various types of output (code, markdown, tables, etc.)
Updating Documentation
When updating documentation:
- Ensure your changes are reflected in both the code docstrings and in the Markdown documentation
- Update examples if necessary
- Test that documentation renders correctly
License
By contributing to this project, you agree that your contributions will be licensed under the same LICENSE as the project.