How jaydoubleu/pycomet works
Main Components
• CLI Layer (Entry Point): Represented by the “cli.py” module, this is where user commands (like commit, preview, and config) are handled.
• Configuration Manager: “config.py” reads user settings from the YAML file (~/.config/pycomet/config.yaml) and applies necessary configurations (including API keys and preference flags).
• AI Integration Module: “ai.py” is dedicated to interfacing with external AI providers (such as Anthropic Claude, OpenAI, Google Gemini, and Azure OpenAI) for generating commit messages.
• Git Interaction Module: “git.py” manages interactions with the local Git repository, facilitating the addition, preview, and actual commit actions.
• Core Models & Helpers: “models.py” and potential utility functions (in other modules) encapsulate core data structures and common logic.
Relationships and Data Flows
• Config Flow: Show that the “Configuration Manager” loads and updates settings from the config file which influences how the AI module and Git module operate.
• Testing and Quality Control: Optionally, note that the “tests” directory includes tests designed to verify behavior across modules (this component can be depicted separately or as annotations to the main modules).
Architectural Patterns and Technologies
• Separation of Concerns: The architecture neatly separates command handling, configuration management, external API integration, and Git interactions.
• Modular Structure: Each Python module (cli.py, config.py, ai.py, git.py, models.py) is designed to tackle a specific aspect of the tool’s functionality.
• External Integration: Emphasize the dependency on AI providers, with the provider chosen via configuration. Also include references to key libraries such as Click (for CLI) and litellm (for AI calls).
• Start from the User Terminal (depicting the user’s execution of commands such as "pycomet commit", "pycomet preview", "pycomet config").
• CLI layer (from cli.py) intercepting these commands.
• From the CLI, branch out:
• One branch to the Configuration module (config.py) which loads settings from the YAML config.
• Another branch to the AI Integration module (ai.py) which handles message generation by making requests to external AI providers.
• After message generation, link to the Git Interaction module (git.py) that processes the commit (using git commands) into the local repository.