@snapcommit/cli 1.0.6 → 1.1.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/natural.js +6 -28
- package/dist/commands/quick.js +7 -49
- package/dist/index.js +5 -2
- package/dist/repl.js +23 -6
- package/dist/utils/version.js +4 -2
- package/package.json +1 -1
package/dist/commands/natural.js
CHANGED
|
@@ -181,17 +181,11 @@ async function naturalCommand(userInput) {
|
|
|
181
181
|
await handleGitHubOperation(intent);
|
|
182
182
|
return;
|
|
183
183
|
}
|
|
184
|
-
// Show intent (for Git operations)
|
|
185
|
-
console.log(chalk_1.default.
|
|
186
|
-
console.log(chalk_1.default.white('This will:'));
|
|
187
|
-
console.log(chalk_1.default.gray(`• ${intent.explanation}\n`));
|
|
188
|
-
// Show educational tip
|
|
189
|
-
if (intent.educationalTip) {
|
|
190
|
-
console.log(chalk_1.default.yellow(`💡 ${intent.educationalTip}\n`));
|
|
191
|
-
}
|
|
184
|
+
// Show intent (for Git operations) - simplified
|
|
185
|
+
console.log(chalk_1.default.cyan(`✨ ${intent.explanation}`));
|
|
192
186
|
// Risk warning
|
|
193
187
|
if (intent.riskLevel === 'high') {
|
|
194
|
-
console.log(chalk_1.default.red('⚠️
|
|
188
|
+
console.log(chalk_1.default.red('⚠️ Destructive operation!'));
|
|
195
189
|
}
|
|
196
190
|
// Confirmation
|
|
197
191
|
if (intent.needsConfirmation) {
|
|
@@ -206,26 +200,10 @@ async function naturalCommand(userInput) {
|
|
|
206
200
|
await handleCommitWithAI();
|
|
207
201
|
return;
|
|
208
202
|
}
|
|
209
|
-
// Execute git commands
|
|
210
|
-
|
|
211
|
-
const result = executeGitCommands(intent.gitCommands, true);
|
|
212
|
-
console.log();
|
|
203
|
+
// Execute git commands
|
|
204
|
+
const result = executeGitCommands(intent.gitCommands, false);
|
|
213
205
|
if (result.success) {
|
|
214
|
-
console.log(chalk_1.default.green
|
|
215
|
-
// Dopamine hit - show stats/streaks
|
|
216
|
-
await showDopamineStats();
|
|
217
|
-
// Suggest next actions
|
|
218
|
-
const suggestions = (0, git_interpreter_1.suggestNextActions)(intent.action, {
|
|
219
|
-
currentBranch,
|
|
220
|
-
hasUncommittedChanges,
|
|
221
|
-
});
|
|
222
|
-
if (suggestions.length > 0) {
|
|
223
|
-
console.log(chalk_1.default.white('💡 What\'s next?'));
|
|
224
|
-
suggestions.forEach((suggestion) => {
|
|
225
|
-
console.log(chalk_1.default.gray(` • ${suggestion}`));
|
|
226
|
-
});
|
|
227
|
-
console.log();
|
|
228
|
-
}
|
|
206
|
+
console.log(chalk_1.default.green(`✅ Done!\n`));
|
|
229
207
|
(0, analytics_1.trackEvent)({ event: analytics_1.EVENTS.NATURAL_COMMAND_SUCCESS });
|
|
230
208
|
}
|
|
231
209
|
else {
|
package/dist/commands/quick.js
CHANGED
|
@@ -1,37 +1,4 @@
|
|
|
1
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
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
4
|
};
|
|
@@ -97,11 +64,9 @@ async function quickCommand() {
|
|
|
97
64
|
console.log(chalk_1.default.red('❌ Not a git repository'));
|
|
98
65
|
process.exit(1);
|
|
99
66
|
}
|
|
100
|
-
console.log(chalk_1.default.blue('⚡ Quick commit mode...\n'));
|
|
101
67
|
// Stage all changes
|
|
102
68
|
try {
|
|
103
69
|
(0, git_1.stageAllChanges)();
|
|
104
|
-
console.log(chalk_1.default.gray('✓ Staged all changes'));
|
|
105
70
|
}
|
|
106
71
|
catch (error) {
|
|
107
72
|
console.log(chalk_1.default.red('❌ Failed to stage changes'));
|
|
@@ -125,27 +90,28 @@ async function quickCommand() {
|
|
|
125
90
|
diff = diff.substring(0, 40000);
|
|
126
91
|
}
|
|
127
92
|
// Generate message
|
|
128
|
-
|
|
93
|
+
process.stdout.write(chalk_1.default.cyan('⚡ Generating commit... '));
|
|
129
94
|
let message;
|
|
130
95
|
let usage;
|
|
131
96
|
try {
|
|
132
97
|
const result = await generateCommitMessageAPI(diff, token);
|
|
133
98
|
message = result.message;
|
|
134
99
|
usage = result.usage;
|
|
100
|
+
process.stdout.write(chalk_1.default.green('✓\n'));
|
|
135
101
|
}
|
|
136
102
|
catch (error) {
|
|
103
|
+
process.stdout.write(chalk_1.default.red('✗\n'));
|
|
137
104
|
(0, analytics_1.trackEvent)({ event: 'commit_error' });
|
|
138
|
-
console.log(chalk_1.default.red(
|
|
105
|
+
console.log(chalk_1.default.red(`❌ ${error.message}\n`));
|
|
139
106
|
process.exit(1);
|
|
140
107
|
}
|
|
141
108
|
// Show message
|
|
142
|
-
console.log(chalk_1.default.
|
|
109
|
+
console.log(chalk_1.default.white(`📝 ${chalk_1.default.bold(message.split('\n')[0])}`));
|
|
143
110
|
// Commit
|
|
144
111
|
try {
|
|
145
112
|
const hash = (0, git_1.commitWithMessage)(message);
|
|
146
113
|
const stats = (0, git_1.getCommitStats)(hash);
|
|
147
|
-
console.log(chalk_1.default.green(
|
|
148
|
-
console.log(chalk_1.default.gray(` +${stats.insertions} -${stats.deletions} across ${stats.files} files\n`));
|
|
114
|
+
console.log(chalk_1.default.green(`✅ ${hash.substring(0, 7)}`), chalk_1.default.gray(`+${stats.insertions} -${stats.deletions} • ${stats.files} ${stats.files === 1 ? 'file' : 'files'}\n`));
|
|
149
115
|
// Track event
|
|
150
116
|
(0, analytics_1.trackEvent)({ event: 'commit_success' });
|
|
151
117
|
// Log to database
|
|
@@ -157,17 +123,9 @@ async function quickCommand() {
|
|
|
157
123
|
deletions: stats.deletions,
|
|
158
124
|
timestamp: Date.now(),
|
|
159
125
|
});
|
|
160
|
-
// Show dopamine stats
|
|
161
|
-
try {
|
|
162
|
-
const { displayQuickDopamine } = await Promise.resolve().then(() => __importStar(require('../utils/dopamine')));
|
|
163
|
-
displayQuickDopamine();
|
|
164
|
-
}
|
|
165
|
-
catch (error) {
|
|
166
|
-
// Optional feature - don't fail if it doesn't work
|
|
167
|
-
}
|
|
168
126
|
}
|
|
169
127
|
catch (error) {
|
|
170
|
-
console.log(chalk_1.default.red('❌ Commit failed'));
|
|
128
|
+
console.log(chalk_1.default.red('\n❌ Commit failed\n'));
|
|
171
129
|
process.exit(1);
|
|
172
130
|
}
|
|
173
131
|
}
|
package/dist/index.js
CHANGED
|
@@ -28,8 +28,11 @@ const program = new commander_1.Command();
|
|
|
28
28
|
// Check for updates (async, non-blocking)
|
|
29
29
|
(0, version_1.checkForUpdates)().then((result) => {
|
|
30
30
|
if (result && result.hasUpdate) {
|
|
31
|
-
console.log(chalk_1.default.yellow(
|
|
32
|
-
console.log(chalk_1.default.
|
|
31
|
+
console.log(chalk_1.default.yellow.bold('\n╔════════════════════════════════════════╗'));
|
|
32
|
+
console.log(chalk_1.default.yellow.bold('║ 🚀 UPDATE AVAILABLE! ║'));
|
|
33
|
+
console.log(chalk_1.default.yellow.bold('╚════════════════════════════════════════╝'));
|
|
34
|
+
console.log(chalk_1.default.white(` Current: ${chalk_1.default.red(result.currentVersion)} → Latest: ${chalk_1.default.green(result.latestVersion)}`));
|
|
35
|
+
console.log(chalk_1.default.cyan(' Update now: ') + chalk_1.default.white('npm install -g @snapcommit/cli@latest\n'));
|
|
33
36
|
}
|
|
34
37
|
}).catch(() => {
|
|
35
38
|
// Silent fail
|
package/dist/repl.js
CHANGED
|
@@ -12,6 +12,7 @@ const quick_1 = require("./commands/quick");
|
|
|
12
12
|
const stats_1 = require("./commands/stats");
|
|
13
13
|
const github_connect_1 = require("./commands/github-connect");
|
|
14
14
|
const repo_manager_1 = require("./utils/repo-manager");
|
|
15
|
+
const version_1 = require("./utils/version");
|
|
15
16
|
/**
|
|
16
17
|
* Start SnapCommit REPL (Read-Eval-Print-Loop)
|
|
17
18
|
* Interactive mode for natural language Git commands
|
|
@@ -29,6 +30,18 @@ async function startREPL() {
|
|
|
29
30
|
process.exit(1);
|
|
30
31
|
}
|
|
31
32
|
console.log(chalk_1.default.green(`✅ Logged in as ${chalk_1.default.bold(authConfig.email)}\n`));
|
|
33
|
+
// Check for updates (non-blocking)
|
|
34
|
+
(0, version_1.checkForUpdates)().then(updateInfo => {
|
|
35
|
+
if (updateInfo && updateInfo.hasUpdate) {
|
|
36
|
+
console.log(chalk_1.default.yellow.bold('╔════════════════════════════════════════╗'));
|
|
37
|
+
console.log(chalk_1.default.yellow.bold('║ 🚀 UPDATE AVAILABLE! ║'));
|
|
38
|
+
console.log(chalk_1.default.yellow.bold('╚════════════════════════════════════════╝'));
|
|
39
|
+
console.log(chalk_1.default.white(` Current: ${chalk_1.default.red(updateInfo.currentVersion)} → Latest: ${chalk_1.default.green(updateInfo.latestVersion)}\n`));
|
|
40
|
+
console.log(chalk_1.default.cyan(' Update now: ') + chalk_1.default.white('npm install -g @snapcommit/cli@latest\n'));
|
|
41
|
+
}
|
|
42
|
+
}).catch(() => {
|
|
43
|
+
// Silent fail - don't interrupt user experience
|
|
44
|
+
});
|
|
32
45
|
// Check GitHub connection status
|
|
33
46
|
const githubConnected = (0, github_connect_1.isGitHubConnected)();
|
|
34
47
|
if (githubConnected) {
|
|
@@ -46,12 +59,16 @@ async function startREPL() {
|
|
|
46
59
|
console.log(chalk_1.default.gray(' • ') + chalk_1.default.white('Exit SnapCommit: ') + chalk_1.default.cyan('exit') + chalk_1.default.gray(' or ') + chalk_1.default.cyan('quit\n'));
|
|
47
60
|
// Show GitHub setup reminder if not connected
|
|
48
61
|
if (!githubConnected) {
|
|
49
|
-
console.log(chalk_1.default.yellow('
|
|
50
|
-
console.log(chalk_1.default.
|
|
51
|
-
console.log(chalk_1.default.
|
|
52
|
-
console.log(chalk_1.default.
|
|
53
|
-
console.log(chalk_1.default.
|
|
54
|
-
console.log(chalk_1.default.gray('
|
|
62
|
+
console.log(chalk_1.default.yellow.bold('┌─────────────────────────────────────────┐'));
|
|
63
|
+
console.log(chalk_1.default.yellow.bold('│ 💡 UNLOCK GITHUB FEATURES! │'));
|
|
64
|
+
console.log(chalk_1.default.yellow.bold('└─────────────────────────────────────────┘\n'));
|
|
65
|
+
console.log(chalk_1.default.white(' Create PRs, check CI, manage issues—all with natural language!\n'));
|
|
66
|
+
console.log(chalk_1.default.cyan.bold(' Quick Setup:'));
|
|
67
|
+
console.log(chalk_1.default.gray(' 1. Run: ') + chalk_1.default.cyan('snap github connect'));
|
|
68
|
+
console.log(chalk_1.default.gray(' 2. Get token: ') + chalk_1.default.cyan('https://github.com/settings/tokens'));
|
|
69
|
+
console.log(chalk_1.default.gray(' 3. Scopes needed: ') + chalk_1.default.white('repo, workflow, read:user'));
|
|
70
|
+
console.log(chalk_1.default.gray(' 4. Paste token when prompted'));
|
|
71
|
+
console.log(chalk_1.default.gray(' 💡 Tip: Set no expiration!\n'));
|
|
55
72
|
}
|
|
56
73
|
console.log(chalk_1.default.gray('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n'));
|
|
57
74
|
console.log(chalk_1.default.bold.yellow('🎯 Try it now! Type what you want to do:\n'));
|
package/dist/utils/version.js
CHANGED
|
@@ -33,7 +33,7 @@ async function checkForUpdates() {
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
// Fetch latest version from npm
|
|
36
|
-
const latestVersion = await getLatestVersionFromNpm('snapcommit');
|
|
36
|
+
const latestVersion = await getLatestVersionFromNpm('@snapcommit/cli');
|
|
37
37
|
// Update cache
|
|
38
38
|
const newCache = {
|
|
39
39
|
lastCheck: Date.now(),
|
|
@@ -53,7 +53,9 @@ async function checkForUpdates() {
|
|
|
53
53
|
}
|
|
54
54
|
function getLatestVersionFromNpm(packageName) {
|
|
55
55
|
return new Promise((resolve, reject) => {
|
|
56
|
-
|
|
56
|
+
// Encode package name for URL (handles scoped packages like @snapcommit/cli)
|
|
57
|
+
const encodedName = packageName.replace('/', '%2F');
|
|
58
|
+
https_1.default.get(`https://registry.npmjs.org/${encodedName}/latest`, (res) => {
|
|
57
59
|
let data = '';
|
|
58
60
|
res.on('data', (chunk) => data += chunk);
|
|
59
61
|
res.on('end', () => {
|