Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .cursor/rules/code-organization.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
description:
globs:
alwaysApply: true
---
# Code Organization

## Core Functionality

The core functionality of git-gpt-commit is organized as follows:

- [index.js](mdc:index.js) - Main entry point with the following key functions:
- `getGitSummary()` - Gets the git diff summary of staged changes
- `gptCommit()` - Generates a commit message using OpenAI API
- `gitExtension()` - Sets up the CLI commands

## Utility Functions

- [utils/sanitizeCommitMessage.js](mdc:utils/sanitizeCommitMessage.js) - Cleans up generated commit messages

## Tests

- [utils/sanitizeCommitMessage.test.js](mdc:utils/sanitizeCommitMessage.test.js) - Tests for the sanitize function
- [vitest.config.js](mdc:vitest.config.js) - Test configuration

## Configuration

The application uses the following configuration mechanisms:

1. Environment variables (.env file) for the OpenAI API key
2. Local config file (~/.git-gpt-commit-config.json) for user preferences
3. Command-line options via Commander.js
92 changes: 92 additions & 0 deletions .cursor/rules/coding-patterns.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
---
description:
globs:
Comment on lines +2 to +3
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Complete the frontmatter metadata fields.

The description and globs fields in the frontmatter are empty. These should be completed to properly define when and where these patterns should be applied.

---
-description: 
-globs: 
+description: Standard coding patterns for CLI, OpenAI API, configuration and user prompts
+globs: **/*.js
alwaysApply: true
---

Committable suggestion skipped: line range outside the PR's diff.

alwaysApply: true
---
# Coding Patterns

## Command Line Interface

The application uses Commander.js for CLI functionality:

```javascript
program
.command('command-name')
.description('Description of the command')
.action(async () => {
// Command implementation
});
```

## OpenAI API Integration

OpenAI API calls follow this pattern:

```javascript
// Initialize OpenAI client
const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });

// Prepare messages
const messages = [
{ role: 'system', content: 'System instruction' },
{ role: 'user', content: 'User message' }
];

// Make API request
const response = await openai.chat.completions.create({
model: 'model-name',
messages,
temperature: 0,
max_tokens: 50
});

// Extract response
const message = response.choices[0].message.content.trim();
```

## Configuration Management

Configuration is stored in the user's home directory:

```javascript
// Define config file path
const CONFIG_FILE = path.join(os.homedir(), '.git-gpt-commit-config.json');

// Load configuration
function loadConfig() {
if (fs.existsSync(CONFIG_FILE)) {
const config = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
// Use config values
}
}

// Save configuration
function saveConfig(config) {
// Load existing config first
let existingConfig = {};
if (fs.existsSync(CONFIG_FILE)) {
existingConfig = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
}
// Merge with new config
const updatedConfig = { ...existingConfig, ...config };
fs.writeFileSync(CONFIG_FILE, JSON.stringify(updatedConfig, null, 2));
}
```

## User Prompts

User interactions use the prompts library:

```javascript
const response = await prompts({
type: 'confirm', // or 'select', etc.
name: 'value',
message: 'Message to display',
initial: true // Default value
});

// Access user response
if (response.value) {
// User confirmed
}
```
53 changes: 53 additions & 0 deletions .cursor/rules/cursor_rules.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
description: Guidelines for creating and maintaining Cursor rules to ensure consistency and effectiveness.
globs: .cursor/rules/*.mdc
alwaysApply: true
---

- **Required Rule Structure:**
```markdown
---
description: Clear, one-line description of what the rule enforces
globs: path/to/files/*.ext, other/path/**/*
alwaysApply: boolean
---

- **Main Points in Bold**
- Sub-points with details
- Examples and explanations
```

- **File References:**
- Use `[filename](mdc:path/to/file)` ([filename](mdc:filename)) to reference files
- Example: [prisma.mdc](mdc:.cursor/rules/prisma.mdc) for rule references
- Example: [schema.prisma](mdc:prisma/schema.prisma) for code references

- **Code Examples:**
- Use language-specific code blocks
```typescript
// ✅ DO: Show good examples
const goodExample = true;

// ❌ DON'T: Show anti-patterns
const badExample = false;
```

- **Rule Content Guidelines:**
- Start with high-level overview
- Include specific, actionable requirements
- Show examples of correct implementation
- Reference existing code when possible
- Keep rules DRY by referencing other rules

- **Rule Maintenance:**
- Update rules when new patterns emerge
- Add examples from actual codebase
- Remove outdated patterns
- Cross-reference related rules

- **Best Practices:**
- Use bullet points for clarity
- Keep descriptions concise
- Include both DO and DON'T examples
- Reference actual code over theoretical examples
- Use consistent formatting across rules
Loading