@firstpick/pi-extension-stats 0.1.5 → 0.1.7
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/README.md +8 -3
- package/index.ts +1 -18
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -24,9 +24,14 @@ No required configuration.
|
|
|
24
24
|
|
|
25
25
|
## Commands
|
|
26
26
|
|
|
27
|
-
- `/stats` — show last 14 days.
|
|
28
|
-
- `/stats
|
|
29
|
-
- `/stats
|
|
27
|
+
- `/stats [days|all]` — show token usage dashboard (default: last 14 days).
|
|
28
|
+
- `/stats tokens` — show current context token breakdown by source/type.
|
|
29
|
+
- `/stats-pi` — show prompt-injection token breakdown.
|
|
30
|
+
- `/stats-last [days|all]` — show non-zero daily usage graph.
|
|
31
|
+
- `/stats-most-expense [days|all]` — show most expensive sessions.
|
|
32
|
+
- `/stats-model-compare [days|all]` — show model token/cost comparison.
|
|
33
|
+
- `/stats-cost-trend [days|all]` — show cost trend and projections.
|
|
34
|
+
- `/stats-cache [days|all]` — show cache efficiency and token mix.
|
|
30
35
|
|
|
31
36
|
## Tools
|
|
32
37
|
|
package/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ import * as fs from "node:fs";
|
|
|
2
2
|
import * as path from "node:path";
|
|
3
3
|
import { buildSessionContext, formatSkillsForPrompt } from "@earendil-works/pi-coding-agent";
|
|
4
4
|
import type { BuildSystemPromptOptions, ExtensionAPI, ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
5
|
+
import { estimatePromptInjectionTokens, estimateTokensFromCharCount, formatTokens } from "@firstpick/pi-utils";
|
|
5
6
|
|
|
6
7
|
type DayUsage = {
|
|
7
8
|
input: number;
|
|
@@ -44,24 +45,6 @@ const DEFAULT_DAYS = 14;
|
|
|
44
45
|
const MAX_BAR_WIDTH = 24;
|
|
45
46
|
const COST_BAR_WIDTH = 10;
|
|
46
47
|
|
|
47
|
-
function formatTokens(count: number): string {
|
|
48
|
-
if (count < 1000) return count.toString();
|
|
49
|
-
if (count < 10000) return `${(count / 1000).toFixed(1)}k`;
|
|
50
|
-
if (count < 1000000) return `${Math.round(count / 1000)}k`;
|
|
51
|
-
if (count < 10000000) return `${(count / 1000000).toFixed(1)}M`;
|
|
52
|
-
return `${Math.round(count / 1000000)}M`;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function estimateTokensFromCharCount(charCount: number): number {
|
|
56
|
-
// Keep this estimate intentionally identical to pi-extension-git-footer-status.
|
|
57
|
-
// Provider tokenizers differ, so chars/4 is the shared rough display estimate.
|
|
58
|
-
return Math.max(0, Math.round(charCount / 4));
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function estimatePromptInjectionTokens(systemPrompt: string): number {
|
|
62
|
-
return estimateTokensFromCharCount(systemPrompt.length);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
48
|
function addPromptSource(sources: PromptInjectionSource[], label: string, content: string | undefined): number {
|
|
66
49
|
if (!content) return 0;
|
|
67
50
|
const chars = content.length;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firstpick/pi-extension-stats",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "Token and cost usage analytics command for Pi session history.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -14,6 +14,9 @@
|
|
|
14
14
|
"./index.ts"
|
|
15
15
|
]
|
|
16
16
|
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@firstpick/pi-utils": "^0.1.3"
|
|
19
|
+
},
|
|
17
20
|
"peerDependencies": {
|
|
18
21
|
"@earendil-works/pi-coding-agent": "*"
|
|
19
22
|
},
|