@snapcommit/cli 2.0.2 → 2.0.4

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.
@@ -10,7 +10,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.executeCursorStyle = executeCursorStyle;
11
11
  const chalk_1 = __importDefault(require("chalk"));
12
12
  const child_process_1 = require("child_process");
13
- const readline_1 = __importDefault(require("readline"));
14
13
  const git_1 = require("../utils/git");
15
14
  const auth_1 = require("../lib/auth");
16
15
  async function executeCursorStyle(userInput) {
@@ -142,8 +141,10 @@ async function getChangeDiff() {
142
141
  }
143
142
  async function generateCommitMessage(diff) {
144
143
  const token = (0, auth_1.getToken)();
145
- if (!token)
144
+ if (!token) {
145
+ console.log(chalk_1.default.yellow('⚠️ No auth token - using default message'));
146
146
  return 'Update changes';
147
+ }
147
148
  try {
148
149
  // Truncate large diffs
149
150
  if (diff.length > 40000) {
@@ -154,10 +155,19 @@ async function generateCommitMessage(diff) {
154
155
  headers: { 'Content-Type': 'application/json' },
155
156
  body: JSON.stringify({ diff, token }),
156
157
  });
158
+ if (!response.ok) {
159
+ console.log(chalk_1.default.yellow(`⚠️ AI request failed (${response.status}) - using default message`));
160
+ return 'Update changes';
161
+ }
157
162
  const data = await response.json();
163
+ if (data.error) {
164
+ console.log(chalk_1.default.yellow(`⚠️ AI error: ${data.error} - using default message`));
165
+ return 'Update changes';
166
+ }
158
167
  return data.message || 'Update changes';
159
168
  }
160
- catch {
169
+ catch (error) {
170
+ console.log(chalk_1.default.yellow(`⚠️ Network error: ${error.message} - using default message`));
161
171
  return 'Update changes';
162
172
  }
163
173
  }
@@ -277,15 +287,17 @@ async function tryAutoFix(error, action) {
277
287
  return false;
278
288
  }
279
289
  function askQuestion(query) {
280
- const rl = readline_1.default.createInterface({
281
- input: process.stdin,
282
- output: process.stdout,
283
- });
284
290
  return new Promise((resolve) => {
285
- rl.question(query, (answer) => {
286
- rl.close();
287
- resolve(answer);
288
- });
291
+ process.stdout.write(query);
292
+ process.stdin.setRawMode(false);
293
+ process.stdin.resume();
294
+ process.stdin.setEncoding('utf8');
295
+ const onData = (data) => {
296
+ process.stdin.removeListener('data', onData);
297
+ process.stdin.pause();
298
+ resolve(data.toString().trim());
299
+ };
300
+ process.stdin.once('data', onData);
289
301
  });
290
302
  }
291
303
  async function editMessage(originalMessage) {
@@ -12,7 +12,7 @@ const fs_1 = __importDefault(require("fs"));
12
12
  const path_1 = __importDefault(require("path"));
13
13
  const os_1 = __importDefault(require("os"));
14
14
  const CACHE_FILE = path_1.default.join(os_1.default.homedir(), '.snapcommit', 'version-cache.json');
15
- const CHECK_INTERVAL = 24 * 60 * 60 * 1000; // 24 hours
15
+ const CHECK_INTERVAL = 1 * 60 * 60 * 1000; // 1 hour (check more frequently during active development)
16
16
  async function checkForUpdates() {
17
17
  try {
18
18
  // Read current version from package.json
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snapcommit/cli",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "Instant AI commits. Beautiful progress tracking. Never write commit messages again.",
5
5
  "main": "dist/index.js",
6
6
  "bin": {