git-mood 2.0.7 → 2.0.9
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 +1 -1
- package/index.js +29 -17
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
</p>
|
|
11
11
|
|
|
12
12
|
<p align="center">
|
|
13
|
-
<img src="https://img.shields.io/badge/version-2.0.
|
|
13
|
+
<img src="https://img.shields.io/badge/version-2.0.9-blue?style=for-the-badge" alt="Version">
|
|
14
14
|
<img src="https://img.shields.io/badge/Node.js-18%2B-green?style=for-the-badge" alt="Node Version">
|
|
15
15
|
<img src="https://img.shields.io/badge/License-ISC-orange?style=for-the-badge" alt="License">
|
|
16
16
|
</p>
|
package/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { program } from 'commander';
|
|
|
3
3
|
import simpleGit from 'simple-git';
|
|
4
4
|
import { GoogleGenerativeAI } from '@google/generative-ai';
|
|
5
5
|
import chalk from 'chalk';
|
|
6
|
-
import
|
|
6
|
+
import inquirerPkg from 'inquirer';
|
|
7
7
|
import Conf from 'conf';
|
|
8
8
|
import fs from 'node:fs/promises';
|
|
9
9
|
import path from 'node:path';
|
|
@@ -11,6 +11,18 @@ import path from 'node:path';
|
|
|
11
11
|
const config = new Conf({ projectName: 'git-mood' });
|
|
12
12
|
const git = simpleGit();
|
|
13
13
|
|
|
14
|
+
// Inquirer has changed module shapes across versions (ESM/CJS interop).
|
|
15
|
+
// Normalize to a single `prompt()` function to avoid runtime "prompt is not a function".
|
|
16
|
+
const inquirer = (inquirerPkg && typeof inquirerPkg === 'object' && 'default' in inquirerPkg)
|
|
17
|
+
? inquirerPkg.default
|
|
18
|
+
: inquirerPkg;
|
|
19
|
+
const inqPrompt = (inquirer && typeof inquirer === 'object' && typeof inquirer.prompt === 'function')
|
|
20
|
+
? inquirer.prompt.bind(inquirer)
|
|
21
|
+
: (typeof inquirer === 'function' ? inquirer : undefined);
|
|
22
|
+
if (typeof inqPrompt !== 'function') {
|
|
23
|
+
throw new Error("Inquirer failed to load: expected a 'prompt' function.");
|
|
24
|
+
}
|
|
25
|
+
|
|
14
26
|
const MODELS = [
|
|
15
27
|
{ id: 'gemini-2.5-flash-lite', name: 'Flash-Lite 2.5 (New & Lightest)' },
|
|
16
28
|
{ id: 'gemini-2.5-flash', name: 'Flash 2.5 (Fast & Balanced)' },
|
|
@@ -148,7 +160,7 @@ async function generateReadme() {
|
|
|
148
160
|
const readmePath = path.join(rootDir, 'README.md');
|
|
149
161
|
const hasReadme = await fileExists(readmePath);
|
|
150
162
|
|
|
151
|
-
const scopeAnswer = await
|
|
163
|
+
const scopeAnswer = await inqPrompt([
|
|
152
164
|
{
|
|
153
165
|
type: 'select',
|
|
154
166
|
name: 'scope',
|
|
@@ -163,7 +175,7 @@ async function generateReadme() {
|
|
|
163
175
|
]);
|
|
164
176
|
|
|
165
177
|
if (hasReadme) {
|
|
166
|
-
const overwriteAnswer = await
|
|
178
|
+
const overwriteAnswer = await inqPrompt([
|
|
167
179
|
{
|
|
168
180
|
type: 'confirm',
|
|
169
181
|
name: 'overwrite',
|
|
@@ -226,7 +238,7 @@ async function generateReadme() {
|
|
|
226
238
|
}
|
|
227
239
|
|
|
228
240
|
if (isRepo) {
|
|
229
|
-
const stageAnswer = await
|
|
241
|
+
const stageAnswer = await inqPrompt([
|
|
230
242
|
{
|
|
231
243
|
type: 'confirm',
|
|
232
244
|
name: 'stage',
|
|
@@ -239,7 +251,7 @@ async function generateReadme() {
|
|
|
239
251
|
await git.add(['README.md']);
|
|
240
252
|
console.log(chalk.green('✅ Staged README.md'));
|
|
241
253
|
|
|
242
|
-
const commitNowAnswer = await
|
|
254
|
+
const commitNowAnswer = await inqPrompt([
|
|
243
255
|
{
|
|
244
256
|
type: 'confirm',
|
|
245
257
|
name: 'commitNow',
|
|
@@ -289,7 +301,7 @@ async function generateCommit(options = {}) {
|
|
|
289
301
|
|
|
290
302
|
const model = getAI();
|
|
291
303
|
// Prompt asking for a conventional commit message
|
|
292
|
-
const
|
|
304
|
+
const aiPrompt = `
|
|
293
305
|
You are an expert developer. Generate a git commit subject and an extended description for these changes.
|
|
294
306
|
The subject MUST follow "Conventional Commits" format (e.g., 'feat: add login', 'fix: resolve crash').
|
|
295
307
|
Keep the subject <= 72 characters and do not wrap it in quotes.
|
|
@@ -301,7 +313,7 @@ async function generateCommit(options = {}) {
|
|
|
301
313
|
${diff.substring(0, 5000)}
|
|
302
314
|
`;
|
|
303
315
|
|
|
304
|
-
const result = await model.generateContent(
|
|
316
|
+
const result = await model.generateContent(aiPrompt);
|
|
305
317
|
const suggestion = parseCommitSuggestion(result.response.text());
|
|
306
318
|
const subject = suggestion.subject;
|
|
307
319
|
const body = suggestion.body;
|
|
@@ -318,7 +330,7 @@ async function generateCommit(options = {}) {
|
|
|
318
330
|
let finalBody = body;
|
|
319
331
|
|
|
320
332
|
if (options.interactive) {
|
|
321
|
-
const edited = await
|
|
333
|
+
const edited = await inqPrompt([
|
|
322
334
|
{
|
|
323
335
|
type: 'input',
|
|
324
336
|
name: 'subject',
|
|
@@ -335,7 +347,7 @@ async function generateCommit(options = {}) {
|
|
|
335
347
|
finalSubject = String(edited.subject ?? '').trim();
|
|
336
348
|
finalBody = String(edited.body ?? '').trim();
|
|
337
349
|
} else {
|
|
338
|
-
const nextAction = await
|
|
350
|
+
const nextAction = await inqPrompt([
|
|
339
351
|
{
|
|
340
352
|
type: 'select',
|
|
341
353
|
name: 'action',
|
|
@@ -355,7 +367,7 @@ async function generateCommit(options = {}) {
|
|
|
355
367
|
}
|
|
356
368
|
|
|
357
369
|
if (nextAction.action === 'edit_commit') {
|
|
358
|
-
const edited = await
|
|
370
|
+
const edited = await inqPrompt([
|
|
359
371
|
{
|
|
360
372
|
type: 'input',
|
|
361
373
|
name: 'subject',
|
|
@@ -384,7 +396,7 @@ async function generateCommit(options = {}) {
|
|
|
384
396
|
console.log(chalk.green("✅ Committed locally!"));
|
|
385
397
|
|
|
386
398
|
// 3. NEW STEP: Ask user to PUSH
|
|
387
|
-
const pushAnswer = await
|
|
399
|
+
const pushAnswer = await inqPrompt([
|
|
388
400
|
{
|
|
389
401
|
type: 'confirm',
|
|
390
402
|
name: 'shouldPush',
|
|
@@ -404,7 +416,7 @@ async function generateCommit(options = {}) {
|
|
|
404
416
|
if (pushError.message.includes('fetch first') || pushError.message.includes('rejected')) {
|
|
405
417
|
console.log(chalk.yellow("\n⚠️ GitHub is ahead of your computer."));
|
|
406
418
|
|
|
407
|
-
const pullAnswer = await
|
|
419
|
+
const pullAnswer = await inqPrompt([
|
|
408
420
|
{
|
|
409
421
|
type: 'confirm',
|
|
410
422
|
name: 'shouldPull',
|
|
@@ -449,7 +461,7 @@ async function codeReview() {
|
|
|
449
461
|
process.stdout.write(chalk.magenta("🕵️ Scanning code for bugs and smell..."));
|
|
450
462
|
|
|
451
463
|
const model = getAI();
|
|
452
|
-
const
|
|
464
|
+
const aiPrompt = `
|
|
453
465
|
Review this code diff like a Senior Engineer.
|
|
454
466
|
1. Identify potential bugs (logic errors, memory leaks).
|
|
455
467
|
2. Point out security risks (exposed keys, unsafe inputs).
|
|
@@ -461,7 +473,7 @@ async function codeReview() {
|
|
|
461
473
|
${diff.substring(0, 8000)}
|
|
462
474
|
`;
|
|
463
475
|
|
|
464
|
-
const result = await model.generateContent(
|
|
476
|
+
const result = await model.generateContent(aiPrompt);
|
|
465
477
|
console.log("\r" + " ".repeat(50) + "\r");
|
|
466
478
|
|
|
467
479
|
console.log(chalk.bold.magenta("\n🛡️ AI CODE REVIEW REPORT 🛡️"));
|
|
@@ -474,7 +486,7 @@ async function codeReview() {
|
|
|
474
486
|
|
|
475
487
|
// --- COMMAND 3: SETUP ---
|
|
476
488
|
async function setupCLI() {
|
|
477
|
-
const answers = await
|
|
489
|
+
const answers = await inqPrompt([
|
|
478
490
|
{
|
|
479
491
|
type: 'input',
|
|
480
492
|
name: 'apiKey',
|
|
@@ -495,7 +507,7 @@ async function setupCLI() {
|
|
|
495
507
|
|
|
496
508
|
// --- COMMAND 4: MODEL (change model) ---
|
|
497
509
|
async function modelCLI() {
|
|
498
|
-
const answer = await
|
|
510
|
+
const answer = await inqPrompt([
|
|
499
511
|
{
|
|
500
512
|
type: 'select',
|
|
501
513
|
name: 'modelId',
|
|
@@ -513,7 +525,7 @@ async function modelCLI() {
|
|
|
513
525
|
program
|
|
514
526
|
.name('git-mood')
|
|
515
527
|
.description('AI-Powered Git Assistant — conventional commits & code review')
|
|
516
|
-
.version('2.0.
|
|
528
|
+
.version('2.0.9');
|
|
517
529
|
|
|
518
530
|
program.command('setup').description('Set Gemini API key and model').action(setupCLI);
|
|
519
531
|
program.command('model').description('Change Gemini model').action(modelCLI);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "git-mood",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.9",
|
|
4
4
|
"description": "AI-powered Git assistant — conventional commits & code review with Gemini",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"chalk": "^5.3.0",
|
|
41
41
|
"commander": "^12.0.0",
|
|
42
42
|
"conf": "^12.0.0",
|
|
43
|
-
"inquirer": "^13.
|
|
43
|
+
"inquirer": "^13.2.2",
|
|
44
44
|
"simple-git": "^3.22.0"
|
|
45
45
|
}
|
|
46
46
|
}
|