commitmind 1.0.0

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 ADDED
@@ -0,0 +1,15 @@
1
+ # ai-commit-gen
2
+
3
+ To install dependencies:
4
+
5
+ ```bash
6
+ bun install
7
+ ```
8
+
9
+ To run:
10
+
11
+ ```bash
12
+ bun run index.ts
13
+ ```
14
+
15
+ This project was created using `bun init` in bun v1.3.4. [Bun](https://bun.com) is a fast all-in-one JavaScript runtime.
package/bun.lock ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "lockfileVersion": 1,
3
+ "configVersion": 1,
4
+ "workspaces": {
5
+ "": {
6
+ "name": "ai-commit-gen",
7
+ "devDependencies": {
8
+ "@types/node": "^25.3.0",
9
+ "typescript": "^5.9.3",
10
+ },
11
+ },
12
+ },
13
+ "packages": {
14
+ "@types/node": ["@types/node@25.3.0", "", { "dependencies": { "undici-types": "~7.18.0" } }, "sha512-4K3bqJpXpqfg2XKGK9bpDTc6xO/xoUP/RBWS7AtRMug6zZFaRekiLzjVtAoZMquxoAbzBvy5nxQ7veS5eYzf8A=="],
15
+
16
+ "typescript": ["typescript@5.9.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="],
17
+
18
+ "undici-types": ["undici-types@7.18.2", "", {}, "sha512-AsuCzffGHJybSaRrmr5eHr81mwJU3kjw6M+uprWvCXiNeN9SOGwQ3Jn8jb8m3Z6izVgknn1R0FTCEAP2QrLY/w=="],
19
+ }
20
+ }
package/dist/git.js ADDED
@@ -0,0 +1,13 @@
1
+ import { execSync } from "child_process";
2
+ export function stageAll() {
3
+ execSync("git add .", { stdio: "inherit" });
4
+ }
5
+ export function getDiff() {
6
+ return execSync("git diff --staged --no-color").toString();
7
+ }
8
+ export function commit(msg) {
9
+ execSync(`git commit -m "${msg}"`, { stdio: "inherit" });
10
+ }
11
+ export function push(branch) {
12
+ execSync(`git push origin ${branch}`, { stdio: "inherit" });
13
+ }
package/dist/index.js ADDED
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env node
2
+ import { stageAll, getDiff, commit, push } from "./git.js";
3
+ import { generateCommit } from "./ollama.js";
4
+ async function main() {
5
+ const command = process.argv[2];
6
+ if (!command) {
7
+ console.log(`
8
+ Usage:
9
+ aic auto
10
+ aic push <branch>
11
+
12
+ Examples:
13
+ aic auto
14
+ aic push main
15
+ `);
16
+ return;
17
+ }
18
+ console.log("📦 Staging changes...");
19
+ await stageAll();
20
+ const diff = await getDiff();
21
+ console.log(" Generating commit...");
22
+ const message = await generateCommit(diff);
23
+ console.log("✅ Commit:", message);
24
+ await commit(message);
25
+ if (command === "push") {
26
+ const branch = process.argv[3] || "main";
27
+ console.log(` Pushing to ${branch}...`);
28
+ await push(branch);
29
+ }
30
+ }
31
+ main();
package/dist/ollama.js ADDED
@@ -0,0 +1,61 @@
1
+ export async function generateCommit(diff) {
2
+ if (!diff) {
3
+ console.log(`No changes done`);
4
+ process.exit(0);
5
+ }
6
+ const prompt = `
7
+ You are a senior software engineer and open-source contributor.
8
+
9
+ Your task is to generate a high-quality, professional Conventional Commit message based on the provided Git diff.
10
+
11
+ Strict rules:
12
+ - Use the Conventional Commits standard.
13
+ - Allowed types only: feat, fix, refactor, docs, chore.
14
+ - Use present tense.
15
+ - Be concise, clear, and meaningful.
16
+ - Maximum 50 characters.
17
+ - No emojis.
18
+ - No trailing period.
19
+ - Focus on the **intent and impact**, not the code.
20
+ - Do not mention filenames, functions, or variables unless essential.
21
+ - Prefer user-facing or architectural meaning.
22
+ - If multiple changes exist, prioritize the most important one.
23
+ - If the diff is unclear, infer the most logical intent.
24
+ - Output ONLY the commit message. No explanation.
25
+
26
+ Guidelines:
27
+ - feat → new functionality or user-visible change
28
+ - fix → bug fixes
29
+ - refactor → code improvements without behavior change
30
+ - docs → documentation changes
31
+ - chore → tooling, config, dependency, or maintenance
32
+
33
+ Examples:
34
+ Diff: adds login API and validation
35
+ Output: feat: add user authentication
36
+
37
+ Diff: resolves crash in payment flow
38
+ Output: fix: prevent payment crash
39
+
40
+ Diff: cleans up duplicated service logic
41
+ Output: refactor: remove duplicate logic
42
+
43
+ Diff: updates README with setup guide
44
+ Output: docs: update setup instructions
45
+
46
+ Now generate the commit message.
47
+
48
+ Diff:
49
+ ${diff}
50
+ `;
51
+ const res = await fetch('http://localhost:11434/api/generate', {
52
+ method: 'POST',
53
+ body: JSON.stringify({
54
+ model: 'llama3.1:latest',
55
+ prompt,
56
+ stream: false,
57
+ })
58
+ });
59
+ const data = await res.json();
60
+ return data.response.trim();
61
+ }
package/package.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "commitmind",
3
+ "version": "1.0.0",
4
+ "author": "Nabin Sharma",
5
+ "bin": {
6
+ "aic": "./dist/index.js"
7
+ },
8
+ "description": "AI-powered Git commit CLI using Ollama",
9
+ "keywords": ["git", "ai", "commit", "ollama", "cli"],
10
+ "license": "MIT",
11
+ "scripts": {
12
+ "build": "tsc"
13
+ },
14
+ "type": "module",
15
+ "devDependencies": {
16
+ "@types/node": "^25.3.0",
17
+ "typescript": "^5.9.3"
18
+ }
19
+ }
package/src/git.ts ADDED
@@ -0,0 +1,17 @@
1
+ import { execSync } from "child_process";
2
+
3
+ export function stageAll() {
4
+ execSync("git add .", { stdio: "inherit" });
5
+ }
6
+
7
+ export function getDiff(): string {
8
+ return execSync("git diff --staged --no-color").toString();
9
+ }
10
+
11
+ export function commit(msg: string) {
12
+ execSync(`git commit -m "${msg}"`, { stdio: "inherit" });
13
+ }
14
+
15
+ export function push(branch: string) {
16
+ execSync(`git push origin ${branch}`, { stdio: "inherit" });
17
+ }
package/src/index.ts ADDED
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { stageAll, getDiff, commit, push } from "./git.js";
4
+ import { generateCommit } from "./ollama.js";
5
+
6
+ async function main() {
7
+ const command = process.argv[2];
8
+
9
+ if (!command) {
10
+ console.log(`
11
+ Usage:
12
+ aic auto
13
+ aic push <branch>
14
+
15
+ Examples:
16
+ aic auto
17
+ aic push main
18
+ `);
19
+ return;
20
+ }
21
+
22
+
23
+ console.log("📦 Staging changes...");
24
+ await stageAll();
25
+
26
+ const diff = await getDiff();
27
+
28
+
29
+ console.log(" Generating commit...");
30
+ const message = await generateCommit(diff);
31
+
32
+ console.log("✅ Commit:", message);
33
+
34
+
35
+ await commit(message);
36
+
37
+
38
+ if (command === "push") {
39
+ const branch = process.argv[3] || "main";
40
+ console.log(` Pushing to ${branch}...`);
41
+ await push(branch);
42
+ }
43
+ }
44
+
45
+ main();
package/src/ollama.ts ADDED
@@ -0,0 +1,70 @@
1
+ type OllamaResponse = {
2
+ response: string;
3
+ };
4
+
5
+ export async function generateCommit(diff: string): Promise<string> {
6
+ if (!diff) {
7
+ console.log(`No changes done`)
8
+ process.exit(0);
9
+ }
10
+ const prompt = `
11
+ You are a senior software engineer and open-source contributor.
12
+
13
+ Your task is to generate a high-quality, professional Conventional Commit message based on the provided Git diff.
14
+
15
+ Strict rules:
16
+ - Use the Conventional Commits standard.
17
+ - Allowed types only: feat, fix, refactor, docs, chore.
18
+ - Use present tense.
19
+ - Be concise, clear, and meaningful.
20
+ - Maximum 50 characters.
21
+ - No emojis.
22
+ - No trailing period.
23
+ - Focus on the **intent and impact**, not the code.
24
+ - Do not mention filenames, functions, or variables unless essential.
25
+ - Prefer user-facing or architectural meaning.
26
+ - If multiple changes exist, prioritize the most important one.
27
+ - If the diff is unclear, infer the most logical intent.
28
+ - Output ONLY the commit message. No explanation.
29
+
30
+ Guidelines:
31
+ - feat → new functionality or user-visible change
32
+ - fix → bug fixes
33
+ - refactor → code improvements without behavior change
34
+ - docs → documentation changes
35
+ - chore → tooling, config, dependency, or maintenance
36
+
37
+ Examples:
38
+ Diff: adds login API and validation
39
+ Output: feat: add user authentication
40
+
41
+ Diff: resolves crash in payment flow
42
+ Output: fix: prevent payment crash
43
+
44
+ Diff: cleans up duplicated service logic
45
+ Output: refactor: remove duplicate logic
46
+
47
+ Diff: updates README with setup guide
48
+ Output: docs: update setup instructions
49
+
50
+ Now generate the commit message.
51
+
52
+ Diff:
53
+ ${diff}
54
+ `
55
+
56
+ const res = await fetch('http://localhost:11434/api/generate', {
57
+ method : 'POST',
58
+ body : JSON.stringify({
59
+ model : 'llama3.1:latest',
60
+ prompt,
61
+ stream : false,
62
+ })
63
+ })
64
+
65
+ const data = await res.json() as OllamaResponse;
66
+ return data.response.trim() ;
67
+ }
68
+
69
+
70
+
package/tsconfig.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "ESNext",
5
+ "outDir": "dist",
6
+ "rootDir": "src",
7
+ "moduleResolution": "node",
8
+ "strict": true,
9
+ "esModuleInterop": true
10
+ },
11
+ "include": ["src"]
12
+ }