tokentracker-cli 0.79.9 → 0.80.1
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/dashboard/dist/assets/{AchievementBadge-B1WOPlu0.js → AchievementBadge-D617bvS9.js} +1 -1
- package/dashboard/dist/assets/{AchievementsPage-9kHEQicS.js → AchievementsPage-mzE76Ah9.js} +2 -2
- package/dashboard/dist/assets/{AchievementsSection-Dw05PYPr.js → AchievementsSection-8CYGBoPJ.js} +1 -1
- package/dashboard/dist/assets/{BadgeDetailModal-DaWgiijJ.js → BadgeDetailModal-DM3veVmW.js} +1 -1
- package/dashboard/dist/assets/{Card-DYhrLLM4.js → Card-DWONuizy.js} +1 -1
- package/dashboard/dist/assets/{ClawdAnimated-BLy2LUKz.js → ClawdAnimated-CGQXyWuH.js} +1 -1
- package/dashboard/dist/assets/{CommunityStatsModal-CWYqfht3.js → CommunityStatsModal-B5yDmJ0o.js} +1 -1
- package/dashboard/dist/assets/{ConfirmModal-DcE2C24Y.js → ConfirmModal-d4wpsMPW.js} +1 -1
- package/dashboard/dist/assets/{Controls-CI7qw0-b.js → Controls-CMSqknaB.js} +1 -1
- package/dashboard/dist/assets/{DashboardPage-CAlgaBa7.js → DashboardPage-Cw6lmVSg.js} +1 -1
- package/dashboard/dist/assets/{DevicePage-DinOyaeN.js → DevicePage-CsPSjSLH.js} +1 -1
- package/dashboard/dist/assets/{DialogClose-CjfSDrLo.js → DialogClose-Cbs-z783.js} +1 -1
- package/dashboard/dist/assets/DialogDescription-B0fmBJxQ.js +1 -0
- package/dashboard/dist/assets/{DialogTitle-f7gNmCca.js → DialogTitle-C4mJiIQW.js} +1 -1
- package/dashboard/dist/assets/{FadeIn-D_5w0Qh0.js → FadeIn-xOJwCmZ8.js} +1 -1
- package/dashboard/dist/assets/{HeaderGithubStar-DTZyNKyL.js → HeaderGithubStar-oRz4rfC8.js} +1 -1
- package/dashboard/dist/assets/{IpCheckPage-D8CViF98.js → IpCheckPage-CTwL-Zmz.js} +1 -1
- package/dashboard/dist/assets/{LandingPage-CqN5KEjV.js → LandingPage-CqYJ3sZh.js} +1 -1
- package/dashboard/dist/assets/{LeaderboardAvatar-CwUVO4wn.js → LeaderboardAvatar-CuF6Kzkj.js} +1 -1
- package/dashboard/dist/assets/{LeaderboardPage-B12HJ9LA.js → LeaderboardPage-BvOPIj-b.js} +2 -2
- package/dashboard/dist/assets/{LeaderboardProfileModal-DFzPpsnV.js → LeaderboardProfileModal-DVXuKkRN.js} +3 -3
- package/dashboard/dist/assets/{LeaderboardProfilePage-Z0ZYpNFd.js → LeaderboardProfilePage-RE1CPqzM.js} +1 -1
- package/dashboard/dist/assets/{LimitsPage-BpwioIa-.js → LimitsPage-BovkRgac.js} +1 -1
- package/dashboard/dist/assets/{LocalOnlyNotice-Covi6zdt.js → LocalOnlyNotice-CTFFU_ip.js} +1 -1
- package/dashboard/dist/assets/{LoginPage-CRqbhwCx.js → LoginPage-mguBCTBZ.js} +1 -1
- package/dashboard/dist/assets/{PetPage-BY_yObVj.js → PetPage-C5KLH6Fm.js} +1 -1
- package/dashboard/dist/assets/{PopoverPopup-B2dE3Ary.js → PopoverPopup-CLDh5yIk.js} +1 -1
- package/dashboard/dist/assets/{ResetPasswordPage-C8IEJbVc.js → ResetPasswordPage-DnhgHQrV.js} +1 -1
- package/dashboard/dist/assets/{Select-BmRLYSqA.js → Select-DPSaPIlz.js} +1 -1
- package/dashboard/dist/assets/{SelectItemText-FC46bk8b.js → SelectItemText-jIBbXpqi.js} +1 -1
- package/dashboard/dist/assets/{SettingsPage-DipzOQVg.js → SettingsPage-BK0IqSjg.js} +1 -1
- package/dashboard/dist/assets/{SkillsPage-CziypUTf.js → SkillsPage-BQNoMpL2.js} +1 -1
- package/dashboard/dist/assets/{WidgetsPage-CJegJhVR.js → WidgetsPage-308d8icu.js} +1 -1
- package/dashboard/dist/assets/{WrappedPage-DcMiKvzf.js → WrappedPage-T720sQ9S.js} +1 -1
- package/dashboard/dist/assets/{agent-logos-S7bF1LwW.js → agent-logos-Blo5C96d.js} +1 -1
- package/dashboard/dist/assets/{arrow-up-right-D0yeL56y.js → arrow-up-right-DKz2Ua6U.js} +1 -1
- package/dashboard/dist/assets/check-fF6lQGN-.js +1 -0
- package/dashboard/dist/assets/{copy-D-z9ZtIu.js → copy-DcUFG0PD.js} +1 -1
- package/dashboard/dist/assets/{download-Dwxnd3QG.js → download-CNK1wtxV.js} +1 -1
- package/dashboard/dist/assets/{flame-Bdqk9A75.js → flame-BEhJZRaZ.js} +1 -1
- package/dashboard/dist/assets/{format-tokens-DNVcCRwm.js → format-tokens-Bsfbd8nj.js} +1 -1
- package/dashboard/dist/assets/{info-CMLT6oUI.js → info-DRJLv-aV.js} +1 -1
- package/dashboard/dist/assets/{link-2-BmiHu726.js → link-2-C0GdaANY.js} +1 -1
- package/dashboard/dist/assets/{loader-circle-CXVUQtzm.js → loader-circle-F9ymYeor.js} +1 -1
- package/dashboard/dist/assets/{main-B9m79io-.js → main-CThKxvKx.js} +3 -3
- package/dashboard/dist/assets/{provider-display-BoAesdke.js → provider-display-D4NdFjHN.js} +1 -1
- package/dashboard/dist/assets/{trash-2-C9Rh2DAL.js → trash-2-D9vulGMW.js} +1 -1
- package/dashboard/dist/assets/{use-community-stats-aZwYxrXR.js → use-community-stats-BU4dXEOM.js} +1 -1
- package/dashboard/dist/assets/{use-limits-display-prefs-tJKR83RT.js → use-limits-display-prefs-Bx2VJhwl.js} +1 -1
- package/dashboard/dist/assets/{use-native-settings-PjfJPK5v.js → use-native-settings-BSXaxaTC.js} +1 -1
- package/dashboard/dist/assets/{use-ordered-list-D1QFmZUY.js → use-ordered-list-OA0HwwEL.js} +1 -1
- package/dashboard/dist/assets/{use-quality-per-dollar-pref-4N3Su4wC.js → use-quality-per-dollar-pref-Bqooc4FA.js} +1 -1
- package/dashboard/dist/assets/{use-transform-D9nurInL.js → use-transform-CZ9FdRGw.js} +1 -1
- package/dashboard/dist/assets/{use-usage-limits-DapTpi_6.js → use-usage-limits-Ct_A4wTr.js} +1 -1
- package/dashboard/dist/assets/{useCurrency-B0DH9ZZA.js → useCurrency-D4bvdaFB.js} +1 -1
- package/dashboard/dist/assets/{useScrollLock-DijV6DYS.js → useScrollLock-ZsWO-GoL.js} +1 -1
- package/dashboard/dist/assets/useTokenFormat-B3huMEws.js +1 -0
- package/dashboard/dist/assets/{zap-BVfhR3Ck.js → zap-C9Mp-GNU.js} +1 -1
- package/dashboard/dist/index.html +1 -1
- package/dashboard/dist/share.html +1 -1
- package/package.json +1 -1
- package/src/commands/init.js +607 -6
- package/src/commands/sync.js +176 -7
- package/src/lib/codex-config.js +135 -40
- package/src/lib/codex-context-breakdown.js +123 -43
- package/src/lib/codex-rollout-parser.js +329 -32
- package/src/lib/local-api.js +11 -5
- package/src/lib/openclaw-session-plugin.js +13 -0
- package/src/lib/pricing/seed-snapshot.json +1 -1
- package/src/lib/rollout.js +230 -10
- package/src/lib/usage-limits.js +9 -5
- package/dashboard/dist/assets/DialogDescription-DWs-KIUA.js +0 -1
- package/dashboard/dist/assets/check-Dn9BLYEf.js +0 -1
- package/dashboard/dist/assets/useTokenFormat-nxdG6gi9.js +0 -1
package/src/commands/init.js
CHANGED
|
@@ -1232,10 +1232,12 @@ function spawnDetached(argv) {
|
|
|
1232
1232
|
} catch (_) {}
|
|
1233
1233
|
}
|
|
1234
1234
|
|
|
1235
|
-
function resolveMaybeHome(p) {
|
|
1235
|
+
function resolveMaybeHome(p, baseDir = null) {
|
|
1236
1236
|
if (typeof p !== 'string') return null;
|
|
1237
1237
|
if (p.startsWith('~/')) return path.join(home, p.slice(2));
|
|
1238
|
-
return path.
|
|
1238
|
+
if (p.startsWith('~\\\\')) return path.join(home, p.slice(2));
|
|
1239
|
+
if (path.isAbsolute(p)) return p;
|
|
1240
|
+
return path.resolve(baseDir || process.cwd(), p);
|
|
1239
1241
|
}
|
|
1240
1242
|
|
|
1241
1243
|
function isSelfNotify(cmd) {
|
|
@@ -1266,14 +1268,15 @@ function isSelfNotifyPath(resolved) {
|
|
|
1266
1268
|
|
|
1267
1269
|
function shouldChainNotify(cmd) {
|
|
1268
1270
|
if (!Array.isArray(cmd) || cmd.length === 0) return false;
|
|
1269
|
-
|
|
1271
|
+
if (!isRunnableCommand(cmd[0])) return false;
|
|
1272
|
+
return hasRunnableInterpreterTarget(cmd);
|
|
1270
1273
|
}
|
|
1271
1274
|
|
|
1272
|
-
function isRunnableCommand(command) {
|
|
1275
|
+
function isRunnableCommand(command, baseDir = null) {
|
|
1273
1276
|
if (typeof command !== 'string' || command.length === 0) return false;
|
|
1274
|
-
const explicitPath =
|
|
1277
|
+
const explicitPath = isExplicitPath(command);
|
|
1275
1278
|
if (!explicitPath) return true;
|
|
1276
|
-
const resolved = resolveMaybeHome(command);
|
|
1279
|
+
const resolved = resolveMaybeHome(command, baseDir);
|
|
1277
1280
|
if (!resolved) return false;
|
|
1278
1281
|
try {
|
|
1279
1282
|
fs.accessSync(resolved, fs.constants.X_OK);
|
|
@@ -1283,6 +1286,593 @@ function isRunnableCommand(command) {
|
|
|
1283
1286
|
}
|
|
1284
1287
|
}
|
|
1285
1288
|
|
|
1289
|
+
function hasRunnableInterpreterTarget(cmd) {
|
|
1290
|
+
const normalized = normalizeInterpreterCommand(cmd);
|
|
1291
|
+
const interpreterCmd = normalized?.cmd;
|
|
1292
|
+
if (!interpreterCmd || interpreterCmd.length === 0) return false;
|
|
1293
|
+
const targetIndex = findInterpreterTargetIndex(interpreterCmd);
|
|
1294
|
+
if (targetIndex == null) {
|
|
1295
|
+
const command = interpreterCmd[0];
|
|
1296
|
+
if (!isExplicitPath(command)) return true;
|
|
1297
|
+
return isRunnableCommand(command, normalized.cwd);
|
|
1298
|
+
}
|
|
1299
|
+
if (targetIndex === -2) return true;
|
|
1300
|
+
if (targetIndex === -1) return false;
|
|
1301
|
+
const target = interpreterCmd[targetIndex];
|
|
1302
|
+
if (!isExplicitPath(target)) return false;
|
|
1303
|
+
const targetCwd = isBunCommand(interpreterCmd[0])
|
|
1304
|
+
? findBunScriptCwd(interpreterCmd, 1, normalized.cwd)
|
|
1305
|
+
: normalized.cwd;
|
|
1306
|
+
return isReadablePath(target, targetCwd);
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1309
|
+
function normalizeInterpreterCommand(cmd) {
|
|
1310
|
+
if (!isEnvCommand(cmd[0])) return { cmd, cwd: null };
|
|
1311
|
+
return extractEnvCommand(cmd);
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1314
|
+
function findInterpreterTargetIndex(cmd) {
|
|
1315
|
+
const command = cmd[0];
|
|
1316
|
+
if (isNodeCommand(command)) {
|
|
1317
|
+
return findNodeLikeScriptIndex(cmd, 1);
|
|
1318
|
+
}
|
|
1319
|
+
if (isBunCommand(command)) {
|
|
1320
|
+
return findBunScriptIndex(cmd, 1);
|
|
1321
|
+
}
|
|
1322
|
+
if (isDenoCommand(command)) {
|
|
1323
|
+
return findDenoScriptIndex(cmd, 1);
|
|
1324
|
+
}
|
|
1325
|
+
return null;
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
function isEnvCommand(command) {
|
|
1329
|
+
const base = commandBase(command);
|
|
1330
|
+
return base === 'env';
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1333
|
+
function extractEnvCommand(cmd) {
|
|
1334
|
+
return normalizeEnvArgs(cmd.slice(1));
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1337
|
+
function normalizeEnvArgs(args, cwd = null) {
|
|
1338
|
+
for (let i = 0; i < args.length; i++) {
|
|
1339
|
+
const arg = args[i];
|
|
1340
|
+
if (typeof arg !== 'string' || arg.length === 0) return null;
|
|
1341
|
+
if (arg === '-' || arg === '--ignore-environment' || isEnvValuelessShortOption(arg)) continue;
|
|
1342
|
+
if (arg === '--') return normalizeEnvCommandOperands(args.slice(i + 1), cwd);
|
|
1343
|
+
if (arg === '-S' || arg === '--split-string') {
|
|
1344
|
+
const split = splitEnvString(args[i + 1]);
|
|
1345
|
+
if (!split) return null;
|
|
1346
|
+
return normalizeEnvArgs(split.concat(args.slice(i + 2)), cwd);
|
|
1347
|
+
}
|
|
1348
|
+
if (arg.startsWith('--split-string=')) {
|
|
1349
|
+
const split = splitEnvString(arg.slice('--split-string='.length));
|
|
1350
|
+
if (!split) return null;
|
|
1351
|
+
return normalizeEnvArgs(split.concat(args.slice(i + 1)), cwd);
|
|
1352
|
+
}
|
|
1353
|
+
if (arg === '-u' || arg === '--unset') {
|
|
1354
|
+
i += 1;
|
|
1355
|
+
continue;
|
|
1356
|
+
}
|
|
1357
|
+
if (arg.startsWith('--unset=')) continue;
|
|
1358
|
+
if (arg === '-C' || arg === '--chdir') {
|
|
1359
|
+
const next = args[i + 1];
|
|
1360
|
+
if (typeof next !== 'string' || next.length === 0) return null;
|
|
1361
|
+
cwd = resolveMaybeHome(next, cwd);
|
|
1362
|
+
i += 1;
|
|
1363
|
+
continue;
|
|
1364
|
+
}
|
|
1365
|
+
if (arg.startsWith('--chdir=')) {
|
|
1366
|
+
const dir = arg.slice('--chdir='.length);
|
|
1367
|
+
if (dir.length === 0) return null;
|
|
1368
|
+
cwd = resolveMaybeHome(dir, cwd);
|
|
1369
|
+
continue;
|
|
1370
|
+
}
|
|
1371
|
+
if (isEnvValueOption(arg)) {
|
|
1372
|
+
i += 1;
|
|
1373
|
+
continue;
|
|
1374
|
+
}
|
|
1375
|
+
if (isEnvInlineValueOption(arg)) continue;
|
|
1376
|
+
if (arg.startsWith('-')) return null;
|
|
1377
|
+
if (/^[A-Za-z_][A-Za-z0-9_]*=/.test(arg)) continue;
|
|
1378
|
+
return { cmd: args.slice(i), cwd };
|
|
1379
|
+
}
|
|
1380
|
+
return null;
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1383
|
+
function normalizeEnvCommandOperands(args, cwd) {
|
|
1384
|
+
for (let i = 0; i < args.length; i++) {
|
|
1385
|
+
const arg = args[i];
|
|
1386
|
+
if (typeof arg !== 'string' || arg.length === 0) return null;
|
|
1387
|
+
if (/^[A-Za-z_][A-Za-z0-9_]*=/.test(arg)) continue;
|
|
1388
|
+
if (arg.startsWith('-')) return null;
|
|
1389
|
+
return { cmd: args.slice(i), cwd };
|
|
1390
|
+
}
|
|
1391
|
+
return null;
|
|
1392
|
+
}
|
|
1393
|
+
|
|
1394
|
+
function isEnvValuelessShortOption(arg) {
|
|
1395
|
+
return /^-[0iv]+$/.test(arg);
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
function isEnvValueOption(arg) {
|
|
1399
|
+
return arg === '-P' || arg === '--path';
|
|
1400
|
+
}
|
|
1401
|
+
|
|
1402
|
+
function isEnvInlineValueOption(arg) {
|
|
1403
|
+
return (
|
|
1404
|
+
arg.startsWith('--path=')
|
|
1405
|
+
);
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
function splitEnvString(value) {
|
|
1409
|
+
if (typeof value !== 'string' || value.length === 0) return null;
|
|
1410
|
+
const parts = [];
|
|
1411
|
+
let current = '';
|
|
1412
|
+
let quote = null;
|
|
1413
|
+
let escaped = false;
|
|
1414
|
+
for (let i = 0; i < value.length; i++) {
|
|
1415
|
+
const ch = value[i];
|
|
1416
|
+
if (escaped) {
|
|
1417
|
+
current += ch;
|
|
1418
|
+
escaped = false;
|
|
1419
|
+
continue;
|
|
1420
|
+
}
|
|
1421
|
+
if (ch === '\\\\' && quote !== "'") {
|
|
1422
|
+
escaped = true;
|
|
1423
|
+
continue;
|
|
1424
|
+
}
|
|
1425
|
+
if (quote) {
|
|
1426
|
+
if (ch === quote) quote = null;
|
|
1427
|
+
else current += ch;
|
|
1428
|
+
continue;
|
|
1429
|
+
}
|
|
1430
|
+
if (ch === '"' || ch === "'") {
|
|
1431
|
+
quote = ch;
|
|
1432
|
+
continue;
|
|
1433
|
+
}
|
|
1434
|
+
if (/\\s/.test(ch)) {
|
|
1435
|
+
if (current.length > 0) {
|
|
1436
|
+
parts.push(current);
|
|
1437
|
+
current = '';
|
|
1438
|
+
}
|
|
1439
|
+
continue;
|
|
1440
|
+
}
|
|
1441
|
+
current += ch;
|
|
1442
|
+
}
|
|
1443
|
+
if (escaped || quote) return null;
|
|
1444
|
+
if (current.length > 0) parts.push(current);
|
|
1445
|
+
return parts.length > 0 ? parts : null;
|
|
1446
|
+
}
|
|
1447
|
+
|
|
1448
|
+
function isNodeCommand(command) {
|
|
1449
|
+
const base = commandBase(command);
|
|
1450
|
+
return base === 'node';
|
|
1451
|
+
}
|
|
1452
|
+
|
|
1453
|
+
function isBunCommand(command) {
|
|
1454
|
+
const base = commandBase(command);
|
|
1455
|
+
return base === 'bun';
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1458
|
+
function isDenoCommand(command) {
|
|
1459
|
+
const base = commandBase(command);
|
|
1460
|
+
return base === 'deno';
|
|
1461
|
+
}
|
|
1462
|
+
|
|
1463
|
+
function commandBase(command) {
|
|
1464
|
+
if (typeof command !== 'string' || command.length === 0) return '';
|
|
1465
|
+
const posixBase = path.basename(command);
|
|
1466
|
+
const winBase = path.win32.basename(command);
|
|
1467
|
+
const base = winBase.length < posixBase.length ? winBase : posixBase;
|
|
1468
|
+
return base.replace(/\\.exe$/i, '').toLowerCase();
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1471
|
+
function findNodeLikeScriptIndex(cmd, startIndex) {
|
|
1472
|
+
for (let i = startIndex; i < cmd.length; i++) {
|
|
1473
|
+
const arg = cmd[i];
|
|
1474
|
+
if (typeof arg !== 'string' || arg.length === 0) return -1;
|
|
1475
|
+
if (arg === '-e' || arg === '--eval' || arg === '-p' || arg === '--print') return -2;
|
|
1476
|
+
if (arg.startsWith('--eval=') || arg.startsWith('--print=')) return -2;
|
|
1477
|
+
if (isNodeLikeOptionWithValue(arg)) {
|
|
1478
|
+
i += 1;
|
|
1479
|
+
continue;
|
|
1480
|
+
}
|
|
1481
|
+
if (hasInlineNodeLikeOptionValue(arg)) continue;
|
|
1482
|
+
if (isNodeLikeValuelessOption(arg)) continue;
|
|
1483
|
+
if (arg.startsWith('-')) return -1;
|
|
1484
|
+
return i;
|
|
1485
|
+
}
|
|
1486
|
+
return -1;
|
|
1487
|
+
}
|
|
1488
|
+
|
|
1489
|
+
function findBunScriptIndex(cmd, startIndex) {
|
|
1490
|
+
for (let i = startIndex; i < cmd.length; i++) {
|
|
1491
|
+
const arg = cmd[i];
|
|
1492
|
+
if (typeof arg !== 'string' || arg.length === 0) return -1;
|
|
1493
|
+
if (arg === '-e' || arg === '--eval' || arg === '-p' || arg === '--print') return -2;
|
|
1494
|
+
if (arg.startsWith('--eval=') || arg.startsWith('--print=')) return -2;
|
|
1495
|
+
if (isBunOptionWithValue(arg)) {
|
|
1496
|
+
i += 1;
|
|
1497
|
+
continue;
|
|
1498
|
+
}
|
|
1499
|
+
if (hasInlineBunOptionValue(arg)) continue;
|
|
1500
|
+
if (isBunValuelessOption(arg)) continue;
|
|
1501
|
+
if (arg === 'run') {
|
|
1502
|
+
return findScriptAfterSubcommand(cmd, i + 1, 'bun');
|
|
1503
|
+
}
|
|
1504
|
+
if (arg.startsWith('-')) return -1;
|
|
1505
|
+
return i;
|
|
1506
|
+
}
|
|
1507
|
+
return -1;
|
|
1508
|
+
}
|
|
1509
|
+
|
|
1510
|
+
function findBunScriptCwd(cmd, startIndex, baseDir = null) {
|
|
1511
|
+
let cwd = baseDir;
|
|
1512
|
+
for (let i = startIndex; i < cmd.length; i++) {
|
|
1513
|
+
const arg = cmd[i];
|
|
1514
|
+
if (typeof arg !== 'string' || arg.length === 0) return cwd;
|
|
1515
|
+
if (arg === '--cwd') {
|
|
1516
|
+
const next = cmd[i + 1];
|
|
1517
|
+
if (typeof next !== 'string' || next.length === 0) return cwd;
|
|
1518
|
+
cwd = resolveMaybeHome(next, cwd);
|
|
1519
|
+
i += 1;
|
|
1520
|
+
continue;
|
|
1521
|
+
}
|
|
1522
|
+
if (arg.startsWith('--cwd=')) {
|
|
1523
|
+
const next = arg.slice('--cwd='.length);
|
|
1524
|
+
if (next.length === 0) return cwd;
|
|
1525
|
+
cwd = resolveMaybeHome(next, cwd);
|
|
1526
|
+
continue;
|
|
1527
|
+
}
|
|
1528
|
+
if (arg === '-e' || arg === '--eval' || arg === '-p' || arg === '--print') return cwd;
|
|
1529
|
+
if (arg.startsWith('--eval=') || arg.startsWith('--print=')) return cwd;
|
|
1530
|
+
if (isBunOptionWithValue(arg)) {
|
|
1531
|
+
i += 1;
|
|
1532
|
+
continue;
|
|
1533
|
+
}
|
|
1534
|
+
if (hasInlineBunOptionValue(arg)) continue;
|
|
1535
|
+
if (isBunValuelessOption(arg)) continue;
|
|
1536
|
+
if (arg === 'run') return findBunScriptCwd(cmd, i + 1, cwd);
|
|
1537
|
+
return cwd;
|
|
1538
|
+
}
|
|
1539
|
+
return cwd;
|
|
1540
|
+
}
|
|
1541
|
+
|
|
1542
|
+
function findDenoScriptIndex(cmd, startIndex) {
|
|
1543
|
+
for (let i = startIndex; i < cmd.length; i++) {
|
|
1544
|
+
const arg = cmd[i];
|
|
1545
|
+
if (typeof arg !== 'string' || arg.length === 0) return -1;
|
|
1546
|
+
if (arg === 'eval') return -2;
|
|
1547
|
+
if (arg === 'run' || arg === 'test' || arg === 'bench' || arg === 'check') {
|
|
1548
|
+
return findScriptAfterSubcommand(cmd, i + 1, 'deno');
|
|
1549
|
+
}
|
|
1550
|
+
if (isDenoOptionWithValue(arg)) {
|
|
1551
|
+
i += 1;
|
|
1552
|
+
continue;
|
|
1553
|
+
}
|
|
1554
|
+
if (hasInlineDenoOptionValue(arg)) continue;
|
|
1555
|
+
if (isDenoValuelessOption(arg)) continue;
|
|
1556
|
+
if (arg.startsWith('-')) return -1;
|
|
1557
|
+
return i;
|
|
1558
|
+
}
|
|
1559
|
+
return -1;
|
|
1560
|
+
}
|
|
1561
|
+
|
|
1562
|
+
function findScriptAfterSubcommand(cmd, startIndex, runtime) {
|
|
1563
|
+
for (let i = startIndex; i < cmd.length; i++) {
|
|
1564
|
+
const arg = cmd[i];
|
|
1565
|
+
if (typeof arg !== 'string' || arg.length === 0) return -1;
|
|
1566
|
+
if (runtime === 'bun' && isBunOptionWithValue(arg)) {
|
|
1567
|
+
i += 1;
|
|
1568
|
+
continue;
|
|
1569
|
+
}
|
|
1570
|
+
if (runtime === 'deno' && isDenoOptionWithValue(arg)) {
|
|
1571
|
+
i += 1;
|
|
1572
|
+
continue;
|
|
1573
|
+
}
|
|
1574
|
+
if (runtime === 'bun' && hasInlineBunOptionValue(arg)) continue;
|
|
1575
|
+
if (runtime === 'deno' && hasInlineDenoOptionValue(arg)) continue;
|
|
1576
|
+
if (runtime === 'bun' && isBunValuelessOption(arg)) continue;
|
|
1577
|
+
if (runtime === 'deno' && isDenoValuelessOption(arg)) continue;
|
|
1578
|
+
if (arg.startsWith('-')) return -1;
|
|
1579
|
+
return i;
|
|
1580
|
+
}
|
|
1581
|
+
return -1;
|
|
1582
|
+
}
|
|
1583
|
+
|
|
1584
|
+
function isNodeLikeOptionWithValue(arg) {
|
|
1585
|
+
return (
|
|
1586
|
+
arg === '-C' ||
|
|
1587
|
+
arg === '-r' ||
|
|
1588
|
+
arg === '--conditions' ||
|
|
1589
|
+
arg === '--debug-port' ||
|
|
1590
|
+
arg === '--disable-warning' ||
|
|
1591
|
+
arg === '--env-file' ||
|
|
1592
|
+
arg === '--env-file-if-exists' ||
|
|
1593
|
+
arg === '--experimental-config-file' ||
|
|
1594
|
+
arg === '--experimental-loader' ||
|
|
1595
|
+
arg === '--import' ||
|
|
1596
|
+
arg === '--inspect-publish-uid' ||
|
|
1597
|
+
arg === '--loader' ||
|
|
1598
|
+
arg === '--localstorage-file' ||
|
|
1599
|
+
arg === '--require'
|
|
1600
|
+
);
|
|
1601
|
+
}
|
|
1602
|
+
|
|
1603
|
+
function hasInlineNodeLikeOptionValue(arg) {
|
|
1604
|
+
return (
|
|
1605
|
+
arg.startsWith('--conditions=') ||
|
|
1606
|
+
arg.startsWith('--debug-port=') ||
|
|
1607
|
+
arg.startsWith('--disable-warning=') ||
|
|
1608
|
+
arg.startsWith('--env-file=') ||
|
|
1609
|
+
arg.startsWith('--env-file-if-exists=') ||
|
|
1610
|
+
arg.startsWith('--experimental-config-file=') ||
|
|
1611
|
+
arg.startsWith('--experimental-loader=') ||
|
|
1612
|
+
arg.startsWith('--import=') ||
|
|
1613
|
+
arg.startsWith('--inspect-publish-uid=') ||
|
|
1614
|
+
arg.startsWith('--loader=') ||
|
|
1615
|
+
arg.startsWith('--localstorage-file=') ||
|
|
1616
|
+
arg.startsWith('--require=')
|
|
1617
|
+
);
|
|
1618
|
+
}
|
|
1619
|
+
|
|
1620
|
+
function isNodeLikeValuelessOption(arg) {
|
|
1621
|
+
return (
|
|
1622
|
+
arg === '-' ||
|
|
1623
|
+
arg === '-c' ||
|
|
1624
|
+
arg === '--' ||
|
|
1625
|
+
arg === '--check' ||
|
|
1626
|
+
arg === '--cpu-prof' ||
|
|
1627
|
+
arg === '--enable-source-maps' ||
|
|
1628
|
+
arg === '--expose-gc' ||
|
|
1629
|
+
arg === '--inspect' ||
|
|
1630
|
+
arg === '--inspect-brk' ||
|
|
1631
|
+
arg === '--inspect-wait' ||
|
|
1632
|
+
arg === '--no-deprecation' ||
|
|
1633
|
+
arg === '--no-warnings' ||
|
|
1634
|
+
arg === '--preserve-symlinks' ||
|
|
1635
|
+
arg === '--preserve-symlinks-main' ||
|
|
1636
|
+
arg === '--throw-deprecation' ||
|
|
1637
|
+
arg === '--trace-deprecation' ||
|
|
1638
|
+
arg === '--trace-warnings'
|
|
1639
|
+
);
|
|
1640
|
+
}
|
|
1641
|
+
|
|
1642
|
+
function isBunOptionWithValue(arg) {
|
|
1643
|
+
return (
|
|
1644
|
+
arg === '-c' ||
|
|
1645
|
+
arg === '-d' ||
|
|
1646
|
+
arg === '-F' ||
|
|
1647
|
+
arg === '-l' ||
|
|
1648
|
+
arg === '-r' ||
|
|
1649
|
+
arg === '--config' ||
|
|
1650
|
+
arg === '--conditions' ||
|
|
1651
|
+
arg === '--console-depth' ||
|
|
1652
|
+
arg === '--cpu-prof-dir' ||
|
|
1653
|
+
arg === '--cpu-prof-interval' ||
|
|
1654
|
+
arg === '--cpu-prof-name' ||
|
|
1655
|
+
arg === '--cwd' ||
|
|
1656
|
+
arg === '--define' ||
|
|
1657
|
+
arg === '--dns-result-order' ||
|
|
1658
|
+
arg === '--drop' ||
|
|
1659
|
+
arg === '--elide-lines' ||
|
|
1660
|
+
arg === '--env-file' ||
|
|
1661
|
+
arg === '--extension-order' ||
|
|
1662
|
+
arg === '--feature' ||
|
|
1663
|
+
arg === '--fetch-preconnect' ||
|
|
1664
|
+
arg === '--filter' ||
|
|
1665
|
+
arg === '--import' ||
|
|
1666
|
+
arg === '--inspect' ||
|
|
1667
|
+
arg === '--inspect-brk' ||
|
|
1668
|
+
arg === '--inspect-wait' ||
|
|
1669
|
+
arg === '--install' ||
|
|
1670
|
+
arg === '--jsx-factory' ||
|
|
1671
|
+
arg === '--jsx-fragment' ||
|
|
1672
|
+
arg === '--jsx-import-source' ||
|
|
1673
|
+
arg === '--jsx-runtime' ||
|
|
1674
|
+
arg === '--loader' ||
|
|
1675
|
+
arg === '--main-fields' ||
|
|
1676
|
+
arg === '--max-http-header-size' ||
|
|
1677
|
+
arg === '--port' ||
|
|
1678
|
+
arg === '--preload' ||
|
|
1679
|
+
arg === '--require' ||
|
|
1680
|
+
arg === '--shell' ||
|
|
1681
|
+
arg === '--title' ||
|
|
1682
|
+
arg === '--tsconfig-override' ||
|
|
1683
|
+
arg === '--unhandled-rejections' ||
|
|
1684
|
+
arg === '--user-agent'
|
|
1685
|
+
);
|
|
1686
|
+
}
|
|
1687
|
+
|
|
1688
|
+
function hasInlineBunOptionValue(arg) {
|
|
1689
|
+
return (
|
|
1690
|
+
arg.startsWith('--config=') ||
|
|
1691
|
+
arg.startsWith('--conditions=') ||
|
|
1692
|
+
arg.startsWith('--console-depth=') ||
|
|
1693
|
+
arg.startsWith('--cpu-prof-dir=') ||
|
|
1694
|
+
arg.startsWith('--cpu-prof-interval=') ||
|
|
1695
|
+
arg.startsWith('--cpu-prof-name=') ||
|
|
1696
|
+
arg.startsWith('--cwd=') ||
|
|
1697
|
+
arg.startsWith('--define=') ||
|
|
1698
|
+
arg.startsWith('--dns-result-order=') ||
|
|
1699
|
+
arg.startsWith('--drop=') ||
|
|
1700
|
+
arg.startsWith('--elide-lines=') ||
|
|
1701
|
+
arg.startsWith('--env-file=') ||
|
|
1702
|
+
arg.startsWith('--extension-order=') ||
|
|
1703
|
+
arg.startsWith('--feature=') ||
|
|
1704
|
+
arg.startsWith('--fetch-preconnect=') ||
|
|
1705
|
+
arg.startsWith('--filter=') ||
|
|
1706
|
+
arg.startsWith('--import=') ||
|
|
1707
|
+
arg.startsWith('--inspect=') ||
|
|
1708
|
+
arg.startsWith('--inspect-brk=') ||
|
|
1709
|
+
arg.startsWith('--inspect-wait=') ||
|
|
1710
|
+
arg.startsWith('--install=') ||
|
|
1711
|
+
arg.startsWith('--jsx-factory=') ||
|
|
1712
|
+
arg.startsWith('--jsx-fragment=') ||
|
|
1713
|
+
arg.startsWith('--jsx-import-source=') ||
|
|
1714
|
+
arg.startsWith('--jsx-runtime=') ||
|
|
1715
|
+
arg.startsWith('--loader=') ||
|
|
1716
|
+
arg.startsWith('--main-fields=') ||
|
|
1717
|
+
arg.startsWith('--max-http-header-size=') ||
|
|
1718
|
+
arg.startsWith('--port=') ||
|
|
1719
|
+
arg.startsWith('--preload=') ||
|
|
1720
|
+
arg.startsWith('--require=') ||
|
|
1721
|
+
arg.startsWith('--shell=') ||
|
|
1722
|
+
arg.startsWith('--title=') ||
|
|
1723
|
+
arg.startsWith('--tsconfig-override=') ||
|
|
1724
|
+
arg.startsWith('--unhandled-rejections=') ||
|
|
1725
|
+
arg.startsWith('--user-agent=')
|
|
1726
|
+
);
|
|
1727
|
+
}
|
|
1728
|
+
|
|
1729
|
+
function isBunValuelessOption(arg) {
|
|
1730
|
+
return (
|
|
1731
|
+
arg === '-b' ||
|
|
1732
|
+
arg === '-i' ||
|
|
1733
|
+
arg === '--bun' ||
|
|
1734
|
+
arg === '--cpu-prof' ||
|
|
1735
|
+
arg === '--cpu-prof-md' ||
|
|
1736
|
+
arg === '--expose-gc' ||
|
|
1737
|
+
arg === '--heap-prof' ||
|
|
1738
|
+
arg === '--heap-prof-md' ||
|
|
1739
|
+
arg === '--hot' ||
|
|
1740
|
+
arg === '--if-present' ||
|
|
1741
|
+
arg === '--ignore-dce-annotations' ||
|
|
1742
|
+
arg === '--jsx-side-effects' ||
|
|
1743
|
+
arg === '--no-addons' ||
|
|
1744
|
+
arg === '--no-clear-screen' ||
|
|
1745
|
+
arg === '--no-deprecation' ||
|
|
1746
|
+
arg === '--no-env-file' ||
|
|
1747
|
+
arg === '--no-exit-on-error' ||
|
|
1748
|
+
arg === '--no-install' ||
|
|
1749
|
+
arg === '--no-macros' ||
|
|
1750
|
+
arg === '--parallel' ||
|
|
1751
|
+
arg === '--prefer-latest' ||
|
|
1752
|
+
arg === '--prefer-offline' ||
|
|
1753
|
+
arg === '--preserve-symlinks' ||
|
|
1754
|
+
arg === '--preserve-symlinks-main' ||
|
|
1755
|
+
arg === '--redis-preconnect' ||
|
|
1756
|
+
arg === '--sequential' ||
|
|
1757
|
+
arg === '--silent' ||
|
|
1758
|
+
arg === '--smol' ||
|
|
1759
|
+
arg === '--sql-preconnect' ||
|
|
1760
|
+
arg === '--throw-deprecation' ||
|
|
1761
|
+
arg === '--use-bundled-ca' ||
|
|
1762
|
+
arg === '--use-openssl-ca' ||
|
|
1763
|
+
arg === '--use-system-ca' ||
|
|
1764
|
+
arg === '--watch' ||
|
|
1765
|
+
arg === '--workspaces' ||
|
|
1766
|
+
arg === '--zero-fill-buffers'
|
|
1767
|
+
);
|
|
1768
|
+
}
|
|
1769
|
+
|
|
1770
|
+
function isDenoOptionWithValue(arg) {
|
|
1771
|
+
return (
|
|
1772
|
+
arg === '-c' ||
|
|
1773
|
+
arg === '--cert' ||
|
|
1774
|
+
arg === '--conditions' ||
|
|
1775
|
+
arg === '--config' ||
|
|
1776
|
+
arg === '--cpu-prof-dir' ||
|
|
1777
|
+
arg === '--cpu-prof-interval' ||
|
|
1778
|
+
arg === '--cpu-prof-name' ||
|
|
1779
|
+
arg === '--ext' ||
|
|
1780
|
+
arg === '--import-map' ||
|
|
1781
|
+
arg === '--location' ||
|
|
1782
|
+
arg === '--lock' ||
|
|
1783
|
+
arg === '--minimum-dependency-age' ||
|
|
1784
|
+
arg === '--preload' ||
|
|
1785
|
+
arg === '--require' ||
|
|
1786
|
+
arg === '--seed'
|
|
1787
|
+
);
|
|
1788
|
+
}
|
|
1789
|
+
|
|
1790
|
+
function hasInlineDenoOptionValue(arg) {
|
|
1791
|
+
return (
|
|
1792
|
+
arg.startsWith('--cert=') ||
|
|
1793
|
+
arg.startsWith('--conditions=') ||
|
|
1794
|
+
arg.startsWith('--config=') ||
|
|
1795
|
+
arg.startsWith('--coverage=') ||
|
|
1796
|
+
arg.startsWith('--cpu-prof-dir=') ||
|
|
1797
|
+
arg.startsWith('--cpu-prof-interval=') ||
|
|
1798
|
+
arg.startsWith('--cpu-prof-name=') ||
|
|
1799
|
+
arg.startsWith('--env-file=') ||
|
|
1800
|
+
arg.startsWith('--ext=') ||
|
|
1801
|
+
arg.startsWith('--import-map=') ||
|
|
1802
|
+
arg.startsWith('--location=') ||
|
|
1803
|
+
arg.startsWith('--lock=') ||
|
|
1804
|
+
arg.startsWith('--minimum-dependency-age=') ||
|
|
1805
|
+
arg.startsWith('--node-modules-dir=') ||
|
|
1806
|
+
arg.startsWith('--preload=') ||
|
|
1807
|
+
arg.startsWith('--require=') ||
|
|
1808
|
+
arg.startsWith('--seed=') ||
|
|
1809
|
+
arg.startsWith('--vendor=') ||
|
|
1810
|
+
arg.startsWith('--v8-flags=') ||
|
|
1811
|
+
/^--(allow|deny|ignore)-[A-Za-z-]+=/.test(arg) ||
|
|
1812
|
+
arg.startsWith('--permission-set=') ||
|
|
1813
|
+
arg.startsWith('--reload=') ||
|
|
1814
|
+
arg.startsWith('--tunnel=') ||
|
|
1815
|
+
arg.startsWith('--watch=') ||
|
|
1816
|
+
arg.startsWith('--watch-exclude=') ||
|
|
1817
|
+
arg.startsWith('--watch-hmr=')
|
|
1818
|
+
);
|
|
1819
|
+
}
|
|
1820
|
+
|
|
1821
|
+
function isDenoValuelessOption(arg) {
|
|
1822
|
+
return (
|
|
1823
|
+
arg === '-A' ||
|
|
1824
|
+
arg === '-P' ||
|
|
1825
|
+
arg === '-q' ||
|
|
1826
|
+
arg === '-r' ||
|
|
1827
|
+
arg === '-t' ||
|
|
1828
|
+
arg === '--allow-all' ||
|
|
1829
|
+
arg === '--cached-only' ||
|
|
1830
|
+
arg === '--coverage' ||
|
|
1831
|
+
arg === '--cpu-prof' ||
|
|
1832
|
+
arg === '--cpu-prof-flamegraph' ||
|
|
1833
|
+
arg === '--cpu-prof-md' ||
|
|
1834
|
+
arg === '--env-file' ||
|
|
1835
|
+
arg === '--frozen' ||
|
|
1836
|
+
arg === '--no-check' ||
|
|
1837
|
+
arg === '--no-clear-screen' ||
|
|
1838
|
+
arg === '--no-code-cache' ||
|
|
1839
|
+
arg === '--no-config' ||
|
|
1840
|
+
arg === '--no-lock' ||
|
|
1841
|
+
arg === '--no-npm' ||
|
|
1842
|
+
arg === '--no-prompt' ||
|
|
1843
|
+
arg === '--no-remote' ||
|
|
1844
|
+
arg === '--node-modules-dir' ||
|
|
1845
|
+
arg === '--quiet' ||
|
|
1846
|
+
arg === '--reload' ||
|
|
1847
|
+
arg === '--tunnel' ||
|
|
1848
|
+
arg === '--unstable' ||
|
|
1849
|
+
arg === '--v8-flags' ||
|
|
1850
|
+
arg === '--vendor' ||
|
|
1851
|
+
arg === '--watch' ||
|
|
1852
|
+
arg === '--watch-exclude' ||
|
|
1853
|
+
arg === '--watch-hmr' ||
|
|
1854
|
+
/^-[RWINESA]$/.test(arg) ||
|
|
1855
|
+
/^--(allow|deny|ignore)-[A-Za-z-]+$/.test(arg) ||
|
|
1856
|
+
arg === '--permission-set'
|
|
1857
|
+
);
|
|
1858
|
+
}
|
|
1859
|
+
|
|
1860
|
+
function isReadablePath(target, baseDir = null) {
|
|
1861
|
+
const resolved = resolveMaybeHome(target, baseDir);
|
|
1862
|
+
if (!resolved) return false;
|
|
1863
|
+
try {
|
|
1864
|
+
fs.accessSync(resolved, fs.constants.R_OK);
|
|
1865
|
+
return true;
|
|
1866
|
+
} catch (_) {
|
|
1867
|
+
return false;
|
|
1868
|
+
}
|
|
1869
|
+
}
|
|
1870
|
+
|
|
1871
|
+
function isExplicitPath(value) {
|
|
1872
|
+
if (typeof value !== 'string' || value.length === 0) return false;
|
|
1873
|
+
return value.startsWith('~/') || value.startsWith('~\\\\') || value.includes('/') || value.includes('\\\\') || /^[A-Za-z]:/.test(value);
|
|
1874
|
+
}
|
|
1875
|
+
|
|
1286
1876
|
function containsSequence(haystack, needle) {
|
|
1287
1877
|
if (!Array.isArray(haystack) || !Array.isArray(needle) || needle.length === 0) return false;
|
|
1288
1878
|
if (needle.length > haystack.length) return false;
|
|
@@ -1332,6 +1922,11 @@ async function isDir(p) {
|
|
|
1332
1922
|
}
|
|
1333
1923
|
|
|
1334
1924
|
async function installLocalTrackerApp({ appDir }) {
|
|
1925
|
+
// Test-only escape hatch: skip the ~10 MB runtime copy (src + dashboard/dist +
|
|
1926
|
+
// node_modules) when a test only exercises hook/config/notify wiring. Copying
|
|
1927
|
+
// the bundle per test case dominates the init test suite's wall time. Tests
|
|
1928
|
+
// that assert on the copied runtime simply leave this unset.
|
|
1929
|
+
if (process.env.TOKENTRACKER_SKIP_LOCAL_RUNTIME_COPY === "1") return;
|
|
1335
1930
|
// Copy the current package's runtime (bin + src) into ~/.tokentracker so notify can run sync without npx.
|
|
1336
1931
|
const packageRoot = path.resolve(__dirname, "../..");
|
|
1337
1932
|
const srcFrom = path.join(packageRoot, "src");
|
|
@@ -1387,6 +1982,12 @@ async function safeRealpath(p) {
|
|
|
1387
1982
|
const FIRST_SYNC_TIMEOUT_MS = 15_000;
|
|
1388
1983
|
|
|
1389
1984
|
async function runFirstSyncAndRead({ trackerBinPath, trackerDir, packageName }) {
|
|
1985
|
+
// Test-only escape hatch: skip spawning a real `sync --drain` subprocess when
|
|
1986
|
+
// a test only exercises init wiring. Returns the same shape derived from an
|
|
1987
|
+
// (empty) queue so callers behave identically without the ~1s spawn per case.
|
|
1988
|
+
if (process.env.TOKENTRACKER_SKIP_FIRST_SYNC === "1") {
|
|
1989
|
+
return readFirstSyncTotals(trackerDir);
|
|
1990
|
+
}
|
|
1390
1991
|
const fallbackPkg = packageName || "tokentracker-cli";
|
|
1391
1992
|
const argv = ["sync", "--drain"];
|
|
1392
1993
|
const hasLocalRuntime = typeof trackerBinPath === "string" && fssync.existsSync(trackerBinPath);
|