commic 1.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.
Files changed (50) hide show
  1. package/.husky/pre-commit +2 -0
  2. package/README.md +306 -0
  3. package/biome.json +50 -0
  4. package/dist/ai/AIService.d.ts +51 -0
  5. package/dist/ai/AIService.d.ts.map +1 -0
  6. package/dist/ai/AIService.js +351 -0
  7. package/dist/ai/AIService.js.map +1 -0
  8. package/dist/config/ConfigManager.d.ts +49 -0
  9. package/dist/config/ConfigManager.d.ts.map +1 -0
  10. package/dist/config/ConfigManager.js +124 -0
  11. package/dist/config/ConfigManager.js.map +1 -0
  12. package/dist/errors/CustomErrors.d.ts +54 -0
  13. package/dist/errors/CustomErrors.d.ts.map +1 -0
  14. package/dist/errors/CustomErrors.js +99 -0
  15. package/dist/errors/CustomErrors.js.map +1 -0
  16. package/dist/git/GitService.d.ts +77 -0
  17. package/dist/git/GitService.d.ts.map +1 -0
  18. package/dist/git/GitService.js +219 -0
  19. package/dist/git/GitService.js.map +1 -0
  20. package/dist/index.d.ts +3 -0
  21. package/dist/index.d.ts.map +1 -0
  22. package/dist/index.js +48 -0
  23. package/dist/index.js.map +1 -0
  24. package/dist/orchestrator/MainOrchestrator.d.ts +63 -0
  25. package/dist/orchestrator/MainOrchestrator.d.ts.map +1 -0
  26. package/dist/orchestrator/MainOrchestrator.js +225 -0
  27. package/dist/orchestrator/MainOrchestrator.js.map +1 -0
  28. package/dist/types/index.d.ts +55 -0
  29. package/dist/types/index.d.ts.map +1 -0
  30. package/dist/types/index.js +2 -0
  31. package/dist/types/index.js.map +1 -0
  32. package/dist/ui/UIManager.d.ts +118 -0
  33. package/dist/ui/UIManager.d.ts.map +1 -0
  34. package/dist/ui/UIManager.js +369 -0
  35. package/dist/ui/UIManager.js.map +1 -0
  36. package/dist/validation/ConventionalCommitsValidator.d.ts +33 -0
  37. package/dist/validation/ConventionalCommitsValidator.d.ts.map +1 -0
  38. package/dist/validation/ConventionalCommitsValidator.js +114 -0
  39. package/dist/validation/ConventionalCommitsValidator.js.map +1 -0
  40. package/package.json +49 -0
  41. package/src/ai/AIService.ts +413 -0
  42. package/src/config/ConfigManager.ts +141 -0
  43. package/src/errors/CustomErrors.ts +176 -0
  44. package/src/git/GitService.ts +246 -0
  45. package/src/index.ts +55 -0
  46. package/src/orchestrator/MainOrchestrator.ts +263 -0
  47. package/src/types/index.ts +60 -0
  48. package/src/ui/UIManager.ts +420 -0
  49. package/src/validation/ConventionalCommitsValidator.ts +139 -0
  50. package/tsconfig.json +24 -0
@@ -0,0 +1,225 @@
1
+ import { AIService } from '../ai/AIService.js';
2
+ import { APIError, ConfigurationError, GitRepositoryError } from '../errors/CustomErrors.js';
3
+ /**
4
+ * Orchestrates the complete workflow of the Commit CLI
5
+ * Coordinates between configuration, Git operations, AI generation, and user interaction
6
+ */
7
+ export class MainOrchestrator {
8
+ configManager;
9
+ gitService;
10
+ uiManager;
11
+ constructor(configManager, gitService, uiManager) {
12
+ this.configManager = configManager;
13
+ this.gitService = gitService;
14
+ this.uiManager = uiManager;
15
+ }
16
+ /**
17
+ * Execute the complete commit workflow
18
+ * @param options CLI options from command line
19
+ */
20
+ async execute(options) {
21
+ try {
22
+ // Show welcome message
23
+ this.uiManager.showWelcome();
24
+ // Step 1: Handle configuration
25
+ const config = await this.handleConfiguration(options.reconfigure);
26
+ // Step 2: Find and validate repository
27
+ const repositoryPath = options.path || '.';
28
+ const repository = await this.findAndValidateRepository(repositoryPath);
29
+ // Step 3: Get Git diff
30
+ const diff = await this.getGitDiff(repository.rootPath);
31
+ // Step 4: Generate commit suggestions
32
+ const suggestions = await this.generateSuggestions(config, diff);
33
+ // Step 5: Let user select a commit message
34
+ const selectedIndex = await this.uiManager.promptForCommitSelection(suggestions);
35
+ // Handle cancellation
36
+ if (selectedIndex === -1) {
37
+ this.uiManager.showInfo('Commit cancelled. No changes were made.');
38
+ return;
39
+ }
40
+ // Step 6: Stage changes if needed
41
+ await this.stageChangesIfNeeded(repository.rootPath, diff);
42
+ // Step 7: Execute commit
43
+ const commitHash = await this.executeCommit(repository.rootPath, suggestions[selectedIndex].message);
44
+ // Step 8: Show success with more details
45
+ const shortHash = commitHash.substring(0, 7);
46
+ const repoName = this.gitService.getRepositoryName(repository.rootPath);
47
+ const branch = await this.gitService.getCurrentBranch(repository.rootPath);
48
+ this.uiManager.showSuccess(`Committed successfully!\n` +
49
+ ` Repository: ${repoName}\n` +
50
+ ` Branch: ${branch}\n` +
51
+ ` Commit: ${this.uiManager.muted(shortHash)}`);
52
+ }
53
+ catch (error) {
54
+ this.handleError(error);
55
+ process.exit(1);
56
+ }
57
+ }
58
+ /**
59
+ * Handle configuration loading or prompting
60
+ * @param forceReconfigure Force reconfiguration even if config exists
61
+ * @returns Configuration object
62
+ */
63
+ async handleConfiguration(forceReconfigure) {
64
+ try {
65
+ // Check if we need to reconfigure
66
+ if (forceReconfigure) {
67
+ this.uiManager.showInfo('Reconfiguring...');
68
+ const config = await this.configManager.promptForConfig(this.uiManager);
69
+ await this.configManager.save(config);
70
+ this.uiManager.showSuccess('Configuration saved!');
71
+ return config;
72
+ }
73
+ // Try to load existing config
74
+ const existingConfig = await this.configManager.load();
75
+ if (existingConfig) {
76
+ return existingConfig;
77
+ }
78
+ // No config exists - prompt for first-time setup
79
+ this.uiManager.showInfo('First-time setup required');
80
+ const config = await this.configManager.promptForConfig(this.uiManager);
81
+ await this.configManager.save(config);
82
+ this.uiManager.showSuccess('Configuration saved!');
83
+ return config;
84
+ }
85
+ catch (error) {
86
+ if (error instanceof ConfigurationError) {
87
+ throw error;
88
+ }
89
+ throw ConfigurationError.configSaveFailed(error);
90
+ }
91
+ }
92
+ /**
93
+ * Find and validate Git repository
94
+ * @param path Path to search for repository
95
+ * @returns Repository information
96
+ */
97
+ async findAndValidateRepository(path) {
98
+ const spinner = this.uiManager.showLoading('Finding Git repository...');
99
+ try {
100
+ const repository = await this.gitService.findRepository(path);
101
+ // Check if repository has commits
102
+ const hasCommits = await this.gitService.hasCommits(repository.rootPath);
103
+ if (!hasCommits) {
104
+ spinner.fail('Repository has no commits');
105
+ throw GitRepositoryError.noCommitsFound();
106
+ }
107
+ // Get repository info
108
+ const repoName = this.gitService.getRepositoryName(repository.rootPath);
109
+ const branch = await this.gitService.getCurrentBranch(repository.rootPath);
110
+ const remoteUrl = await this.gitService.getRemoteUrl(repository.rootPath);
111
+ spinner.succeed('Repository found');
112
+ // Show repository info with better spacing
113
+ this.uiManager.newLine();
114
+ this.uiManager.showRepositoryInfo(repoName, branch, repository.rootPath, remoteUrl);
115
+ return repository;
116
+ }
117
+ catch (error) {
118
+ spinner.fail('Failed to find repository');
119
+ throw error;
120
+ }
121
+ }
122
+ /**
123
+ * Get Git diff and validate changes exist
124
+ * @param repoPath Repository root path
125
+ * @returns Git diff
126
+ */
127
+ async getGitDiff(repoPath) {
128
+ const spinner = this.uiManager.showLoading('Analyzing changes...');
129
+ try {
130
+ const diff = await this.gitService.getDiff(repoPath);
131
+ if (!diff.hasChanges) {
132
+ spinner.fail('No changes to commit');
133
+ throw GitRepositoryError.noChanges();
134
+ }
135
+ // Get diff statistics
136
+ const stats = await this.gitService.getDiffStats(repoPath);
137
+ spinner.succeed('Changes analyzed');
138
+ // Show change statistics with better spacing
139
+ this.uiManager.showChangeStats(stats);
140
+ return diff;
141
+ }
142
+ catch (error) {
143
+ spinner.fail('Failed to analyze changes');
144
+ throw error;
145
+ }
146
+ }
147
+ /**
148
+ * Generate commit message suggestions using AI
149
+ * @param config Configuration with API key
150
+ * @param diff Git diff
151
+ * @returns Array of suggestions
152
+ */
153
+ async generateSuggestions(config, diff) {
154
+ this.uiManager.newLine();
155
+ this.uiManager.showSectionHeader('🤖 AI Generation');
156
+ this.uiManager.showAIGenerationInfo(config.model, 4);
157
+ const spinner = this.uiManager.showLoading(' Generating commit messages...');
158
+ try {
159
+ const aiService = new AIService(config.apiKey, config.model);
160
+ const suggestions = await aiService.generateCommitMessages(diff, 4);
161
+ spinner.succeed(` Generated ${suggestions.length} suggestions`);
162
+ this.uiManager.newLine();
163
+ return suggestions;
164
+ }
165
+ catch (error) {
166
+ spinner.fail(' Failed to generate suggestions');
167
+ throw error;
168
+ }
169
+ }
170
+ /**
171
+ * Stage changes if there are unstaged changes
172
+ * @param repoPath Repository root path
173
+ * @param diff Git diff
174
+ */
175
+ async stageChangesIfNeeded(repoPath, diff) {
176
+ if (diff.unstaged && diff.unstaged.length > 0) {
177
+ this.uiManager.newLine();
178
+ const spinner = this.uiManager.showLoading('Staging changes...');
179
+ try {
180
+ await this.gitService.stageAll(repoPath);
181
+ spinner.succeed('Changes staged');
182
+ this.uiManager.newLine();
183
+ }
184
+ catch (error) {
185
+ spinner.fail('Failed to stage changes');
186
+ throw error;
187
+ }
188
+ }
189
+ }
190
+ /**
191
+ * Execute Git commit
192
+ * @param repoPath Repository root path
193
+ * @param message Commit message
194
+ * @returns Commit hash
195
+ */
196
+ async executeCommit(repoPath, message) {
197
+ this.uiManager.newLine();
198
+ const spinner = this.uiManager.showLoading('Committing changes...');
199
+ try {
200
+ const commitHash = await this.gitService.commit(repoPath, message);
201
+ spinner.succeed('Commit created successfully');
202
+ this.uiManager.newLine();
203
+ return commitHash;
204
+ }
205
+ catch (error) {
206
+ spinner.fail('Commit failed');
207
+ throw error;
208
+ }
209
+ }
210
+ /**
211
+ * Handle errors with user-friendly messages
212
+ * @param error Error to handle
213
+ */
214
+ handleError(error) {
215
+ if (error instanceof GitRepositoryError ||
216
+ error instanceof ConfigurationError ||
217
+ error instanceof APIError) {
218
+ this.uiManager.showErrorWithSuggestion(error.message, error.suggestion || '');
219
+ }
220
+ else {
221
+ this.uiManager.showError('An unexpected error occurred', error.message);
222
+ }
223
+ }
224
+ }
225
+ //# sourceMappingURL=MainOrchestrator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MainOrchestrator.js","sourceRoot":"","sources":["../../src/orchestrator/MainOrchestrator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAA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,UAAU,IAAI,EAAE,CAAC,CAAC;QAChF,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,8BAA8B,EAAG,KAAe,CAAC,OAAO,CAAC,CAAC;QACrF,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Configuration structure stored in ~/.commit-cli/config.json
3
+ */
4
+ export interface Config {
5
+ apiKey: string;
6
+ model: string;
7
+ version: string;
8
+ }
9
+ /**
10
+ * Git repository information
11
+ */
12
+ export interface GitRepository {
13
+ path: string;
14
+ rootPath: string;
15
+ }
16
+ /**
17
+ * Git diff information
18
+ */
19
+ export interface GitDiff {
20
+ staged: string;
21
+ unstaged: string;
22
+ hasChanges: boolean;
23
+ }
24
+ /**
25
+ * Commit message suggestion
26
+ */
27
+ export interface CommitSuggestion {
28
+ message: string;
29
+ type: 'single-line' | 'multi-line';
30
+ }
31
+ /**
32
+ * Validation result for commit messages
33
+ */
34
+ export interface ValidationResult {
35
+ valid: boolean;
36
+ errors: string[];
37
+ }
38
+ /**
39
+ * Parsed commit message structure
40
+ */
41
+ export interface ParsedCommitMessage {
42
+ type: string;
43
+ scope?: string;
44
+ breaking: boolean;
45
+ description: string;
46
+ body?: string;
47
+ }
48
+ /**
49
+ * CLI options from command line arguments
50
+ */
51
+ export interface CLIOptions {
52
+ path?: string;
53
+ reconfigure?: boolean;
54
+ }
55
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,OAAO,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,aAAa,GAAG,YAAY,CAAC;CACpC;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,118 @@
1
+ import { type Ora } from 'ora';
2
+ import type { CommitSuggestion } from '../types/index.js';
3
+ /**
4
+ * Manages terminal UI rendering and visual feedback
5
+ * Provides consistent, colorful interface with emojis and loading indicators
6
+ */
7
+ export declare class UIManager {
8
+ private readonly colors;
9
+ /**
10
+ * Display welcome message with branding
11
+ */
12
+ showWelcome(): void;
13
+ /**
14
+ * Display success message with checkmark emoji
15
+ * @param message Success message to display
16
+ */
17
+ showSuccess(message: string): void;
18
+ /**
19
+ * Display error message with cross emoji
20
+ * @param message Error message to display
21
+ * @param details Optional detailed error information
22
+ */
23
+ showError(message: string, details?: string): void;
24
+ /**
25
+ * Display error with suggestion
26
+ * @param message Error message
27
+ * @param suggestion Actionable suggestion for user
28
+ */
29
+ showErrorWithSuggestion(message: string, suggestion: string): void;
30
+ /**
31
+ * Display informational message with bulb emoji
32
+ * @param message Info message to display
33
+ */
34
+ showInfo(message: string): void;
35
+ /**
36
+ * Display warning message
37
+ * @param message Warning message to display
38
+ */
39
+ showWarning(message: string): void;
40
+ /**
41
+ * Apply muted (gray) color to text
42
+ * @param text Text to color
43
+ * @returns Colored text string
44
+ */
45
+ muted(text: string): string;
46
+ /**
47
+ * Create and start a loading spinner
48
+ * @param message Loading message to display
49
+ * @returns Ora spinner instance
50
+ */
51
+ showLoading(message: string): Ora;
52
+ /**
53
+ * Display a section header
54
+ * @param title Section title
55
+ */
56
+ showSectionHeader(title: string): void;
57
+ /**
58
+ * Display formatted commit message preview
59
+ * @param message Commit message to preview
60
+ * @param index Optional index number
61
+ */
62
+ showCommitPreview(message: string, index?: number): void;
63
+ /**
64
+ * Clear the console
65
+ */
66
+ clear(): void;
67
+ /**
68
+ * Display a blank line
69
+ */
70
+ newLine(): void;
71
+ /**
72
+ * Display repository information banner
73
+ * @param repoName Repository name
74
+ * @param branch Current branch
75
+ * @param repoPath Repository path
76
+ * @param remoteUrl Optional remote repository URL
77
+ */
78
+ showRepositoryInfo(repoName: string, branch: string, repoPath: string, remoteUrl?: string | null): void;
79
+ /**
80
+ * Display change statistics
81
+ * @param stats Statistics object with files, insertions, deletions
82
+ */
83
+ showChangeStats(stats: {
84
+ filesChanged: number;
85
+ insertions: number;
86
+ deletions: number;
87
+ }): void;
88
+ /**
89
+ * Display AI generation info
90
+ * @param model Model name being used
91
+ * @param suggestionCount Number of suggestions generated
92
+ */
93
+ showAIGenerationInfo(model: string, suggestionCount: number): void;
94
+ /**
95
+ * Prompt user for API key
96
+ * @returns Entered API key
97
+ */
98
+ promptForApiKey(): Promise<string>;
99
+ /**
100
+ * Prompt user to select a Gemini model
101
+ * @param models Available model options
102
+ * @returns Selected model
103
+ */
104
+ promptForModel(models: string[]): Promise<string>;
105
+ /**
106
+ * Prompt user to select a commit message from suggestions
107
+ * @param suggestions Array of commit message suggestions
108
+ * @returns Index of selected suggestion, or -1 if cancelled
109
+ */
110
+ promptForCommitSelection(suggestions: CommitSuggestion[]): Promise<number>;
111
+ /**
112
+ * Prompt for confirmation
113
+ * @param message Confirmation message
114
+ * @returns true if confirmed, false otherwise
115
+ */
116
+ promptForConfirmation(message: string): Promise<boolean>;
117
+ }
118
+ //# sourceMappingURL=UIManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UIManager.d.ts","sourceRoot":"","sources":["../../src/ui/UIManager.ts"],"names":[],"mappings":"AAGA,OAAY,EAAE,KAAK,GAAG,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D;;;GAGG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAOrB;IAEF;;OAEG;IACH,WAAW,IAAI,IAAI;IA0CnB;;;OAGG;IACH,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAIlC;;;;OAIG;IACH,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI;IAQlD;;;;OAIG;IACH,uBAAuB,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI;IAKlE;;;OAGG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI/B;;;OAGG;IACH,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAIlC;;;;OAIG;IACH,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAI3B;;;;OAIG;IACH,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG;IAQjC;;;OAGG;IACH,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAMtC;;;;OAIG;IACH,iBAAiB,CAAC,OA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