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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ jobs:
publish:
needs: build
runs-on: ubuntu-latest
# if: github.event_name == 'release'
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
if: github.event_name == 'release'
# if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v2

Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# commitaai 🚀

AI-powered commit message generator using OpenAI. Get meaningful and structured commit messages in seconds!
`commitaai` is a powerful npm package designed to automate the creation of commit messages. By leveraging AI, it analyzes the changes you've staged in your project and generates well-structured and meaningful commit messages. With just a simple command, commitaai identifies the differences in your code, then crafts a concise title and description for your commit. This helps you save time, maintain consistency, and adhere to conventional commit practices, making version control more efficient. Ideal for developers looking to simplify their workflow and ensure their commit messages are clear, relevant, and uniform.

Whether you're a solo developer or part of a team, `commitaai` helps improve your project’s version history by maintaining clean and descriptive commit messages. It’s the perfect tool for developers who want to boost their efficiency and keep their codebase organized.


[![NPM Version](https://img.shields.io/npm/v/fireorm.svg?style=flat)](https://www.npmjs.com/package/commitaai)
Expand Down Expand Up @@ -67,7 +69,8 @@ After generating the commit message, you’ll be asked to confirm before it is c

Your OpenAI API key is stored locally in `~/.env` and never shared or transmitted elsewhere.
The tool only analyzes staged Git changes, ensuring sensitive files remain untouched.
🤝 Contributing

# 🤝 Contributing

PRs are welcome! If you’d like to improve the tool, check out `CONTRIBUTING.md` for guidelines.

Expand Down
27 changes: 18 additions & 9 deletions cli/commands/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,21 @@ const command = new Command('generate')
.alias('g')
.description('Generate a commit message based on git diff')
.action(async () => {
process.noDeprecation = true;
// Start the spinner with the initial message.
const spinner = showSpinner('Fetching git diff...');

try {
const diff = await fetchGitDiff();
spinner.stop();

// Update the spinner text before moving on.
spinner.text = 'Generating commit message...';

const rawMessage = await generateCommitMessage(diff);

// Mark the spinner as succeeded.
spinner.succeed('Commit message generated successfully!');

const formattedMessage = formatCommitMessage(rawMessage);
console.log(`\nYour Commit Message:\n${formattedMessage}\n\n`);

Expand All @@ -32,13 +38,16 @@ const command = new Command('generate')
]);

if (shouldCommit) {
exec(`git commit -m "${formattedMessage.replace(/"/g, '\\"')}"`, (err, stdout, stderr) => {
if (err) {
console.error('Error committing changes:', err);
return;
exec(
`git commit -m "${formattedMessage.replace(/"/g, '\\"')}"`,
(err, stdout, stderr) => {
if (err) {
console.error('Error committing changes:', err);
return;
}
console.log('Commit successful!');
}
console.log('Commit successful!');
});
);
} else {
console.log('Commit aborted by the user.');
}
Expand Down
2 changes: 1 addition & 1 deletion cli/index.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ program
.name("commitaai")
.description("Generate AI-crafted commit messages")
// .option("-g, --generate", "Generate a commit message")
.version("1.0.2");
.version("1.0.4");

program.addCommand(generateCommand);
program.addCommand(configureCommand)
Expand Down
17 changes: 11 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,22 @@
"commander": "13.1.0",
"dotenv": "^16.4.7",
"inquirer": "^12.4.1",
"openai": "4.83.0",
"node-fetch": "^3.3.2",
"openai": "4.85.1",
"ora": "8.2.0",
"simple-git": "^3.27.0",
"typescript": "5.7.3",
"whatwg-url": "^14.1.1",
"winston": "^3.17.0"
},
"version": "1.0.2",
"version": "1.0.4",
"publishConfig": {
"access": "public"
},
"access": "public"
},
"keywords": [
"commitaai"
]
"commitaai"
],
"resolutions": {
"whatwg-url": "^14.0.0"
}
}
3 changes: 0 additions & 3 deletions src/services/abstractionService.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { Logger } from '../utils/logger.js';
import openaiGenerator from './generators/openai.js';

Logger.info('Initializing commit message generator');

export async function generateCommitMessage(diff) {
const generator = openaiGenerator
return await generator.generate(diff);
Expand Down
Loading