@taj-special/dravix-code 1.1.4 → 1.1.5
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 +0 -89
- package/dist/services/ai.js +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -184,83 +184,6 @@ async function browserAuth() {
|
|
|
184
184
|
}, 300_000);
|
|
185
185
|
});
|
|
186
186
|
}
|
|
187
|
-
async function checkForUpdate() {
|
|
188
|
-
try {
|
|
189
|
-
const res = await fetch('https://registry.npmjs.org/@taj-special/dravix-code/latest', {
|
|
190
|
-
signal: AbortSignal.timeout(5000),
|
|
191
|
-
});
|
|
192
|
-
const data = await res.json();
|
|
193
|
-
const latest = data.version ?? '';
|
|
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
|
-
}
|
|
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;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
187
|
async function main() {
|
|
265
188
|
// Ensure UTF-8 output on Windows
|
|
266
189
|
if (process.platform === 'win32') {
|
|
@@ -270,8 +193,6 @@ async function main() {
|
|
|
270
193
|
catch { }
|
|
271
194
|
}
|
|
272
195
|
const arg = process.argv[2];
|
|
273
|
-
// Start version check in background immediately — result awaited after banner
|
|
274
|
-
const updatePromise = checkForUpdate();
|
|
275
196
|
if (arg === '--help' || arg === '-h') {
|
|
276
197
|
banner();
|
|
277
198
|
printHelp();
|
|
@@ -297,16 +218,6 @@ async function main() {
|
|
|
297
218
|
else {
|
|
298
219
|
banner();
|
|
299
220
|
}
|
|
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
|
-
}
|
|
310
221
|
const { name, email } = getSavedUser();
|
|
311
222
|
const cwd = (arg && !arg.startsWith('--')) ? path.resolve(arg) : process.cwd();
|
|
312
223
|
// 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.5',
|
|
64
64
|
},
|
|
65
65
|
body: JSON.stringify({
|
|
66
66
|
provider: 'openrouter',
|