@mehmetsagir/git-ai 0.0.9 → 0.0.19
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 +135 -297
- package/dist/commit.d.ts +1 -4
- package/dist/commit.d.ts.map +1 -1
- package/dist/commit.js +214 -208
- package/dist/commit.js.map +1 -1
- package/dist/config.d.ts +0 -39
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +3 -95
- package/dist/config.js.map +1 -1
- package/dist/git.d.ts +19 -51
- package/dist/git.d.ts.map +1 -1
- package/dist/git.js +137 -269
- package/dist/git.js.map +1 -1
- package/dist/index.js +54 -109
- package/dist/index.js.map +1 -1
- package/dist/openai.d.ts +2 -21
- package/dist/openai.d.ts.map +1 -1
- package/dist/openai.js +17 -96
- package/dist/openai.js.map +1 -1
- package/dist/prompts.d.ts +2 -16
- package/dist/prompts.d.ts.map +1 -1
- package/dist/prompts.js +32 -146
- package/dist/prompts.js.map +1 -1
- package/dist/reset.d.ts +0 -3
- package/dist/reset.d.ts.map +1 -1
- package/dist/reset.js +10 -20
- package/dist/reset.js.map +1 -1
- package/dist/setup.d.ts +0 -3
- package/dist/setup.d.ts.map +1 -1
- package/dist/setup.js +28 -156
- package/dist/setup.js.map +1 -1
- package/dist/stash.d.ts +2 -0
- package/dist/stash.d.ts.map +1 -0
- package/dist/stash.js +818 -0
- package/dist/stash.js.map +1 -0
- package/dist/types.d.ts +9 -23
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/hunk-parser.d.ts +22 -0
- package/dist/utils/hunk-parser.d.ts.map +1 -0
- package/dist/utils/hunk-parser.js +155 -0
- package/dist/utils/hunk-parser.js.map +1 -0
- package/package.json +8 -9
- package/dist/add.d.ts +0 -5
- package/dist/add.d.ts.map +0 -1
- package/dist/add.js +0 -98
- package/dist/add.js.map +0 -1
- package/dist/commit-processor.d.ts +0 -6
- package/dist/commit-processor.d.ts.map +0 -1
- package/dist/commit-processor.js +0 -226
- package/dist/commit-processor.js.map +0 -1
- package/dist/update.d.ts +0 -9
- package/dist/update.d.ts.map +0 -1
- package/dist/update.js +0 -69
- package/dist/update.js.map +0 -1
- package/dist/user-management.d.ts +0 -10
- package/dist/user-management.d.ts.map +0 -1
- package/dist/user-management.js +0 -175
- package/dist/user-management.js.map +0 -1
- package/dist/users.d.ts +0 -9
- package/dist/users.d.ts.map +0 -1
- package/dist/users.js +0 -129
- package/dist/users.js.map +0 -1
- package/dist/utils/validation.d.ts +0 -24
- package/dist/utils/validation.d.ts.map +0 -1
- package/dist/utils/validation.js +0 -81
- package/dist/utils/validation.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -41,120 +41,65 @@ const commander_1 = require("commander");
|
|
|
41
41
|
const chalk_1 = __importDefault(require("chalk"));
|
|
42
42
|
const setup = __importStar(require("./setup"));
|
|
43
43
|
const commit = __importStar(require("./commit"));
|
|
44
|
-
const users = __importStar(require("./users"));
|
|
45
44
|
const reset = __importStar(require("./reset"));
|
|
46
|
-
const
|
|
47
|
-
const update = __importStar(require("./update"));
|
|
48
|
-
const package_json_1 = __importDefault(require("../package.json"));
|
|
45
|
+
const stash = __importStar(require("./stash"));
|
|
49
46
|
const errors_1 = require("./utils/errors");
|
|
50
47
|
const program = new commander_1.Command();
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
*/
|
|
54
|
-
function handleError(error, showStack = false) {
|
|
55
|
-
const err = error instanceof Error ? error : new Error((0, errors_1.getErrorMessage)(error));
|
|
56
|
-
console.error(chalk_1.default.red(`\n❌ Error: ${err.message}\n`));
|
|
57
|
-
if (showStack && err.stack) {
|
|
58
|
-
console.error(chalk_1.default.gray(err.stack));
|
|
59
|
-
}
|
|
48
|
+
function handleError(error) {
|
|
49
|
+
console.error(chalk_1.default.red(`\n❌ Error: ${(0, errors_1.getErrorMessage)(error)}\n`));
|
|
60
50
|
process.exit(1);
|
|
61
51
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
})();
|
|
73
|
-
// Don't continue - the async function will exit the process when done
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
// Check for updates silently in background (after a delay to not block startup)
|
|
77
|
-
setTimeout(() => {
|
|
78
|
-
update.checkForUpdates();
|
|
79
|
-
}, 1000);
|
|
80
|
-
program
|
|
81
|
-
.name("git-ai")
|
|
82
|
-
.description("AI-powered git commit tool that analyzes diffs and creates conventional commit messages")
|
|
83
|
-
.version(package_json_1.default.version)
|
|
84
|
-
.option("--update", "Check for updates and update to latest version");
|
|
85
|
-
program
|
|
86
|
-
.command("setup")
|
|
87
|
-
.description("Initial setup - OpenAI API key and git user configuration")
|
|
88
|
-
.action(async () => {
|
|
89
|
-
try {
|
|
90
|
-
await setup.runSetup();
|
|
91
|
-
}
|
|
92
|
-
catch (error) {
|
|
93
|
-
handleError(error);
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
program
|
|
97
|
-
.command("commit")
|
|
98
|
-
.description("Analyze git diffs and create commits")
|
|
99
|
-
.option("-u, --user <user>", "Git user ID or email to use (instead of default user)")
|
|
100
|
-
.action(async (options) => {
|
|
101
|
-
try {
|
|
102
|
-
await commit.runCommit(options.user);
|
|
103
|
-
}
|
|
104
|
-
catch (error) {
|
|
105
|
-
handleError(error, true);
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
program
|
|
109
|
-
.command("add")
|
|
110
|
-
.alias("add-user")
|
|
111
|
-
.description("Add a new git user profile")
|
|
112
|
-
.action(async () => {
|
|
113
|
-
try {
|
|
114
|
-
await add.addUser();
|
|
115
|
-
}
|
|
116
|
-
catch (error) {
|
|
117
|
-
handleError(error);
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
program
|
|
121
|
-
.command("list")
|
|
122
|
-
.alias("users")
|
|
123
|
-
.description("List all configured git user profiles")
|
|
124
|
-
.action(() => {
|
|
125
|
-
try {
|
|
126
|
-
users.listUsers();
|
|
127
|
-
}
|
|
128
|
-
catch (error) {
|
|
129
|
-
handleError(error);
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
program
|
|
133
|
-
.command("remove")
|
|
134
|
-
.alias("delete")
|
|
135
|
-
.description("Remove a git user profile")
|
|
136
|
-
.action(async () => {
|
|
137
|
-
try {
|
|
138
|
-
await users.removeUser();
|
|
139
|
-
}
|
|
140
|
-
catch (error) {
|
|
141
|
-
handleError(error);
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
program
|
|
145
|
-
.command("reset")
|
|
146
|
-
.description("Reset all configuration (deletes OpenAI key and all git users)")
|
|
147
|
-
.action(async () => {
|
|
148
|
-
try {
|
|
149
|
-
await reset.resetConfig();
|
|
150
|
-
}
|
|
151
|
-
catch (error) {
|
|
152
|
-
handleError(error);
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
if (process.argv.length === 2) {
|
|
156
|
-
program.help();
|
|
52
|
+
program
|
|
53
|
+
.name("git-ai")
|
|
54
|
+
.description("AI-powered git commit tool")
|
|
55
|
+
.version(require("../package.json").version);
|
|
56
|
+
program
|
|
57
|
+
.command("setup")
|
|
58
|
+
.description("Configure OpenAI API key")
|
|
59
|
+
.action(async () => {
|
|
60
|
+
try {
|
|
61
|
+
await setup.runSetup();
|
|
157
62
|
}
|
|
158
|
-
|
|
63
|
+
catch (error) {
|
|
64
|
+
handleError(error);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
program
|
|
68
|
+
.command("commit")
|
|
69
|
+
.description("Analyze changes and create commits")
|
|
70
|
+
.action(async () => {
|
|
71
|
+
try {
|
|
72
|
+
await commit.runCommit();
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
handleError(error);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
program
|
|
79
|
+
.command("reset")
|
|
80
|
+
.description("Reset configuration")
|
|
81
|
+
.action(async () => {
|
|
82
|
+
try {
|
|
83
|
+
await reset.resetConfig();
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
handleError(error);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
program
|
|
90
|
+
.command("stash")
|
|
91
|
+
.description("View git stashes in browser")
|
|
92
|
+
.action(async () => {
|
|
93
|
+
try {
|
|
94
|
+
await stash.runStashViewer();
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
handleError(error);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
// Show help if no command provided
|
|
101
|
+
if (process.argv.length === 2) {
|
|
102
|
+
program.help();
|
|
159
103
|
}
|
|
104
|
+
program.parse(process.argv);
|
|
160
105
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,yCAAoC;AACpC,kDAA0B;AAC1B,+CAAiC;AACjC,iDAAmC;AACnC,+CAAiC;AACjC,+CAAiC;AACjC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,yCAAoC;AACpC,kDAA0B;AAC1B,+CAAiC;AACjC,iDAAmC;AACnC,+CAAiC;AACjC,+CAAiC;AACjC,2CAAiD;AAEjD,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,SAAS,WAAW,CAAC,KAAc;IACjC,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,cAAc,IAAA,wBAAe,EAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IACnE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,OAAO;KACJ,IAAI,CAAC,QAAQ,CAAC;KACd,WAAW,CAAC,4BAA4B,CAAC;KACzC,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC,CAAC;AAE/C,OAAO;KACJ,OAAO,CAAC,OAAO,CAAC;KAChB,WAAW,CAAC,0BAA0B,CAAC;KACvC,MAAM,CAAC,KAAK,IAAI,EAAE;IACjB,IAAI,CAAC;QACH,MAAM,KAAK,CAAC,QAAQ,EAAE,CAAC;IACzB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,WAAW,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;AACH,CAAC,CAAC,CAAC;AAEL,OAAO;KACJ,OAAO,CAAC,QAAQ,CAAC;KACjB,WAAW,CAAC,oCAAoC,CAAC;KACjD,MAAM,CAAC,KAAK,IAAI,EAAE;IACjB,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,SAAS,EAAE,CAAC;IAC3B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,WAAW,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;AACH,CAAC,CAAC,CAAC;AAEL,OAAO;KACJ,OAAO,CAAC,OAAO,CAAC;KAChB,WAAW,CAAC,qBAAqB,CAAC;KAClC,MAAM,CAAC,KAAK,IAAI,EAAE;IACjB,IAAI,CAAC;QACH,MAAM,KAAK,CAAC,WAAW,EAAE,CAAC;IAC5B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,WAAW,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;AACH,CAAC,CAAC,CAAC;AAEL,OAAO;KACJ,OAAO,CAAC,OAAO,CAAC;KAChB,WAAW,CAAC,6BAA6B,CAAC;KAC1C,MAAM,CAAC,KAAK,IAAI,EAAE;IACjB,IAAI,CAAC;QACH,MAAM,KAAK,CAAC,cAAc,EAAE,CAAC;IAC/B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,WAAW,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;AACH,CAAC,CAAC,CAAC;AAEL,mCAAmC;AACnC,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;IAC9B,OAAO,CAAC,IAAI,EAAE,CAAC;AACjB,CAAC;AAED,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
package/dist/openai.d.ts
CHANGED
|
@@ -1,22 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Initialize OpenAI client
|
|
5
|
-
*/
|
|
6
|
-
export declare function initOpenAI(apiKey: string): OpenAI;
|
|
7
|
-
/**
|
|
8
|
-
* Get OpenAI client
|
|
9
|
-
*/
|
|
10
|
-
export declare function getOpenAIClient(): OpenAI;
|
|
11
|
-
/**
|
|
12
|
-
* Analyze git diff and create commit groups
|
|
13
|
-
*/
|
|
14
|
-
export declare function analyzeDiffAndGroup(diff: string, apiKey: string): Promise<AnalysisResult>;
|
|
15
|
-
/**
|
|
16
|
-
* Generate commit message for a single diff (simple usage)
|
|
17
|
-
*/
|
|
18
|
-
export declare function generateCommitMessage(diff: string, apiKey: string): Promise<{
|
|
19
|
-
commitMessage: string;
|
|
20
|
-
commitBody: string;
|
|
21
|
-
}>;
|
|
1
|
+
import { AnalysisResult } from "./types";
|
|
2
|
+
export declare function analyzeAndGroup(formattedDiff: string, stats: string, apiKey: string): Promise<AnalysisResult>;
|
|
22
3
|
//# sourceMappingURL=openai.d.ts.map
|
package/dist/openai.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../src/openai.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../src/openai.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,wBAAsB,eAAe,CACnC,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,cAAc,CAAC,CAmBzB"}
|
package/dist/openai.js
CHANGED
|
@@ -36,103 +36,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.
|
|
40
|
-
exports.getOpenAIClient = getOpenAIClient;
|
|
41
|
-
exports.analyzeDiffAndGroup = analyzeDiffAndGroup;
|
|
42
|
-
exports.generateCommitMessage = generateCommitMessage;
|
|
39
|
+
exports.analyzeAndGroup = analyzeAndGroup;
|
|
43
40
|
const openai_1 = __importDefault(require("openai"));
|
|
44
41
|
const prompts = __importStar(require("./prompts"));
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (!openaiClient) {
|
|
62
|
-
throw new Error('OpenAI client not initialized. Call initOpenAI() first.');
|
|
63
|
-
}
|
|
64
|
-
return openaiClient;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Analyze git diff and create commit groups
|
|
68
|
-
*/
|
|
69
|
-
async function analyzeDiffAndGroup(diff, apiKey) {
|
|
70
|
-
if (!apiKey) {
|
|
71
|
-
throw new Error('OpenAI API key is required');
|
|
72
|
-
}
|
|
73
|
-
initOpenAI(apiKey);
|
|
74
|
-
const client = getOpenAIClient();
|
|
75
|
-
const systemPrompt = prompts.getDiffAnalysisSystemPrompt();
|
|
76
|
-
const userPrompt = prompts.getDiffAnalysisUserPrompt(diff);
|
|
77
|
-
try {
|
|
78
|
-
const response = await client.chat.completions.create({
|
|
79
|
-
model: 'gpt-4o-mini',
|
|
80
|
-
messages: [
|
|
81
|
-
{ role: 'system', content: systemPrompt },
|
|
82
|
-
{ role: 'user', content: userPrompt }
|
|
83
|
-
],
|
|
84
|
-
temperature: 0.3,
|
|
85
|
-
response_format: { type: 'json_object' }
|
|
86
|
-
});
|
|
87
|
-
const content = response.choices[0]?.message?.content;
|
|
88
|
-
if (!content) {
|
|
89
|
-
throw new Error('No response from OpenAI');
|
|
90
|
-
}
|
|
91
|
-
const result = JSON.parse(content);
|
|
92
|
-
return result;
|
|
93
|
-
}
|
|
94
|
-
catch (error) {
|
|
95
|
-
const message = (0, errors_1.getErrorMessage)(error);
|
|
96
|
-
if (message.includes('API key')) {
|
|
97
|
-
throw new Error('Invalid OpenAI API key');
|
|
98
|
-
}
|
|
99
|
-
throw new Error(`OpenAI API error: ${message}`);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Generate commit message for a single diff (simple usage)
|
|
104
|
-
*/
|
|
105
|
-
async function generateCommitMessage(diff, apiKey) {
|
|
106
|
-
if (!apiKey) {
|
|
107
|
-
throw new Error('OpenAI API key is required');
|
|
108
|
-
}
|
|
109
|
-
initOpenAI(apiKey);
|
|
110
|
-
const client = getOpenAIClient();
|
|
111
|
-
const systemPrompt = prompts.getSingleCommitSystemPrompt();
|
|
112
|
-
const userPrompt = prompts.getSingleCommitUserPrompt(diff);
|
|
113
|
-
try {
|
|
114
|
-
const response = await client.chat.completions.create({
|
|
115
|
-
model: 'gpt-4o-mini',
|
|
116
|
-
messages: [
|
|
117
|
-
{ role: 'system', content: systemPrompt },
|
|
118
|
-
{ role: 'user', content: userPrompt }
|
|
119
|
-
],
|
|
120
|
-
temperature: 0.3,
|
|
121
|
-
response_format: { type: 'json_object' }
|
|
122
|
-
});
|
|
123
|
-
const content = response.choices[0]?.message?.content;
|
|
124
|
-
if (!content) {
|
|
125
|
-
throw new Error('No response from OpenAI');
|
|
126
|
-
}
|
|
127
|
-
const result = JSON.parse(content);
|
|
128
|
-
return result;
|
|
129
|
-
}
|
|
130
|
-
catch (error) {
|
|
131
|
-
const message = (0, errors_1.getErrorMessage)(error);
|
|
132
|
-
if (message.includes('API key')) {
|
|
133
|
-
throw new Error('Invalid OpenAI API key');
|
|
134
|
-
}
|
|
135
|
-
throw new Error(`OpenAI API error: ${message}`);
|
|
136
|
-
}
|
|
42
|
+
async function analyzeAndGroup(formattedDiff, stats, apiKey) {
|
|
43
|
+
const client = new openai_1.default({ apiKey });
|
|
44
|
+
const response = await client.chat.completions.create({
|
|
45
|
+
model: "gpt-4o-mini",
|
|
46
|
+
messages: [
|
|
47
|
+
{ role: "system", content: prompts.getSystemPrompt() },
|
|
48
|
+
{ role: "user", content: prompts.getUserPrompt(formattedDiff, stats) },
|
|
49
|
+
],
|
|
50
|
+
temperature: 0.3,
|
|
51
|
+
response_format: { type: "json_object" },
|
|
52
|
+
});
|
|
53
|
+
const content = response.choices[0]?.message?.content;
|
|
54
|
+
if (!content) {
|
|
55
|
+
throw new Error("No response from OpenAI");
|
|
56
|
+
}
|
|
57
|
+
return JSON.parse(content);
|
|
137
58
|
}
|
|
138
59
|
//# sourceMappingURL=openai.js.map
|
package/dist/openai.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai.js","sourceRoot":"","sources":["../src/openai.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"openai.js","sourceRoot":"","sources":["../src/openai.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,0CAuBC;AA3BD,oDAA4B;AAC5B,mDAAqC;AAG9B,KAAK,UAAU,eAAe,CACnC,aAAqB,EACrB,KAAa,EACb,MAAc;IAEd,MAAM,MAAM,GAAG,IAAI,gBAAM,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IAEtC,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;QACpD,KAAK,EAAE,aAAa;QACpB,QAAQ,EAAE;YACR,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,eAAe,EAAE,EAAE;YACtD,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,aAAa,EAAE,KAAK,CAAC,EAAE;SACvE;QACD,WAAW,EAAE,GAAG;QAChB,eAAe,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE;KACzC,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC;IACtD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAED,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAmB,CAAC;AAC/C,CAAC"}
|
package/dist/prompts.d.ts
CHANGED
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
|
-
export declare function getDiffAnalysisSystemPrompt(): string;
|
|
5
|
-
/**
|
|
6
|
-
* Get user prompt for diff analysis
|
|
7
|
-
*/
|
|
8
|
-
export declare function getDiffAnalysisUserPrompt(diff: string): string;
|
|
9
|
-
/**
|
|
10
|
-
* Get system prompt for single commit message generation
|
|
11
|
-
*/
|
|
12
|
-
export declare function getSingleCommitSystemPrompt(): string;
|
|
13
|
-
/**
|
|
14
|
-
* Get user prompt for single commit message
|
|
15
|
-
*/
|
|
16
|
-
export declare function getSingleCommitUserPrompt(diff: string): string;
|
|
1
|
+
export declare function getSystemPrompt(): string;
|
|
2
|
+
export declare function getUserPrompt(formattedDiff: string, stats: string): string;
|
|
17
3
|
//# sourceMappingURL=prompts.d.ts.map
|
package/dist/prompts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AAAA,wBAAgB,eAAe,IAAI,MAAM,CAwCxC;AAED,wBAAgB,aAAa,CAAC,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAU1E"}
|
package/dist/prompts.js
CHANGED
|
@@ -1,171 +1,57 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Get system prompt for diff analysis and grouping
|
|
9
|
-
*/
|
|
10
|
-
function getDiffAnalysisSystemPrompt() {
|
|
11
|
-
return `You are a git commit expert. You analyze git diffs, group them logically, and create Conventional Commits standard commit messages for each group.
|
|
3
|
+
exports.getSystemPrompt = getSystemPrompt;
|
|
4
|
+
exports.getUserPrompt = getUserPrompt;
|
|
5
|
+
function getSystemPrompt() {
|
|
6
|
+
return `You are a git commit expert. Analyze diff hunks and group them into logical commits.
|
|
12
7
|
|
|
13
|
-
|
|
8
|
+
IMPORTANT: Each file may have multiple independent changes (hunks). Group related hunks together, even if they're from different files. Unrelated changes in the same file should be in different commits.
|
|
14
9
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
GROUPING RULES:
|
|
11
|
+
1. Group hunks by logical change (same feature, same fix, same refactor)
|
|
12
|
+
2. Related changes across multiple files go together
|
|
13
|
+
3. Unrelated changes in the SAME file should be SEPARATE commits
|
|
14
|
+
4. Keep test hunks with their source code hunks
|
|
15
|
+
5. Binary files are treated as single hunks
|
|
21
16
|
|
|
22
|
-
|
|
23
|
-
- Base/utility files that other files depend on should be committed FIRST
|
|
24
|
-
- Files that depend on others should be committed AFTER their dependencies
|
|
25
|
-
- Example: If types.ts is used by service.ts, commit types.ts first, then service.ts
|
|
26
|
-
|
|
27
|
-
3. **Feature-Based Grouping**:
|
|
28
|
-
- Group by feature/module (authentication, payment, user management, etc.)
|
|
29
|
-
- Group by component area (UI components, API endpoints, database models)
|
|
30
|
-
- Group by layer (models, services, controllers, views)
|
|
31
|
-
|
|
32
|
-
4. **Type-Based Grouping** (when features are unrelated):
|
|
33
|
-
- All documentation changes together
|
|
34
|
-
- All test files together (if not related to specific features)
|
|
35
|
-
- All style/formatting changes together
|
|
36
|
-
- All configuration changes together
|
|
37
|
-
|
|
38
|
-
5. **Atomic Commits**:
|
|
39
|
-
- Each commit should represent ONE complete, logical change
|
|
40
|
-
- Each commit should leave the codebase in a working state
|
|
41
|
-
- Avoid mixing unrelated changes in one commit
|
|
42
|
-
|
|
43
|
-
6. **Optimal Grouping Strategy**:
|
|
44
|
-
- MAXIMIZE grouping: Put as many related files together as possible
|
|
45
|
-
- MINIMIZE commits: Create fewer, well-grouped commits rather than many tiny commits
|
|
46
|
-
- Only create separate commits when files are truly unrelated
|
|
47
|
-
- If 10 files are all part of one feature, they should be ONE commit, not 10
|
|
48
|
-
|
|
49
|
-
GROUPING EXAMPLES:
|
|
50
|
-
|
|
51
|
-
✅ GOOD GROUPING:
|
|
52
|
-
- Group 1: Authentication feature (auth.ts, auth.test.ts, auth.types.ts, auth.config.ts) - 4 files, 1 commit
|
|
53
|
-
- Group 2: User profile feature (profile.ts, profile.test.ts, profile.types.ts) - 3 files, 1 commit
|
|
54
|
-
|
|
55
|
-
❌ BAD GROUPING:
|
|
56
|
-
- Group 1: auth.ts - 1 file
|
|
57
|
-
- Group 2: auth.test.ts - 1 file
|
|
58
|
-
- Group 3: auth.types.ts - 1 file
|
|
59
|
-
(This is wrong! These are related and should be ONE commit)
|
|
60
|
-
|
|
61
|
-
Conventional Commits format:
|
|
17
|
+
COMMIT MESSAGE FORMAT (Conventional Commits):
|
|
62
18
|
<type>(<scope>): <subject>
|
|
63
19
|
|
|
64
|
-
<body>
|
|
65
|
-
|
|
66
|
-
<footer>
|
|
67
|
-
|
|
68
20
|
Types:
|
|
69
21
|
- feat: New feature
|
|
70
22
|
- fix: Bug fix
|
|
71
|
-
- refactor: Code
|
|
72
|
-
- style: Formatting,
|
|
23
|
+
- refactor: Code restructuring
|
|
24
|
+
- style: Formatting, CSS
|
|
73
25
|
- docs: Documentation
|
|
74
26
|
- test: Tests
|
|
75
|
-
- chore: Maintenance
|
|
76
|
-
|
|
77
|
-
Each commit group must contain:
|
|
78
|
-
1. Group number (sequential: 1, 2, 3...)
|
|
79
|
-
2. Group description (what feature/change this represents)
|
|
80
|
-
3. File list (full file paths - ALL related files together)
|
|
81
|
-
4. Commit message in Conventional Commits format
|
|
82
|
-
5. Commit message body (detailed description of changes)
|
|
83
|
-
|
|
84
|
-
IMPORTANT:
|
|
85
|
-
- Each group will be created as a SEPARATE COMMIT
|
|
86
|
-
- Group files MAXIMALLY - put all related files together
|
|
87
|
-
- Only separate into different commits if files are truly unrelated
|
|
88
|
-
- Order groups by dependencies (base files first, dependent files later)
|
|
27
|
+
- chore: Maintenance, config
|
|
89
28
|
|
|
90
|
-
Respond in JSON
|
|
29
|
+
Respond in JSON:
|
|
91
30
|
{
|
|
92
31
|
"groups": [
|
|
93
32
|
{
|
|
94
33
|
"number": 1,
|
|
95
|
-
"description": "
|
|
96
|
-
"
|
|
97
|
-
|
|
98
|
-
|
|
34
|
+
"description": "Brief description of what this commit does",
|
|
35
|
+
"hunks": [
|
|
36
|
+
{ "file": "path/to/file.ts", "hunkIndex": 0 },
|
|
37
|
+
{ "file": "path/to/file.ts", "hunkIndex": 2 },
|
|
38
|
+
{ "file": "path/to/other.ts", "hunkIndex": 0 }
|
|
39
|
+
],
|
|
40
|
+
"commitMessage": "feat(scope): description",
|
|
41
|
+
"commitBody": "Optional details"
|
|
99
42
|
}
|
|
100
|
-
]
|
|
101
|
-
"summary": "Total X groups, Y file changes"
|
|
43
|
+
]
|
|
102
44
|
}`;
|
|
103
45
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
*/
|
|
107
|
-
function getDiffAnalysisUserPrompt(diff) {
|
|
108
|
-
return `Analyze the following git diff and group it into logical commit groups.
|
|
46
|
+
function getUserPrompt(formattedDiff, stats) {
|
|
47
|
+
return `Analyze these changes and group the hunks into logical commits.
|
|
109
48
|
|
|
110
|
-
|
|
111
|
-
1. **MAXIMIZE GROUPING**: Put ALL related files together in the same commit
|
|
112
|
-
2. **Identify relationships**: Look for imports, shared functionality, feature boundaries
|
|
113
|
-
3. **Group by feature first**: If files are part of the same feature, they MUST be in one commit
|
|
114
|
-
4. **Minimize commit count**: Only create separate commits when files are truly unrelated
|
|
115
|
-
5. **Order by dependencies**: Commit base/utility files before files that use them
|
|
49
|
+
${stats}
|
|
116
50
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
- Do files implement the same feature? → Same commit
|
|
120
|
-
- Are there test files? → Same commit as the code they test
|
|
121
|
-
- Are there type definitions? → Same commit as the code that uses them
|
|
122
|
-
|
|
123
|
-
\`\`\`
|
|
124
|
-
${diff}
|
|
125
|
-
\`\`\`
|
|
126
|
-
|
|
127
|
-
Create the MINIMUM number of well-grouped commits. Group related files together aggressively.
|
|
128
|
-
|
|
129
|
-
Please respond in JSON format.`;
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Get system prompt for single commit message generation
|
|
133
|
-
*/
|
|
134
|
-
function getSingleCommitSystemPrompt() {
|
|
135
|
-
return `You are a git commit expert. You analyze git diffs and create Conventional Commits standard commit messages.
|
|
51
|
+
CHANGES:
|
|
52
|
+
${formattedDiff}
|
|
136
53
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
<body>
|
|
141
|
-
|
|
142
|
-
<footer>
|
|
143
|
-
|
|
144
|
-
Types:
|
|
145
|
-
- feat: New feature
|
|
146
|
-
- fix: Bug fix
|
|
147
|
-
- refactor: Code refactoring
|
|
148
|
-
- style: Formatting, styling changes
|
|
149
|
-
- docs: Documentation
|
|
150
|
-
- test: Tests
|
|
151
|
-
- chore: Maintenance tasks
|
|
152
|
-
|
|
153
|
-
Commit message should be short and descriptive. Body should contain details of the changes.`;
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Get user prompt for single commit message
|
|
157
|
-
*/
|
|
158
|
-
function getSingleCommitUserPrompt(diff) {
|
|
159
|
-
return `Analyze the following git diff and create a commit message in Conventional Commits format.
|
|
160
|
-
|
|
161
|
-
\`\`\`
|
|
162
|
-
${diff}
|
|
163
|
-
\`\`\`
|
|
164
|
-
|
|
165
|
-
Respond in JSON format:
|
|
166
|
-
{
|
|
167
|
-
"commitMessage": "feat(auth): add OAuth2 authentication support",
|
|
168
|
-
"commitBody": "Detailed description here..."
|
|
169
|
-
}`;
|
|
54
|
+
Group related hunks together. If a file has multiple unrelated changes, put them in separate commits.
|
|
55
|
+
Each hunk must be in exactly one group. Respond in JSON format.`;
|
|
170
56
|
}
|
|
171
57
|
//# sourceMappingURL=prompts.js.map
|
package/dist/prompts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":";;AAAA,0CAwCC;AAED,sCAUC;AApDD,SAAgB,eAAe;IAC7B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsCP,CAAC;AACH,CAAC;AAED,SAAgB,aAAa,CAAC,aAAqB,EAAE,KAAa;IAChE,OAAO;;EAEP,KAAK;;;EAGL,aAAa;;;gEAGiD,CAAC;AACjE,CAAC"}
|
package/dist/reset.d.ts
CHANGED
package/dist/reset.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reset.d.ts","sourceRoot":"","sources":["../src/reset.ts"],"names":[],"mappings":"AAIA
|
|
1
|
+
{"version":3,"file":"reset.d.ts","sourceRoot":"","sources":["../src/reset.ts"],"names":[],"mappings":"AAIA,wBAAsB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAyBjD"}
|
package/dist/reset.js
CHANGED
|
@@ -40,38 +40,28 @@ exports.resetConfig = resetConfig;
|
|
|
40
40
|
const chalk_1 = __importDefault(require("chalk"));
|
|
41
41
|
const inquirer_1 = __importDefault(require("inquirer"));
|
|
42
42
|
const config = __importStar(require("./config"));
|
|
43
|
-
/**
|
|
44
|
-
* Reset configuration
|
|
45
|
-
*/
|
|
46
43
|
async function resetConfig() {
|
|
47
44
|
if (!config.configExists()) {
|
|
48
|
-
console.log(chalk_1.default.yellow(
|
|
45
|
+
console.log(chalk_1.default.yellow("⚠ No configuration found.\n"));
|
|
49
46
|
return;
|
|
50
47
|
}
|
|
51
|
-
console.log(chalk_1.default.red.bold('\n⚠️ Reset Configuration\n'));
|
|
52
|
-
console.log(chalk_1.default.yellow('This will delete all configuration including:'));
|
|
53
|
-
console.log(chalk_1.default.yellow(' - OpenAI API key'));
|
|
54
|
-
console.log(chalk_1.default.yellow(' - All git user profiles'));
|
|
55
|
-
console.log(chalk_1.default.yellow(' - Default user settings\n'));
|
|
56
48
|
const { confirm } = await inquirer_1.default.prompt([
|
|
57
49
|
{
|
|
58
|
-
type:
|
|
59
|
-
name:
|
|
60
|
-
message:
|
|
61
|
-
default: false
|
|
62
|
-
}
|
|
50
|
+
type: "confirm",
|
|
51
|
+
name: "confirm",
|
|
52
|
+
message: "Delete all configuration (API key)?",
|
|
53
|
+
default: false,
|
|
54
|
+
},
|
|
63
55
|
]);
|
|
64
56
|
if (!confirm) {
|
|
65
|
-
console.log(chalk_1.default.yellow(
|
|
57
|
+
console.log(chalk_1.default.yellow("Cancelled.\n"));
|
|
66
58
|
return;
|
|
67
59
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
console.log(chalk_1.default.green('✓ Configuration reset successfully.\n'));
|
|
71
|
-
console.log(chalk_1.default.blue('Run "git-ai setup" to configure again.\n'));
|
|
60
|
+
if (config.resetConfig()) {
|
|
61
|
+
console.log(chalk_1.default.green("✓ Configuration reset.\n"));
|
|
72
62
|
}
|
|
73
63
|
else {
|
|
74
|
-
console.log(chalk_1.default.red(
|
|
64
|
+
console.log(chalk_1.default.red("❌ Failed to reset.\n"));
|
|
75
65
|
}
|
|
76
66
|
}
|
|
77
67
|
//# sourceMappingURL=reset.js.map
|