@snapcommit/cli 1.1.4 → 1.2.1

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.
@@ -59,7 +59,7 @@ async function commitCommand() {
59
59
  console.log();
60
60
  console.log(chalk_1.default.white('Visit: ') + chalk_1.default.cyan('https://snapcommit.dev/pricing'));
61
61
  console.log();
62
- process.exit(1);
62
+ return;
63
63
  }
64
64
  // Check rate limit (prevent abuse)
65
65
  const userPlan = (0, manager_1.isProUser)() ? 'pro' : 'free';
@@ -75,14 +75,14 @@ async function commitCommand() {
75
75
  console.log(chalk_1.default.white(' Visit: ') + chalk_1.default.cyan('https://snapcommit.dev/pricing'));
76
76
  }
77
77
  console.log();
78
- process.exit(1);
78
+ return;
79
79
  }
80
80
  console.log(chalk_1.default.blue('šŸ” Analyzing your changes...\n'));
81
81
  // Check if we're in a git repo
82
82
  if (!(0, git_1.isGitRepo)()) {
83
83
  console.log(chalk_1.default.red('āŒ Not a git repository'));
84
- console.log(chalk_1.default.gray(' Run this command inside a git repo'));
85
- process.exit(1);
84
+ console.log(chalk_1.default.gray(' Run this command inside a git repo\n'));
85
+ return;
86
86
  }
87
87
  // Get status
88
88
  let status;
@@ -91,8 +91,8 @@ async function commitCommand() {
91
91
  }
92
92
  catch (error) {
93
93
  console.log(chalk_1.default.red('āŒ Failed to get git status'));
94
- console.log(chalk_1.default.gray(` ${error.message}`));
95
- process.exit(1);
94
+ console.log(chalk_1.default.gray(` ${error.message}\n`));
95
+ return;
96
96
  }
97
97
  // If nothing staged, ask if they want to stage all
98
98
  if (status.staged === 0 && (status.unstaged > 0 || status.untracked > 0)) {
@@ -108,19 +108,19 @@ async function commitCommand() {
108
108
  }
109
109
  catch (error) {
110
110
  console.log(chalk_1.default.red('āŒ Failed to stage changes'));
111
- console.log(chalk_1.default.gray(` ${error.message}`));
112
- process.exit(1);
111
+ console.log(chalk_1.default.gray(` ${error.message}\n`));
112
+ return;
113
113
  }
114
114
  }
115
115
  else {
116
- console.log(chalk_1.default.gray(' Cancelled. Stage files with: git add <files>'));
117
- process.exit(0);
116
+ console.log(chalk_1.default.gray(' Cancelled. Stage files with: git add <files>\n'));
117
+ return;
118
118
  }
119
119
  }
120
120
  if (status.staged === 0) {
121
121
  console.log(chalk_1.default.yellow('āš ļø No changes to commit'));
122
- console.log(chalk_1.default.gray(' Make some changes and stage them with git add'));
123
- process.exit(0);
122
+ console.log(chalk_1.default.gray(' Make some changes and stage them with git add\n'));
123
+ return;
124
124
  }
125
125
  // Get the diff
126
126
  let diff;
@@ -129,8 +129,8 @@ async function commitCommand() {
129
129
  }
130
130
  catch (error) {
131
131
  console.log(chalk_1.default.red('āŒ Failed to get git diff'));
132
- console.log(chalk_1.default.gray(` ${error.message}`));
133
- process.exit(1);
132
+ console.log(chalk_1.default.gray(` ${error.message}\n`));
133
+ return;
134
134
  }
135
135
  // Check if diff is too large (>50KB)
136
136
  if (diff.length > 50000) {
@@ -157,8 +157,8 @@ async function commitCommand() {
157
157
  console.log(chalk_1.default.red('āŒ Failed to generate commit message'));
158
158
  console.log(chalk_1.default.gray(` ${error.message}`));
159
159
  console.log();
160
- console.log(chalk_1.default.yellow('šŸ’” Tip: Check your ANTHROPIC_API_KEY in .env'));
161
- process.exit(1);
160
+ console.log(chalk_1.default.yellow('šŸ’” Tip: Check your ANTHROPIC_API_KEY in .env\n'));
161
+ return;
162
162
  }
163
163
  // Display all options
164
164
  displayCommitOptions(options);
@@ -167,8 +167,8 @@ async function commitCommand() {
167
167
  chalk_1.default.gray('(e)dit / (c)ancel: '));
168
168
  let message;
169
169
  if (choice.toLowerCase() === 'c' || choice.toLowerCase() === 'cancel') {
170
- console.log(chalk_1.default.gray('\nCancelled.'));
171
- process.exit(0);
170
+ console.log(chalk_1.default.gray('\nCancelled.\n'));
171
+ return;
172
172
  }
173
173
  else if (choice.toLowerCase() === 'e' || choice.toLowerCase() === 'edit') {
174
174
  // Let user edit the first option
package/dist/repl.js CHANGED
@@ -85,7 +85,8 @@ async function startREPL() {
85
85
  console.log(chalk_1.default.gray('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n'));
86
86
  console.log(chalk_1.default.bold('šŸ’” What can SnapCommit do?\n'));
87
87
  console.log(chalk_1.default.gray(' • ') + chalk_1.default.white('Natural language Git: ') + chalk_1.default.cyan('"undo my last commit"'));
88
- console.log(chalk_1.default.gray(' • ') + chalk_1.default.white('Quick AI commits: ') + chalk_1.default.cyan('quick'));
88
+ console.log(chalk_1.default.gray(' • ') + chalk_1.default.white('Quick AI commits: ') + chalk_1.default.cyan('quick') + chalk_1.default.gray(' (fast, no prompts)'));
89
+ console.log(chalk_1.default.gray(' • ') + chalk_1.default.white('Interactive commits: ') + chalk_1.default.cyan('commit') + chalk_1.default.gray(' (choose & edit)'));
89
90
  console.log(chalk_1.default.gray(' • ') + chalk_1.default.white('Switch repos: ') + chalk_1.default.cyan('cd /path/to/repo') + chalk_1.default.gray(' or ') + chalk_1.default.cyan('repos'));
90
91
  if (githubConnected) {
91
92
  console.log(chalk_1.default.gray(' • ') + chalk_1.default.white('GitHub operations: ') + chalk_1.default.cyan('"create a PR", "check CI"'));
@@ -130,6 +131,14 @@ async function startREPL() {
130
131
  rl.prompt();
131
132
  return;
132
133
  }
134
+ if (line === 'commit' || line === 'c') {
135
+ const { commitCommand } = await Promise.resolve().then(() => __importStar(require('./commands/commit')));
136
+ rl.pause(); // Pause REPL readline to avoid conflicts
137
+ await commitCommand();
138
+ rl.resume(); // Resume REPL readline
139
+ rl.prompt();
140
+ return;
141
+ }
133
142
  if (line === 'stats' || line === 's') {
134
143
  (0, stats_1.statsCommand)();
135
144
  rl.prompt();
@@ -204,10 +213,11 @@ async function startREPL() {
204
213
  }
205
214
  if (line === 'help' || line === 'h') {
206
215
  console.log(chalk_1.default.bold('\nšŸ’” SnapCommit Commands:\n'));
216
+ console.log(chalk_1.default.gray(' • ') + chalk_1.default.cyan('quick') + chalk_1.default.gray(' - Quick AI commit (fast, no prompts)'));
217
+ console.log(chalk_1.default.gray(' • ') + chalk_1.default.cyan('commit') + chalk_1.default.gray(' - Interactive commit (choose & edit AI message)'));
207
218
  console.log(chalk_1.default.gray(' • ') + chalk_1.default.cyan('update') + chalk_1.default.gray(' - Update SnapCommit to latest version'));
208
219
  console.log(chalk_1.default.gray(' • ') + chalk_1.default.cyan('cd /path/to/repo') + chalk_1.default.gray(' - Switch to a different repository'));
209
220
  console.log(chalk_1.default.gray(' • ') + chalk_1.default.cyan('repos') + chalk_1.default.gray(' - Show recent repositories'));
210
- console.log(chalk_1.default.gray(' • ') + chalk_1.default.cyan('quick') + chalk_1.default.gray(' - Quick AI commit (stage all + commit)'));
211
221
  console.log(chalk_1.default.gray(' • ') + chalk_1.default.cyan('stats') + chalk_1.default.gray(' - Show your coding stats'));
212
222
  console.log(chalk_1.default.gray(' • ') + chalk_1.default.cyan('exit/quit') + chalk_1.default.gray(' - Exit SnapCommit'));
213
223
  console.log(chalk_1.default.gray(' • ') + chalk_1.default.white('Or just type what you want: ') + chalk_1.default.cyan('"create a new branch called feature-x"\n'));
@@ -216,10 +226,13 @@ async function startREPL() {
216
226
  }
217
227
  // Everything else is natural language
218
228
  try {
229
+ rl.pause(); // Pause REPL readline to avoid conflicts
219
230
  await (0, natural_1.naturalCommand)(line);
231
+ rl.resume(); // Resume REPL readline
220
232
  }
221
233
  catch (error) {
222
234
  console.log(chalk_1.default.red(`\nāŒ Error: ${error.message}\n`));
235
+ rl.resume(); // Make sure to resume even on error
223
236
  }
224
237
  rl.prompt();
225
238
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snapcommit/cli",
3
- "version": "1.1.4",
3
+ "version": "1.2.1",
4
4
  "description": "Instant AI commits. Beautiful progress tracking. Never write commit messages again.",
5
5
  "main": "dist/index.js",
6
6
  "bin": {