@mehmetsagir/git-ai 0.0.4 → 0.0.6
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/dist/commit-processor.d.ts +1 -1
- package/dist/commit-processor.d.ts.map +1 -1
- package/dist/commit-processor.js +36 -19
- package/dist/commit-processor.js.map +1 -1
- package/dist/commit.d.ts.map +1 -1
- package/dist/commit.js +72 -60
- package/dist/commit.js.map +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +8 -9
- package/dist/config.js.map +1 -1
- package/dist/git.d.ts +2 -2
- package/dist/git.d.ts.map +1 -1
- package/dist/git.js +48 -41
- package/dist/git.js.map +1 -1
- package/dist/index.js +87 -85
- package/dist/index.js.map +1 -1
- package/dist/openai.d.ts.map +1 -1
- package/dist/openai.js +7 -6
- package/dist/openai.js.map +1 -1
- package/dist/setup.d.ts.map +1 -1
- package/dist/setup.js +8 -34
- package/dist/setup.js.map +1 -1
- package/dist/update.d.ts.map +1 -1
- package/dist/update.js +4 -49
- package/dist/update.js.map +1 -1
- package/dist/user-management.d.ts.map +1 -1
- package/dist/user-management.js +8 -58
- package/dist/user-management.js.map +1 -1
- package/dist/utils/errors.d.ts +12 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +26 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/validation.d.ts +24 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +81 -0
- package/dist/utils/validation.js.map +1 -0
- package/package.json +1 -1
package/dist/git.js
CHANGED
|
@@ -17,6 +17,7 @@ exports.getStagedFiles = getStagedFiles;
|
|
|
17
17
|
exports.getAllChangedFiles = getAllChangedFiles;
|
|
18
18
|
exports.isGitRepository = isGitRepository;
|
|
19
19
|
const simple_git_1 = __importDefault(require("simple-git"));
|
|
20
|
+
const errors_1 = require("./utils/errors");
|
|
20
21
|
/**
|
|
21
22
|
* Create git repository instance
|
|
22
23
|
*/
|
|
@@ -29,12 +30,11 @@ function getGitInstance(repoPath = process.cwd()) {
|
|
|
29
30
|
async function getStagedDiff() {
|
|
30
31
|
try {
|
|
31
32
|
const git = getGitInstance();
|
|
32
|
-
const diff = await git.diff([
|
|
33
|
+
const diff = await git.diff(["--cached"]);
|
|
33
34
|
return diff;
|
|
34
35
|
}
|
|
35
36
|
catch (error) {
|
|
36
|
-
|
|
37
|
-
throw new Error(`Error getting staged diff: ${err.message}`);
|
|
37
|
+
throw new Error(`Error getting staged diff: ${(0, errors_1.getErrorMessage)(error)}`);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
@@ -47,8 +47,7 @@ async function getUnstagedDiff() {
|
|
|
47
47
|
return diff;
|
|
48
48
|
}
|
|
49
49
|
catch (error) {
|
|
50
|
-
|
|
51
|
-
throw new Error(`Error getting unstaged diff: ${err.message}`);
|
|
50
|
+
throw new Error(`Error getting unstaged diff: ${(0, errors_1.getErrorMessage)(error)}`);
|
|
52
51
|
}
|
|
53
52
|
}
|
|
54
53
|
/**
|
|
@@ -61,12 +60,11 @@ async function getAllDiff() {
|
|
|
61
60
|
return {
|
|
62
61
|
staged,
|
|
63
62
|
unstaged,
|
|
64
|
-
all: `${staged}\n${unstaged}`.trim()
|
|
63
|
+
all: `${staged}\n${unstaged}`.trim(),
|
|
65
64
|
};
|
|
66
65
|
}
|
|
67
66
|
catch (error) {
|
|
68
|
-
|
|
69
|
-
throw new Error(`Error getting diff: ${err.message}`);
|
|
67
|
+
throw new Error(`Error getting diff: ${(0, errors_1.getErrorMessage)(error)}`);
|
|
70
68
|
}
|
|
71
69
|
}
|
|
72
70
|
/**
|
|
@@ -79,8 +77,7 @@ async function hasChanges() {
|
|
|
79
77
|
return status.files.length > 0;
|
|
80
78
|
}
|
|
81
79
|
catch (error) {
|
|
82
|
-
|
|
83
|
-
throw new Error(`Error checking for changes: ${err.message}`);
|
|
80
|
+
throw new Error(`Error checking for changes: ${(0, errors_1.getErrorMessage)(error)}`);
|
|
84
81
|
}
|
|
85
82
|
}
|
|
86
83
|
/**
|
|
@@ -90,14 +87,19 @@ async function getGitUserInfo() {
|
|
|
90
87
|
try {
|
|
91
88
|
const git = getGitInstance();
|
|
92
89
|
const [name, email] = await Promise.all([
|
|
93
|
-
git
|
|
94
|
-
|
|
90
|
+
git
|
|
91
|
+
.getConfig("user.name")
|
|
92
|
+
.then((config) => config.value || null)
|
|
93
|
+
.catch(() => null),
|
|
94
|
+
git
|
|
95
|
+
.getConfig("user.email")
|
|
96
|
+
.then((config) => config.value || null)
|
|
97
|
+
.catch(() => null),
|
|
95
98
|
]);
|
|
96
99
|
return { name, email };
|
|
97
100
|
}
|
|
98
101
|
catch (error) {
|
|
99
|
-
|
|
100
|
-
throw new Error(`Error getting git user info: ${err.message}`);
|
|
102
|
+
throw new Error(`Error getting git user info: ${(0, errors_1.getErrorMessage)(error)}`);
|
|
101
103
|
}
|
|
102
104
|
}
|
|
103
105
|
/**
|
|
@@ -109,15 +111,21 @@ async function getAllGitUserProfiles() {
|
|
|
109
111
|
const profiles = [];
|
|
110
112
|
// Global config
|
|
111
113
|
try {
|
|
112
|
-
const globalName = await git
|
|
113
|
-
|
|
114
|
+
const globalName = await git
|
|
115
|
+
.getConfig("user.name", "global")
|
|
116
|
+
.then((c) => c.value)
|
|
117
|
+
.catch(() => null);
|
|
118
|
+
const globalEmail = await git
|
|
119
|
+
.getConfig("user.email", "global")
|
|
120
|
+
.then((c) => c.value)
|
|
121
|
+
.catch(() => null);
|
|
114
122
|
if (globalName && globalEmail) {
|
|
115
123
|
profiles.push({
|
|
116
124
|
id: `global-${globalEmail}`,
|
|
117
125
|
name: globalName,
|
|
118
126
|
email: globalEmail,
|
|
119
|
-
scope:
|
|
120
|
-
label: `${globalName} <${globalEmail}> (Global)
|
|
127
|
+
scope: "global",
|
|
128
|
+
label: `${globalName} <${globalEmail}> (Global)`,
|
|
121
129
|
});
|
|
122
130
|
}
|
|
123
131
|
}
|
|
@@ -126,17 +134,23 @@ async function getAllGitUserProfiles() {
|
|
|
126
134
|
}
|
|
127
135
|
// Local config
|
|
128
136
|
try {
|
|
129
|
-
const localName = await git
|
|
130
|
-
|
|
137
|
+
const localName = await git
|
|
138
|
+
.getConfig("user.name", "local")
|
|
139
|
+
.then((c) => c.value)
|
|
140
|
+
.catch(() => null);
|
|
141
|
+
const localEmail = await git
|
|
142
|
+
.getConfig("user.email", "local")
|
|
143
|
+
.then((c) => c.value)
|
|
144
|
+
.catch(() => null);
|
|
131
145
|
if (localName && localEmail) {
|
|
132
|
-
const isDuplicate = profiles.some(p => p.email === localEmail && p.name === localName);
|
|
146
|
+
const isDuplicate = profiles.some((p) => p.email === localEmail && p.name === localName);
|
|
133
147
|
if (!isDuplicate) {
|
|
134
148
|
profiles.push({
|
|
135
149
|
id: `local-${localEmail}`,
|
|
136
150
|
name: localName,
|
|
137
151
|
email: localEmail,
|
|
138
|
-
scope:
|
|
139
|
-
label: `${localName} <${localEmail}> (Local)
|
|
152
|
+
scope: "local",
|
|
153
|
+
label: `${localName} <${localEmail}> (Local)`,
|
|
140
154
|
});
|
|
141
155
|
}
|
|
142
156
|
}
|
|
@@ -147,23 +161,21 @@ async function getAllGitUserProfiles() {
|
|
|
147
161
|
return profiles;
|
|
148
162
|
}
|
|
149
163
|
catch (error) {
|
|
150
|
-
|
|
151
|
-
throw new Error(`Error getting git user profiles: ${err.message}`);
|
|
164
|
+
throw new Error(`Error getting git user profiles: ${(0, errors_1.getErrorMessage)(error)}`);
|
|
152
165
|
}
|
|
153
166
|
}
|
|
154
167
|
/**
|
|
155
168
|
* Set git user
|
|
156
169
|
*/
|
|
157
|
-
async function setGitUser(name, email, scope =
|
|
170
|
+
async function setGitUser(name, email, scope = "local") {
|
|
158
171
|
try {
|
|
159
172
|
const git = getGitInstance();
|
|
160
|
-
await git.addConfig(
|
|
161
|
-
await git.addConfig(
|
|
173
|
+
await git.addConfig("user.name", name, scope === "global");
|
|
174
|
+
await git.addConfig("user.email", email, scope === "global");
|
|
162
175
|
return true;
|
|
163
176
|
}
|
|
164
177
|
catch (error) {
|
|
165
|
-
|
|
166
|
-
throw new Error(`Error setting git user: ${err.message}`);
|
|
178
|
+
throw new Error(`Error setting git user: ${(0, errors_1.getErrorMessage)(error)}`);
|
|
167
179
|
}
|
|
168
180
|
}
|
|
169
181
|
/**
|
|
@@ -176,8 +188,7 @@ async function stageFiles(files) {
|
|
|
176
188
|
return true;
|
|
177
189
|
}
|
|
178
190
|
catch (error) {
|
|
179
|
-
|
|
180
|
-
throw new Error(`Error staging files: ${err.message}`);
|
|
191
|
+
throw new Error(`Error staging files: ${(0, errors_1.getErrorMessage)(error)}`);
|
|
181
192
|
}
|
|
182
193
|
}
|
|
183
194
|
/**
|
|
@@ -190,8 +201,7 @@ async function unstageAll() {
|
|
|
190
201
|
return true;
|
|
191
202
|
}
|
|
192
203
|
catch (error) {
|
|
193
|
-
|
|
194
|
-
throw new Error(`Error unstaging: ${err.message}`);
|
|
204
|
+
throw new Error(`Error unstaging: ${(0, errors_1.getErrorMessage)(error)}`);
|
|
195
205
|
}
|
|
196
206
|
}
|
|
197
207
|
/**
|
|
@@ -202,14 +212,13 @@ async function createCommit(message, authorName = null, authorEmail = null) {
|
|
|
202
212
|
const git = getGitInstance();
|
|
203
213
|
const options = {};
|
|
204
214
|
if (authorName && authorEmail) {
|
|
205
|
-
options[
|
|
215
|
+
options["--author"] = `${authorName} <${authorEmail}>`;
|
|
206
216
|
}
|
|
207
217
|
await git.commit(message, options);
|
|
208
218
|
return true;
|
|
209
219
|
}
|
|
210
220
|
catch (error) {
|
|
211
|
-
|
|
212
|
-
throw new Error(`Error creating commit: ${err.message}`);
|
|
221
|
+
throw new Error(`Error creating commit: ${(0, errors_1.getErrorMessage)(error)}`);
|
|
213
222
|
}
|
|
214
223
|
}
|
|
215
224
|
/**
|
|
@@ -222,8 +231,7 @@ async function getStagedFiles() {
|
|
|
222
231
|
return status.staged;
|
|
223
232
|
}
|
|
224
233
|
catch (error) {
|
|
225
|
-
|
|
226
|
-
throw new Error(`Error getting staged files: ${err.message}`);
|
|
234
|
+
throw new Error(`Error getting staged files: ${(0, errors_1.getErrorMessage)(error)}`);
|
|
227
235
|
}
|
|
228
236
|
}
|
|
229
237
|
/**
|
|
@@ -236,8 +244,7 @@ async function getAllChangedFiles() {
|
|
|
236
244
|
return [...status.staged, ...status.not_added, ...status.modified];
|
|
237
245
|
}
|
|
238
246
|
catch (error) {
|
|
239
|
-
|
|
240
|
-
throw new Error(`Error getting changed files: ${err.message}`);
|
|
247
|
+
throw new Error(`Error getting changed files: ${(0, errors_1.getErrorMessage)(error)}`);
|
|
241
248
|
}
|
|
242
249
|
}
|
|
243
250
|
/**
|
package/dist/git.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git.js","sourceRoot":"","sources":["../src/git.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"git.js","sourceRoot":"","sources":["../src/git.ts"],"names":[],"mappings":";;;;;AAcA,sCAQC;AAKD,0CAQC;AAKD,gCAYC;AAKD,gCAQC;AAKD,wCAkBC;AAKD,sDA8DC;AAKD,gCAaC;AAKD,gCAQC;AAKD,gCAQC;AAKD,oCAgBC;AAKD,wCAQC;AAKD,gDAQC;AAKD,0CAQC;AAnQD,4DAAkD;AAElD,2CAAiD;AAEjD;;GAEG;AACH,SAAS,cAAc,CAAC,WAAmB,OAAO,CAAC,GAAG,EAAE;IACtD,OAAO,IAAA,oBAAS,EAAC,QAAQ,CAAC,CAAC;AAC7B,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,aAAa;IACjC,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,cAAc,EAAE,CAAC;QAC7B,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;QAC1C,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAA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M,GAAG,GAAG,cAAc,EAAE,CAAC;QAC7B,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,MAAM,EAAE,CAAC;QAClC,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,MAAM,CAAC,SAAS,EAAE,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IACrE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,gCAAgC,IAAA,wBAAe,EAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAC5E,CAAC;AACH,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,eAAe;IACnC,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,cAAc,EAAE,CAAC;QAC7B,MAAM,GAAG,CAAC,MAAM,EAAE,CAAC;QACnB,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -46,12 +46,13 @@ const reset = __importStar(require("./reset"));
|
|
|
46
46
|
const add = __importStar(require("./add"));
|
|
47
47
|
const update = __importStar(require("./update"));
|
|
48
48
|
const package_json_1 = __importDefault(require("../package.json"));
|
|
49
|
+
const errors_1 = require("./utils/errors");
|
|
49
50
|
const program = new commander_1.Command();
|
|
50
51
|
/**
|
|
51
52
|
* Handle command errors consistently
|
|
52
53
|
*/
|
|
53
54
|
function handleError(error, showStack = false) {
|
|
54
|
-
const err = error;
|
|
55
|
+
const err = error instanceof Error ? error : new Error((0, errors_1.getErrorMessage)(error));
|
|
55
56
|
console.error(chalk_1.default.red(`\n❌ Error: ${err.message}\n`));
|
|
56
57
|
if (showStack && err.stack) {
|
|
57
58
|
console.error(chalk_1.default.gray(err.stack));
|
|
@@ -59,7 +60,7 @@ function handleError(error, showStack = false) {
|
|
|
59
60
|
process.exit(1);
|
|
60
61
|
}
|
|
61
62
|
// Check for --update flag before parsing
|
|
62
|
-
if (process.argv.includes(
|
|
63
|
+
if (process.argv.includes("--update")) {
|
|
63
64
|
(async () => {
|
|
64
65
|
try {
|
|
65
66
|
await update.checkAndUpdate();
|
|
@@ -69,90 +70,91 @@ if (process.argv.includes('--update')) {
|
|
|
69
70
|
handleError(error);
|
|
70
71
|
}
|
|
71
72
|
})();
|
|
72
|
-
// Don't continue
|
|
73
|
-
process.exit(0);
|
|
73
|
+
// Don't continue - the async function will exit the process when done
|
|
74
74
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
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();
|
|
152
157
|
}
|
|
153
|
-
|
|
154
|
-
if (process.argv.length === 2) {
|
|
155
|
-
program.help();
|
|
158
|
+
program.parse(process.argv);
|
|
156
159
|
}
|
|
157
|
-
program.parse(process.argv);
|
|
158
160
|
//# 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,2CAA6B;AAC7B,iDAAmC;AACnC,mEAA0C;
|
|
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,2CAA6B;AAC7B,iDAAmC;AACnC,mEAA0C;AAC1C,2CAAiD;AAEjD,MAA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;QACrB,CAAC;IACH,CAAC,CAAC,CAAC;IAEL,OAAO;SACJ,OAAO,CAAC,QAAQ,CAAC;SACjB,KAAK,CAAC,QAAQ,CAAC;SACf,WAAW,CAAC,2BAA2B,CAAC;SACxC,MAAM,CAAC,KAAK,IAAI,EAAE;QACjB,IAAI,CAAC;YACH,MAAM,KAAK,CAAC,UAAU,EAAE,CAAC;QAC3B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,WAAW,CAAC,KAAK,CAAC,CAAC;QACrB,CAAC;IACH,CAAC,CAAC,CAAC;IAEL,OAAO;SACJ,OAAO,CAAC,OAAO,CAAC;SAChB,WAAW,CAAC,gEAAgE,CAAC;SAC7E,MAAM,CAAC,KAAK,IAAI,EAAE;QACjB,IAAI,CAAC;YACH,MAAM,KAAK,CAAC,WAAW,EAAE,CAAC;QAC5B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,WAAW,CAAC,KAAK,CAAC,CAAC;QACrB,CAAC;IACH,CAAC,CAAC,CAAC;IAEL,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9B,OAAO,CAAC,IAAI,EAAE,CAAC;IACjB,CAAC;IAED,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC"}
|
package/dist/openai.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../src/openai.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../src/openai.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAKzC;;GAEG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAMjD;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAKxC;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAmC/F;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;IAAE,aAAa,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,CAmChI"}
|
package/dist/openai.js
CHANGED
|
@@ -42,6 +42,7 @@ exports.analyzeDiffAndGroup = analyzeDiffAndGroup;
|
|
|
42
42
|
exports.generateCommitMessage = generateCommitMessage;
|
|
43
43
|
const openai_1 = __importDefault(require("openai"));
|
|
44
44
|
const prompts = __importStar(require("./prompts"));
|
|
45
|
+
const errors_1 = require("./utils/errors");
|
|
45
46
|
let openaiClient = null;
|
|
46
47
|
/**
|
|
47
48
|
* Initialize OpenAI client
|
|
@@ -91,11 +92,11 @@ async function analyzeDiffAndGroup(diff, apiKey) {
|
|
|
91
92
|
return result;
|
|
92
93
|
}
|
|
93
94
|
catch (error) {
|
|
94
|
-
const
|
|
95
|
-
if (
|
|
95
|
+
const message = (0, errors_1.getErrorMessage)(error);
|
|
96
|
+
if (message.includes('API key')) {
|
|
96
97
|
throw new Error('Invalid OpenAI API key');
|
|
97
98
|
}
|
|
98
|
-
throw new Error(`OpenAI API error: ${
|
|
99
|
+
throw new Error(`OpenAI API error: ${message}`);
|
|
99
100
|
}
|
|
100
101
|
}
|
|
101
102
|
/**
|
|
@@ -127,11 +128,11 @@ async function generateCommitMessage(diff, apiKey) {
|
|
|
127
128
|
return result;
|
|
128
129
|
}
|
|
129
130
|
catch (error) {
|
|
130
|
-
const
|
|
131
|
-
if (
|
|
131
|
+
const message = (0, errors_1.getErrorMessage)(error);
|
|
132
|
+
if (message.includes('API key')) {
|
|
132
133
|
throw new Error('Invalid OpenAI API key');
|
|
133
134
|
}
|
|
134
|
-
throw new Error(`OpenAI API error: ${
|
|
135
|
+
throw new Error(`OpenAI API error: ${message}`);
|
|
135
136
|
}
|
|
136
137
|
}
|
|
137
138
|
//# 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,gCAMC;AAKD,0CAKC;AAKD,kDAmCC;AAKD,sDAmCC;AA1GD,oDAA4B;AAC5B,mDAAqC;AAErC,2CAAiD;AAEjD,IAAI,YAAY,GAAkB,IAAI,CAAC;AAEvC;;GAEG;AACH,SAAgB,UAAU,CAAC,MAAc;IACvC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;IAChD,CAAC;IACD,YAAY,GAAG,IAAI,gBAAM,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IACtC,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;GAEG;AACH,SAAgB,eAAe;IAC7B,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC7E,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,mBAAmB,CAAC,IAAY,EAAE,MAAc;IACpE,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;IAChD,CAAC;IAED,UAAU,CAAC,MAAM,CAAC,CAAC;IACn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@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AASA;;GAEG;AACH,wBAAsB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CA2K9C"}
|
package/dist/setup.js
CHANGED
|
@@ -42,6 +42,8 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
42
42
|
const config = __importStar(require("./config"));
|
|
43
43
|
const git = __importStar(require("./git"));
|
|
44
44
|
const userManagement = __importStar(require("./user-management"));
|
|
45
|
+
const validation_1 = require("./utils/validation");
|
|
46
|
+
const errors_1 = require("./utils/errors");
|
|
45
47
|
/**
|
|
46
48
|
* Run setup command
|
|
47
49
|
*/
|
|
@@ -52,15 +54,7 @@ async function runSetup() {
|
|
|
52
54
|
type: 'password',
|
|
53
55
|
name: 'openaiKey',
|
|
54
56
|
message: 'Enter OpenAI API Key:',
|
|
55
|
-
validate:
|
|
56
|
-
if (!input || input.trim().length === 0) {
|
|
57
|
-
return 'OpenAI API Key is required!';
|
|
58
|
-
}
|
|
59
|
-
if (!input.startsWith('sk-')) {
|
|
60
|
-
return 'OpenAI API Key must start with "sk-"!';
|
|
61
|
-
}
|
|
62
|
-
return true;
|
|
63
|
-
}
|
|
57
|
+
validate: validation_1.validateOpenAIKey
|
|
64
58
|
}
|
|
65
59
|
]);
|
|
66
60
|
config.setOpenAIKey(openaiKey);
|
|
@@ -71,8 +65,7 @@ async function runSetup() {
|
|
|
71
65
|
gitProfiles = await git.getAllGitUserProfiles();
|
|
72
66
|
}
|
|
73
67
|
catch (error) {
|
|
74
|
-
|
|
75
|
-
console.log(chalk_1.default.yellow(`⚠ Could not get git user profiles: ${err.message}`));
|
|
68
|
+
console.log(chalk_1.default.yellow(`⚠ Could not get git user profiles: ${(0, errors_1.getErrorMessage)(error)}`));
|
|
76
69
|
}
|
|
77
70
|
if (gitProfiles.length === 0) {
|
|
78
71
|
try {
|
|
@@ -88,8 +81,7 @@ async function runSetup() {
|
|
|
88
81
|
}
|
|
89
82
|
}
|
|
90
83
|
catch (error) {
|
|
91
|
-
|
|
92
|
-
console.log(chalk_1.default.yellow(`⚠ Could not get current git user info: ${err.message}`));
|
|
84
|
+
console.log(chalk_1.default.yellow(`⚠ Could not get current git user info: ${(0, errors_1.getErrorMessage)(error)}`));
|
|
93
85
|
}
|
|
94
86
|
}
|
|
95
87
|
if (gitProfiles.length === 0) {
|
|
@@ -108,34 +100,16 @@ async function runSetup() {
|
|
|
108
100
|
type: 'input',
|
|
109
101
|
name: 'name',
|
|
110
102
|
message: 'Git user name (or "q" to cancel):',
|
|
111
|
-
validate:
|
|
112
|
-
const trimmed = input.trim();
|
|
113
|
-
if (trimmed.toLowerCase() === 'q') {
|
|
114
|
-
return true;
|
|
115
|
-
}
|
|
116
|
-
return trimmed.length > 0 || 'Name is required!';
|
|
117
|
-
}
|
|
103
|
+
validate: validation_1.validateUserName
|
|
118
104
|
},
|
|
119
105
|
{
|
|
120
106
|
type: 'input',
|
|
121
107
|
name: 'email',
|
|
122
108
|
message: 'Git user email (or "q" to cancel):',
|
|
123
|
-
validate: (input) =>
|
|
124
|
-
const trimmed = input.trim();
|
|
125
|
-
if (trimmed.toLowerCase() === 'q') {
|
|
126
|
-
return true;
|
|
127
|
-
}
|
|
128
|
-
if (!trimmed || trimmed.length === 0) {
|
|
129
|
-
return 'Email is required!';
|
|
130
|
-
}
|
|
131
|
-
if (!trimmed.includes('@')) {
|
|
132
|
-
return 'Please enter a valid email address!';
|
|
133
|
-
}
|
|
134
|
-
return true;
|
|
135
|
-
}
|
|
109
|
+
validate: (input) => (0, validation_1.validateUserEmail)(input, [])
|
|
136
110
|
}
|
|
137
111
|
]);
|
|
138
|
-
if (
|
|
112
|
+
if ((0, validation_1.isCancellation)(name) || (0, validation_1.isCancellation)(email)) {
|
|
139
113
|
console.log(chalk_1.default.yellow('⚠ Manual user addition cancelled.\n'));
|
|
140
114
|
}
|
|
141
115
|
else {
|