commit-agent-cli 0.1.1 → 0.1.3
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 -0
- package/dist/index.js +68 -4
- package/package.json +4 -2
package/README.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -386,9 +386,34 @@ ${diff}`)
|
|
|
386
386
|
|
|
387
387
|
// src/index.ts
|
|
388
388
|
var import_picocolors = __toESM(require_picocolors(), 1);
|
|
389
|
+
import updateNotifier from "update-notifier";
|
|
390
|
+
import { readFileSync } from "fs";
|
|
391
|
+
import { fileURLToPath } from "url";
|
|
392
|
+
import { dirname, join as joinPath } from "path";
|
|
389
393
|
import { homedir } from "os";
|
|
390
394
|
import { join as join2 } from "path";
|
|
391
395
|
import { readFile as readFile2, writeFile } from "fs/promises";
|
|
396
|
+
var __filename = fileURLToPath(import.meta.url);
|
|
397
|
+
var __dirname = dirname(__filename);
|
|
398
|
+
var packageJson = JSON.parse(
|
|
399
|
+
readFileSync(joinPath(__dirname, "../package.json"), "utf-8")
|
|
400
|
+
);
|
|
401
|
+
var notifier = updateNotifier({
|
|
402
|
+
pkg: packageJson,
|
|
403
|
+
updateCheckInterval: 1e3 * 60 * 60 * 24
|
|
404
|
+
// Check once per day
|
|
405
|
+
});
|
|
406
|
+
if (notifier.update) {
|
|
407
|
+
const currentVersion = import_picocolors.default.dim(notifier.update.current);
|
|
408
|
+
const latestVersion = import_picocolors.default.green(notifier.update.latest);
|
|
409
|
+
const command = import_picocolors.default.cyan(`npm install -g ${packageJson.name}`);
|
|
410
|
+
console.log("");
|
|
411
|
+
console.log(import_picocolors.default.yellow("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"));
|
|
412
|
+
console.log(import_picocolors.default.yellow("\u2502") + " Update available: " + currentVersion + " \u2192 " + latestVersion + " ".repeat(20) + import_picocolors.default.yellow("\u2502"));
|
|
413
|
+
console.log(import_picocolors.default.yellow("\u2502") + " Run " + command + " to update" + " ".repeat(10) + import_picocolors.default.yellow("\u2502"));
|
|
414
|
+
console.log(import_picocolors.default.yellow("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518"));
|
|
415
|
+
console.log("");
|
|
416
|
+
}
|
|
392
417
|
var CONFIG_PATH = join2(homedir(), ".commit-cli.json");
|
|
393
418
|
async function getStoredKey() {
|
|
394
419
|
try {
|
|
@@ -499,11 +524,40 @@ async function main() {
|
|
|
499
524
|
commitMessage = await generateCommitMessage(diff, preferences);
|
|
500
525
|
} catch (error) {
|
|
501
526
|
s.stop("Generation failed.");
|
|
527
|
+
if (error.message?.includes("401") || error.message?.includes("authentication_error") || error.message?.includes("invalid x-api-key") || error.message?.includes("invalid api key")) {
|
|
528
|
+
cancel("Invalid API Key detected.");
|
|
529
|
+
const retryWithNewKey = await confirm({
|
|
530
|
+
message: "Would you like to enter a new API key?",
|
|
531
|
+
initialValue: true
|
|
532
|
+
});
|
|
533
|
+
if (isCancel(retryWithNewKey) || !retryWithNewKey) {
|
|
534
|
+
cancel("Operation cancelled.");
|
|
535
|
+
process.exit(0);
|
|
536
|
+
}
|
|
537
|
+
const newKey = await text({
|
|
538
|
+
message: "Enter your Anthropic API Key (sk-...):",
|
|
539
|
+
placeholder: "sk-ant-api...",
|
|
540
|
+
validate: (value) => {
|
|
541
|
+
if (!value) return "API Key is required";
|
|
542
|
+
if (!value.startsWith("sk-")) return "Invalid API Key format (should start with sk-)";
|
|
543
|
+
}
|
|
544
|
+
});
|
|
545
|
+
if (isCancel(newKey)) {
|
|
546
|
+
cancel("Operation cancelled.");
|
|
547
|
+
process.exit(0);
|
|
548
|
+
}
|
|
549
|
+
apiKey = newKey;
|
|
550
|
+
process.env.ANTHROPIC_API_KEY = apiKey;
|
|
551
|
+
await storeKey(apiKey);
|
|
552
|
+
note("API Key updated. Retrying...", "Key Updated");
|
|
553
|
+
continue;
|
|
554
|
+
}
|
|
502
555
|
cancel(`Error: ${error.message}`);
|
|
503
556
|
return;
|
|
504
557
|
}
|
|
505
558
|
s.stop("Message generated.");
|
|
506
|
-
const
|
|
559
|
+
const terminalWidth = process.stdout.columns || 80;
|
|
560
|
+
const maxWidth = Math.max(40, terminalWidth - 12);
|
|
507
561
|
const lines = commitMessage.split("\n");
|
|
508
562
|
const wrappedLines = [];
|
|
509
563
|
for (const line of lines) {
|
|
@@ -513,11 +567,21 @@ async function main() {
|
|
|
513
567
|
const words = line.split(" ");
|
|
514
568
|
let currentLine = "";
|
|
515
569
|
for (const word of words) {
|
|
516
|
-
|
|
517
|
-
|
|
570
|
+
const testLine = currentLine ? currentLine + " " + word : word;
|
|
571
|
+
if (testLine.length <= maxWidth) {
|
|
572
|
+
currentLine = testLine;
|
|
518
573
|
} else {
|
|
519
574
|
if (currentLine) wrappedLines.push(currentLine);
|
|
520
|
-
|
|
575
|
+
if (word.length > maxWidth) {
|
|
576
|
+
let remaining = word;
|
|
577
|
+
while (remaining.length > maxWidth) {
|
|
578
|
+
wrappedLines.push(remaining.substring(0, maxWidth));
|
|
579
|
+
remaining = remaining.substring(maxWidth);
|
|
580
|
+
}
|
|
581
|
+
currentLine = remaining;
|
|
582
|
+
} else {
|
|
583
|
+
currentLine = word;
|
|
584
|
+
}
|
|
521
585
|
}
|
|
522
586
|
}
|
|
523
587
|
if (currentLine) wrappedLines.push(currentLine);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "commit-agent-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "AI-powered git commit CLI using LangGraph and Claude 4.5",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -43,14 +43,16 @@
|
|
|
43
43
|
"commit-agent-cli": "^0.1.0",
|
|
44
44
|
"dotenv": "^16.4.5",
|
|
45
45
|
"execa": "^9.3.1",
|
|
46
|
+
"update-notifier": "^7.3.1",
|
|
46
47
|
"zod": "^3.23.8"
|
|
47
48
|
},
|
|
48
49
|
"devDependencies": {
|
|
49
50
|
"@types/node": "^22.5.4",
|
|
51
|
+
"@types/update-notifier": "^6.0.8",
|
|
50
52
|
"tsup": "^8.2.4",
|
|
51
53
|
"typescript": "^5.5.4"
|
|
52
54
|
},
|
|
53
55
|
"engines": {
|
|
54
56
|
"node": ">=18"
|
|
55
57
|
}
|
|
56
|
-
}
|
|
58
|
+
}
|