From bd7d7121df754f01908ecce25988643bdb4b39ad Mon Sep 17 00:00:00 2001 From: sumansaurabh Date: Sun, 9 Mar 2025 01:47:54 +0530 Subject: [PATCH 1/3] feat(docs): add comprehensive Penify CLI documentation and example workflows --- README.md | 163 +++++++------------------ docs/commit-commands.md | 161 +++++++++++++++++++++++++ docs/config-commands.md | 166 +++++++++++++++++++++++++ docs/detailed-usage.md | 160 +++++++++++++++++++++++++ docs/example-workflows.md | 143 ++++++++++++++++++++++ docs/penify-cli-documentation.md | 200 +++++++++++++++++++++++++++++++ 6 files changed, 873 insertions(+), 120 deletions(-) create mode 100644 docs/commit-commands.md create mode 100644 docs/config-commands.md create mode 100644 docs/detailed-usage.md create mode 100644 docs/example-workflows.md create mode 100644 docs/penify-cli-documentation.md diff --git a/README.md b/README.md index db0ad8c..97f4c10 100644 --- a/README.md +++ b/README.md @@ -1,166 +1,89 @@ -# Penify CLI Tool +# Penify CLI -![Tests](https://github.com/yourorganization/penify-cli/workflows/Tests/badge.svg) -![Coverage](./coverage.svg) +Penify CLI is a tool that enhances your development workflow with AI-powered capabilities: -A CLI tool to generate smart commit messages, code documentation, and more. - -## Features - -- Automatically generate documentation for your code -- Support for multiple programming languages -- Git hook integration for automatic documentation on commits -- Folder and file analysis +- Generate smart commit messages using local LLM models or cloud API +- Automatically create code documentation +- Integrate with JIRA for enhanced commit messages +- Install Git hooks for automated documentation generation ## Installation -Install from PyPI: - ```bash pip install penifycli ``` -## Usage - -Penify CLI provides several subcommands for different functionalities, organized into basic commands (no login required) and advanced commands (login required). - -## Basic Commands (No login required) +## Authentication -### Commit +Penify CLI supports two authentication methods: -Generate smart commit messages using local LLM: +### 1. Login to Penify Account (Required for Advanced Features) ```bash -penifycli commit [-m "Optional message"] [-e] [-d] +penifycli login ``` -Options: -- `-m, --message`: Optional custom commit message -- `-e, --terminal`: Open editor to modify commit message before committing -- `-d, --description`: Generate commit message with both title and description (without this flag, only title is generated) +This command will open your browser and prompt you to log in to your Penify account. Once authenticated, your API token will be saved locally. -### Config +### 2. Environment Variable -Configure local LLM and JIRA settings: +For CI/CD pipelines or automated environments, you can set: ```bash -# Configure LLM settings -penifycli config llm --model MODEL_NAME [--api-base API_URL] [--api-key API_KEY] - -# Configure LLM settings through web interface -penifycli config llm-web - -# Configure JIRA settings -penifycli config jira --url JIRA_URL --username USERNAME --api-token TOKEN [--verify] - -# Configure JIRA settings through web interface -penifycli config jira-web +export PENIFY_API_TOKEN=your_api_token ``` -## Advanced Commands (Login required) - -### Login +## Basic Usage -To log in and obtain an API token: +### Generate Smart Commit Messages ```bash -penifycli login +penifycli commit ``` -This command will open a browser window for authentication. After successful login, the API key will be saved locally for future use. - -### Documentation Generation - -Generate documentation for Git diff, files or folders: +### Generate Code Documentation ```bash -# Generate documentation for latest Git commit diff +# Generate documentation for current Git diff (requires login) penifycli docgen -# Generate documentation for specific file or folder -penifycli docgen -l /path/to/file/or/folder -``` - -Options: -- `-l, --location`: Path to specific file or folder for documentation generation (defaults to current directory) +# Generate documentation for a specific file +penifycli docgen -l path/to/file.py -### Git Hook Management +# Generate documentation for a folder +penifycli docgen -l path/to/folder +``` -Install or uninstall Git post-commit hooks: +### Configure Local LLM or JIRA ```bash -# Install Git hook -penifycli docgen install-hook [-l /path/to/repo] +# Configure Local LLM for commit message generation +penifycli config llm -# Uninstall Git hook -penifycli docgen uninstall-hook [-l /path/to/repo] +# Configure JIRA integration +penifycli config jira ``` -Options: -- `-l, --location`: Path to the Git repository (defaults to current directory) - -## Authentication - -Penify CLI uses an API token for authentication with advanced features. - -If no token is available and you try to access an advanced feature, you'll be prompted to log in. - -## Local LLM Configuration - -For commit message generation, Penify can use a local LLM. Configure it using: +### Automate Documentation with Git Hooks ```bash -penifycli config llm --model MODEL_NAME --api-base API_URL --api-key API_KEY -``` - -Common configurations: -- OpenAI: `--model gpt-3.5-turbo --api-base https://api.openai.com/v1 --api-key YOUR_KEY` -- Anthropic: `--model claude-2 --api-base https://api.anthropic.com --api-key YOUR_KEY` - -## JIRA Integration - -Configure JIRA integration to enhance commit messages with issue details: +# Install a post-commit hook +penifycli docgen install-hook -```bash -penifycli config jira --url https://your-domain.atlassian.net --username your-email@example.com --api-token YOUR_API_TOKEN +# Remove the hook +penifycli docgen uninstall-hook ``` -## Development - -To set up the development environment: - -1. Clone the repository: - ```bash - git clone https://github.com/SingularityX-ai/penify-cli.git - ``` - -2. Install the package in editable mode: - ```bash - pip install -e . - ``` - -### Running Tests +## Getting Help ```bash -pytest -``` - -## License - -This project is licensed under the MIT License. - -## Author - -Suman Saurabh (ss.sumansaurabh92@gmail.com) +# Get general help +penifycli --help -## Contributing - -Contributions are welcome! Please feel free to submit a Pull Request. - -## Issues - -If you encounter any problems or have suggestions, please file an issue on the [GitHub repository](https://github.com/SingularityX-ai/penifycli/issues). - -## Support +# Get help for a specific command +penifycli commit --help +penifycli docgen --help +penifycli config --help +``` -For automated API Documentation, Architecture Documentation, Code Documentation, Pull Request Documentation, or if you need a demo, please join our [Discord support channel](https://discord.gg/wqrc8JeV). \ No newline at end of file +For detailed documentation and examples, see [docs/detailed-usage.md](docs/detailed-usage.md). \ No newline at end of file diff --git a/docs/commit-commands.md b/docs/commit-commands.md new file mode 100644 index 0000000..5eab520 --- /dev/null +++ b/docs/commit-commands.md @@ -0,0 +1,161 @@ +# Penify CLI - Commit Commands + +The `commit` command allows you to generate smart, AI-powered commit messages for your Git changes. This document explains all available options and combinations. + +## Basic Usage + +```bash +penifycli commit +``` + +By default, this command: +- Analyzes your staged Git changes +- Generates a concise commit title only +- Uses local LLM if configured, or falls back to Penify API + +## Command Options + +### `-m, --message` + +Provide context for the commit message generation: + +```bash +penifycli commit -m "Fix login flow" +``` + +This hint helps the AI understand your intention and improves the quality of the generated message. + +### `-e, --terminal` + +Open an editor to review and edit the generated commit message before committing: + +```bash +penifycli commit -e +``` + +This opens your default Git editor with the generated message for review. + +### `-d, --description` + +Generate a detailed commit message with both title and description: + +```bash +penifycli commit -d +``` + +Without this flag, only the commit title is generated. + +## Option Combinations + +You can combine these options for different workflows: + +### Generate Title Only with Context + +```bash +penifycli commit -m "Update login UI" +``` + +### Generate Title and Description with Context + +```bash +penifycli commit -m "Update login UI" -d +``` + +### Generate and Edit Full Commit Message + +```bash +penifycli commit -d -e +``` + +### Generate, Edit, and Provide Context + +```bash +penifycli commit -m "Refactor authentication" -d -e +``` + +## LLM and JIRA Integration + +### Using Local LLM + +If you've configured a local LLM using `penifycli config llm`, the commit command will automatically use it for message generation. + +Benefits: +- Privacy: your code changes don't leave your machine +- Speed: no network latency +- Works offline + +### JIRA Enhancement + +If you've configured JIRA integration using `penifycli config jira`, the commit command will: + +1. Detect JIRA issue references in your changes +2. Fetch issue details from your JIRA instance +3. Include issue information in the commit message +4. Format the commit message according to JIRA's smart commit format + +Example output: +``` +PROJ-123: Fix authentication bug in login flow + +- Updated OAuth token validation +- Fixed session timeout handling +- Added unit tests for edge cases + +[PROJ-123] +``` + +## Configuration Requirements + +For the `commit` command to work: + +1. You must have configured either: + - Local LLM via `penifycli config llm`, OR + - Logged in via `penifycli login` + +2. For JIRA enhancement (optional): + - Configure JIRA via `penifycli config jira` + +## Examples + +### Basic Commit with Default Settings + +```bash +# Stage your changes +git add . + +# Generate commit message +penifycli commit + +# Commit with the generated message +git commit -m "Generated message here" +``` + +### Full Workflow with All Features + +```bash +# Stage your changes +git add . + +# Generate detailed commit message with JIRA integration, +# provide context, and open editor for review +penifycli commit -m "Fix login issue" -d -e + +# The commit is automatically completed after you save and exit the editor +``` + +## Troubleshooting + +### Common Issues + +1. **"No LLM model or API token provided"** + - Run `penifycli config llm` to configure a local LLM, or + - Run `penifycli login` to authenticate with Penify + +2. **"Failed to connect to JIRA"** + - Check your JIRA configuration with `cat ~/.penify` + - Verify your network connection + - Ensure your JIRA credentials are valid + +3. **"Error initializing LLM client"** + - Verify your LLM configuration settings + - Ensure the LLM API is accessible diff --git a/docs/config-commands.md b/docs/config-commands.md new file mode 100644 index 0000000..2174ced --- /dev/null +++ b/docs/config-commands.md @@ -0,0 +1,166 @@ +# Penify CLI - Configuration Commands + +The `config` command allows you to set up and manage configuration settings for Penify CLI. This document explains all available configuration options and how to use them. + +## Configuration Overview + +Penify CLI stores configuration in a JSON file at `~/.penify/config.json`. The configuration includes: + +- LLM (Large Language Model) settings for local commit message generation +- JIRA integration settings for enhanced commit messages +- API tokens and other credentials + +## Basic Usage + +```bash +# Configure LLM settings +penifycli config llm + +# Configure JIRA integration +penifycli config jira +``` + +## LLM Configuration + +### Web Interface + +Running `penifycli config llm` opens a web interface in your browser where you can configure: + +1. **Model**: The LLM model to use (e.g., `gpt-3.5-turbo`) +2. **API Base URL**: The endpoint URL for your LLM API (e.g., `https://api.openai.com/v1`) +3. **API Key**: Your authentication key for the LLM API + +### Supported LLMs + +Penify CLI supports various LLM providers: + +#### OpenAI +- Model: `gpt-3.5-turbo` or `gpt-4` +- API Base: `https://api.openai.com/v1` +- API Key: Your OpenAI API key + +#### Anthropic +- Model: `claude-instant-1` or `claude-2` +- API Base: `https://api.anthropic.com/v1` +- API Key: Your Anthropic API key + +#### Ollama (Local) +- Model: `llama2` or any model you have installed +- API Base: `http://localhost:11434` +- API Key: (leave blank) + +#### Azure OpenAI +- Model: Your deployed model name +- API Base: Your Azure endpoint +- API Key: Your Azure API key + +### Configuration File Structure + +After configuration, your `~/.penify/config.json` will contain: + +```json +{ + "llm": { + "model": "gpt-3.5-turbo", + "api_base": "https://api.openai.com/v1", + "api_key": "sk-..." + } +} +``` + +## JIRA Configuration + +### Web Interface + +Running `penifycli config jira` opens a web interface where you can configure: + +1. **JIRA URL**: Your JIRA instance URL (e.g., `https://yourcompany.atlassian.net`) +2. **Username**: Your JIRA username (typically your email) +3. **API Token**: Your JIRA API token + +### Creating a JIRA API Token + +1. Log in to [https://id.atlassian.com/manage-profile/security/api-tokens](https://id.atlassian.com/manage-profile/security/api-tokens) +2. Click "Create API token" +3. Give it a name (e.g., "Penify CLI") +4. Copy the generated token and paste it into the configuration + +### Configuration File Structure + +After configuration, your `~/.penify/config.json` will contain: + +```json +{ + "jira": { + "url": "https://yourcompany.atlassian.net", + "username": "your.email@example.com", + "api_token": "your-jira-api-token" + } +} +``` + +## Configuration Locations + +Penify CLI looks for configuration in multiple locations: + +1. Project-specific: `.penify/config.json` in the Git repository root +2. User-specific: `~/.penify/config.json` in your home directory + +The project-specific configuration takes precedence if both exist. + +## Environment Variables + +You can override configuration settings using environment variables: + +- `PENIFY_API_TOKEN`: Override the stored API token +- `PENIFY_LLM_MODEL`: Override the configured LLM model +- `PENIFY_LLM_API_BASE`: Override the configured LLM API base URL +- `PENIFY_LLM_API_KEY`: Override the configured LLM API key +- `PENIFY_JIRA_URL`: Override the configured JIRA URL +- `PENIFY_JIRA_USER`: Override the configured JIRA username +- `PENIFY_JIRA_TOKEN`: Override the configured JIRA API token + +Example: +```bash +export PENIFY_LLM_MODEL="gpt-4" +penifycli commit +``` + +## Command-Line Configuration + +For advanced users or scripting, you can directly edit the configuration file: + +```bash +# View current configuration +cat ~/.penify/config.json + +# Edit configuration with your preferred editor +nano ~/.penify/config.json +``` + +## Sharing Configuration + +You can share configuration between machines by copying the `.penify/config.json` file. However, be cautious with API keys and credentials. + +For team settings, consider: +1. Using a project-specific `.penify/config.json` with shared settings +2. Excluding API keys from shared configuration +3. Using environment variables for sensitive credentials + +## Troubleshooting + +### Common Issues + +1. **"Error reading configuration file"** + - Check if the file exists: `ls -la ~/.penify` + - Ensure it contains valid JSON: `cat ~/.penify/config.json` + +2. **"Failed to connect to LLM API"** + - Verify API base URL and API key + - Check network connectivity to the API endpoint + - Ensure your account has access to the specified model + +3. **"Failed to connect to JIRA"** + - Check JIRA URL format (should include `https://`) + - Verify username and API token + - Ensure your JIRA account has API access permissions diff --git a/docs/detailed-usage.md b/docs/detailed-usage.md new file mode 100644 index 0000000..70cd6d9 --- /dev/null +++ b/docs/detailed-usage.md @@ -0,0 +1,160 @@ +# Penify CLI - Detailed Usage Guide + +This document provides in-depth information about all features and capabilities of the Penify CLI tool. + +## Table of Contents + +- [Penify CLI - Detailed Usage Guide](#penify-cli---detailed-usage-guide) + - [Table of Contents](#table-of-contents) + - [Authentication](#authentication) + - [Login Process](#login-process) + - [API Token Storage](#api-token-storage) + - [Token Precedence](#token-precedence) + - [Command Overview](#command-overview) + - [Commit Message Generation](#commit-message-generation) + - [Code Documentation Generation](#code-documentation-generation) + - [Use Cases](#use-cases) + - [Authentication Requirement](#authentication-requirement) + - [Configuration Settings](#configuration-settings) + - [Git Hooks](#git-hooks) + - [Post-Commit Hook](#post-commit-hook) + - [Custom Hook Location](#custom-hook-location) + - [Advanced Use Cases](#advanced-use-cases) + - [CI/CD Integration](#cicd-integration) + - [Remote Repository Documentation](#remote-repository-documentation) + - [Troubleshooting](#troubleshooting) + - [Common Issues](#common-issues) + - [Logs](#logs) + - [Support](#support) + +## Authentication + +### Login Process + +When you run `penifycli login`, the tool: + +1. Opens your default web browser +2. Redirects you to Penify's login page +3. Captures the authentication token after successful login +4. Saves the token in `~/.penify` file + +### API Token Storage + +API tokens are stored in your home directory in the `.penify` file. This JSON file contains: + +```json +{ + "api_keys": "your-api-token", + "llm": { "model": "...", "api_base": "...", "api_key": "..." }, + "jira": { "url": "...", "username": "...", "api_token": "..." } +} +``` + +### Token Precedence + +1. Environment variable `PENIFY_API_TOKEN` (highest priority) +2. Token in `~/.penify` file + +## Command Overview + +``` +penifycli +├── commit Generate smart commit messages +├── config Configure local LLM and JIRA +│ ├── llm Configure local LLM settings +│ └── jira Configure JIRA integration +├── login Log in to Penify account +└── docgen Generate code documentation + ├── install-hook Install Git post-commit hook + └── uninstall-hook Remove Git post-commit hook +``` + +## Commit Message Generation + +The `commit` command analyzes your staged changes and generates meaningful commit messages. It can: + +- Use a local LLM if configured +- Enhance messages with JIRA issue details +- Provide both title and description + +For specific options and examples, see [docs/commit-commands.md](commit-commands.md). + +## Code Documentation Generation + +The `docgen` command generates documentation for your code: + +### Use Cases + +1. **Current Git Diff**: Default behavior, documents only changed files +2. **Specific File**: Pass a file path with `-l path/to/file.py` +3. **Entire Folder**: Pass a folder path with `-l path/to/folder` + +### Authentication Requirement + +This feature requires authentication with a Penify account. Run `penifycli login` before using documentation features. + +## Configuration Settings + +Configure local settings using the `config` command: + +- **LLM Settings**: Configure a local LLM for commit message generation +- **JIRA Settings**: Set up JIRA integration for enhanced commit messages + +For detailed configuration options, see [docs/config-commands.md](config-commands.md). + +## Git Hooks + +Penify can install Git hooks to automate documentation generation: + +### Post-Commit Hook + +- **Install**: `penifycli docgen install-hook` +- **What it does**: Automatically generates documentation for changed files after each commit +- **Uninstall**: `penifycli docgen uninstall-hook` + +### Custom Hook Location + +You can specify a custom location for Git hooks: + +```bash +penifycli docgen install-hook -l /path/to/git/repo +``` + +## Advanced Use Cases + +### CI/CD Integration + +For CI/CD pipelines: + +1. Set `PENIFY_API_TOKEN` as an environment variable +2. Run commands without requiring interactive login + +### Remote Repository Documentation + +Generate documentation for an entire repository: + +```bash +git clone https://github.com/user/repo +cd repo +penifycli docgen -l . +``` + +## Troubleshooting + +### Common Issues + +1. **API Key Errors**: Ensure you've run `penifycli login` or set `PENIFY_API_TOKEN` +2. **LLM Configuration**: Check your LLM settings with `cat ~/.penify` +3. **JIRA Integration**: Verify JIRA credentials in your configuration + +### Logs + +For more detailed logs, you can set the environment variable: + +```bash +export PENIFY_DEBUG=1 +``` + +### Support + +For additional help, visit [https://docs.penify.dev/](https://docs.penify.dev/) or contact support@penify.dev diff --git a/docs/example-workflows.md b/docs/example-workflows.md new file mode 100644 index 0000000..cc2a872 --- /dev/null +++ b/docs/example-workflows.md @@ -0,0 +1,143 @@ +# Penify CLI Example Workflows + +This document demonstrates how to use Penify CLI in real-world development workflows to improve your productivity. + +## Workflow 1: Efficient Git Commits with AI + +### Setup + +First, configure your local LLM for offline operation: + +```bash +penifycli config llm +``` + +Configure your JIRA integration for enhanced commit messages: + +```bash +penifycli config jira +``` + +### Daily Workflow + +1. Make your code changes as usual +2. When ready to commit, use Penify to generate a smart commit message: + +```bash +penifycli commit +``` + +3. Review and confirm the generated commit message +4. Git commit and push as usual + +### Benefits + +- Consistent and descriptive commit messages +- Automatic inclusion of relevant JIRA ticket information +- Time saved from writing detailed commit messages + +## Workflow 2: Documentation Generation Pipeline + +### Setup + +Login to Penify to access advanced documentation features: + +```bash +penifycli login +``` + +Install the Git hook for automatic documentation generation: + +```bash +penifycli docgen install-hook +``` + +### Daily Workflow + +1. Make your code changes as usual +2. Commit your changes +3. Documentation is automatically generated for changed files +4. Review the generated documentation + +### Manual Documentation + +For specific files or folders: + +```bash +penifycli docgen -l src/components/authentication +``` + +### Benefits + +- Always up-to-date documentation +- Consistent documentation style +- Time saved from writing detailed documentation + +## Workflow 3: Code Review Enhancement + +### Setup + +Ensure you're logged into Penify: + +```bash +penifycli login +``` + +### Workflow + +1. Before submitting a PR, generate documentation for changed files: + +```bash +penifycli docgen +``` + +2. Include the generated documentation in your PR +3. Reviewers can better understand your changes with the AI-generated explanations + +### Benefits + +- Improved PR quality +- Faster code reviews +- Better team understanding of code changes + +## Workflow 4: Onboarding New Team Members + +### For Team Leads + +Generate comprehensive documentation for the entire codebase: + +```bash +penifycli docgen -l . +``` + +### For New Team Members + +Generate focused documentation for components you're working on: + +```bash +penifycli docgen -l src/components/my-feature +``` + +### Benefits + +- Faster onboarding +- Better understanding of code structure +- Reduced questions to senior team members + +## Workflow 5: Legacy Code Understanding + +When working with unfamiliar legacy code: + +```bash +# Document a specific complex file +penifycli docgen -l src/legacy/complex_module.py + +# Document an entire legacy component +penifycli docgen -l src/legacy/old_component +``` + +### Benefits + +- Quickly understand complex legacy systems +- Reduce time spent deciphering undocumented code +- Make safer changes to legacy systems diff --git a/docs/penify-cli-documentation.md b/docs/penify-cli-documentation.md new file mode 100644 index 0000000..c60467f --- /dev/null +++ b/docs/penify-cli-documentation.md @@ -0,0 +1,200 @@ +# Penify CLI Documentation + +Penify CLI is a powerful tool for enhancing your development workflow with AI-powered features like commit message generation, code documentation, and JIRA integration. + +## Installation + +```bash +pip install penifycli +``` + +## Getting Started + +After installation, you can check the version of Penify CLI: + +```bash +penifycli --version +``` + +## Commands Overview + +- `commit`: Generate smart commit messages using local-LLM +- `config`: Configure local-LLM and JIRA settings +- `login`: Log in to Penify to use advanced features +- `docgen`: Generate code documentation for Git diffs, files, or folders + +## Detailed Command Documentation + +### Commit Command + +The `commit` command generates intelligent commit messages using local LLM models or Penify services. + +#### Usage: + +```bash +penifycli commit [options] +``` + +#### Options: + +- `-m, --message TEXT`: Provide context for the commit message generation +- `-e, --terminal`: Open an editor to modify the generated commit message before applying it +- `-d, --description`: Generate a detailed commit message with both title and description + +#### Examples: + +**Basic usage:** +```bash +penifycli commit +``` + +**Provide context for better results:** +```bash +penifycli commit -m "Fixed the login button" +``` + +**Generate a detailed commit message and open editor:** +```bash +penifycli commit -e -d +``` + +#### Requirements: + +- Either a local LLM configuration (via `penifycli config llm`) or Penify login +- For JIRA integration, configure JIRA settings (via `penifycli config jira`) + +--- + +### Config Command + +The `config` command helps you configure local LLM settings and JIRA integration for enhanced commit messages. + +#### Usage: + +```bash +penifycli config [subcommand] +``` + +#### Subcommands: + +- `llm`: Configure local Large Language Model settings +- `jira`: Configure JIRA integration settings + +#### Examples: + +**Configure local LLM:** +```bash +penifycli config llm +``` +This opens a web interface to configure: +- Model name (e.g., gpt-3.5-turbo, llama2) +- API base URL (e.g., https://api.openai.com/v1) +- API key + +**Configure JIRA integration:** +```bash +penifycli config jira +``` +This opens a web interface to configure: +- JIRA URL (e.g., https://your-domain.atlassian.net) +- Username (typically your email) +- API token + +--- + +### Login Command + +The `login` command authenticates you with Penify for advanced features like code documentation generation. + +#### Usage: + +```bash +penifycli login +``` + +#### What happens: +1. A browser window opens to the Penify login page +2. After successful login, your API key is automatically saved +3. The tool is now authorized to use Penify's advanced features + +#### Example: + +```bash +penifycli login +``` + +--- + +### Docgen Command + +The `docgen` command generates documentation for your code using Penify's AI services. + +#### Usage: + +```bash +penifycli docgen [options] [subcommand] +``` + +#### Options: + +- `-l, --location PATH`: Path to a specific file or folder to document (default: current working directory) + +#### Subcommands: + +- `install-hook`: Install a Git post-commit hook to automatically generate documentation +- `uninstall-hook`: Remove the Git post-commit hook + +#### Examples: + +**Document current Git diff:** +```bash +penifycli docgen +``` + +**Document a specific file:** +```bash +penifycli docgen -l src/main.py +``` + +**Document an entire folder:** +```bash +penifycli docgen -l src/components +``` + +**Install the Git hook for automatic documentation:** +```bash +penifycli docgen install-hook +``` + +**Uninstall the Git hook:** +```bash +penifycli docgen uninstall-hook +``` + +#### Requirements: + +- Requires login to Penify (`penifycli login`) + +## Configuration Files + +Penify CLI stores configuration in the following locations: + +- Global configuration: `~/.penify` +- Project-specific configuration: `.penify` in your Git repository root + +## Environment Variables + +- `PENIFY_API_TOKEN`: Can be used to provide the API token instead of logging in + +## Troubleshooting + +If you encounter issues: + +1. Check your configuration with `cat ~/.penify` +2. Verify network connectivity to API endpoints +3. Ensure your API keys and tokens are valid +4. For JIRA integration issues, verify your JIRA credentials + +## Additional Resources + +For more information, visit the [Penify Documentation](https://docs.penify.dev/). From f2b67725bdca0131d3dd03fd962d693aebe0d2bb Mon Sep 17 00:00:00 2001 From: sumansaurabh Date: Sun, 9 Mar 2025 02:30:48 +0530 Subject: [PATCH 2/3] feat(docs): add detailed documentation for Penify CLI's docgen command and Git hook integration --- docs/doc_commands.md | 327 +++++++++++++++++++++++++++++++ docs/penify-cli-documentation.md | 7 + 2 files changed, 334 insertions(+) create mode 100644 docs/doc_commands.md diff --git a/docs/doc_commands.md b/docs/doc_commands.md new file mode 100644 index 0000000..9d8c633 --- /dev/null +++ b/docs/doc_commands.md @@ -0,0 +1,327 @@ +# Penify CLI - Documentation Generation Commands + +This document provides a detailed guide to all permutations and combinations of the `docgen` command, including extensive information about Git hook commands for automating documentation generation. + +## Table of Contents + +- [Basic Usage](#basic-usage) +- [Command Options](#command-options) +- [Option Combinations](#option-combinations) +- [Git Hook Commands](#git-hook-commands) + - [Hook Installation](#hook-installation) + - [Hook Customization](#hook-customization) + - [Hook Uninstallation](#hook-uninstallation) +- [Advanced Use Cases](#advanced-use-cases) +- [Troubleshooting](#troubleshooting) + +## Basic Usage + +```bash +penifycli docgen +``` + +By default, this command: +- Analyzes the current Git diff (changes since last commit) +- Generates documentation for changed files only +- Requires authentication via `penifycli login` + +## Command Options + +### `-l, --location` + +Specify a target for documentation generation: + +```bash +# Generate documentation for a specific file +penifycli docgen -l path/to/file.py + +# Generate documentation for a specific folder +penifycli docgen -l path/to/folder +``` + +Without this flag, Penify analyzes only Git-tracked modified files. + +### Subcommands + +#### `install-hook` + +Install a Git post-commit hook to automatically generate documentation: + +```bash +penifycli docgen install-hook +``` + +#### `uninstall-hook` + +Remove the Git post-commit hook: + +```bash +penifycli docgen uninstall-hook +``` + +## Option Combinations + +### Generate Documentation for Current Git Diff + +```bash +# Basic usage - current Git diff +penifycli docgen +``` + +### Generate Documentation for a Specific File + +```bash +# Single file documentation +penifycli docgen -l src/main.py +``` + +### Generate Documentation for a Folder + +```bash +# Folder documentation +penifycli docgen -l src/models/ +``` + +### Install Hook in Current Repository + +```bash +# Install hook in current Git repository +penifycli docgen install-hook +``` + +### Install Hook in Specific Repository + +```bash +# Install hook in a specific Git repository +penifycli docgen install-hook -l /path/to/repo +``` + +### Uninstall Hook from Current Repository + +```bash +# Uninstall hook from current Git repository +penifycli docgen uninstall-hook +``` + +### Uninstall Hook from Specific Repository + +```bash +# Uninstall hook from a specific Git repository +penifycli docgen uninstall-hook -l /path/to/repo +``` + +## Git Hook Commands + +Penify provides Git hook commands to automate documentation generation as part of your Git workflow. + +### Hook Installation + +#### How Hooks Work + +When you install a Git hook with `penifycli docgen install-hook`, Penify: + +1. Creates a post-commit hook script in the `.git/hooks` directory +2. Makes the script executable +3. Configures the hook to run `penifycli docgen` after each commit + +#### Hook Script Content + +The generated post-commit hook contains: + +```bash +#!/bin/sh +# This is a post-commit hook generated by penifycli. +# Automatically generates documentation for changed files after each commit. + +penifycli docgen -gf /path/to/git/repository -t your_api_token +``` + +#### Installation Location + +By default, hooks are installed in the current Git repository. You can specify a different location: + +```bash +penifycli docgen install-hook -l /path/to/repo +``` + +#### Installation Requirements + +To install hooks, you need: +- A valid Penify API token (login first with `penifycli login`) +- Write permissions to the `.git/hooks` directory + +#### Verifying Installation + +After installation, you can verify that the hook is installed: + +```bash +cat .git/hooks/post-commit +``` + +### Hook Customization + +You can customize the post-commit hook after installation: + +#### Modifying Hook Behavior + +1. Edit the `.git/hooks/post-commit` file +2. Add additional options to the `penifycli docgen` command +3. Add other commands to run after commit + +Example of a customized hook: + +```bash +#!/bin/sh +# This is a post-commit hook generated by penifycli. +# Automatically generates documentation for changed files after each commit. + +# Generate documentation +penifycli docgen -gf /path/to/git/repository -t your_api_token + +# Additional custom commands +echo "Documentation generation complete!" +``` + +#### Advanced Hook Scenarios + +**Conditional Documentation Generation**: + +```bash +#!/bin/sh +# Only generate documentation for commits to the main branch +BRANCH=$(git rev-parse --abbrev-ref HEAD) +if [ "$BRANCH" = "main" ]; then + penifycli docgen -gf /path/to/git/repository -t your_api_token +fi +``` + +**Documenting Specific Files/Folders**: + +```bash +#!/bin/sh +# Only document Python files in the src directory +penifycli docgen -l src/ -gf /path/to/git/repository -t your_api_token +``` + +### Hook Uninstallation + +#### Standard Uninstallation + +To remove a hook from the current repository: + +```bash +penifycli docgen uninstall-hook +``` + +#### Specific Repository Uninstallation + +To remove a hook from a specific repository: + +```bash +penifycli docgen uninstall-hook -l /path/to/repo +``` + +#### Manual Hook Removal + +If needed, you can manually remove the hook: + +```bash +rm .git/hooks/post-commit +``` + +#### Verifying Uninstallation + +Check that the hook was successfully removed: + +```bash +ls -la .git/hooks/post-commit # Should return "No such file or directory" +``` + +## Advanced Use Cases + +### Continuous Integration + +Run documentation generation in CI pipelines: + +```bash +# In your CI script +export PENIFY_API_TOKEN=your_api_token +penifycli docgen -l src/ +``` + +### Batch Documentation + +Generate documentation for multiple repositories: + +```bash +# Bash script for batch documentation +for repo in repo1 repo2 repo3; do + cd /path/to/$repo + penifycli docgen -l . +done +``` + +### Custom Git Hook Integration + +Integrate with other Git hooks: + +```bash +# In .git/hooks/pre-push +penifycli docgen -l src/ +``` + +### Documenting Release Tags + +Generate documentation when creating a release tag: + +```bash +# Document everything when creating a tag +git tag -a v1.0.0 +penifycli docgen -l . # Document entire codebase +git commit --amend -m "Release v1.0.0 with updated documentation" +``` + +## Troubleshooting + +### Common Issues + +1. **"Authentication required"** + - Run `penifycli login` before using documentation features + - Check your API token with `cat ~/.penify` + +2. **"Permission denied when installing hook"** + - Check Git repository permissions + - Try running with sudo (if appropriate for your environment) + - Ensure the `.git/hooks` directory exists + +3. **"Hook installed but not running"** + - Check if the hook is executable: `ls -la .git/hooks/post-commit` + - Make it executable if needed: `chmod +x .git/hooks/post-commit` + - Check for syntax errors in the hook script + +4. **"File or directory not found"** + - Verify the path provided to the `-l` option + - Ensure you're running the command from the correct directory + +5. **"Hook uninstallation failed"** + - Check permissions on the `.git/hooks` directory + - Try manual removal: `rm .git/hooks/post-commit` + +### Debugging + +For detailed output when running documentation commands: + +```bash +export PENIFY_DEBUG=1 +penifycli docgen -l src/ +``` + +### Getting Help + +For command-specific help: + +```bash +penifycli docgen --help +penifycli docgen install-hook --help +penifycli docgen uninstall-hook --help +``` diff --git a/docs/penify-cli-documentation.md b/docs/penify-cli-documentation.md index c60467f..1a22b77 100644 --- a/docs/penify-cli-documentation.md +++ b/docs/penify-cli-documentation.md @@ -1,3 +1,10 @@ +--- +layout: doc +title: Streamline Git Commits and Code Documentation with Penify-CLI's Automated Generation +description: Discover how Penify-CLI automates both Git commit messages and code documentation, with Jira integration and flexible options. Save time, improve repository clarity, and boost productivity with this detailed guide to usage and best practices. +keywords: Penify-CLI, Git commit messages, code documentation, Jira integration, automated documentation, version control, repository management, developer productivity +author: Suman Sauarbh +--- # Penify CLI Documentation Penify CLI is a powerful tool for enhancing your development workflow with AI-powered features like commit message generation, code documentation, and JIRA integration. From 9c59d3964772509c592155fe148156ba33c5f66c Mon Sep 17 00:00:00 2001 From: sumansaurabh Date: Sun, 9 Mar 2025 02:31:11 +0530 Subject: [PATCH 3/3] feat(docs): enhance README with detailed usage instructions and command options --- README.md | 163 ++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 120 insertions(+), 43 deletions(-) diff --git a/README.md b/README.md index 97f4c10..db0ad8c 100644 --- a/README.md +++ b/README.md @@ -1,89 +1,166 @@ -# Penify CLI +# Penify CLI Tool -Penify CLI is a tool that enhances your development workflow with AI-powered capabilities: +![Tests](https://github.com/yourorganization/penify-cli/workflows/Tests/badge.svg) +![Coverage](./coverage.svg) -- Generate smart commit messages using local LLM models or cloud API -- Automatically create code documentation -- Integrate with JIRA for enhanced commit messages -- Install Git hooks for automated documentation generation +A CLI tool to generate smart commit messages, code documentation, and more. + +## Features + +- Automatically generate documentation for your code +- Support for multiple programming languages +- Git hook integration for automatic documentation on commits +- Folder and file analysis ## Installation +Install from PyPI: + ```bash pip install penifycli ``` -## Authentication +## Usage + +Penify CLI provides several subcommands for different functionalities, organized into basic commands (no login required) and advanced commands (login required). + +## Basic Commands (No login required) -Penify CLI supports two authentication methods: +### Commit -### 1. Login to Penify Account (Required for Advanced Features) +Generate smart commit messages using local LLM: ```bash -penifycli login +penifycli commit [-m "Optional message"] [-e] [-d] ``` -This command will open your browser and prompt you to log in to your Penify account. Once authenticated, your API token will be saved locally. +Options: +- `-m, --message`: Optional custom commit message +- `-e, --terminal`: Open editor to modify commit message before committing +- `-d, --description`: Generate commit message with both title and description (without this flag, only title is generated) -### 2. Environment Variable +### Config -For CI/CD pipelines or automated environments, you can set: +Configure local LLM and JIRA settings: ```bash -export PENIFY_API_TOKEN=your_api_token +# Configure LLM settings +penifycli config llm --model MODEL_NAME [--api-base API_URL] [--api-key API_KEY] + +# Configure LLM settings through web interface +penifycli config llm-web + +# Configure JIRA settings +penifycli config jira --url JIRA_URL --username USERNAME --api-token TOKEN [--verify] + +# Configure JIRA settings through web interface +penifycli config jira-web ``` -## Basic Usage +## Advanced Commands (Login required) + +### Login -### Generate Smart Commit Messages +To log in and obtain an API token: ```bash -penifycli commit +penifycli login ``` -### Generate Code Documentation +This command will open a browser window for authentication. After successful login, the API key will be saved locally for future use. + +### Documentation Generation + +Generate documentation for Git diff, files or folders: ```bash -# Generate documentation for current Git diff (requires login) +# Generate documentation for latest Git commit diff penifycli docgen -# Generate documentation for a specific file -penifycli docgen -l path/to/file.py - -# Generate documentation for a folder -penifycli docgen -l path/to/folder +# Generate documentation for specific file or folder +penifycli docgen -l /path/to/file/or/folder ``` -### Configure Local LLM or JIRA +Options: +- `-l, --location`: Path to specific file or folder for documentation generation (defaults to current directory) + +### Git Hook Management + +Install or uninstall Git post-commit hooks: ```bash -# Configure Local LLM for commit message generation -penifycli config llm +# Install Git hook +penifycli docgen install-hook [-l /path/to/repo] -# Configure JIRA integration -penifycli config jira +# Uninstall Git hook +penifycli docgen uninstall-hook [-l /path/to/repo] ``` -### Automate Documentation with Git Hooks +Options: +- `-l, --location`: Path to the Git repository (defaults to current directory) -```bash -# Install a post-commit hook -penifycli docgen install-hook +## Authentication + +Penify CLI uses an API token for authentication with advanced features. + +If no token is available and you try to access an advanced feature, you'll be prompted to log in. -# Remove the hook -penifycli docgen uninstall-hook +## Local LLM Configuration + +For commit message generation, Penify can use a local LLM. Configure it using: + +```bash +penifycli config llm --model MODEL_NAME --api-base API_URL --api-key API_KEY ``` -## Getting Help +Common configurations: +- OpenAI: `--model gpt-3.5-turbo --api-base https://api.openai.com/v1 --api-key YOUR_KEY` +- Anthropic: `--model claude-2 --api-base https://api.anthropic.com --api-key YOUR_KEY` + +## JIRA Integration + +Configure JIRA integration to enhance commit messages with issue details: ```bash -# Get general help -penifycli --help +penifycli config jira --url https://your-domain.atlassian.net --username your-email@example.com --api-token YOUR_API_TOKEN +``` + +## Development + +To set up the development environment: + +1. Clone the repository: + ```bash + git clone https://github.com/SingularityX-ai/penify-cli.git + ``` + +2. Install the package in editable mode: + ```bash + pip install -e . + ``` + +### Running Tests -# Get help for a specific command -penifycli commit --help -penifycli docgen --help -penifycli config --help +```bash +pytest ``` -For detailed documentation and examples, see [docs/detailed-usage.md](docs/detailed-usage.md). \ No newline at end of file +## License + +This project is licensed under the MIT License. + +## Author + +Suman Saurabh (ss.sumansaurabh92@gmail.com) + +## Contributing + +Contributions are welcome! Please feel free to submit a Pull Request. + +## Issues + +If you encounter any problems or have suggestions, please file an issue on the [GitHub repository](https://github.com/SingularityX-ai/penifycli/issues). + +## Support + +For automated API Documentation, Architecture Documentation, Code Documentation, Pull Request Documentation, or if you need a demo, please join our [Discord support channel](https://discord.gg/wqrc8JeV). \ No newline at end of file