@snapcommit/cli 1.1.3 ā 1.2.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.
- package/dist/commands/commit.js +18 -18
- package/dist/repl.js +23 -2
- package/package.json +1 -1
package/dist/commands/commit.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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,12 @@ 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
|
+
await commitCommand();
|
|
137
|
+
rl.prompt();
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
133
140
|
if (line === 'stats' || line === 's') {
|
|
134
141
|
(0, stats_1.statsCommand)();
|
|
135
142
|
rl.prompt();
|
|
@@ -189,12 +196,26 @@ async function startREPL() {
|
|
|
189
196
|
rl.prompt();
|
|
190
197
|
return;
|
|
191
198
|
}
|
|
199
|
+
// Detect npm/shell commands and provide helpful guidance
|
|
200
|
+
if (line.startsWith('npm ') || line.startsWith('yarn ') || line.startsWith('pnpm ')) {
|
|
201
|
+
console.log(chalk_1.default.yellow('\nš” You\'re inside the SnapCommit REPL!\n'));
|
|
202
|
+
if (line.includes('install') && line.includes('snapcommit')) {
|
|
203
|
+
console.log(chalk_1.default.white(' To update SnapCommit, just type: ') + chalk_1.default.cyan.bold('update\n'));
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
console.log(chalk_1.default.white(' Shell commands don\'t work here.'));
|
|
207
|
+
console.log(chalk_1.default.gray(' Exit with ') + chalk_1.default.cyan('exit') + chalk_1.default.gray(' to run shell commands\n'));
|
|
208
|
+
}
|
|
209
|
+
rl.prompt();
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
192
212
|
if (line === 'help' || line === 'h') {
|
|
193
213
|
console.log(chalk_1.default.bold('\nš” SnapCommit Commands:\n'));
|
|
214
|
+
console.log(chalk_1.default.gray(' ⢠') + chalk_1.default.cyan('quick') + chalk_1.default.gray(' - Quick AI commit (fast, no prompts)'));
|
|
215
|
+
console.log(chalk_1.default.gray(' ⢠') + chalk_1.default.cyan('commit') + chalk_1.default.gray(' - Interactive commit (choose & edit AI message)'));
|
|
194
216
|
console.log(chalk_1.default.gray(' ⢠') + chalk_1.default.cyan('update') + chalk_1.default.gray(' - Update SnapCommit to latest version'));
|
|
195
217
|
console.log(chalk_1.default.gray(' ⢠') + chalk_1.default.cyan('cd /path/to/repo') + chalk_1.default.gray(' - Switch to a different repository'));
|
|
196
218
|
console.log(chalk_1.default.gray(' ⢠') + chalk_1.default.cyan('repos') + chalk_1.default.gray(' - Show recent repositories'));
|
|
197
|
-
console.log(chalk_1.default.gray(' ⢠') + chalk_1.default.cyan('quick') + chalk_1.default.gray(' - Quick AI commit (stage all + commit)'));
|
|
198
219
|
console.log(chalk_1.default.gray(' ⢠') + chalk_1.default.cyan('stats') + chalk_1.default.gray(' - Show your coding stats'));
|
|
199
220
|
console.log(chalk_1.default.gray(' ⢠') + chalk_1.default.cyan('exit/quit') + chalk_1.default.gray(' - Exit SnapCommit'));
|
|
200
221
|
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'));
|