Skip to content

Commit 18dbc13

Browse files
Merge pull request #15 from laststance/feat/testing-environment
2 parents ddf9215 + cae9403 commit 18dbc13

28 files changed

+2147
-4
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
description:
3+
globs:
4+
alwaysApply: true
5+
---
6+
# Code Organization
7+
8+
## Core Functionality
9+
10+
The core functionality of git-gpt-commit is organized as follows:
11+
12+
- [index.js](mdc:index.js) - Main entry point with the following key functions:
13+
- `getGitSummary()` - Gets the git diff summary of staged changes
14+
- `gptCommit()` - Generates a commit message using OpenAI API
15+
- `gitExtension()` - Sets up the CLI commands
16+
17+
## Utility Functions
18+
19+
- [utils/sanitizeCommitMessage.js](mdc:utils/sanitizeCommitMessage.js) - Cleans up generated commit messages
20+
21+
## Tests
22+
23+
- [utils/sanitizeCommitMessage.test.js](mdc:utils/sanitizeCommitMessage.test.js) - Tests for the sanitize function
24+
- [vitest.config.js](mdc:vitest.config.js) - Test configuration
25+
26+
## Configuration
27+
28+
The application uses the following configuration mechanisms:
29+
30+
1. Environment variables (.env file) for the OpenAI API key
31+
2. Local config file (~/.git-gpt-commit-config.json) for user preferences
32+
3. Command-line options via Commander.js

.cursor/rules/coding-patterns.mdc

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
---
2+
description:
3+
globs:
4+
alwaysApply: true
5+
---
6+
# Coding Patterns
7+
8+
## Command Line Interface
9+
10+
The application uses Commander.js for CLI functionality:
11+
12+
```javascript
13+
program
14+
.command('command-name')
15+
.description('Description of the command')
16+
.action(async () => {
17+
// Command implementation
18+
});
19+
```
20+
21+
## OpenAI API Integration
22+
23+
OpenAI API calls follow this pattern:
24+
25+
```javascript
26+
// Initialize OpenAI client
27+
const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
28+
29+
// Prepare messages
30+
const messages = [
31+
{ role: 'system', content: 'System instruction' },
32+
{ role: 'user', content: 'User message' }
33+
];
34+
35+
// Make API request
36+
const response = await openai.chat.completions.create({
37+
model: 'model-name',
38+
messages,
39+
temperature: 0,
40+
max_tokens: 50
41+
});
42+
43+
// Extract response
44+
const message = response.choices[0].message.content.trim();
45+
```
46+
47+
## Configuration Management
48+
49+
Configuration is stored in the user's home directory:
50+
51+
```javascript
52+
// Define config file path
53+
const CONFIG_FILE = path.join(os.homedir(), '.git-gpt-commit-config.json');
54+
55+
// Load configuration
56+
function loadConfig() {
57+
if (fs.existsSync(CONFIG_FILE)) {
58+
const config = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
59+
// Use config values
60+
}
61+
}
62+
63+
// Save configuration
64+
function saveConfig(config) {
65+
// Load existing config first
66+
let existingConfig = {};
67+
if (fs.existsSync(CONFIG_FILE)) {
68+
existingConfig = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
69+
}
70+
// Merge with new config
71+
const updatedConfig = { ...existingConfig, ...config };
72+
fs.writeFileSync(CONFIG_FILE, JSON.stringify(updatedConfig, null, 2));
73+
}
74+
```
75+
76+
## User Prompts
77+
78+
User interactions use the prompts library:
79+
80+
```javascript
81+
const response = await prompts({
82+
type: 'confirm', // or 'select', etc.
83+
name: 'value',
84+
message: 'Message to display',
85+
initial: true // Default value
86+
});
87+
88+
// Access user response
89+
if (response.value) {
90+
// User confirmed
91+
}
92+
```

.cursor/rules/cursor_rules.mdc

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
description: Guidelines for creating and maintaining Cursor rules to ensure consistency and effectiveness.
3+
globs: .cursor/rules/*.mdc
4+
alwaysApply: true
5+
---
6+
7+
- **Required Rule Structure:**
8+
```markdown
9+
---
10+
description: Clear, one-line description of what the rule enforces
11+
globs: path/to/files/*.ext, other/path/**/*
12+
alwaysApply: boolean
13+
---
14+
15+
- **Main Points in Bold**
16+
- Sub-points with details
17+
- Examples and explanations
18+
```
19+
20+
- **File References:**
21+
- Use `[filename](mdc:path/to/file)` ([filename](mdc:filename)) to reference files
22+
- Example: [prisma.mdc](mdc:.cursor/rules/prisma.mdc) for rule references
23+
- Example: [schema.prisma](mdc:prisma/schema.prisma) for code references
24+
25+
- **Code Examples:**
26+
- Use language-specific code blocks
27+
```typescript
28+
// ✅ DO: Show good examples
29+
const goodExample = true;
30+
31+
// ❌ DON'T: Show anti-patterns
32+
const badExample = false;
33+
```
34+
35+
- **Rule Content Guidelines:**
36+
- Start with high-level overview
37+
- Include specific, actionable requirements
38+
- Show examples of correct implementation
39+
- Reference existing code when possible
40+
- Keep rules DRY by referencing other rules
41+
42+
- **Rule Maintenance:**
43+
- Update rules when new patterns emerge
44+
- Add examples from actual codebase
45+
- Remove outdated patterns
46+
- Cross-reference related rules
47+
48+
- **Best Practices:**
49+
- Use bullet points for clarity
50+
- Keep descriptions concise
51+
- Include both DO and DON'T examples
52+
- Reference actual code over theoretical examples
53+
- Use consistent formatting across rules

0 commit comments

Comments
 (0)