@untools/commitgen 0.0.5 → 0.1.1
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 +333 -0
- package/dist/commands/configure.d.ts +1 -0
- package/dist/commands/configure.js +96 -0
- package/dist/commands/configure.js.map +1 -0
- package/dist/config.d.ts +15 -0
- package/dist/config.js +56 -0
- package/dist/config.js.map +1 -0
- package/dist/index.js +258 -180
- package/dist/index.js.map +1 -1
- package/dist/providers/base.d.ts +9 -0
- package/dist/providers/base.js +107 -0
- package/dist/providers/base.js.map +1 -0
- package/dist/providers/index.d.ts +4 -0
- package/dist/providers/index.js +41 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/providers/vercel-google.d.ts +10 -0
- package/dist/providers/vercel-google.js +93 -0
- package/dist/providers/vercel-google.js.map +1 -0
- package/dist/types.d.ts +25 -0
- package/dist/types.js +4 -0
- package/dist/types.js.map +1 -0
- package/package.json +12 -2
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ./src/providers/base.ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.BaseProvider = void 0;
|
|
5
|
+
class BaseProvider {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.analysis = null;
|
|
8
|
+
}
|
|
9
|
+
inferFeatureType(files) {
|
|
10
|
+
if (files.some((f) => f.includes("component") || f.includes("Component")))
|
|
11
|
+
return "component";
|
|
12
|
+
if (files.some((f) => f.includes("util") || f.includes("helper")))
|
|
13
|
+
return "utility";
|
|
14
|
+
if (files.some((f) => f.includes("api") || f.includes("endpoint")))
|
|
15
|
+
return "API endpoint";
|
|
16
|
+
if (files.some((f) => f.includes("model") || f.includes("schema")))
|
|
17
|
+
return "model";
|
|
18
|
+
if (files.some((f) => f.includes("service")))
|
|
19
|
+
return "service";
|
|
20
|
+
if (files.some((f) => f.includes("hook")))
|
|
21
|
+
return "hook";
|
|
22
|
+
if (files.some((f) => f.includes("type") || f.includes("interface")))
|
|
23
|
+
return "types";
|
|
24
|
+
return "feature";
|
|
25
|
+
}
|
|
26
|
+
inferScope(files) {
|
|
27
|
+
if (files.length === 0)
|
|
28
|
+
return "project";
|
|
29
|
+
const dirs = files
|
|
30
|
+
.map((f) => f.split("/")[0])
|
|
31
|
+
.filter((d) => d && !d.startsWith("."));
|
|
32
|
+
if (dirs.length === 0)
|
|
33
|
+
return "root";
|
|
34
|
+
const dirCount = dirs.reduce((acc, d) => {
|
|
35
|
+
acc[d] = (acc[d] || 0) + 1;
|
|
36
|
+
return acc;
|
|
37
|
+
}, {});
|
|
38
|
+
const mostCommon = Object.entries(dirCount).sort((a, b) => b[1] - a[1])[0][0];
|
|
39
|
+
if (dirCount[mostCommon] >= files.length * 0.6) {
|
|
40
|
+
return mostCommon;
|
|
41
|
+
}
|
|
42
|
+
return "multiple modules";
|
|
43
|
+
}
|
|
44
|
+
buildSystemPrompt() {
|
|
45
|
+
return `You are an expert at writing conventional commit messages.
|
|
46
|
+
Your task is to analyze git changes and generate clear, concise commit messages following the Conventional Commits specification.
|
|
47
|
+
|
|
48
|
+
Commit types:
|
|
49
|
+
- feat: A new feature
|
|
50
|
+
- fix: A bug fix
|
|
51
|
+
- docs: Documentation changes
|
|
52
|
+
- style: Code style changes (formatting, missing semi-colons, etc)
|
|
53
|
+
- refactor: Code changes that neither fix a bug nor add a feature
|
|
54
|
+
- perf: Performance improvements
|
|
55
|
+
- test: Adding or updating tests
|
|
56
|
+
- build: Changes to build system or dependencies
|
|
57
|
+
- ci: Changes to CI configuration
|
|
58
|
+
- chore: Other changes that don't modify src or test files
|
|
59
|
+
- revert: Reverts a previous commit
|
|
60
|
+
|
|
61
|
+
Format: type(scope): subject
|
|
62
|
+
|
|
63
|
+
Rules:
|
|
64
|
+
- Use imperative mood ("add" not "added" or "adds")
|
|
65
|
+
- Don't capitalize first letter of subject
|
|
66
|
+
- No period at the end of subject
|
|
67
|
+
- Keep subject under 50 characters
|
|
68
|
+
- Be specific but concise
|
|
69
|
+
- Include scope when relevant
|
|
70
|
+
- Add breaking change marker (!) when applicable`;
|
|
71
|
+
}
|
|
72
|
+
buildAnalysisPrompt(analysis) {
|
|
73
|
+
const { filesChanged, additions, deletions, diff } = analysis;
|
|
74
|
+
return `Analyze these git changes and generate 3-5 commit message suggestions:
|
|
75
|
+
|
|
76
|
+
Files changed (${filesChanged.length}):
|
|
77
|
+
${filesChanged
|
|
78
|
+
.slice(0, 20)
|
|
79
|
+
.map((f) => `- ${f}`)
|
|
80
|
+
.join("\n")}
|
|
81
|
+
${filesChanged.length > 20 ? `... and ${filesChanged.length - 20} more files` : ""}
|
|
82
|
+
|
|
83
|
+
Statistics:
|
|
84
|
+
- Additions: +${additions}
|
|
85
|
+
- Deletions: -${deletions}
|
|
86
|
+
|
|
87
|
+
Git diff (first 2000 characters):
|
|
88
|
+
\`\`\`
|
|
89
|
+
${diff.slice(0, 2000)}
|
|
90
|
+
\`\`\`
|
|
91
|
+
|
|
92
|
+
Return your response as a JSON array of commit messages:
|
|
93
|
+
[
|
|
94
|
+
{
|
|
95
|
+
"type": "feat",
|
|
96
|
+
"scope": "auth",
|
|
97
|
+
"subject": "add OAuth2 authentication",
|
|
98
|
+
"body": "Optional detailed description",
|
|
99
|
+
"breaking": false
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
|
|
103
|
+
Generate 3-5 suggestions, ordered from most to least relevant.`;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
exports.BaseProvider = BaseProvider;
|
|
107
|
+
//# sourceMappingURL=base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/providers/base.ts"],"names":[],"mappings":";AAAA,0BAA0B;;;AAI1B,MAAsB,YAAY;IAAlC;QACY,aAAQ,GAAuB,IAAI,CAAC;IAiHhD,CAAC;IA3GW,gBAAgB,CAAC,KAAe;QACxC,IAAI,KAAK,CAAC,IAAI,CA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C,CAAC,EAAE,EAAE,CAAC;aACZ,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC;aACpB,IAAI,CAAC,IAAI,CAAC;EACX,YAAY,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,WAAW,YAAY,CAAC,MAAM,GAAG,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE;;;gBAGlE,SAAS;gBACT,SAAS;;;;EAIvB,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC;;;;;;;;;;;;;;+DAc0C,CAAC;IAC9D,CAAC;CACF;AAlHD,oCAkHC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ./src/providers/index.ts
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.createProvider = createProvider;
|
|
19
|
+
const vercel_google_1 = require("./vercel-google");
|
|
20
|
+
function createProvider(config) {
|
|
21
|
+
switch (config.provider) {
|
|
22
|
+
case "vercel-google":
|
|
23
|
+
return new vercel_google_1.VercelGoogleProvider(config.apiKey, config.model);
|
|
24
|
+
// Future providers
|
|
25
|
+
// case 'vercel-openai':
|
|
26
|
+
// return new VercelOpenAIProvider(config.apiKey, config.model);
|
|
27
|
+
// case 'groq':
|
|
28
|
+
// return new GroqProvider(config.apiKey, config.model);
|
|
29
|
+
// case 'openai':
|
|
30
|
+
// return new OpenAIProvider(config.apiKey, config.model);
|
|
31
|
+
// case 'google':
|
|
32
|
+
// return new GoogleProvider(config.apiKey, config.model);
|
|
33
|
+
// case 'local':
|
|
34
|
+
// return new LocalProvider(config.baseUrl, config.model);
|
|
35
|
+
default:
|
|
36
|
+
throw new Error(`Unsupported provider: ${config.provider}`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
__exportStar(require("./vercel-google"), exports);
|
|
40
|
+
__exportStar(require("./base"), exports);
|
|
41
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":";AAAA,2BAA2B;;;;;;;;;;;;;;;;AAK3B,wCAoBC;AAvBD,mDAAuD;AAGvD,SAAgB,cAAc,CAAC,MAAsB;IACnD,QAAQ,MAAM,CAAC,QAAQ,EAAE,CAAC;QACxB,KAAK,eAAe;YAClB,OAAO,IAAI,oCAAoB,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;QAE/D,mBAAmB;QACnB,wBAAwB;QACxB,kEAAkE;QAClE,eAAe;QACf,0DAA0D;QAC1D,iBAAiB;QACjB,4DAA4D;QAC5D,iBAAiB;QACjB,4DAA4D;QAC5D,gBAAgB;QAChB,4DAA4D;QAE5D;YACE,MAAM,IAAI,KAAK,CAAC,yBAAyB,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;IAChE,CAAC;AACH,CAAC;AAED,kDAAgC;AAChC,yCAAuB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BaseProvider } from "./base";
|
|
2
|
+
import { GitAnalysis, CommitMessage, AIProvider } from "../types";
|
|
3
|
+
export declare class VercelGoogleProvider extends BaseProvider implements AIProvider {
|
|
4
|
+
name: string;
|
|
5
|
+
private apiKey;
|
|
6
|
+
private model;
|
|
7
|
+
constructor(apiKey?: string, model?: string);
|
|
8
|
+
generateCommitMessage(analysis: GitAnalysis): Promise<CommitMessage[]>;
|
|
9
|
+
private getFallbackSuggestions;
|
|
10
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ./src/providers/vercel-google.ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.VercelGoogleProvider = void 0;
|
|
5
|
+
const google_1 = require("@ai-sdk/google");
|
|
6
|
+
const ai_1 = require("ai");
|
|
7
|
+
const base_1 = require("./base");
|
|
8
|
+
class VercelGoogleProvider extends base_1.BaseProvider {
|
|
9
|
+
constructor(apiKey, model = "gemini-2.5-flash") {
|
|
10
|
+
super();
|
|
11
|
+
this.name = "vercel-google";
|
|
12
|
+
this.apiKey = apiKey || process.env.GOOGLE_GENERATIVE_AI_API_KEY || "";
|
|
13
|
+
this.model = model;
|
|
14
|
+
if (!this.apiKey) {
|
|
15
|
+
throw new Error("Google API key is required. Set GOOGLE_GENERATIVE_AI_API_KEY environment variable or pass it in config.");
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
async generateCommitMessage(analysis) {
|
|
19
|
+
this.analysis = analysis;
|
|
20
|
+
try {
|
|
21
|
+
const google = (0, google_1.createGoogleGenerativeAI)({
|
|
22
|
+
apiKey: this.apiKey,
|
|
23
|
+
});
|
|
24
|
+
const { text } = await (0, ai_1.generateText)({
|
|
25
|
+
model: google(this.model),
|
|
26
|
+
system: this.buildSystemPrompt(),
|
|
27
|
+
prompt: this.buildAnalysisPrompt(analysis),
|
|
28
|
+
temperature: 0.7,
|
|
29
|
+
});
|
|
30
|
+
// Parse JSON response
|
|
31
|
+
const jsonMatch = text.match(/\[[\s\S]*\]/);
|
|
32
|
+
if (!jsonMatch) {
|
|
33
|
+
throw new Error("Failed to parse AI response");
|
|
34
|
+
}
|
|
35
|
+
const suggestions = JSON.parse(jsonMatch[0]);
|
|
36
|
+
return suggestions.slice(0, 5);
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
console.error("Error generating commit message:", error);
|
|
40
|
+
// Fallback to rule-based suggestions
|
|
41
|
+
return this.getFallbackSuggestions(analysis);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
getFallbackSuggestions(analysis) {
|
|
45
|
+
const { filesChanged, additions, deletions } = analysis;
|
|
46
|
+
const suggestions = [];
|
|
47
|
+
const hasTests = filesChanged.some((f) => f.includes("test") || f.includes("spec") || f.includes("__tests__"));
|
|
48
|
+
const hasDocs = filesChanged.some((f) => f.includes("README") || f.includes(".md"));
|
|
49
|
+
const hasConfig = filesChanged.some((f) => f.includes("config") ||
|
|
50
|
+
f.includes(".json") ||
|
|
51
|
+
f.includes("package.json"));
|
|
52
|
+
if (additions > deletions * 2 && additions > 20) {
|
|
53
|
+
suggestions.push({
|
|
54
|
+
type: "feat",
|
|
55
|
+
subject: `add ${this.inferFeatureType(filesChanged)}`,
|
|
56
|
+
scope: this.inferScope(filesChanged),
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
if (deletions > additions * 2 && deletions > 20) {
|
|
60
|
+
suggestions.push({
|
|
61
|
+
type: "refactor",
|
|
62
|
+
subject: `remove unused ${this.inferFeatureType(filesChanged)}`,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
if (hasTests) {
|
|
66
|
+
suggestions.push({
|
|
67
|
+
type: "test",
|
|
68
|
+
subject: `add tests for ${this.inferScope(filesChanged)}`,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
if (hasDocs) {
|
|
72
|
+
suggestions.push({
|
|
73
|
+
type: "docs",
|
|
74
|
+
subject: "update documentation",
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
if (hasConfig) {
|
|
78
|
+
suggestions.push({
|
|
79
|
+
type: "chore",
|
|
80
|
+
subject: "update configuration",
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
if (suggestions.length === 0) {
|
|
84
|
+
suggestions.push({
|
|
85
|
+
type: "feat",
|
|
86
|
+
subject: `update ${this.inferScope(filesChanged)}`,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
return suggestions;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
exports.VercelGoogleProvider = VercelGoogleProvider;
|
|
93
|
+
//# sourceMappingURL=vercel-google.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vercel-google.js","sourceRoot":"","sources":["../../src/providers/vercel-google.ts"],"names":[],"mappings":";AAAA,mCAAmC;;;AAEnC,2CAA0D;AAC1D,2BAAkC;AAClC,iCAAsC;AAGtC,MAAa,oBAAqB,SAAQ,mBAAY;IAKpD,YAAY,MAAe,EAAE,QAAgB,kBAAkB;QAC7D,KAAK,EAAE,CAAC;QALV,SAAI,GAAG,eAAe,CAAC;QAMrB,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,4BAA4B,IAAI,EAAE,CAAC;QACvE,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QAEnB,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CACb,yGAAyG,CAC1G,CAAC;QACJ,CAAC;IACH,CAAC;IAED,KAAK,CAAC,qBAAqB,CAAC,QAAqB;QAC/C,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAEzB,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAA,iCAAwB,EAAC;gBACtC,MAAM,EAAE,IAAI,CAAC,MAAM;aACpB,CAAC,CAAC;YAEH,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAA,iBAAY,EAAC;gBAClC,KAAK,EAAE,MAAM,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K,CAAC,EAAE,CAAC;YAC7B,WAAW,CAAC,IAAI,CAAC;gBACf,IAAI,EAAE,MAAM;gBACZ,OAAO,EAAE,UAAU,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE;aACnD,CAAC,CAAC;QACL,CAAC;QAED,OAAO,WAAW,CAAC;IACrB,CAAC;CACF;AA7GD,oDA6GC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface CommitMessage {
|
|
2
|
+
type: string;
|
|
3
|
+
scope?: string;
|
|
4
|
+
subject: string;
|
|
5
|
+
body?: string;
|
|
6
|
+
breaking?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface GitAnalysis {
|
|
9
|
+
filesChanged: string[];
|
|
10
|
+
additions: number;
|
|
11
|
+
deletions: number;
|
|
12
|
+
hasStaged: boolean;
|
|
13
|
+
hasUnstaged: boolean;
|
|
14
|
+
diff: string;
|
|
15
|
+
}
|
|
16
|
+
export interface AIProvider {
|
|
17
|
+
name: string;
|
|
18
|
+
generateCommitMessage(analysis: GitAnalysis): Promise<CommitMessage[]>;
|
|
19
|
+
}
|
|
20
|
+
export interface ProviderConfig {
|
|
21
|
+
provider: "vercel-google" | "vercel-openai" | "groq" | "openai" | "google" | "local";
|
|
22
|
+
apiKey?: string;
|
|
23
|
+
model?: string;
|
|
24
|
+
baseUrl?: string;
|
|
25
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA,iBAAiB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@untools/commitgen",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "CLI to create generate commit messages",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -17,7 +17,15 @@
|
|
|
17
17
|
"release:patch": "standard-version --release-as patch"
|
|
18
18
|
},
|
|
19
19
|
"keywords": [
|
|
20
|
-
"
|
|
20
|
+
"git",
|
|
21
|
+
"commit",
|
|
22
|
+
"conventional-commits",
|
|
23
|
+
"ai",
|
|
24
|
+
"cli",
|
|
25
|
+
"typescript",
|
|
26
|
+
"commitizen",
|
|
27
|
+
"gemini",
|
|
28
|
+
"openai"
|
|
21
29
|
],
|
|
22
30
|
"files": [
|
|
23
31
|
"dist"
|
|
@@ -39,7 +47,9 @@
|
|
|
39
47
|
},
|
|
40
48
|
"homepage": "https://github.com/aevrHQ/untools-commitgen#readme",
|
|
41
49
|
"dependencies": {
|
|
50
|
+
"@ai-sdk/google": "^2.0.26",
|
|
42
51
|
"@untools/port-gen": "^0.0.2",
|
|
52
|
+
"ai": "^5.0.86",
|
|
43
53
|
"chalk": "^4.1.2",
|
|
44
54
|
"commander": "^13.1.0",
|
|
45
55
|
"degit": "^2.8.4",
|