@polka-codes/cli 0.9.92 → 0.9.93
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 +69 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -25661,6 +25661,9 @@ class UsageMeter {
|
|
|
25661
25661
|
let requestsWithCache = 0;
|
|
25662
25662
|
for (const entry of entries) {
|
|
25663
25663
|
const metadata = entry.metadata;
|
|
25664
|
+
if (typeof metadata !== "object" || metadata === null) {
|
|
25665
|
+
continue;
|
|
25666
|
+
}
|
|
25664
25667
|
const cachedTokens = metadata.cachedPromptTokens ?? metadata.cacheReadTokens ?? metadata.prompt_cache_hit_tokens ?? 0;
|
|
25665
25668
|
if (cachedTokens > 0) {
|
|
25666
25669
|
totalCachedTokens += cachedTokens;
|
|
@@ -73524,7 +73527,7 @@ var init_provider = __esm(() => {
|
|
|
73524
73527
|
|
|
73525
73528
|
// ../../node_modules/sql.js/dist/sql-wasm.js
|
|
73526
73529
|
var require_sql_wasm = __commonJS((exports, module) => {
|
|
73527
|
-
var __dirname = "/
|
|
73530
|
+
var __dirname = "/Users/xiliangchen/projects/polka-codes/node_modules/sql.js/dist";
|
|
73528
73531
|
var initSqlJsPromise = undefined;
|
|
73529
73532
|
var initSqlJs = function(moduleConfig) {
|
|
73530
73533
|
if (initSqlJsPromise) {
|
|
@@ -75810,16 +75813,64 @@ var require_sql_wasm = __commonJS((exports, module) => {
|
|
|
75810
75813
|
import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
|
|
75811
75814
|
import { randomUUID } from "node:crypto";
|
|
75812
75815
|
import { existsSync as existsSync4 } from "node:fs";
|
|
75813
|
-
import { mkdir as mkdir2, readFile as readFile4, rename as rename2, writeFile as writeFile2 } from "node:fs/promises";
|
|
75814
|
-
import { dirname as dirname3, resolve as resolve5 } from "node:path";
|
|
75816
|
+
import { mkdir as mkdir2, readdir as readdir2, readFile as readFile4, rename as rename2, unlink as unlink2, writeFile as writeFile2 } from "node:fs/promises";
|
|
75817
|
+
import { basename as basename2, dirname as dirname3, resolve as resolve5 } from "node:path";
|
|
75815
75818
|
import { fileURLToPath } from "node:url";
|
|
75816
75819
|
|
|
75817
75820
|
class FileLock {
|
|
75818
75821
|
lockfilePath;
|
|
75819
75822
|
static LOCK_TIMEOUT = 30000;
|
|
75823
|
+
static CLEANUP_AGE = 600000;
|
|
75824
|
+
static lastCleanupTime = 0;
|
|
75825
|
+
static CLEANUP_THROTTLE = 60000;
|
|
75820
75826
|
constructor(dbPath) {
|
|
75821
75827
|
this.lockfilePath = `${dbPath}.lock`;
|
|
75822
75828
|
}
|
|
75829
|
+
static resetCleanupThrottle() {
|
|
75830
|
+
FileLock.lastCleanupTime = 0;
|
|
75831
|
+
}
|
|
75832
|
+
static async cleanupOldLockFiles(dbPath, maxAge = FileLock.CLEANUP_AGE, force = false) {
|
|
75833
|
+
const now2 = Date.now();
|
|
75834
|
+
if (!force && now2 - FileLock.lastCleanupTime < FileLock.CLEANUP_THROTTLE) {
|
|
75835
|
+
return;
|
|
75836
|
+
}
|
|
75837
|
+
FileLock.lastCleanupTime = now2;
|
|
75838
|
+
try {
|
|
75839
|
+
const lockDir = dirname3(dbPath);
|
|
75840
|
+
const dbBaseName = basename2(dbPath);
|
|
75841
|
+
const files = await readdir2(lockDir);
|
|
75842
|
+
const now3 = Date.now();
|
|
75843
|
+
let cleanedCount = 0;
|
|
75844
|
+
for (const file2 of files) {
|
|
75845
|
+
if (!file2.startsWith(`${dbBaseName}.lock.`)) {
|
|
75846
|
+
continue;
|
|
75847
|
+
}
|
|
75848
|
+
const match = file2.match(/\.lock\.(released|stale|invalid|corrupt)\.(\d+)$/);
|
|
75849
|
+
if (!match) {
|
|
75850
|
+
continue;
|
|
75851
|
+
}
|
|
75852
|
+
const filePath = resolve5(lockDir, file2);
|
|
75853
|
+
const timestamp = Number.parseInt(match[2], 10);
|
|
75854
|
+
const age = now3 - timestamp;
|
|
75855
|
+
if (age > maxAge) {
|
|
75856
|
+
try {
|
|
75857
|
+
await unlink2(filePath);
|
|
75858
|
+
cleanedCount++;
|
|
75859
|
+
} catch (error48) {
|
|
75860
|
+
const errorCode = error48?.code;
|
|
75861
|
+
if (errorCode !== "ENOENT") {
|
|
75862
|
+
console.warn(`[FileLock] Failed to delete old lock file ${file2}: ${error48 instanceof Error ? error48.message : String(error48)}`);
|
|
75863
|
+
}
|
|
75864
|
+
}
|
|
75865
|
+
}
|
|
75866
|
+
}
|
|
75867
|
+
if (cleanedCount > 0) {
|
|
75868
|
+
console.log(`[FileLock] Cleaned up ${cleanedCount} old lock file(s) (older than ${maxAge}ms)`);
|
|
75869
|
+
}
|
|
75870
|
+
} catch (error48) {
|
|
75871
|
+
console.debug(`[FileLock] Cleanup encountered an error: ${error48 instanceof Error ? error48.message : String(error48)}`);
|
|
75872
|
+
}
|
|
75873
|
+
}
|
|
75823
75874
|
async acquire(retries = 10, delay2 = 100) {
|
|
75824
75875
|
for (let i2 = 0;i2 < retries; i2++) {
|
|
75825
75876
|
try {
|
|
@@ -75870,6 +75921,8 @@ class FileLock {
|
|
|
75870
75921
|
async release() {
|
|
75871
75922
|
try {
|
|
75872
75923
|
await rename2(this.lockfilePath, `${this.lockfilePath}.released.${Date.now()}`);
|
|
75924
|
+
const dbPath = this.lockfilePath.slice(0, -5);
|
|
75925
|
+
FileLock.cleanupOldLockFiles(dbPath).catch(() => {});
|
|
75873
75926
|
} catch (error48) {
|
|
75874
75927
|
const errorCode = error48.code;
|
|
75875
75928
|
if (errorCode !== "ENOENT") {
|
|
@@ -75953,6 +76006,9 @@ var init_sqlite_memory_store = __esm(() => {
|
|
|
75953
76006
|
inTransaction = false;
|
|
75954
76007
|
transactionMutex = new ReentrantMutex;
|
|
75955
76008
|
fileLock;
|
|
76009
|
+
static resetCleanupThrottle() {
|
|
76010
|
+
FileLock.resetCleanupThrottle();
|
|
76011
|
+
}
|
|
75956
76012
|
getDbPath() {
|
|
75957
76013
|
return this.config.path || DEFAULT_MEMORY_CONFIG.path;
|
|
75958
76014
|
}
|
|
@@ -75989,6 +76045,7 @@ var init_sqlite_memory_store = __esm(() => {
|
|
|
75989
76045
|
if (!existsSync4(dir)) {
|
|
75990
76046
|
await mkdir2(dir, { recursive: true, mode: 448 });
|
|
75991
76047
|
}
|
|
76048
|
+
FileLock.cleanupOldLockFiles(dbPath).catch(() => {});
|
|
75992
76049
|
let dbData;
|
|
75993
76050
|
if (existsSync4(dbPath)) {
|
|
75994
76051
|
const lock = this.getFileLock();
|
|
@@ -94068,9 +94125,11 @@ function createGitReadBinaryFile(commit2) {
|
|
|
94068
94125
|
}
|
|
94069
94126
|
};
|
|
94070
94127
|
}
|
|
94071
|
-
const
|
|
94128
|
+
const isWindows2 = process.platform === "win32";
|
|
94129
|
+
const command = isWindows2 ? `cmd /c "git show ${quotedCommit}:${quotedUrl} | base64 -w 0 2>&1"` : `sh -c "git show ${quotedCommit}:${quotedUrl} | base64 2>&1"`;
|
|
94130
|
+
const result = await provider3.executeCommand(command, false);
|
|
94072
94131
|
if (result.exitCode === 0) {
|
|
94073
|
-
const base64Data =
|
|
94132
|
+
const base64Data = result.stdout.replace(/\n/g, "");
|
|
94074
94133
|
return {
|
|
94075
94134
|
success: true,
|
|
94076
94135
|
message: {
|
|
@@ -94086,11 +94145,13 @@ function createGitReadBinaryFile(commit2) {
|
|
|
94086
94145
|
}
|
|
94087
94146
|
};
|
|
94088
94147
|
} else {
|
|
94148
|
+
const isBase64Error = result.stderr.includes("not recognized") || result.stderr.includes("command not found") || result.stderr.includes("base64");
|
|
94149
|
+
const errorMessage = isBase64Error ? `Failed to read binary file: base64 command not found. On Windows, ensure Git Bash or Unix tools are installed and in PATH.` : `Failed to read binary file: ${result.stderr}`;
|
|
94089
94150
|
return {
|
|
94090
94151
|
success: false,
|
|
94091
94152
|
message: {
|
|
94092
94153
|
type: "error-text",
|
|
94093
|
-
value:
|
|
94154
|
+
value: errorMessage
|
|
94094
94155
|
}
|
|
94095
94156
|
};
|
|
94096
94157
|
}
|
|
@@ -112279,7 +112340,7 @@ var {
|
|
|
112279
112340
|
Help
|
|
112280
112341
|
} = import__.default;
|
|
112281
112342
|
// package.json
|
|
112282
|
-
var version = "0.9.
|
|
112343
|
+
var version = "0.9.93";
|
|
112283
112344
|
|
|
112284
112345
|
// src/commands/agent.ts
|
|
112285
112346
|
init_src();
|
|
@@ -121396,6 +121457,7 @@ var reviewCommand = new Command("review").description("Review a GitHub pull requ
|
|
|
121396
121457
|
const workflowOpts = getBaseWorkflowOptions(command);
|
|
121397
121458
|
if (json2) {
|
|
121398
121459
|
workflowOpts.interactive = false;
|
|
121460
|
+
workflowOpts.silent = true;
|
|
121399
121461
|
}
|
|
121400
121462
|
const { verbose } = workflowOpts;
|
|
121401
121463
|
const logger = createLogger({
|