UNPKG

@cirrusinvicta/ai-commit-toolkit

Version:

AI-powered conventional commit generation with centralized configuration, OpenAI integration, and automated deployment workflows

193 lines (156 loc) 9.76 kB
#!/bin/bash # AI Prompts Configuration # Centralized prompts for AI commit toolkit scripts # This file is sourced by various scripts that need AI prompts # Main AI commit generation prompt # Used by: ai-commit.sh, test-ai-setup.sh AI_COMMIT_PROMPT="Generate a conventional commit message for the following changes. Guidelines: - Format: type(scope): subject - Subject line: max 72 characters, focused on WHAT changed (not HOW) - Header (type + scope + subject): max 100 characters - Type and scope must be lowercase - Use 'feat' for new user-facing functionality or capabilities - Use 'fix' for bug fixes and corrections - Use 'chore' for maintenance tasks, tooling, and non-functional changes - Use 'refactor' for code restructuring without changing behavior - Use 'test' for adding/improving/fixing tests - Use 'docs' for documentation changes - Use 'perf' for performance improvements - For multiple unrelated changes, choose the most significant one for the subject - ONLY if the subject alone isn't sufficient, include a multi-line body (wrapped at 72 chars per line) - IF using a multi-line body, keep it consice and only include absolutely necessary details - Use a bullet list in the body for multiple significant changes - Include a footer ONLY when there are actual breaking changes or issue references (Examples: 'BREAKING CHANGE: API endpoint removed', 'Fixes #456' - only if relevant) IMPORTANT FOR MAJOR COMMITS: - If you see files with 200+ lines added, this is likely a major feature implementation - Look for patterns like: scope-helper.sh, scope-detector.sh, enhanced documentation - These indicate a comprehensive feature addition, not just setup/config - Examples of what to look for: * Files ending in -helper.sh, -detector.sh = new tooling systems * Large .md files in docs/ = comprehensive documentation for major features * Multiple related scripts = complete feature implementation - For such commits, use 'feat' not 'chore', and highlight the main capability being added Scope Selection (important): - Use the predefined scope mappings when available - For hierarchical features, use dot notation (e.g., mail.allow-block-lists, reports.email-traffic) - Common scopes: mail, dns, reports, settings, auth, billing, onboarding, dashboard, admin - Technical scopes: api, ui, db, perf, security, infra, docs, tests - Cross-cutting: a11y, i18n, mobile, seo, analytics, monitoring - If changes span multiple areas, choose the most significant scope - For accessibility improvements, always use 'a11y' scope regardless of area Examples of proper scope usage: - Allow/Block Lists feature: feat(mail.allow-block-lists): add search functionality - DNS policies: feat(dns.policies): implement custom filtering rules - Test improvements: test(tests): enhance unit test coverage for CLI functionality - Accessibility: chore(a11y): add aria labels to form inputs - API endpoints: feat(api): add user preference endpoints - Multiple areas: chore(setup): initialize project configuration Language Style (important): - Style mode: \$COMMIT_MESSAGE_STYLE - If 'user-centric' (default): Use business/user-friendly language - Focus on user-facing features and business value - Convert technical terms to user-friendly descriptions - Examples: 'User Profile page' not 'UserProfile.vue', 'Login functionality' not 'AuthService.js' - Emphasize what users can now do or what problems are solved - If 'developer-centric': Use technical component names and file references - Include specific file names, component names, and technical details - Focus on code structure and technical implementation For multiple files: - If files are related (same feature/fix), use a unified subject - If files are diverse, use a general scope like 'setup', 'config', or 'project' - Prioritize the most impactful change in the subject line Examples for user-centric style: - Change: Update UserProfile.vue, ProfileSettings.js Commit: feat(profile): enhance user profile customization options - Change: Fix AuthService.js login validation Commit: fix(auth): resolve login validation issues - Change: Add PaymentModal.vue, PaymentService.js Commit: feat(payments): add credit card payment processing Examples for developer-centric style: - Change: Update UserProfile.vue, ProfileSettings.js Commit: feat(profile): update UserProfile.vue and ProfileSettings.js - Change: Fix AuthService.js login validation Commit: fix(auth): fix validation logic in AuthService.js - Change: Add PaymentModal.vue, PaymentService.js Commit: feat(payments): implement PaymentModal and PaymentService Example (multi-line body for multiple changes): chore(setup): initialize AI commit toolkit - Add Husky hooks for commit message validation - Configure commitlint for conventional commits - Create environment and configuration files - Install project dependencies and scripts Files changed: \$FILES Changes: \$DIFF Important: - Do NOT add issue references like 'Closes #123' unless the changes actually reference a specific issue - Do NOT add 'BREAKING CHANGE:' unless there are actual breaking changes - Focus on describing the actual changes, not fictional examples Respond with ONLY the commit message. Do not include explanations or commentary." # AI commit helper prompt (for interactive mode) # Used by: commit-helper-ai.sh AI_COMMIT_HELPER_PROMPT="Generate a conventional commit message for these changes. Language Style: - Style mode: \$COMMIT_MESSAGE_STYLE - If 'user-centric': Use business/user-friendly language focusing on user value - If 'developer-centric': Use technical component names and file references Context: - Repository: \$REPO_NAME - Branch: \$BRANCH_NAME - Files modified: \$FILES Rules: - Use the 'chore' type for version bumps, release process changes, or package manager lockfile updates. - Maximum 100 characters for header (including type, scope, and subject) - Maximum 72 characters for subject - Format: type(scope): description - Include a body only if the primary purpose is not clear from the header - Body should be wrapped at 72 characters - Include a footer ONLY for actual breaking changes or real issue references - Type and scope should be lowercase - Be descriptive but concise - Consider the business impact - Focus on WHAT changed, not HOW Changes: \$DIFF Important: Only add issue references or breaking change notes if they are actually relevant to the changes. Provide the commit message and a brief explanation of why this format was chosen." # OpenAI API Configuration OPENAI_MODEL="gpt-4o-mini" OPENAI_MAX_TOKENS=100 OPENAI_TEMPERATURE=0.3 OPENAI_API_URL="https://api.openai.com/v1/chat/completions" # Commit message style configuration # Options: "user-centric" (default) or "developer-centric" # user-centric: Uses business/user-friendly language (e.g., "User Profile page" instead of "UserProfile.vue") # developer-centric: Uses technical component names and file references COMMIT_MESSAGE_STYLE="user-centric" # ===== SCOPE MAPPING CONFIGURATION ===== # Define consistent scopes for different areas of your application # Format: "scope:description|scope:description" # Use these mappings to ensure consistent scope naming across commits # Application Feature Areas SCOPE_MAP_FEATURES="mail:Email and mail protection features|dns:DNS filtering and management|reports:Analytics and reporting dashboard|settings:Application configuration and preferences|auth:Authentication and user management|billing:Subscription and payment features|onboarding:User setup and welcome flows|dashboard:Main dashboard and overview|admin:Administrative functions and controls" # Technical Areas SCOPE_MAP_TECHNICAL="api:Backend API endpoints and services|ui:User interface components and styling|db:Database schema and migrations|perf:Performance optimizations|security:Security enhancements and fixes|infra:Infrastructure and deployment|docs:Documentation updates|tests:Test suites and quality assurance" # Cross-cutting Concerns SCOPE_MAP_CONCERNS="a11y:Accessibility improvements|i18n:Internationalization and localization|mobile:Mobile responsiveness and features|seo:Search engine optimization|analytics:User behavior tracking|monitoring:Application health and metrics" # Sub-scope Examples (use dot notation for hierarchical scopes) # Examples: mail.allow-block-lists, mail.quarantine, reports.email-traffic, settings.notifications SCOPE_MAP_EXAMPLES="mail.allow-block-lists:Allow/Block Lists management|mail.quarantine:Email quarantine features|mail.scanning:Email scanning and filtering|dns.policies:DNS filtering policies|dns.custom-rules:Custom DNS filtering rules|reports.email-traffic:Email traffic analytics|reports.threat-detection:Security threat reports|settings.notifications:Notification preferences|settings.integrations:Third-party integrations|auth.mfa:Multi-factor authentication|auth.sso:Single sign-on features" # Scope Validation (optional - comma-separated list of allowed scopes) # Leave empty to allow any scope, or specify exact scopes to enforce consistency # Example: "mail,dns,reports,settings,auth,billing,onboarding,dashboard,admin,api,ui,db,a11y" ALLOWED_SCOPES="" # Commit message validation rules MAX_COMMIT_LENGTH=100 WARN_COMMIT_LENGTH=72 # Valid conventional commit types VALID_COMMIT_TYPES="feat,fix,docs,style,refactor,perf,test,chore,build,ci,revert" # Exclusion patterns for files/directories to ignore in AI commit context # Note: package-lock.json is excluded from AI analysis but should still be committed AI_COMMIT_EXCLUDE="node_modules/ package-lock.json .env" # Exclusion patterns for .gitignore (what should never be committed) # Note: package-lock.json is NOT included here - it should be committed GITIGNORE_EXCLUDE="node_modules .env"