@polka-codes/cli 0.9.91 → 0.9.92
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 +51 -8
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -16534,12 +16534,12 @@ var init_memory = __esm(() => {
|
|
|
16534
16534
|
memoryConfigSchema = exports_external.object({
|
|
16535
16535
|
enabled: exports_external.boolean().optional().default(true),
|
|
16536
16536
|
type: exports_external.enum(["sqlite", "memory"]).optional().default("sqlite"),
|
|
16537
|
-
path: exports_external.string().optional().default("~/.config/
|
|
16537
|
+
path: exports_external.string().optional().default("~/.config/polkacodes/memory/memory.sqlite")
|
|
16538
16538
|
}).strict().optional();
|
|
16539
16539
|
DEFAULT_MEMORY_CONFIG = {
|
|
16540
16540
|
enabled: true,
|
|
16541
16541
|
type: "sqlite",
|
|
16542
|
-
path: "~/.config/
|
|
16542
|
+
path: "~/.config/polkacodes/memory/memory.sqlite"
|
|
16543
16543
|
};
|
|
16544
16544
|
});
|
|
16545
16545
|
|
|
@@ -25517,6 +25517,7 @@ var init_tools2 = __esm(() => {
|
|
|
25517
25517
|
// ../core/src/UsageMeter.ts
|
|
25518
25518
|
class UsageMeter {
|
|
25519
25519
|
#totals = { input: 0, output: 0, cachedRead: 0, cost: 0, messageCount: 0 };
|
|
25520
|
+
#providerMetadataEntries = [];
|
|
25520
25521
|
#modelInfos;
|
|
25521
25522
|
#maxMessages;
|
|
25522
25523
|
#maxCost;
|
|
@@ -25598,8 +25599,17 @@ class UsageMeter {
|
|
|
25598
25599
|
this.#totals.cachedRead += result.cachedRead || 0;
|
|
25599
25600
|
this.#totals.cost += result.cost || 0;
|
|
25600
25601
|
this.#totals.messageCount += 1;
|
|
25602
|
+
if (resp.providerMetadata && Object.keys(resp.providerMetadata).length > 0) {
|
|
25603
|
+
const providerKey = Object.keys(resp.providerMetadata)[0];
|
|
25604
|
+
this.#providerMetadataEntries.push({
|
|
25605
|
+
provider: providerKey || llm.provider,
|
|
25606
|
+
model: llm.modelId,
|
|
25607
|
+
metadata: resp.providerMetadata[providerKey] || resp.providerMetadata,
|
|
25608
|
+
timestamp: Date.now()
|
|
25609
|
+
});
|
|
25610
|
+
}
|
|
25601
25611
|
}
|
|
25602
|
-
setUsage(newUsage) {
|
|
25612
|
+
setUsage(newUsage, options = {}) {
|
|
25603
25613
|
if (newUsage.input != null)
|
|
25604
25614
|
this.#totals.input = newUsage.input;
|
|
25605
25615
|
if (newUsage.output != null)
|
|
@@ -25610,12 +25620,16 @@ class UsageMeter {
|
|
|
25610
25620
|
this.#totals.cost = newUsage.cost;
|
|
25611
25621
|
if (newUsage.messageCount != null)
|
|
25612
25622
|
this.#totals.messageCount = newUsage.messageCount;
|
|
25623
|
+
if (options.clearMetadata) {
|
|
25624
|
+
this.#providerMetadataEntries = [];
|
|
25625
|
+
}
|
|
25613
25626
|
}
|
|
25614
25627
|
incrementMessageCount(n = 1) {
|
|
25615
25628
|
this.#totals.messageCount += n;
|
|
25616
25629
|
}
|
|
25617
25630
|
resetUsage() {
|
|
25618
25631
|
this.#totals = { input: 0, output: 0, cachedRead: 0, cost: 0, messageCount: 0 };
|
|
25632
|
+
this.#providerMetadataEntries = [];
|
|
25619
25633
|
}
|
|
25620
25634
|
isLimitExceeded() {
|
|
25621
25635
|
const messageCount = this.#maxMessages > 0 && this.#totals.messageCount >= this.#maxMessages;
|
|
@@ -25637,6 +25651,34 @@ class UsageMeter {
|
|
|
25637
25651
|
get usage() {
|
|
25638
25652
|
return { ...this.#totals };
|
|
25639
25653
|
}
|
|
25654
|
+
get providerMetadata() {
|
|
25655
|
+
return [...this.#providerMetadataEntries];
|
|
25656
|
+
}
|
|
25657
|
+
get cacheStats() {
|
|
25658
|
+
const entries = this.#providerMetadataEntries;
|
|
25659
|
+
const totalRequests = entries.length;
|
|
25660
|
+
let totalCachedTokens = 0;
|
|
25661
|
+
let requestsWithCache = 0;
|
|
25662
|
+
for (const entry of entries) {
|
|
25663
|
+
const metadata = entry.metadata;
|
|
25664
|
+
const cachedTokens = metadata.cachedPromptTokens ?? metadata.cacheReadTokens ?? metadata.prompt_cache_hit_tokens ?? 0;
|
|
25665
|
+
if (cachedTokens > 0) {
|
|
25666
|
+
totalCachedTokens += cachedTokens;
|
|
25667
|
+
requestsWithCache++;
|
|
25668
|
+
}
|
|
25669
|
+
}
|
|
25670
|
+
const cacheHitRate = totalRequests > 0 ? requestsWithCache / totalRequests : 0;
|
|
25671
|
+
return {
|
|
25672
|
+
totalCachedTokens,
|
|
25673
|
+
totalRequests,
|
|
25674
|
+
requestsWithCache,
|
|
25675
|
+
cacheHitRate,
|
|
25676
|
+
entries: [...this.#providerMetadataEntries]
|
|
25677
|
+
};
|
|
25678
|
+
}
|
|
25679
|
+
clearProviderMetadata() {
|
|
25680
|
+
this.#providerMetadataEntries = [];
|
|
25681
|
+
}
|
|
25640
25682
|
merge(other) {
|
|
25641
25683
|
const otherUsage = other.usage;
|
|
25642
25684
|
this.#totals.input += otherUsage.input;
|
|
@@ -25644,6 +25686,7 @@ class UsageMeter {
|
|
|
25644
25686
|
this.#totals.cachedRead += otherUsage.cachedRead;
|
|
25645
25687
|
this.#totals.cost += otherUsage.cost;
|
|
25646
25688
|
this.#totals.messageCount += otherUsage.messageCount;
|
|
25689
|
+
this.#providerMetadataEntries.push(...other.providerMetadata);
|
|
25647
25690
|
}
|
|
25648
25691
|
getUsageText() {
|
|
25649
25692
|
const u = this.usage;
|
|
@@ -73481,7 +73524,7 @@ var init_provider = __esm(() => {
|
|
|
73481
73524
|
|
|
73482
73525
|
// ../../node_modules/sql.js/dist/sql-wasm.js
|
|
73483
73526
|
var require_sql_wasm = __commonJS((exports, module) => {
|
|
73484
|
-
var __dirname = "/
|
|
73527
|
+
var __dirname = "/home/ubuntu/polka-codes/node_modules/sql.js/dist";
|
|
73485
73528
|
var initSqlJsPromise = undefined;
|
|
73486
73529
|
var initSqlJs = function(moduleConfig) {
|
|
73487
73530
|
if (initSqlJsPromise) {
|
|
@@ -94441,7 +94484,7 @@ var reviewWorkflow = async (input, context) => {
|
|
|
94441
94484
|
return { overview: "No changes to review.", specificReviews: [] };
|
|
94442
94485
|
}
|
|
94443
94486
|
const targetCommit = extractTargetCommit(range, pr2);
|
|
94444
|
-
const isRange = range
|
|
94487
|
+
const isRange = range?.includes("..");
|
|
94445
94488
|
const finalChangeInfo = targetCommit && !isRange ? { ...changeInfo, targetCommit } : changeInfo;
|
|
94446
94489
|
const fileTools = targetCommit && !isRange ? createGitAwareTools(targetCommit) : { readFile: readFile_default, listFiles: listFiles_default, readBinaryFile: readBinaryFile_default };
|
|
94447
94490
|
const reviewTools = targetCommit && !isRange ? [fileTools.readFile, fileTools.readBinaryFile, fileTools.listFiles, createGitAwareDiff(targetCommit)] : [readFile_default, readBinaryFile_default, searchFiles_default, listFiles_default, gitDiff_default];
|
|
@@ -112236,7 +112279,7 @@ var {
|
|
|
112236
112279
|
Help
|
|
112237
112280
|
} = import__.default;
|
|
112238
112281
|
// package.json
|
|
112239
|
-
var version = "0.9.
|
|
112282
|
+
var version = "0.9.92";
|
|
112240
112283
|
|
|
112241
112284
|
// src/commands/agent.ts
|
|
112242
112285
|
init_src();
|
|
@@ -120933,8 +120976,8 @@ async function memoryStatus() {
|
|
|
120933
120976
|
const stats = await store.getStats();
|
|
120934
120977
|
const globalConfigPath = getGlobalConfigPath();
|
|
120935
120978
|
const config4 = await loadConfigAtPath(globalConfigPath);
|
|
120936
|
-
const memoryConfig = config4?.memory || { path: "~/.config/
|
|
120937
|
-
const dbPath = resolveHomePath(memoryConfig.path || "~/.config/
|
|
120979
|
+
const memoryConfig = config4?.memory || { path: "~/.config/polkacodes/memory/memory.sqlite" };
|
|
120980
|
+
const dbPath = resolveHomePath(memoryConfig.path || "~/.config/polkacodes/memory/memory.sqlite");
|
|
120938
120981
|
console.log(`
|
|
120939
120982
|
Memory Store Status:`);
|
|
120940
120983
|
console.log("─".repeat(80));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polka-codes/cli",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.92",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"author": "github@polka.codes",
|
|
6
6
|
"type": "module",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"@inquirer/prompts": "^8.1.0",
|
|
30
30
|
"@modelcontextprotocol/sdk": "^1.25.1",
|
|
31
31
|
"@openrouter/ai-sdk-provider": "^1.5.4",
|
|
32
|
-
"@polka-codes/cli-shared": "0.9.
|
|
33
|
-
"@polka-codes/core": "0.9.
|
|
32
|
+
"@polka-codes/cli-shared": "0.9.91",
|
|
33
|
+
"@polka-codes/core": "0.9.91",
|
|
34
34
|
"ai": "^5.0.117",
|
|
35
35
|
"chalk": "^5.6.2",
|
|
36
36
|
"commander": "^14.0.2",
|