Skip to content

Commit

Permalink
feat(main): Add commit prompt constant
Browse files Browse the repository at this point in the history
- Add COMMIT_PROMPT constant with detailed instructions
  * Provides guidelines for generating conventional commit messages
  * Includes format, structure, language, and content requirements
  * Specifies response format for commit message generator
- Update getCommitMessage function to use new prompt
  * Replaces previous prompt with COMMIT_PROMPT constant
  * Ensures commit messages follow new standards
  • Loading branch information
sidedwards committed Oct 23, 2024
1 parent e9052e3 commit de738bf
Showing 1 changed file with 38 additions and 28 deletions.
66 changes: 38 additions & 28 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,34 +24,44 @@ function stopLoading(intervalId: number) {
Deno.stdout.writeSync(new TextEncoder().encode('\x1B[?25h')); // Show cursor
}

// Add these constants at the top
const COMMIT_PROMPT = `You are a Git Commit Message Generator. Create a detailed, specific commit message that:
1. Starts with the most significant change (max 50 chars)
2. Uses imperative mood ("Add" not "Added")
3. Separates subject from body with a blank line
4. Includes detailed bullet points that explain:
- What changed
- Why it was changed
- Impact of the change
5. Lists breaking changes with "BREAKING:" prefix
6. Keeps technical implementation details minimal
Example:
Add user authentication system
- Add JWT-based authentication for all API routes
* Improves security by requiring token validation
* Enables user-specific access controls
- Implement rate limiting to prevent abuse
* 100 requests per minute per user
* Configurable through environment variables
- Add Redis for token storage and session management
* Enables horizontal scaling
* 24-hour token expiration
BREAKING: All API routes now require Authorization header
Token format changed to JWT standard`;
const COMMIT_PROMPT = `You are a Git Commit Message Generator that follows conventional commit standards. Generate commit messages directly without explanations or markdown formatting.
1. Follow the format: <type>(<scope>): <subject>
Types: feat|fix|docs|style|refactor|test|chore
Subject: max 50 chars, imperative mood
2. Structure the message with:
- Header: Brief summary in present tense
- Blank line
- Body: Bullet points explaining what/why/impact
- Footer: Breaking changes, references
3. Use precise, actionable language:
✓ "Add user authentication"
✗ "Added some auth stuff"
4. Include only:
• Specific changes made
• Reasoning behind changes
• Impact on functionality
• Breaking changes (if any)
5. Mark breaking changes as:
BREAKING CHANGE: <description>
RESPONSE FORMAT:
<type>(<scope>): <subject>
- Main change description
* Impact or detail
* Additional context
- Secondary change
* Impact or detail
* Additional context
BREAKING CHANGE: <description> (if applicable)
Do not include any explanatory text, markdown formatting, or quotes around the message.`;

// Function to call the Anthropic API
async function getCommitMessage(diff: string, apiKey: string): Promise<string> {
Expand Down

0 comments on commit de738bf

Please sign in to comment.