-
Notifications
You must be signed in to change notification settings - Fork 2
Add initial documentation for project structure and coding guidelines #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e3ef0e3
Add initial documentation for project structure and coding guidelines
ryota-murakami bd4b161
Add gpt-4o model option to the selection list in index.js
ryota-murakami 4107464
add task-master-ai
ryota-murakami 2e77ce7
feat: Add default name handling and test environment setup
ryota-murakami cae9403
remove unused files
ryota-murakami File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| --- | ||
| description: | ||
| globs: | ||
| 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 | ||
| } | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.