This document outlines the technical stack and specific rules for using libraries within the ai-gen-dev project. Following these guidelines ensures consistency, maintainability, and clarity in the codebase.
The ai-gen-dev CLI tool is built with the following technologies:
- Runtime: Node.js (version >=18.0.0), providing the server-side JavaScript execution environment.
- Language: JavaScript (ES Modules), utilizing modern
import/exportsyntax. - CLI Framework: Commander.js is used to build the command-line interface, parse arguments, and define commands.
- AI Integration: Google Generative AI SDK (
@google/generative-ai) powers all AI-driven features by interacting with the Gemini API. - Git Interaction: simple-git provides a lightweight interface for executing Git commands within the application.
- Console Output: Chalk is used for adding color and styling to console output, enhancing user experience.
- Configuration Management: Conf handles local configuration, securely storing the user's Gemini API key.
- CI/CD: GitHub Actions are used to automate workflows for publishing to NPM and version bumping.
To maintain a clean and predictable architecture, adhere to the following rules when modifying the codebase:
-
CLI Structure (
commander)- Rule: All CLI commands, options, and arguments must be defined in
bin/cli.jsusing thecommanderlibrary. - Reason: This file serves as the single source of truth for the application's command-line interface.
- Rule: All CLI commands, options, and arguments must be defined in
-
AI Generation (
@google/generative-ai)- Rule: All calls to the Gemini API for content generation must be abstracted within
src/aiGenerator.js. Do not instantiate theGoogleGenerativeAIclient elsewhere. - Reason: Centralizing AI logic makes it easier to manage prompts, update models, and handle API changes.
- Rule: All calls to the Gemini API for content generation must be abstracted within
-
Git Operations (
simple-git)- Rule: Any interaction with the Git repository (e.g., checking status, getting diffs, committing) must use the
simple-gitwrapper. All Git-related utility functions should reside insrc/gitUtils.js. - Reason: Avoids executing raw Git commands and provides a consistent, error-handled API for Git operations.
- Rule: Any interaction with the Git repository (e.g., checking status, getting diffs, committing) must use the
-
User-Facing Messages (
chalk)- Rule: Use
chalkfor all console output directed at the user. Use distinct colors for different message types (e.g.,chalk.greenfor success,chalk.redfor errors,chalk.bluefor information). - Reason: Improves readability and provides a better user experience.
- Rule: Use
-
Configuration (
conf)- Rule: All access to the user's configuration (i.e., the Gemini API key) must go through the getter and setter functions (
getApiKey,setApiKey) insrc/config.js. - Reason: Encapsulates the logic for storing and retrieving configuration, allowing the underlying storage mechanism to be changed without affecting the rest of the application.
- Rule: All access to the user's configuration (i.e., the Gemini API key) must go through the getter and setter functions (
-
File System (
fs,ignore)- Rule: For simple file reading/writing, use the native Node.js
fsmodule. For complex project scanning that must respect.gitignorerules, use the existingscanProjectfunction insrc/projectScanner.js. - Reason: Uses the right tool for the job—simplicity for basic tasks and robustness for complex ones.
- Rule: For simple file reading/writing, use the native Node.js