commit-agent-cli 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -85
- package/dist/index.js +43 -4
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -1,101 +1,49 @@
|
|
|
1
1
|
# commit-agent-cli
|
|
2
2
|
|
|
3
|
-
AI-powered git commit
|
|
3
|
+
> AI-powered git commit message generator using Claude 4.5 and LangGraph
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Generate intelligent, context-aware commit messages by simply typing `commit`.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- **🕵️ Agentic Exploration**: The AI agent can autonomously explore your codebase and git history:
|
|
9
|
-
- Read files to understand context
|
|
10
|
-
- List directories to understand project structure
|
|
11
|
-
- Check commit history to learn your project's conventions
|
|
12
|
-
- View staged, unstaged, and untracked files
|
|
13
|
-
- Examine detailed diffs for specific files
|
|
14
|
-
- **👁️ Transparent**: See exactly what the agent is doing with detailed console logs showing every file read, directory listed, and git command executed.
|
|
15
|
-
- **⚙️ Customizable**: First-time setup asks for your preferences:
|
|
16
|
-
- Use conventional commit prefixes (feat:, fix:, chore:, etc.) or natural language
|
|
17
|
-
- Choose between concise or descriptive commit messages
|
|
18
|
-
- **✨ Interactive**: Beautiful CLI interface built with `@clack/prompts`.
|
|
19
|
-
- **🔒 Secure**: API keys and preferences are stored locally in `~/.commit-cli.json`.
|
|
20
|
-
|
|
21
|
-
## Installation
|
|
7
|
+
## Quick Start
|
|
22
8
|
|
|
23
9
|
```bash
|
|
10
|
+
# Install globally
|
|
24
11
|
npm install -g commit-agent-cli
|
|
25
|
-
```
|
|
26
12
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
2. Run the tool:
|
|
35
|
-
```bash
|
|
36
|
-
commit
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
3. **First Time Setup**:
|
|
40
|
-
- You'll be prompted to enter your Anthropic API Key (`sk-...`)
|
|
41
|
-
- Choose whether to use conventional commit prefixes
|
|
42
|
-
- Select your preferred commit message style (concise vs descriptive)
|
|
43
|
-
- These preferences are saved and can be changed by editing `~/.commit-cli.json`
|
|
44
|
-
|
|
45
|
-
4. **Watch the Agent Work**:
|
|
46
|
-
The CLI will show you exactly what the agent is doing:
|
|
47
|
-
```
|
|
48
|
-
📜 Agent is checking last 10 commits
|
|
49
|
-
📋 Agent is listing staged files
|
|
50
|
-
🔍 Agent is reading: src/index.ts
|
|
51
|
-
📂 Agent is listing directory: src
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
5. **Review and Commit**:
|
|
55
|
-
- Review the generated commit message
|
|
56
|
-
- Choose to commit, regenerate, or cancel
|
|
57
|
-
- Optionally push changes immediately
|
|
58
|
-
|
|
59
|
-
## Agent Capabilities
|
|
60
|
-
|
|
61
|
-
The AI agent has access to these tools to understand your codebase:
|
|
62
|
-
|
|
63
|
-
- **read_file**: Read any file to understand code context
|
|
64
|
-
- **list_dir**: Explore directory structure
|
|
65
|
-
- **git_commit_history**: Learn from your previous commits
|
|
66
|
-
- **git_staged_files**: See what's being committed
|
|
67
|
-
- **git_unstaged_files**: View unstaged changes
|
|
68
|
-
- **git_untracked_files**: List untracked files
|
|
69
|
-
- **git_show_file_diff**: Examine detailed diffs
|
|
70
|
-
|
|
71
|
-
The agent will intelligently use these tools to generate contextually appropriate commit messages.
|
|
72
|
-
|
|
73
|
-
## Configuration
|
|
74
|
-
|
|
75
|
-
Your configuration is stored in `~/.commit-cli.json`:
|
|
76
|
-
|
|
77
|
-
```json
|
|
78
|
-
{
|
|
79
|
-
"ANTHROPIC_API_KEY": "sk-ant-...",
|
|
80
|
-
"preferences": {
|
|
81
|
-
"useConventionalCommits": true,
|
|
82
|
-
"commitMessageStyle": "concise"
|
|
83
|
-
}
|
|
84
|
-
}
|
|
13
|
+
# Stage your changes
|
|
14
|
+
git add .
|
|
15
|
+
|
|
16
|
+
# Generate commit message
|
|
17
|
+
commit
|
|
85
18
|
```
|
|
86
19
|
|
|
87
|
-
|
|
20
|
+
## First-Time Setup
|
|
88
21
|
|
|
89
|
-
|
|
22
|
+
You'll be prompted to:
|
|
23
|
+
1. Enter your [Anthropic API Key](https://console.anthropic.com)
|
|
24
|
+
2. Choose commit message preferences (conventional commits, verbosity)
|
|
90
25
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
26
|
+
## Features
|
|
27
|
+
|
|
28
|
+
- 🤖 AI-powered with Claude 4.5
|
|
29
|
+
- 🕵️ Autonomous codebase exploration
|
|
30
|
+
- 👁️ Transparent agent actions
|
|
31
|
+
- ⚙️ Customizable commit styles
|
|
32
|
+
- 🔒 Secure local storage
|
|
33
|
+
|
|
34
|
+
## Documentation
|
|
35
|
+
|
|
36
|
+
📚 **[View Full Documentation](./docs/README.md)** - Detailed guides, configuration, and examples
|
|
37
|
+
|
|
38
|
+
## Requirements
|
|
39
|
+
|
|
40
|
+
- Node.js 18+
|
|
41
|
+
- Anthropic API key
|
|
98
42
|
|
|
99
43
|
## License
|
|
100
44
|
|
|
101
45
|
MIT
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
**Links:** [GitHub](https://github.com/sunggyeol/commit-agent-cli) • [Issues](https://github.com/sunggyeol/commit-agent-cli/issues) • [Docs](./docs/README.md)
|
package/dist/index.js
CHANGED
|
@@ -499,11 +499,40 @@ async function main() {
|
|
|
499
499
|
commitMessage = await generateCommitMessage(diff, preferences);
|
|
500
500
|
} catch (error) {
|
|
501
501
|
s.stop("Generation failed.");
|
|
502
|
+
if (error.message?.includes("401") || error.message?.includes("authentication_error") || error.message?.includes("invalid x-api-key") || error.message?.includes("invalid api key")) {
|
|
503
|
+
cancel("Invalid API Key detected.");
|
|
504
|
+
const retryWithNewKey = await confirm({
|
|
505
|
+
message: "Would you like to enter a new API key?",
|
|
506
|
+
initialValue: true
|
|
507
|
+
});
|
|
508
|
+
if (isCancel(retryWithNewKey) || !retryWithNewKey) {
|
|
509
|
+
cancel("Operation cancelled.");
|
|
510
|
+
process.exit(0);
|
|
511
|
+
}
|
|
512
|
+
const newKey = await text({
|
|
513
|
+
message: "Enter your Anthropic API Key (sk-...):",
|
|
514
|
+
placeholder: "sk-ant-api...",
|
|
515
|
+
validate: (value) => {
|
|
516
|
+
if (!value) return "API Key is required";
|
|
517
|
+
if (!value.startsWith("sk-")) return "Invalid API Key format (should start with sk-)";
|
|
518
|
+
}
|
|
519
|
+
});
|
|
520
|
+
if (isCancel(newKey)) {
|
|
521
|
+
cancel("Operation cancelled.");
|
|
522
|
+
process.exit(0);
|
|
523
|
+
}
|
|
524
|
+
apiKey = newKey;
|
|
525
|
+
process.env.ANTHROPIC_API_KEY = apiKey;
|
|
526
|
+
await storeKey(apiKey);
|
|
527
|
+
note("API Key updated. Retrying...", "Key Updated");
|
|
528
|
+
continue;
|
|
529
|
+
}
|
|
502
530
|
cancel(`Error: ${error.message}`);
|
|
503
531
|
return;
|
|
504
532
|
}
|
|
505
533
|
s.stop("Message generated.");
|
|
506
|
-
const
|
|
534
|
+
const terminalWidth = process.stdout.columns || 80;
|
|
535
|
+
const maxWidth = Math.max(40, terminalWidth - 12);
|
|
507
536
|
const lines = commitMessage.split("\n");
|
|
508
537
|
const wrappedLines = [];
|
|
509
538
|
for (const line of lines) {
|
|
@@ -513,11 +542,21 @@ async function main() {
|
|
|
513
542
|
const words = line.split(" ");
|
|
514
543
|
let currentLine = "";
|
|
515
544
|
for (const word of words) {
|
|
516
|
-
|
|
517
|
-
|
|
545
|
+
const testLine = currentLine ? currentLine + " " + word : word;
|
|
546
|
+
if (testLine.length <= maxWidth) {
|
|
547
|
+
currentLine = testLine;
|
|
518
548
|
} else {
|
|
519
549
|
if (currentLine) wrappedLines.push(currentLine);
|
|
520
|
-
|
|
550
|
+
if (word.length > maxWidth) {
|
|
551
|
+
let remaining = word;
|
|
552
|
+
while (remaining.length > maxWidth) {
|
|
553
|
+
wrappedLines.push(remaining.substring(0, maxWidth));
|
|
554
|
+
remaining = remaining.substring(maxWidth);
|
|
555
|
+
}
|
|
556
|
+
currentLine = remaining;
|
|
557
|
+
} else {
|
|
558
|
+
currentLine = word;
|
|
559
|
+
}
|
|
521
560
|
}
|
|
522
561
|
}
|
|
523
562
|
if (currentLine) wrappedLines.push(currentLine);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "commit-agent-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "AI-powered git commit CLI using LangGraph and Claude 4.5",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"dist"
|
|
10
10
|
],
|
|
11
11
|
"bin": {
|
|
12
|
-
"commit": "
|
|
12
|
+
"commit": "dist/index.js"
|
|
13
13
|
},
|
|
14
14
|
"scripts": {
|
|
15
15
|
"build": "tsup src/index.ts --format esm --dts --clean",
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"@langchain/core": "^0.3.0",
|
|
41
41
|
"@langchain/langgraph": "^0.2.0",
|
|
42
42
|
"ai": "^3.3.33",
|
|
43
|
+
"commit-agent-cli": "^0.1.0",
|
|
43
44
|
"dotenv": "^16.4.5",
|
|
44
45
|
"execa": "^9.3.1",
|
|
45
46
|
"zod": "^3.23.8"
|