neuro-commit 0.1.1 → 0.1.3

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.
@@ -2,6 +2,17 @@
2
2
 
3
3
  const readline = require("readline");
4
4
  const { runCommitMode } = require("../src/commit");
5
+ const pkg = require("../package.json");
6
+
7
+ // --- ANSI helpers ---
8
+ const RESET = "\x1b[0m";
9
+ const BOLD = "\x1b[1m";
10
+ const DIM = "\x1b[2m";
11
+ const GREEN = "\x1b[32m";
12
+ const YELLOW = "\x1b[33m";
13
+ const CYAN = "\x1b[36m";
14
+ const HIDE_CURSOR = "\x1b[?25l";
15
+ const SHOW_CURSOR = "\x1b[?25h";
5
16
 
6
17
  const banner = `
7
18
  ███╗ ██╗███████╗██╗ ██╗██████╗ ██████╗ ██████╗ ██████╗ ███╗ ███╗███╗ ███╗██╗████████╗
@@ -12,20 +23,45 @@ const banner = `
12
23
  ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝
13
24
  `;
14
25
 
26
+ // --- CLI flags ---
27
+ const args = process.argv.slice(2);
28
+
29
+ if (args.includes("--help") || args.includes("-h")) {
30
+ console.log(`
31
+ ${BOLD}neuro-commit${RESET} v${pkg.version} — AI-powered commit message generator
32
+
33
+ ${BOLD}USAGE${RESET}
34
+ neuro-commit Launch interactive mode
35
+ neuro-commit [options]
36
+
37
+ ${BOLD}OPTIONS${RESET}
38
+ -h, --help Show this help message
39
+ -v, --version Show installed version
40
+
41
+ ${BOLD}WORKFLOW${RESET}
42
+ 1. Stage your changes ${DIM}git add <files>${RESET}
43
+ 2. Run neuro-commit ${DIM}neuro-commit${RESET}
44
+ 3. Copy generated file ${DIM}neuro-commit.md${RESET}
45
+ 4. Paste into your LLM ${DIM}(ChatGPT, Claude, etc.)${RESET}
46
+ 5. Get your commit message!
47
+
48
+ ${BOLD}LINKS${RESET}
49
+ Repository ${CYAN}${pkg.homepage}${RESET}
50
+ Issues ${CYAN}${pkg.bugs.url}${RESET}
51
+ `);
52
+ process.exit(0);
53
+ }
54
+
55
+ if (args.includes("--version") || args.includes("-v")) {
56
+ console.log(`neuro-commit v${pkg.version}`);
57
+ process.exit(0);
58
+ }
59
+
15
60
  // --- Menu options ---
16
61
  const menuItems = [
17
62
  { label: "Commit", icon: "📝", description: "Generate a commit message" },
18
63
  ];
19
64
 
20
- // --- ANSI helpers ---
21
- const RESET = "\x1b[0m";
22
- const BOLD = "\x1b[1m";
23
- const DIM = "\x1b[2m";
24
- const GREEN = "\x1b[32m";
25
- const CYAN = "\x1b[36m";
26
- const HIDE_CURSOR = "\x1b[?25l";
27
- const SHOW_CURSOR = "\x1b[?25h";
28
-
29
65
  // Ensure cursor is restored if the process exits unexpectedly
30
66
  process.on("exit", () => {
31
67
  process.stdout.write(SHOW_CURSOR);
@@ -121,15 +157,33 @@ async function main() {
121
157
 
122
158
  try {
123
159
  const { default: updateNotifier } = await import("update-notifier");
124
- const pkg = require("../package.json");
125
160
 
126
- updateNotifier({
161
+ const notifier = updateNotifier({
127
162
  pkg,
128
- updateCheckInterval: 1000 * 60 * 60 * 24,
129
- }).notify({
130
- defer: false,
131
- isGlobal: true,
163
+ updateCheckInterval: 0,
132
164
  });
165
+
166
+ // Cache may be empty on first run — fetch directly as fallback
167
+ let updateInfo = notifier.update;
168
+ if (!updateInfo) {
169
+ try {
170
+ updateInfo = await notifier.fetchInfo();
171
+ if (updateInfo.type === "latest") {
172
+ updateInfo = null;
173
+ }
174
+ } catch {
175
+ // Network error — skip silently
176
+ }
177
+ }
178
+
179
+ if (updateInfo) {
180
+ console.log(
181
+ ` ${YELLOW}Update available!${RESET} ${DIM}${updateInfo.current}${RESET} → ${GREEN}${updateInfo.latest}${RESET}`,
182
+ );
183
+ console.log(
184
+ ` Run ${CYAN}npm install -g neuro-commit${RESET} to update\n`,
185
+ );
186
+ }
133
187
  } catch {
134
188
  // Ignore update check errors
135
189
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neuro-commit",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "neuro-commit CLI utility",
5
5
  "author": "cr1ma.dev",
6
6
  "bin": {
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
  /**