ai-git-tool 1.1.0 → 1.3.0

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.
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.truncateByChars = truncateByChars;
4
+ exports.getOptionValue = getOptionValue;
5
+ /**
6
+ * テキストを指定文字数で切り詰める
7
+ */
8
+ function truncateByChars(input, maxChars) {
9
+ if (input.length <= maxChars) {
10
+ return input;
11
+ }
12
+ return `${input.slice(0, maxChars)}\n\n... (truncated)`;
13
+ }
14
+ /**
15
+ * オプション値を取得
16
+ */
17
+ function getOptionValue(argv, name) {
18
+ const idx = argv.indexOf(name);
19
+ if (idx === -1) {
20
+ return undefined;
21
+ }
22
+ return argv[idx + 1];
23
+ }
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.askUser = askUser;
37
+ exports.editInEditor = editInEditor;
38
+ const readline = __importStar(require("readline"));
39
+ const fs = __importStar(require("fs"));
40
+ const os = __importStar(require("os"));
41
+ const path = __importStar(require("path"));
42
+ const child_process_1 = require("child_process");
43
+ /**
44
+ * ユーザーに質問して回答を取得
45
+ */
46
+ function askUser(question) {
47
+ const rl = readline.createInterface({
48
+ input: process.stdin,
49
+ output: process.stdout,
50
+ });
51
+ return new Promise((resolve) => {
52
+ rl.question(question, (answer) => {
53
+ rl.close();
54
+ resolve(answer.trim().toLowerCase());
55
+ });
56
+ });
57
+ }
58
+ /**
59
+ * エディタでテキストを編集
60
+ */
61
+ function editInEditor(message) {
62
+ const tmpFile = path.join(os.tmpdir(), `commit-msg-${Date.now()}.txt`);
63
+ fs.writeFileSync(tmpFile, message, "utf-8");
64
+ const editor = process.env.EDITOR || "vi";
65
+ const result = (0, child_process_1.spawnSync)(editor, [tmpFile], { stdio: "inherit" });
66
+ if (result.error) {
67
+ console.error(`Error: Failed to open editor: ${result.error.message}`);
68
+ process.exit(1);
69
+ }
70
+ const edited = fs.readFileSync(tmpFile, "utf-8").trim();
71
+ fs.unlinkSync(tmpFile);
72
+ return edited;
73
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-git-tool",
3
- "version": "1.1.0",
3
+ "version": "1.3.0",
4
4
  "description": "AI-powered git commit and PR description generator using Groq API",
5
5
  "main": "dist/index.js",
6
6
  "bin": {