@taj-special/dravix-code 1.1.3 → 1.1.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.
- package/dist/cli/index.js +80 -11
- package/dist/services/ai.js +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -184,23 +184,82 @@ async function browserAuth() {
|
|
|
184
184
|
}, 300_000);
|
|
185
185
|
});
|
|
186
186
|
}
|
|
187
|
-
async function
|
|
187
|
+
async function checkForUpdate() {
|
|
188
188
|
try {
|
|
189
189
|
const res = await fetch('https://registry.npmjs.org/@taj-special/dravix-code/latest', {
|
|
190
190
|
signal: AbortSignal.timeout(5000),
|
|
191
191
|
});
|
|
192
192
|
const data = await res.json();
|
|
193
193
|
const latest = data.version ?? '';
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
194
|
+
return (latest && latest !== VERSION) ? latest : '';
|
|
195
|
+
}
|
|
196
|
+
catch {
|
|
197
|
+
return '';
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
async function promptUpdate(latest) {
|
|
201
|
+
const Y = chalk.hex('#fcd34d');
|
|
202
|
+
const W = chalk.hex('#e2e8f0');
|
|
203
|
+
const DIM = chalk.hex('#4b5563');
|
|
204
|
+
const P = chalk.hex('#818cf8');
|
|
205
|
+
console.log('\n ' + Y('⬆') + ' ' + W.bold('Update available') + ' ' + DIM(`v${VERSION}`) + DIM(' → ') + P.bold(`v${latest}`));
|
|
206
|
+
console.log(' ' + DIM('─'.repeat(45)));
|
|
207
|
+
const enterKey = chalk.bgHex('#312e81').hex('#c7d2fe').bold(' Enter ');
|
|
208
|
+
const escKey = chalk.hex('#374151').bold(' Esc ');
|
|
209
|
+
console.log('\n ' + enterKey + W(' Update now and restart'));
|
|
210
|
+
console.log(' ' + escKey + colors.muted(' Skip for now') + '\n');
|
|
211
|
+
return new Promise((resolve) => {
|
|
212
|
+
process.stdin.setRawMode(true);
|
|
213
|
+
process.stdin.resume();
|
|
214
|
+
process.stdin.setEncoding('utf8');
|
|
215
|
+
function onKey(data) {
|
|
216
|
+
if (data === '\r' || data === '\n' || data === 'y' || data === 'Y') {
|
|
217
|
+
cleanup();
|
|
218
|
+
resolve(true);
|
|
219
|
+
}
|
|
220
|
+
else if (data === '\x1b' || data === '\x03' || data === 'n' || data === 'N') {
|
|
221
|
+
cleanup();
|
|
222
|
+
resolve(false);
|
|
223
|
+
}
|
|
201
224
|
}
|
|
225
|
+
function cleanup() {
|
|
226
|
+
process.stdin.removeListener('data', onKey);
|
|
227
|
+
process.stdin.setRawMode(false);
|
|
228
|
+
process.stdin.pause();
|
|
229
|
+
}
|
|
230
|
+
process.stdin.on('data', onKey);
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
async function runUpdate() {
|
|
234
|
+
const W = chalk.hex('#e2e8f0');
|
|
235
|
+
const DIM = chalk.hex('#4b5563');
|
|
236
|
+
const G = chalk.hex('#34d399');
|
|
237
|
+
let frameIdx = 0;
|
|
238
|
+
let done = false;
|
|
239
|
+
const spinner = setInterval(() => {
|
|
240
|
+
if (done)
|
|
241
|
+
return;
|
|
242
|
+
process.stdout.write(`\r ${colors.muted(SPINNER[frameIdx % SPINNER.length])} ${colors.muted('Installing update...')}`);
|
|
243
|
+
frameIdx++;
|
|
244
|
+
}, 80);
|
|
245
|
+
try {
|
|
246
|
+
execSync('npm install -g @taj-special/dravix-code', { stdio: 'pipe' });
|
|
247
|
+
done = true;
|
|
248
|
+
clearInterval(spinner);
|
|
249
|
+
process.stdout.write('\r\x1b[K');
|
|
250
|
+
console.log(' ' + G('✓') + ' ' + W.bold('Updated successfully!'));
|
|
251
|
+
console.log(' ' + DIM('Run dravix again to start with the new version.') + '\n');
|
|
252
|
+
return true;
|
|
253
|
+
}
|
|
254
|
+
catch (e) {
|
|
255
|
+
done = true;
|
|
256
|
+
clearInterval(spinner);
|
|
257
|
+
process.stdout.write('\r\x1b[K');
|
|
258
|
+
const msg = e instanceof Error ? e.message.split('\n')[0] : String(e);
|
|
259
|
+
console.log(' ' + colors.error('✗') + ' ' + W('Update failed: ') + colors.muted(msg));
|
|
260
|
+
console.log(' ' + DIM('Run manually: npm install -g @taj-special/dravix-code') + '\n');
|
|
261
|
+
return false;
|
|
202
262
|
}
|
|
203
|
-
catch { /* ignore network errors */ }
|
|
204
263
|
}
|
|
205
264
|
async function main() {
|
|
206
265
|
// Ensure UTF-8 output on Windows
|
|
@@ -211,8 +270,8 @@ async function main() {
|
|
|
211
270
|
catch { }
|
|
212
271
|
}
|
|
213
272
|
const arg = process.argv[2];
|
|
214
|
-
//
|
|
215
|
-
|
|
273
|
+
// Start version check in background immediately — result awaited after banner
|
|
274
|
+
const updatePromise = checkForUpdate();
|
|
216
275
|
if (arg === '--help' || arg === '-h') {
|
|
217
276
|
banner();
|
|
218
277
|
printHelp();
|
|
@@ -238,6 +297,16 @@ async function main() {
|
|
|
238
297
|
else {
|
|
239
298
|
banner();
|
|
240
299
|
}
|
|
300
|
+
// Check update result (network already in flight — usually instant by now)
|
|
301
|
+
const latestVersion = await updatePromise.catch(() => '');
|
|
302
|
+
if (latestVersion) {
|
|
303
|
+
const shouldUpdate = await promptUpdate(latestVersion);
|
|
304
|
+
if (shouldUpdate) {
|
|
305
|
+
const ok = await runUpdate();
|
|
306
|
+
if (ok)
|
|
307
|
+
process.exit(0);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
241
310
|
const { name, email } = getSavedUser();
|
|
242
311
|
const cwd = (arg && !arg.startsWith('--')) ? path.resolve(arg) : process.cwd();
|
|
243
312
|
// Fetch plan + usage in parallel
|
package/dist/services/ai.js
CHANGED
|
@@ -60,7 +60,7 @@ async function doSingleRequest(messages, token, abort, onChunk) {
|
|
|
60
60
|
headers: {
|
|
61
61
|
'Content-Type': 'application/json',
|
|
62
62
|
'X-CLI-Token': token,
|
|
63
|
-
'X-CLI-Version': '1.1.
|
|
63
|
+
'X-CLI-Version': '1.1.4',
|
|
64
64
|
},
|
|
65
65
|
body: JSON.stringify({
|
|
66
66
|
provider: 'openrouter',
|