@firstpick/pi-extension-git-footer-status 0.1.8 → 0.2.0
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/index.ts +29 -19
- package/package.json +4 -1
package/index.ts
CHANGED
|
@@ -3,6 +3,13 @@ import { homedir } from "node:os";
|
|
|
3
3
|
import { isAbsolute, resolve, sep } from "node:path";
|
|
4
4
|
import type { AssistantMessage } from "@earendil-works/pi-ai";
|
|
5
5
|
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
6
|
+
import {
|
|
7
|
+
collectInitialPromptCalibration,
|
|
8
|
+
estimateInitialPromptInput,
|
|
9
|
+
estimateTokensFromCharCount,
|
|
10
|
+
formatTokens,
|
|
11
|
+
type InitialPromptToolInfo,
|
|
12
|
+
} from "@firstpick/pi-utils";
|
|
6
13
|
import { truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
|
|
7
14
|
|
|
8
15
|
type GitSnapshot = {
|
|
@@ -62,14 +69,6 @@ function formatCwd(cwd: string): string {
|
|
|
62
69
|
return cwd;
|
|
63
70
|
}
|
|
64
71
|
|
|
65
|
-
function formatTokens(count: number): string {
|
|
66
|
-
if (count < 1000) return count.toString();
|
|
67
|
-
if (count < 10000) return `${(count / 1000).toFixed(1)}k`;
|
|
68
|
-
if (count < 1000000) return `${Math.round(count / 1000)}k`;
|
|
69
|
-
if (count < 10000000) return `${(count / 1000000).toFixed(1)}M`;
|
|
70
|
-
return `${Math.round(count / 1000000)}M`;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
72
|
function normalizeTimestampMs(timestamp: number): number {
|
|
74
73
|
// Handle mixed timestamp units from different session formats.
|
|
75
74
|
// seconds -> ms (e.g. 1715000000)
|
|
@@ -97,16 +96,6 @@ type LiveTokenSample = {
|
|
|
97
96
|
tokens: number;
|
|
98
97
|
};
|
|
99
98
|
|
|
100
|
-
function estimateTokensFromCharCount(charCount: number): number {
|
|
101
|
-
// Provider tokenizers differ and streaming usage is normally only available at message end.
|
|
102
|
-
// chars/4 is the common rough estimate for live display; final usage uses provider counts.
|
|
103
|
-
return Math.max(0, Math.round(charCount / 4));
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function estimatePromptInjectionTokens(systemPrompt: string): number {
|
|
107
|
-
return estimateTokensFromCharCount(systemPrompt.length);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
99
|
function formatTokenSpeed(tokensPerSecond: number): string {
|
|
111
100
|
if (tokensPerSecond < 100) {
|
|
112
101
|
if (tokensPerSecond >= 10) return tokensPerSecond.toFixed(1);
|
|
@@ -500,7 +489,28 @@ export default function gitFooterStatus(pi: ExtensionAPI) {
|
|
|
500
489
|
latestTokenSpeed = historicalTokenSpeed;
|
|
501
490
|
}
|
|
502
491
|
|
|
503
|
-
|
|
492
|
+
let activeTools: string[] = [];
|
|
493
|
+
let allTools: InitialPromptToolInfo[] = [];
|
|
494
|
+
try {
|
|
495
|
+
activeTools = pi.getActiveTools();
|
|
496
|
+
} catch {
|
|
497
|
+
activeTools = [];
|
|
498
|
+
}
|
|
499
|
+
try {
|
|
500
|
+
allTools = pi.getAllTools().map((tool) => ({
|
|
501
|
+
name: tool.name,
|
|
502
|
+
description: tool.description,
|
|
503
|
+
parameters: tool.parameters,
|
|
504
|
+
}));
|
|
505
|
+
} catch {
|
|
506
|
+
allTools = [];
|
|
507
|
+
}
|
|
508
|
+
const promptInjectionTokens = estimateInitialPromptInput({
|
|
509
|
+
systemPrompt: ctx.getSystemPrompt(),
|
|
510
|
+
activeTools,
|
|
511
|
+
allTools,
|
|
512
|
+
calibration: collectInitialPromptCalibration(ctx.sessionManager.getSessionDir()),
|
|
513
|
+
}).total;
|
|
504
514
|
|
|
505
515
|
const contextUsage = ctx.getContextUsage();
|
|
506
516
|
const contextWindow = contextUsage?.contextWindow ?? ctx.model?.contextWindow ?? 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firstpick/pi-extension-git-footer-status",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Enhanced Pi footer with git status, token usage, context usage, and model telemetry.",
|
|
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
|
"@earendil-works/pi-ai": "*",
|