neuro-commit 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 +59 -16
- package/bin/neuro-commit.js +15 -0
- package/package.json +3 -2
- package/src/commit.js +46 -0
package/README.md
CHANGED
|
@@ -1,17 +1,43 @@
|
|
|
1
1
|
<h1 align="center">NeuroCommit</h1>
|
|
2
2
|
<p align="center">
|
|
3
|
-
<
|
|
4
|
-
<a href="https://www.npmjs.com/package/neuro-commit"><img src="https://img.shields.io/npm/dm/neuro-commit.svg?colorB=97CA00&label=downloads"></a>
|
|
5
|
-
<a href="https://github.com/cr1ma/neuro-commit/blob/main/LICENSE"><img src="https://img.shields.io/github/license/cr1ma/neuro-commit"></a>
|
|
6
|
-
<a href="https://github.com/cr1ma/neuro-commit/actions/workflows/publish.yml"><img src="https://github.com/cr1ma/neuro-commit/actions/workflows/publish.yml/badge.svg"></a>
|
|
3
|
+
<strong>AI-ready commit message generator powered by <code>git diff</code></strong>
|
|
7
4
|
</p>
|
|
8
|
-
|
|
9
5
|
<p align="center">
|
|
10
|
-
|
|
6
|
+
<a href="https://www.npmjs.com/package/neuro-commit"><img src="https://img.shields.io/npm/v/neuro-commit.svg?colorB=97CA00&label=version" alt="npm version"></a>
|
|
7
|
+
<a href="https://www.npmjs.com/package/neuro-commit"><img src="https://img.shields.io/npm/dm/neuro-commit.svg?colorB=97CA00&label=downloads" alt="npm downloads"></a>
|
|
8
|
+
<a href="https://github.com/cr1ma/neuro-commit/blob/main/LICENSE"><img src="https://img.shields.io/github/license/cr1ma/neuro-commit" alt="license"></a>
|
|
9
|
+
<a href="https://github.com/cr1ma/neuro-commit/actions/workflows/publish.yml"><img src="https://github.com/cr1ma/neuro-commit/actions/workflows/publish.yml/badge.svg" alt="publish status"></a>
|
|
10
|
+
<a href="https://github.com/cr1ma/neuro-commit/issues"><img src="https://img.shields.io/github/issues/cr1ma/neuro-commit" alt="open issues"></a>
|
|
11
11
|
</p>
|
|
12
12
|
|
|
13
13
|
---
|
|
14
14
|
|
|
15
|
+
**NeuroCommit** is a zero-config CLI tool that analyzes your staged Git changes and generates a clean, structured Markdown summary — ready to be fed into any AI/LLM for high-quality commit message generation.
|
|
16
|
+
|
|
17
|
+
<p align="center">
|
|
18
|
+
<img src="docs/assets/neuro-commit-screenshot.png" alt="NeuroCommit CLI screenshot" width="700">
|
|
19
|
+
</p>
|
|
20
|
+
|
|
21
|
+
## Table of Contents
|
|
22
|
+
|
|
23
|
+
- [Features](#-features)
|
|
24
|
+
- [Quick Start](#-quick-start)
|
|
25
|
+
- [How It Works](#-how-it-works)
|
|
26
|
+
- [Development](#-development)
|
|
27
|
+
- [Contributing](#-contributing)
|
|
28
|
+
- [Security](#-security)
|
|
29
|
+
- [License](#-license)
|
|
30
|
+
- [Star History](#-star-history)
|
|
31
|
+
|
|
32
|
+
## ✨ Features
|
|
33
|
+
|
|
34
|
+
- **Zero configuration** — works out of the box with any Git repository
|
|
35
|
+
- **Interactive TUI** — beautiful terminal menu with keyboard navigation
|
|
36
|
+
- **Smart lock file handling** — detects lock files (`package-lock.json`, `yarn.lock`, `pnpm-lock.yaml`, `Cargo.lock`, etc.) and omits their noisy diffs
|
|
37
|
+
- **Token estimation** — reports estimated token count (using `o200k_base` tokenizer) so you know the prompt size before pasting into an LLM
|
|
38
|
+
- **Structured Markdown output** — generates a `neuro-commit.md` with file list, per-file stats, and full diff
|
|
39
|
+
- **Update notifications** — automatically notifies you when a new version is available
|
|
40
|
+
|
|
15
41
|
## 🚀 Quick Start
|
|
16
42
|
|
|
17
43
|
### Using npx (No Installation Required)
|
|
@@ -37,18 +63,29 @@ neuro-commit
|
|
|
37
63
|
1. Stage your changes with `git add`
|
|
38
64
|
2. Run `neuro-commit`
|
|
39
65
|
3. Select **Commit** mode from the interactive menu
|
|
40
|
-
4. The tool collects your staged diff, file list and stats
|
|
41
|
-
5. A `neuro-commit.md` file is generated in the current directory
|
|
42
|
-
-
|
|
43
|
-
- Lock file
|
|
44
|
-
- Summary
|
|
66
|
+
4. The tool collects your staged diff, file list, and per-file stats
|
|
67
|
+
5. A `neuro-commit.md` file is generated in the current directory containing:
|
|
68
|
+
- File list with statuses (`Added`, `Modified`, `Deleted`, etc.) and per-file insertions/deletions
|
|
69
|
+
- Lock file entries listed without their diffs
|
|
70
|
+
- Summary line with total files changed, insertions, and deletions
|
|
45
71
|
- Full diff output in a fenced `diff` code block
|
|
72
|
+
6. Copy the contents of `neuro-commit.md` into your preferred AI assistant and ask it to write a commit message
|
|
46
73
|
|
|
47
|
-
> **
|
|
74
|
+
> **Tip:** Lock files (`package-lock.json`, `pnpm-lock.yaml`, `yarn.lock`, `uv.lock`, `Cargo.lock`, and others) are listed as changed but their diffs are omitted to keep the output clean and token-efficient.
|
|
48
75
|
|
|
49
76
|
## 🔧 Development
|
|
50
77
|
|
|
51
78
|
```bash
|
|
79
|
+
# Clone the repository
|
|
80
|
+
git clone https://github.com/cr1ma/neuro-commit.git
|
|
81
|
+
cd neuro-commit
|
|
82
|
+
|
|
83
|
+
# Install dependencies
|
|
84
|
+
npm install
|
|
85
|
+
|
|
86
|
+
# Run locally
|
|
87
|
+
npm start
|
|
88
|
+
|
|
52
89
|
# Lint
|
|
53
90
|
npm run lint
|
|
54
91
|
|
|
@@ -56,13 +93,19 @@ npm run lint
|
|
|
56
93
|
npm run lint:fix
|
|
57
94
|
```
|
|
58
95
|
|
|
59
|
-
##
|
|
96
|
+
## 🤝 Contributing
|
|
60
97
|
|
|
61
|
-
[
|
|
98
|
+
Contributions, issues, and feature requests are welcome! Please read the [Contributing Guide](CONTRIBUTING.md) before submitting a pull request.
|
|
62
99
|
|
|
63
|
-
|
|
100
|
+
Feel free to check the [open issues](https://github.com/cr1ma/neuro-commit/issues).
|
|
101
|
+
|
|
102
|
+
## 🔒 Security
|
|
103
|
+
|
|
104
|
+
To report a vulnerability, please see our [Security Policy](SECURITY.md).
|
|
105
|
+
|
|
106
|
+
## 📝 License
|
|
64
107
|
|
|
65
|
-
|
|
108
|
+
This project is licensed under the [Apache License 2.0](LICENSE).
|
|
66
109
|
|
|
67
110
|
## ⭐ Star History
|
|
68
111
|
|
package/bin/neuro-commit.js
CHANGED
|
@@ -119,6 +119,21 @@ async function main() {
|
|
|
119
119
|
console.clear();
|
|
120
120
|
console.log(banner);
|
|
121
121
|
|
|
122
|
+
try {
|
|
123
|
+
const { default: updateNotifier } = await import("update-notifier");
|
|
124
|
+
const pkg = require("../package.json");
|
|
125
|
+
|
|
126
|
+
updateNotifier({
|
|
127
|
+
pkg,
|
|
128
|
+
updateCheckInterval: 1000 * 60 * 60 * 24,
|
|
129
|
+
}).notify({
|
|
130
|
+
defer: false,
|
|
131
|
+
isGlobal: true,
|
|
132
|
+
});
|
|
133
|
+
} catch {
|
|
134
|
+
// Ignore update check errors
|
|
135
|
+
}
|
|
136
|
+
|
|
122
137
|
const choice = await showMenu();
|
|
123
138
|
|
|
124
139
|
switch (choice) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "neuro-commit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "neuro-commit CLI utility",
|
|
5
5
|
"author": "cr1ma.dev",
|
|
6
6
|
"bin": {
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"globals": "^17.3.0"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"tiktoken": "^1.0.22"
|
|
41
|
+
"tiktoken": "^1.0.22",
|
|
42
|
+
"update-notifier": "^7.3.1"
|
|
42
43
|
}
|
|
43
44
|
}
|
package/src/commit.js
CHANGED
|
@@ -22,12 +22,50 @@ const CYAN = "\x1b[36m";
|
|
|
22
22
|
const OUTPUT_FILE = "neuro-commit.md";
|
|
23
23
|
const encoder = get_encoding("o200k_base");
|
|
24
24
|
|
|
25
|
+
// AI Prompt that will be added at the beginning of the generated file
|
|
26
|
+
const AI_PROMPT = `You are an expert in writing commit messages for repositories. Your task is to write me a commit message based on my diff file, which I will provide to you.
|
|
27
|
+
|
|
28
|
+
### Rules for writing a commit message:
|
|
29
|
+
|
|
30
|
+
1. Write in English, strictly considering the context.
|
|
31
|
+
2. Return the answer using markdown formatting.
|
|
32
|
+
3. Use the imperative mood, as if you are giving a command to the system that corresponds to messages that create changes in the code.
|
|
33
|
+
4. The first line of the message (title) should be short, usually no longer than 50 characters. This makes it easier to quickly understand the changes. Do not end the title with a period.
|
|
34
|
+
5. Leave one empty line after the title before starting the body of the message. This separation helps Git tools to correctly display the message text.
|
|
35
|
+
6. Commits with messages like "Fix" or "Update" do not provide useful information. Always explain what exactly was fixed or updated.
|
|
36
|
+
7. **Use lowercase letters to describe change types. Use** semantic tags in message titles:
|
|
37
|
+
- \`feat:\` — adding a new feature
|
|
38
|
+
- \`fix:\` — bug fixes
|
|
39
|
+
- \`docs:\` — changes in documentation
|
|
40
|
+
- \`style:\` — changes that do not affect the code (e.g., formatting fixes)
|
|
41
|
+
- \`refactor:\` — code change that doesn't add new functionality or fix bugs
|
|
42
|
+
- \`test:\` — adding or changing tests
|
|
43
|
+
|
|
44
|
+
### Example of a correct commit message:
|
|
45
|
+
|
|
46
|
+
\`\`\`diff
|
|
47
|
+
refactor: update environment configuration and API connection
|
|
48
|
+
|
|
49
|
+
- Edited \`.env\` file to support different environments (production, development) and API connection modes (docker, local, remote).
|
|
50
|
+
- Updated \`config.py\` to load tokens and URLs depending on the environment and API mode.
|
|
51
|
+
- Removed logic for determining the operating system.
|
|
52
|
+
- Updated \`api_client.py\` to use BASE_API_URL instead of OS-specific URLs.
|
|
53
|
+
- Reduced the number of retries in \`_make_request\`.
|
|
54
|
+
\`\`\`
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
`;
|
|
59
|
+
|
|
25
60
|
/**
|
|
26
61
|
* Build the markdown content for neuro-commit.md
|
|
27
62
|
*/
|
|
28
63
|
function buildMarkdown(stagedFiles, diff, numstat) {
|
|
29
64
|
const lines = [];
|
|
30
65
|
|
|
66
|
+
// Start with the AI prompt
|
|
67
|
+
lines.push(AI_PROMPT);
|
|
68
|
+
|
|
31
69
|
const lockFiles = stagedFiles.filter((f) => isLockFile(f.file));
|
|
32
70
|
const regularFiles = stagedFiles.filter((f) => !isLockFile(f.file));
|
|
33
71
|
|
|
@@ -104,6 +142,14 @@ function printSummary(files, content, outputFile) {
|
|
|
104
142
|
`${CYAN}✓${RESET} Generated ${BOLD}${outputFile}${RESET} ${DIM}(${formatNumber(totalFiles)} files, ${formatNumber(totalTokens)} tokens, ${formatNumber(totalChars)} chars)${RESET}`,
|
|
105
143
|
);
|
|
106
144
|
console.log("");
|
|
145
|
+
console.log(`${BOLD}Next steps:${RESET}`);
|
|
146
|
+
console.log(` 1. Open ${CYAN}${outputFile}${RESET}`);
|
|
147
|
+
console.log(
|
|
148
|
+
` 2. Copy the ${BOLD}entire content${RESET} (AI prompt is already included!)`,
|
|
149
|
+
);
|
|
150
|
+
console.log(` 3. Paste into your LLM (ChatGPT, Claude, etc.)`);
|
|
151
|
+
console.log(` 4. Get your perfect commit message! 🎉`);
|
|
152
|
+
console.log("");
|
|
107
153
|
}
|
|
108
154
|
|
|
109
155
|
/**
|