genai-commit 0.0.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,359 @@
1
+ import * as chalk from 'chalk';
2
+
3
+ /**
4
+ * Commit-related type definitions
5
+ */
6
+ interface Commit {
7
+ files: string[];
8
+ title: string;
9
+ message: string;
10
+ jiraKey?: string;
11
+ }
12
+ interface CommitResult {
13
+ commits: Commit[];
14
+ }
15
+ type Language = 'en' | 'ko';
16
+ interface CommitGenerationOptions {
17
+ titleLang: Language;
18
+ messageLang: Language;
19
+ }
20
+
21
+ /**
22
+ * Git-related type definitions
23
+ */
24
+ type ChangeStatus = 'A' | 'M' | 'D' | 'R' | '?';
25
+ interface GitChange {
26
+ file: string;
27
+ status: ChangeStatus;
28
+ }
29
+ interface GitStats {
30
+ added: number;
31
+ modified: number;
32
+ deleted: number;
33
+ renamed: number;
34
+ untracked: number;
35
+ total: number;
36
+ }
37
+ interface GitDiffResult {
38
+ branch: string;
39
+ changes: GitChange[];
40
+ stats: GitStats;
41
+ treeSummary: string;
42
+ diffContent: string;
43
+ validFiles: Set<string>;
44
+ }
45
+ interface DiffOptions {
46
+ maxInputSize: number;
47
+ maxDiffSize: number;
48
+ treeDepth: number;
49
+ }
50
+
51
+ /**
52
+ * Configuration type definitions
53
+ */
54
+
55
+ interface GencoConfig {
56
+ maxInputSize: number;
57
+ maxDiffSize: number;
58
+ timeout: number;
59
+ treeDepth: number;
60
+ maxRetries: number;
61
+ titleLang: Language;
62
+ messageLang: Language;
63
+ }
64
+
65
+ /**
66
+ * Default configuration values
67
+ */
68
+
69
+ declare const DEFAULT_CONFIG: GencoConfig;
70
+ declare const CURSOR_DEFAULT_MODEL = "gemini-3-flash";
71
+ declare const CLAUDE_DEFAULT_MODEL = "haiku";
72
+
73
+ /**
74
+ * Provider type definitions
75
+ */
76
+
77
+ type ProviderType = 'claude-code' | 'cursor-cli';
78
+ type PromptType = 'commit' | 'regroup';
79
+ interface ProviderResponse {
80
+ raw: string;
81
+ sessionId?: string;
82
+ }
83
+ interface ProviderStatus {
84
+ available: boolean;
85
+ version?: string;
86
+ details: string;
87
+ }
88
+ interface ProviderOptions {
89
+ model?: string;
90
+ timeout?: number;
91
+ }
92
+ /**
93
+ * AI Provider interface - implemented by claude and cursor providers
94
+ */
95
+ interface AIProvider {
96
+ readonly name: ProviderType;
97
+ /**
98
+ * Generate commit messages from input
99
+ */
100
+ generate(input: string, promptType: PromptType): Promise<ProviderResponse>;
101
+ /**
102
+ * Parse raw response into structured commits
103
+ */
104
+ parseResponse(response: ProviderResponse): CommitResult;
105
+ /**
106
+ * Authenticate with the provider
107
+ */
108
+ login(): Promise<void>;
109
+ /**
110
+ * Check provider status and authentication
111
+ */
112
+ status(): Promise<ProviderStatus>;
113
+ /**
114
+ * Get current session ID (for resume capability)
115
+ */
116
+ getSessionId(): string | undefined;
117
+ /**
118
+ * Clear session state
119
+ */
120
+ clearSession(): void;
121
+ }
122
+
123
+ /**
124
+ * Claude Code CLI provider implementation
125
+ */
126
+
127
+ declare class ClaudeCodeProvider implements AIProvider {
128
+ readonly name: "claude-code";
129
+ private sessionId?;
130
+ private timeout;
131
+ private model;
132
+ constructor(options?: ProviderOptions);
133
+ generate(input: string, promptType: PromptType): Promise<ProviderResponse>;
134
+ parseResponse(response: ProviderResponse): CommitResult;
135
+ login(): Promise<void>;
136
+ status(): Promise<ProviderStatus>;
137
+ getSessionId(): string | undefined;
138
+ clearSession(): void;
139
+ }
140
+
141
+ /**
142
+ * Cursor CLI provider implementation
143
+ */
144
+
145
+ declare class CursorCLIProvider implements AIProvider {
146
+ readonly name: "cursor-cli";
147
+ private timeout;
148
+ private model;
149
+ constructor(options?: ProviderOptions);
150
+ generate(input: string, promptType: PromptType): Promise<ProviderResponse>;
151
+ parseResponse(response: ProviderResponse): CommitResult;
152
+ login(): Promise<void>;
153
+ status(): Promise<ProviderStatus>;
154
+ getSessionId(): string | undefined;
155
+ clearSession(): void;
156
+ }
157
+
158
+ /**
159
+ * Provider module exports and factory
160
+ */
161
+
162
+ /**
163
+ * Create a provider instance by type
164
+ */
165
+ declare function createProvider(type: ProviderType, options?: ProviderOptions): AIProvider;
166
+ /**
167
+ * Validate provider type string
168
+ */
169
+ declare function isValidProviderType(type: string): type is ProviderType;
170
+
171
+ /**
172
+ * Git status collection
173
+ */
174
+
175
+ /**
176
+ * Check if current directory is a git repository
177
+ */
178
+ declare function isGitRepository(cwd?: string): Promise<boolean>;
179
+ /**
180
+ * Get current branch name
181
+ */
182
+ declare function getCurrentBranch(cwd?: string): Promise<string>;
183
+ /**
184
+ * Get git status and convert to our format
185
+ */
186
+ declare function getGitStatus(cwd?: string): Promise<{
187
+ changes: GitChange[];
188
+ stats: GitStats;
189
+ }>;
190
+ /**
191
+ * Get all valid changed files (for validation)
192
+ */
193
+ declare function getAllChangedFiles(cwd?: string): Promise<Set<string>>;
194
+ /**
195
+ * Check if there are any changes to commit
196
+ */
197
+ declare function hasChanges(cwd?: string): Promise<boolean>;
198
+
199
+ /**
200
+ * Tree summary compression (ported from bash awk logic)
201
+ */
202
+
203
+ interface TreeSummaryOptions {
204
+ treeDepth: number;
205
+ compressionThreshold: number;
206
+ }
207
+ /**
208
+ * Generate compressed tree summary for a list of files
209
+ * Ported from bash awk logic in generate-commit-msg-claude.sh
210
+ */
211
+ declare function generateTreeSummary(files: string[], changeType: ChangeStatus, options?: Partial<TreeSummaryOptions>): string;
212
+ /**
213
+ * Generate full tree summary from git changes
214
+ */
215
+ declare function generateFullTreeSummary(branch: string, changes: GitChange[], options?: Partial<TreeSummaryOptions>): string;
216
+
217
+ /**
218
+ * Git diff extraction with size limits
219
+ */
220
+
221
+ /**
222
+ * Get diff for modified files with size limit
223
+ */
224
+ declare function getModifiedDiffs(maxSize: number, cwd?: string): Promise<string>;
225
+ /**
226
+ * Get complete diff content with tree summary
227
+ */
228
+ declare function getDiffContent(treeSummary: string, options?: Partial<DiffOptions>, cwd?: string): Promise<string>;
229
+
230
+ /**
231
+ * Git commit execution
232
+ */
233
+
234
+ /**
235
+ * Stage files for commit
236
+ */
237
+ declare function stageFiles(files: string[], cwd?: string): Promise<void>;
238
+ /**
239
+ * Execute all commits in order
240
+ */
241
+ declare function executeCommits(commits: Commit[], cwd?: string): Promise<boolean>;
242
+
243
+ /**
244
+ * JSON response parser for Claude Code CLI
245
+ */
246
+
247
+ /**
248
+ * Parse JSON response from Claude CLI
249
+ */
250
+ declare function parseJsonResponse(raw: string): CommitResult;
251
+
252
+ /**
253
+ * Delimiter-based response parser for Cursor CLI
254
+ * Parses ===COMMIT=== delimited format
255
+ */
256
+
257
+ /**
258
+ * Parse delimiter-based response from Cursor CLI
259
+ */
260
+ declare function parseDelimiterResponse(raw: string): CommitResult;
261
+ /**
262
+ * Convert commits to delimiter format (for debugging/testing)
263
+ */
264
+ declare function toDelimiterFormat(commits: Commit[]): string;
265
+
266
+ /**
267
+ * Jira key extraction utilities
268
+ */
269
+ /**
270
+ * Extract Jira keys from a URL or text
271
+ * @param input URL or text containing Jira keys
272
+ * @returns Array of unique Jira keys
273
+ */
274
+ declare function extractJiraKeys(input: string): string[];
275
+ /**
276
+ * Format multiple Jira keys as comma-separated string
277
+ */
278
+ declare function formatJiraKeys(keys: string[]): string;
279
+ /**
280
+ * Check if a string contains valid Jira keys
281
+ */
282
+ declare function hasJiraKeys(input: string): boolean;
283
+
284
+ /**
285
+ * Embedded prompt templates for AI providers
286
+ */
287
+ type ProviderPromptType = 'claude' | 'cursor';
288
+ type PromptCategory = 'commit' | 'regroup';
289
+ /**
290
+ * Get prompt template for a provider and category
291
+ */
292
+ declare function getPromptTemplate(provider: ProviderPromptType, category: PromptCategory): string;
293
+ /**
294
+ * Get JSON schema for structured output
295
+ */
296
+ declare function getJsonSchema(): object;
297
+
298
+ /**
299
+ * Colored console output utilities
300
+ */
301
+ declare const logger: {
302
+ info: (message: string) => void;
303
+ success: (message: string) => void;
304
+ warning: (message: string) => void;
305
+ error: (message: string) => void;
306
+ highlight: (message: string) => void;
307
+ dim: (message: string) => void;
308
+ };
309
+ declare const colors: {
310
+ red: chalk.ChalkInstance;
311
+ green: chalk.ChalkInstance;
312
+ yellow: chalk.ChalkInstance;
313
+ cyan: chalk.ChalkInstance;
314
+ blue: chalk.ChalkInstance;
315
+ magenta: chalk.ChalkInstance;
316
+ dim: chalk.ChalkInstance;
317
+ bold: chalk.ChalkInstance;
318
+ };
319
+
320
+ /**
321
+ * Shell command execution utilities
322
+ */
323
+ interface ExecOptions {
324
+ input?: string;
325
+ timeout?: number;
326
+ cwd?: string;
327
+ }
328
+ interface ExecResult {
329
+ stdout: string;
330
+ stderr: string;
331
+ exitCode: number;
332
+ }
333
+ /**
334
+ * Execute a command with optional input and timeout
335
+ */
336
+ declare function execCommand(command: string, args: string[], options?: ExecOptions): Promise<ExecResult>;
337
+ /**
338
+ * Execute a command and return stdout only
339
+ */
340
+ declare function execSimple(command: string, args: string[], options?: ExecOptions): Promise<string>;
341
+
342
+ /**
343
+ * Validation utilities
344
+ */
345
+
346
+ /**
347
+ * Validate commit title length
348
+ */
349
+ declare function validateTitleLength(commits: Commit[]): void;
350
+ /**
351
+ * Validate that files in commits exist in the valid files list
352
+ */
353
+ declare function validateFilesExist(commits: Commit[], validFiles: Set<string>): void;
354
+ /**
355
+ * Check if a string is a valid Conventional Commit title
356
+ */
357
+ declare function isValidConventionalCommit(title: string): boolean;
358
+
359
+ export { type AIProvider, CLAUDE_DEFAULT_MODEL, CURSOR_DEFAULT_MODEL, type ChangeStatus, ClaudeCodeProvider, type Commit, type CommitGenerationOptions, type CommitResult, CursorCLIProvider, DEFAULT_CONFIG, type DiffOptions, type GencoConfig, type GitChange, type GitDiffResult, type GitStats, type Language, type PromptType, type ProviderOptions, type ProviderResponse, type ProviderStatus, type ProviderType, colors, createProvider, execCommand, execSimple, executeCommits, extractJiraKeys, formatJiraKeys, generateFullTreeSummary, generateTreeSummary, getAllChangedFiles, getCurrentBranch, getDiffContent, getGitStatus, getJsonSchema, getModifiedDiffs, getPromptTemplate, hasChanges, hasJiraKeys, isGitRepository, isValidConventionalCommit, isValidProviderType, logger, parseDelimiterResponse, parseJsonResponse, stageFiles, toDelimiterFormat, validateFilesExist, validateTitleLength };
package/dist/index.js ADDED
@@ -0,0 +1,71 @@
1
+ import {
2
+ CLAUDE_DEFAULT_MODEL,
3
+ CURSOR_DEFAULT_MODEL,
4
+ ClaudeCodeProvider,
5
+ CursorCLIProvider,
6
+ DEFAULT_CONFIG,
7
+ colors,
8
+ createProvider,
9
+ execCommand,
10
+ execSimple,
11
+ executeCommits,
12
+ extractJiraKeys,
13
+ formatJiraKeys,
14
+ generateFullTreeSummary,
15
+ generateTreeSummary,
16
+ getAllChangedFiles,
17
+ getCurrentBranch,
18
+ getDiffContent,
19
+ getGitStatus,
20
+ getJsonSchema,
21
+ getModifiedDiffs,
22
+ getPromptTemplate,
23
+ hasChanges,
24
+ hasJiraKeys,
25
+ isGitRepository,
26
+ isValidConventionalCommit,
27
+ isValidProviderType,
28
+ logger,
29
+ parseDelimiterResponse,
30
+ parseJsonResponse,
31
+ stageFiles,
32
+ toDelimiterFormat,
33
+ validateFilesExist,
34
+ validateTitleLength
35
+ } from "./chunk-PPSTCEXT.js";
36
+ export {
37
+ CLAUDE_DEFAULT_MODEL,
38
+ CURSOR_DEFAULT_MODEL,
39
+ ClaudeCodeProvider,
40
+ CursorCLIProvider,
41
+ DEFAULT_CONFIG,
42
+ colors,
43
+ createProvider,
44
+ execCommand,
45
+ execSimple,
46
+ executeCommits,
47
+ extractJiraKeys,
48
+ formatJiraKeys,
49
+ generateFullTreeSummary,
50
+ generateTreeSummary,
51
+ getAllChangedFiles,
52
+ getCurrentBranch,
53
+ getDiffContent,
54
+ getGitStatus,
55
+ getJsonSchema,
56
+ getModifiedDiffs,
57
+ getPromptTemplate,
58
+ hasChanges,
59
+ hasJiraKeys,
60
+ isGitRepository,
61
+ isValidConventionalCommit,
62
+ isValidProviderType,
63
+ logger,
64
+ parseDelimiterResponse,
65
+ parseJsonResponse,
66
+ stageFiles,
67
+ toDelimiterFormat,
68
+ validateFilesExist,
69
+ validateTitleLength
70
+ };
71
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/package.json ADDED
@@ -0,0 +1,75 @@
1
+ {
2
+ "name": "genai-commit",
3
+ "version": "0.0.0",
4
+ "description": "AI-powered commit message generator using Claude Code or Cursor CLI",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "bin": {
9
+ "genai-commit": "./bin/genai-commit.js"
10
+ },
11
+ "files": [
12
+ "dist",
13
+ "bin"
14
+ ],
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/index.d.ts",
18
+ "import": "./dist/index.js"
19
+ }
20
+ },
21
+ "scripts": {
22
+ "build": "tsup",
23
+ "dev": "tsx src/cli.ts",
24
+ "test": "vitest",
25
+ "test:run": "vitest run",
26
+ "lint": "eslint 'src/**/*.ts'",
27
+ "format": "prettier --write 'src/**/*.ts'",
28
+ "typecheck": "tsc --noEmit",
29
+ "prepublishOnly": "npm run build",
30
+ "release": "release-it",
31
+ "release:beta": "release-it --preRelease=beta"
32
+ },
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "git+https://github.com/Seungwoo321/genai-commit.git"
36
+ },
37
+ "bugs": {
38
+ "url": "https://github.com/Seungwoo321/genai-commit/issues"
39
+ },
40
+ "homepage": "https://github.com/Seungwoo321/genai-commit#readme",
41
+ "engines": {
42
+ "node": ">=18.0.0"
43
+ },
44
+ "keywords": [
45
+ "git",
46
+ "commit",
47
+ "ai",
48
+ "claude",
49
+ "cursor",
50
+ "conventional-commits",
51
+ "jira",
52
+ "cli",
53
+ "commit-message",
54
+ "generator",
55
+ "genai-commit"
56
+ ],
57
+ "author": "",
58
+ "license": "MIT",
59
+ "dependencies": {
60
+ "chalk": "^5.3.0",
61
+ "commander": "^12.1.0",
62
+ "inquirer": "^9.2.12",
63
+ "ora": "^8.0.1",
64
+ "simple-git": "^3.22.0",
65
+ "zod": "^3.22.4"
66
+ },
67
+ "devDependencies": {
68
+ "@types/node": "^20.11.0",
69
+ "release-it": "^17.10.0",
70
+ "tsup": "^8.0.1",
71
+ "tsx": "^4.7.0",
72
+ "typescript": "^5.3.3",
73
+ "vitest": "^1.2.0"
74
+ }
75
+ }