@yishiguji/tokenarena 0.14.0 → 0.14.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/dist/index.js +72 -56
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -969,7 +969,55 @@ import { dirname, join as join6 } from "path";
|
|
|
969
969
|
|
|
970
970
|
// src/infrastructure/sqlite.ts
|
|
971
971
|
import { execFileSync } from "child_process";
|
|
972
|
+
import { statSync } from "fs";
|
|
972
973
|
import { pathToFileURL } from "url";
|
|
974
|
+
|
|
975
|
+
// src/utils/logger.ts
|
|
976
|
+
var LOG_LEVELS = {
|
|
977
|
+
debug: 0,
|
|
978
|
+
info: 1,
|
|
979
|
+
warn: 2,
|
|
980
|
+
error: 3
|
|
981
|
+
};
|
|
982
|
+
var Logger = class {
|
|
983
|
+
level;
|
|
984
|
+
constructor(level = "info") {
|
|
985
|
+
this.level = level;
|
|
986
|
+
}
|
|
987
|
+
setLevel(level) {
|
|
988
|
+
this.level = level;
|
|
989
|
+
}
|
|
990
|
+
debug(msg) {
|
|
991
|
+
if (LOG_LEVELS[this.level] <= LOG_LEVELS.debug) {
|
|
992
|
+
process.stderr.write(`[debug] ${msg}
|
|
993
|
+
`);
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
info(msg) {
|
|
997
|
+
if (LOG_LEVELS[this.level] <= LOG_LEVELS.info) {
|
|
998
|
+
process.stdout.write(`${msg}
|
|
999
|
+
`);
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
warn(msg) {
|
|
1003
|
+
if (LOG_LEVELS[this.level] <= LOG_LEVELS.warn) {
|
|
1004
|
+
process.stderr.write(`warn: ${msg}
|
|
1005
|
+
`);
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
error(msg) {
|
|
1009
|
+
if (LOG_LEVELS[this.level] <= LOG_LEVELS.error) {
|
|
1010
|
+
process.stderr.write(`error: ${msg}
|
|
1011
|
+
`);
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
log(msg) {
|
|
1015
|
+
this.info(msg);
|
|
1016
|
+
}
|
|
1017
|
+
};
|
|
1018
|
+
var logger = new Logger();
|
|
1019
|
+
|
|
1020
|
+
// src/infrastructure/sqlite.ts
|
|
973
1021
|
function withSuppressedSqliteWarning(fn) {
|
|
974
1022
|
const originalEmitWarning = process.emitWarning;
|
|
975
1023
|
process.emitWarning = ((warning, ...args) => {
|
|
@@ -984,21 +1032,34 @@ function withSuppressedSqliteWarning(fn) {
|
|
|
984
1032
|
process.emitWarning = originalEmitWarning;
|
|
985
1033
|
});
|
|
986
1034
|
}
|
|
1035
|
+
function warnWhenWalSkipped(dbPath) {
|
|
1036
|
+
try {
|
|
1037
|
+
const pendingBytes = statSync(`${dbPath}-wal`).size;
|
|
1038
|
+
if (pendingBytes > 0) {
|
|
1039
|
+
logger.warn(
|
|
1040
|
+
`${dbPath} was read without its write-ahead log (${pendingBytes} bytes pending), so the newest records may be missing. This happens when the database directory is not writable.`
|
|
1041
|
+
);
|
|
1042
|
+
}
|
|
1043
|
+
} catch {
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
987
1046
|
async function readSqliteRowsWithBuiltin(dbPath, query) {
|
|
988
1047
|
try {
|
|
989
1048
|
return await withSuppressedSqliteWarning(async () => {
|
|
990
1049
|
const sqliteModuleId = "node:sqlite";
|
|
991
1050
|
const sqlite = await import(sqliteModuleId);
|
|
992
|
-
const
|
|
993
|
-
|
|
994
|
-
`${pathToFileURL(dbPath).href}?mode=ro&immutable=1`
|
|
995
|
-
];
|
|
1051
|
+
const immutableLocation = `${pathToFileURL(dbPath).href}?mode=ro&immutable=1`;
|
|
1052
|
+
const locations = [dbPath, immutableLocation];
|
|
996
1053
|
let lastError = null;
|
|
997
1054
|
for (const location of locations) {
|
|
998
1055
|
let db = null;
|
|
999
1056
|
try {
|
|
1000
1057
|
db = new sqlite.DatabaseSync(location);
|
|
1001
|
-
|
|
1058
|
+
const rows = db.prepare(query).all();
|
|
1059
|
+
if (location === immutableLocation) {
|
|
1060
|
+
warnWhenWalSkipped(dbPath);
|
|
1061
|
+
}
|
|
1062
|
+
return rows;
|
|
1002
1063
|
} catch (err) {
|
|
1003
1064
|
lastError = err;
|
|
1004
1065
|
const error = err;
|
|
@@ -3331,7 +3392,7 @@ var QwenPawParser = class {
|
|
|
3331
3392
|
registerParser(new QwenPawParser());
|
|
3332
3393
|
|
|
3333
3394
|
// src/parsers/cline.ts
|
|
3334
|
-
import { readFileSync as readFileSync6, statSync } from "fs";
|
|
3395
|
+
import { readFileSync as readFileSync6, statSync as statSync2 } from "fs";
|
|
3335
3396
|
import { homedir as homedir18 } from "os";
|
|
3336
3397
|
import { basename as basename7, join as join19 } from "path";
|
|
3337
3398
|
var EXTENSION_ID = "saoudrizwan.claude-dev";
|
|
@@ -3368,7 +3429,7 @@ function findClineExtensionDirs() {
|
|
|
3368
3429
|
for (const root of getHostRoots()) {
|
|
3369
3430
|
const ext = join19(root, "User", "globalStorage", EXTENSION_ID);
|
|
3370
3431
|
try {
|
|
3371
|
-
if (
|
|
3432
|
+
if (statSync2(ext).isDirectory()) dirs.push(ext);
|
|
3372
3433
|
} catch {
|
|
3373
3434
|
}
|
|
3374
3435
|
}
|
|
@@ -3485,7 +3546,7 @@ import {
|
|
|
3485
3546
|
readdirSync as readdirSync10,
|
|
3486
3547
|
readFileSync as readFileSync7,
|
|
3487
3548
|
rmSync,
|
|
3488
|
-
statSync as
|
|
3549
|
+
statSync as statSync3
|
|
3489
3550
|
} from "fs";
|
|
3490
3551
|
import { homedir as homedir19, tmpdir } from "os";
|
|
3491
3552
|
import { join as join20, resolve } from "path";
|
|
@@ -3566,7 +3627,7 @@ function readJsonl(jsonlPath) {
|
|
|
3566
3627
|
if (lines.length === 0) return [];
|
|
3567
3628
|
let mtime;
|
|
3568
3629
|
try {
|
|
3569
|
-
mtime =
|
|
3630
|
+
mtime = statSync3(jsonlPath).mtime;
|
|
3570
3631
|
} catch {
|
|
3571
3632
|
mtime = /* @__PURE__ */ new Date();
|
|
3572
3633
|
}
|
|
@@ -3711,7 +3772,7 @@ var KiroParser = class {
|
|
|
3711
3772
|
registerParser(new KiroParser());
|
|
3712
3773
|
|
|
3713
3774
|
// src/parsers/roo-code.ts
|
|
3714
|
-
import { readdirSync as readdirSync11, readFileSync as readFileSync8, statSync as
|
|
3775
|
+
import { readdirSync as readdirSync11, readFileSync as readFileSync8, statSync as statSync4 } from "fs";
|
|
3715
3776
|
import { homedir as homedir20 } from "os";
|
|
3716
3777
|
import { basename as basename8, join as join21 } from "path";
|
|
3717
3778
|
var EXTENSION_ID2 = "rooveterinaryinc.roo-cline";
|
|
@@ -3748,7 +3809,7 @@ function findExtensionDirs() {
|
|
|
3748
3809
|
for (const root of getHostRoots2()) {
|
|
3749
3810
|
const ext = join21(root, "User", "globalStorage", EXTENSION_ID2);
|
|
3750
3811
|
try {
|
|
3751
|
-
if (
|
|
3812
|
+
if (statSync4(ext).isDirectory()) dirs.push(ext);
|
|
3752
3813
|
} catch {
|
|
3753
3814
|
}
|
|
3754
3815
|
}
|
|
@@ -5718,51 +5779,6 @@ async function promptSelect(options) {
|
|
|
5718
5779
|
});
|
|
5719
5780
|
}
|
|
5720
5781
|
|
|
5721
|
-
// src/utils/logger.ts
|
|
5722
|
-
var LOG_LEVELS = {
|
|
5723
|
-
debug: 0,
|
|
5724
|
-
info: 1,
|
|
5725
|
-
warn: 2,
|
|
5726
|
-
error: 3
|
|
5727
|
-
};
|
|
5728
|
-
var Logger = class {
|
|
5729
|
-
level;
|
|
5730
|
-
constructor(level = "info") {
|
|
5731
|
-
this.level = level;
|
|
5732
|
-
}
|
|
5733
|
-
setLevel(level) {
|
|
5734
|
-
this.level = level;
|
|
5735
|
-
}
|
|
5736
|
-
debug(msg) {
|
|
5737
|
-
if (LOG_LEVELS[this.level] <= LOG_LEVELS.debug) {
|
|
5738
|
-
process.stderr.write(`[debug] ${msg}
|
|
5739
|
-
`);
|
|
5740
|
-
}
|
|
5741
|
-
}
|
|
5742
|
-
info(msg) {
|
|
5743
|
-
if (LOG_LEVELS[this.level] <= LOG_LEVELS.info) {
|
|
5744
|
-
process.stdout.write(`${msg}
|
|
5745
|
-
`);
|
|
5746
|
-
}
|
|
5747
|
-
}
|
|
5748
|
-
warn(msg) {
|
|
5749
|
-
if (LOG_LEVELS[this.level] <= LOG_LEVELS.warn) {
|
|
5750
|
-
process.stderr.write(`warn: ${msg}
|
|
5751
|
-
`);
|
|
5752
|
-
}
|
|
5753
|
-
}
|
|
5754
|
-
error(msg) {
|
|
5755
|
-
if (LOG_LEVELS[this.level] <= LOG_LEVELS.error) {
|
|
5756
|
-
process.stderr.write(`error: ${msg}
|
|
5757
|
-
`);
|
|
5758
|
-
}
|
|
5759
|
-
}
|
|
5760
|
-
log(msg) {
|
|
5761
|
-
this.info(msg);
|
|
5762
|
-
}
|
|
5763
|
-
};
|
|
5764
|
-
var logger = new Logger();
|
|
5765
|
-
|
|
5766
5782
|
// src/commands/config.ts
|
|
5767
5783
|
var VALID_KEYS = ["apiKey", "apiUrl", "syncInterval", "logLevel"];
|
|
5768
5784
|
function isConfigKey(value) {
|