pi-open-tui 0.3.0 → 0.3.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/extensions/open-tui/state.ts +26 -18
- package/package.json +4 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { Usage } from "@earendil-works/pi-ai";
|
|
1
2
|
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import type { AssistantMessage } from "@earendil-works/pi-ai";
|
|
3
3
|
import type { GitStatus } from "./git.ts";
|
|
4
4
|
import { emptyGitStatus } from "./git.ts";
|
|
5
5
|
import type { RuntimeInfo } from "./runtime.ts";
|
|
@@ -39,24 +39,32 @@ export function getUsageTotals(ctx: ExtensionContext): UsageTotals {
|
|
|
39
39
|
latestCacheHitRate: undefined,
|
|
40
40
|
};
|
|
41
41
|
for (const entry of ctx.sessionManager.getEntries()) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
42
|
+
let u: Usage | undefined;
|
|
43
|
+
let updateCacheHitRate = false;
|
|
44
|
+
if (entry.type === "message" && entry.message.role === "assistant") {
|
|
45
|
+
u = entry.message.usage;
|
|
46
|
+
updateCacheHitRate = true;
|
|
47
|
+
} else if (entry.type === "message" && entry.message.role === "toolResult") {
|
|
48
|
+
u = entry.message.usage;
|
|
49
|
+
} else if (entry.type === "branch_summary" || entry.type === "compaction") {
|
|
50
|
+
u = entry.usage;
|
|
51
|
+
}
|
|
52
|
+
if (!u) continue;
|
|
53
|
+
const input = finiteOrZero(u.input);
|
|
54
|
+
const cacheRead = finiteOrZero(u.cacheRead);
|
|
55
|
+
const cacheWrite = finiteOrZero(u.cacheWrite);
|
|
56
|
+
// input matches /session's "uncached" total: cacheWrite is billed near full
|
|
57
|
+
// price (fresh content), only cacheRead is discounted repeat content.
|
|
58
|
+
totals.input += input + cacheWrite;
|
|
59
|
+
totals.output += finiteOrZero(u.output);
|
|
60
|
+
totals.cacheRead += cacheRead;
|
|
61
|
+
totals.cacheWrite += cacheWrite;
|
|
62
|
+
totals.cost += finiteOrZero(u.cost?.total);
|
|
63
|
+
if (updateCacheHitRate) {
|
|
56
64
|
const promptTokens = input + cacheRead + cacheWrite;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
65
|
+
totals.latestCacheHitRate = promptTokens > 0
|
|
66
|
+
? (cacheRead / promptTokens) * 100
|
|
67
|
+
: undefined;
|
|
60
68
|
}
|
|
61
69
|
}
|
|
62
70
|
usageCache = { key, totals };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-open-tui",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "A polished TUI for Pi coding agent: animated logo header, Starship-style footer, rounded editor with model metadata, and prompt-box user messages.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
"image": "https://raw.githubusercontent.com/OldSuns/pi-open-tui/main/assets/preview_dashboard_1.png"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"@earendil-works/pi-coding-agent": ">=0.
|
|
39
|
-
"@earendil-works/pi-ai": ">=0.
|
|
40
|
-
"@earendil-works/pi-tui": ">=0.
|
|
38
|
+
"@earendil-works/pi-coding-agent": ">=0.81",
|
|
39
|
+
"@earendil-works/pi-ai": ">=0.81",
|
|
40
|
+
"@earendil-works/pi-tui": ">=0.81"
|
|
41
41
|
},
|
|
42
42
|
"peerDependenciesMeta": {
|
|
43
43
|
"@earendil-works/pi-coding-agent": {
|