@narumitw/pi-starship 0.65.2 → 0.66.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/CHANGELOG.md +6 -0
- package/README.md +5 -0
- package/dist/chunks/{chunk-PZWT7OTP.ts → chunk-BOMYDCT7.ts} +3 -3
- package/dist/chunks/{chunk-5YA3XF7S.ts → chunk-CUXPMKBQ.ts} +16 -1
- package/dist/chunks/chunk-CUXPMKBQ.ts.map +7 -0
- package/dist/chunks/{chunk-RQY2AYI2.ts → chunk-UZJIMIWL.ts} +2 -2
- package/dist/chunks/{command-configuration-menu-JHKQ5SDW.ts → command-configuration-menu-N3SP6R3I.ts} +3 -3
- package/dist/chunks/{command-settings-chat-RN2GDMF5.ts → command-settings-chat-4NLO3RDC.ts} +4 -4
- package/dist/chunks/{commands-XIRYGV7S.ts → commands-MSJ67CTR.ts} +6 -6
- package/dist/index.ts +20 -6
- package/dist/index.ts.map +2 -2
- package/package.json +1 -1
- package/skills/configure-pi-starship/references/module-catalog.md +17 -1
- package/skills/configure-pi-starship/references/modules.md +27 -0
- package/src/modules/catalog.ts +4 -0
- package/src/modules/tokens-per-second.ts +14 -0
- package/src/modules/types.ts +1 -0
- package/src/pi-starship.ts +4 -7
- package/src/usage.ts +25 -0
- package/dist/chunks/chunk-5YA3XF7S.ts.map +0 -7
- /package/dist/chunks/{chunk-PZWT7OTP.ts.map → chunk-BOMYDCT7.ts.map} +0 -0
- /package/dist/chunks/{chunk-RQY2AYI2.ts.map → chunk-UZJIMIWL.ts.map} +0 -0
- /package/dist/chunks/{command-configuration-menu-JHKQ5SDW.ts.map → command-configuration-menu-N3SP6R3I.ts.map} +0 -0
- /package/dist/chunks/{command-settings-chat-RN2GDMF5.ts.map → command-settings-chat-4NLO3RDC.ts.map} +0 -0
- /package/dist/chunks/{commands-XIRYGV7S.ts.map → commands-MSJ67CTR.ts.map} +0 -0
package/package.json
CHANGED
|
@@ -27,7 +27,7 @@ All enum values are case-sensitive.
|
|
|
27
27
|
|
|
28
28
|
## Catalog order
|
|
29
29
|
|
|
30
|
-
`brand` → `provider` → `model` → `thinking` → `directory` → `git_worktree` → `git_branch` → `github_pr` → `git_commit` → `git_state` → `git_metrics` → `git_status` → `jj_bookmark` → `jj_change` → `jj_metrics` → `jj_status` → `package` → `nodejs` → `python` → `rust` → `golang` → `bun` → `deno` → `mise` → `direnv` → `conda` → `pixi` → `nix_shell` → `guix_shell` → `docker_context` → `kubernetes` → `terraform` → `aws` → `gcloud` → `azure` → `openstack` → `os` → `container` → `hostname` → `username` → `memory_usage` → `battery` → `activity` → `context` → `tokens` → `cache` → `cost` → `time` → `turn` → `fill` → `extension_status`
|
|
30
|
+
`brand` → `provider` → `model` → `thinking` → `directory` → `git_worktree` → `git_branch` → `github_pr` → `git_commit` → `git_state` → `git_metrics` → `git_status` → `jj_bookmark` → `jj_change` → `jj_metrics` → `jj_status` → `package` → `nodejs` → `python` → `rust` → `golang` → `bun` → `deno` → `mise` → `direnv` → `conda` → `pixi` → `nix_shell` → `guix_shell` → `docker_context` → `kubernetes` → `terraform` → `aws` → `gcloud` → `azure` → `openstack` → `os` → `container` → `hostname` → `username` → `memory_usage` → `battery` → `activity` → `context` → `tokens` → `tokens_per_second` → `cache` → `cost` → `time` → `turn` → `fill` → `extension_status`
|
|
31
31
|
|
|
32
32
|
## Module schemas
|
|
33
33
|
|
|
@@ -1139,6 +1139,22 @@ Accepted style fields:
|
|
|
1139
1139
|
| --- | --- |
|
|
1140
1140
|
| `style` | `"bold cyan"` |
|
|
1141
1141
|
|
|
1142
|
+
### `tokens_per_second`
|
|
1143
|
+
|
|
1144
|
+
Average output tokens per second for the latest completed assistant response on the active branch.
|
|
1145
|
+
|
|
1146
|
+
- Format variables: `$symbol`, `$rate`.
|
|
1147
|
+
- Style variables in `format`: `$style`.
|
|
1148
|
+
- Default `format`: `"[$rate tok/s ]($style)"`.
|
|
1149
|
+
- Default `symbol`: `""`.
|
|
1150
|
+
- Default `disabled`: `true`.
|
|
1151
|
+
|
|
1152
|
+
Accepted style fields:
|
|
1153
|
+
|
|
1154
|
+
| Field | Default |
|
|
1155
|
+
| --- | --- |
|
|
1156
|
+
| `style` | `"bold cyan"` |
|
|
1157
|
+
|
|
1142
1158
|
### `cache`
|
|
1143
1159
|
|
|
1144
1160
|
Prompt-cache usage and latest cache hit rate.
|
|
@@ -27,6 +27,7 @@ Use this authoritative public reference whenever a question or change involves a
|
|
|
27
27
|
| `activity` | `$symbol`, `$state`, `$tool`, `$count`, `$kind`, `$title`, `$text` | Extension UI waits, active tools, streaming, completion, or idle |
|
|
28
28
|
| `context` | `$symbol`, `$percentage`, `$tokens`, `$window` | Context-window use |
|
|
29
29
|
| `tokens` | `$symbol`, `$input`, `$output`, `$total` | Token totals |
|
|
30
|
+
| `tokens_per_second` | `$symbol`, `$rate` | Latest completed assistant response's average output rate on the active branch; disabled by default |
|
|
30
31
|
| `cache` | `$symbol`, `$rate`, `$read`, `$write` | Prompt-cache reads, writes, and latest hit rate; disabled by default |
|
|
31
32
|
| `cost` | `$symbol`, `$cost`, `$subscription`, `$source` | Session cost, provider-total provenance, and optional `(sub)` marker |
|
|
32
33
|
| `time` | `$symbol`, `$time` | Formatted clock; local `HH:mm` by default |
|
|
@@ -229,6 +230,32 @@ These are inert labels, not evidence of cluster access or valid credentials.
|
|
|
229
230
|
- Subscription-backed OAuth models and `kimi-coding` set cost `$subscription` to `(sub)`.
|
|
230
231
|
The dollar value is usage cost, not proof of an amount billed under a subscription.
|
|
231
232
|
|
|
233
|
+
### Tokens per second
|
|
234
|
+
|
|
235
|
+
`tokens_per_second` shows the latest completed assistant response on the active branch, not cumulative session throughput.
|
|
236
|
+
Enable it explicitly and include it in the root format, or use `$all` after enabling it:
|
|
237
|
+
|
|
238
|
+
```toml
|
|
239
|
+
format = "$model$tokens$tokens_per_second"
|
|
240
|
+
|
|
241
|
+
[tokens_per_second]
|
|
242
|
+
disabled = false
|
|
243
|
+
format = "[$rate tok/s ]($style)"
|
|
244
|
+
style = "bold cyan"
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
`$rate` is `usage.output / (durationMs / 1000)`, formatted to one decimal place; 85 output tokens over 2 seconds displays `42.5 tok/s`.
|
|
248
|
+
The duration is Pi's recorded full-response duration, including request latency and thinking time, but not subsequent tool execution or time between responses.
|
|
249
|
+
Output tokens use the provider's accounting, which can include reasoning tokens; this is not a visible-text estimate or a decode-only speed measurement.
|
|
250
|
+
Responses ending with `stop`, `length`, or `toolUse` can supply a rate, including tool-calling responses before their tools finish.
|
|
251
|
+
|
|
252
|
+
The latest completed response remains visible while a new response is streaming; partial usage is not estimated.
|
|
253
|
+
A latest failed, aborted, pending, deferred, or untimed response hides the module instead of showing an older response's rate.
|
|
254
|
+
Missing, nonfinite, or negative output counts, nonpositive or nonfinite durations, and nonfinite calculated rates also hide the module; valid zero output shows `0.0 tok/s`.
|
|
255
|
+
Older sessions and some deferred results have no recorded duration.
|
|
256
|
+
Resume, reload, fork, and tree navigation derive the value from the active branch, so abandoned-branch responses, tool results, compactions, branch summaries, and cache-warming usage do not supply the rate.
|
|
257
|
+
This module does not change the cumulative accounting used by `tokens`, `cache`, or `cost`.
|
|
258
|
+
|
|
232
259
|
### Directory, Git, and environment contraction
|
|
233
260
|
|
|
234
261
|
These modules keep their display policy local. Existing Pi defaults remain unchanged:
|
package/src/modules/catalog.ts
CHANGED
|
@@ -26,6 +26,7 @@ import { systemModules } from "./system.js";
|
|
|
26
26
|
import { thinkingModule } from "./thinking.js";
|
|
27
27
|
import { timeModule } from "./time.js";
|
|
28
28
|
import { tokensModule } from "./tokens.js";
|
|
29
|
+
import { tokensPerSecondModule } from "./tokens-per-second.js";
|
|
29
30
|
import { turnModule } from "./turn.js";
|
|
30
31
|
import type { ModuleDefinition } from "./types.js";
|
|
31
32
|
|
|
@@ -53,6 +54,7 @@ const MODULE_IMPLEMENTATIONS = [
|
|
|
53
54
|
activityModule,
|
|
54
55
|
contextModule,
|
|
55
56
|
tokensModule,
|
|
57
|
+
tokensPerSecondModule,
|
|
56
58
|
cacheModule,
|
|
57
59
|
costModule,
|
|
58
60
|
timeModule,
|
|
@@ -114,6 +116,8 @@ const MODULE_DESCRIPTIONS = {
|
|
|
114
116
|
thinking: "Current Pi thinking level or streaming state.",
|
|
115
117
|
time: "Current local time.",
|
|
116
118
|
tokens: "Session input and output token totals.",
|
|
119
|
+
tokens_per_second:
|
|
120
|
+
"Average output tokens per second for the latest completed assistant response on the active branch.",
|
|
117
121
|
turn: "Current user-turn count.",
|
|
118
122
|
username: "Current user identity when configured to display.",
|
|
119
123
|
} as const satisfies Record<ModuleName, string>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { defineModule } from "./types.js";
|
|
2
|
+
|
|
3
|
+
export const tokensPerSecondModule = defineModule({
|
|
4
|
+
name: "tokens_per_second",
|
|
5
|
+
variables: ["symbol", "rate"],
|
|
6
|
+
defaults: {
|
|
7
|
+
format: "[$rate tok/s ]($style)",
|
|
8
|
+
symbol: "",
|
|
9
|
+
style: "bold cyan",
|
|
10
|
+
disabled: true,
|
|
11
|
+
},
|
|
12
|
+
values: ({ runtime }) =>
|
|
13
|
+
runtime.tokensPerSecond === undefined ? undefined : { rate: runtime.tokensPerSecond.toFixed(1) },
|
|
14
|
+
});
|
package/src/modules/types.ts
CHANGED
package/src/pi-starship.ts
CHANGED
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
type WorkspaceRefreshInput,
|
|
30
30
|
workspaceSnapshotEqual,
|
|
31
31
|
} from "./runtime/workspace.js";
|
|
32
|
-
import { summarizeFooterUsage } from "./usage.js";
|
|
32
|
+
import { latestTokensPerSecond, summarizeFooterUsage } from "./usage.js";
|
|
33
33
|
|
|
34
34
|
const REFRESH_INTERVAL_MS = 30_000;
|
|
35
35
|
const GITHUB_PR_REFRESH_INTERVAL_MS = 60_000;
|
|
@@ -711,19 +711,21 @@ function runtimeSnapshot(
|
|
|
711
711
|
footerData: Pick<ReadonlyFooterDataProvider, "getGitBranch" | "getExtensionStatuses">,
|
|
712
712
|
runtime: RuntimeState,
|
|
713
713
|
): StarshipRuntimeSnapshot {
|
|
714
|
+
const branch = ctx.sessionManager.getBranch();
|
|
714
715
|
return {
|
|
715
716
|
cwd: ctx.cwd,
|
|
716
717
|
homeDir: homedir(),
|
|
717
718
|
gitRoot: runtime.git?.root,
|
|
718
719
|
model: ctx.model ? { provider: ctx.model.provider, id: ctx.model.id } : undefined,
|
|
719
720
|
thinkingLevel: runtime.thinkingLevel,
|
|
720
|
-
turnCount:
|
|
721
|
+
turnCount: branch.filter((entry) => entry.type === "message" && entry.message.role === "user").length,
|
|
721
722
|
activeTools: runtime.activeTools,
|
|
722
723
|
isStreaming: runtime.isStreaming,
|
|
723
724
|
uiPrompt: runtime.uiPrompt,
|
|
724
725
|
lastCompletedTool: runtime.lastCompletedTool,
|
|
725
726
|
contextUsage: ctx.getContextUsage() ?? undefined,
|
|
726
727
|
tokenTotals: summarizeFooterUsage(ctx.sessionManager.getEntries()),
|
|
728
|
+
tokensPerSecond: latestTokensPerSecond(branch),
|
|
727
729
|
usingSubscription: isSubscriptionBacked(ctx),
|
|
728
730
|
gitBranch: runtime.git?.branch?.name ?? footerData.getGitBranch(),
|
|
729
731
|
gitBranchDetails: runtime.git?.branch,
|
|
@@ -739,11 +741,6 @@ function runtimeSnapshot(
|
|
|
739
741
|
};
|
|
740
742
|
}
|
|
741
743
|
|
|
742
|
-
function userTurnCount(ctx: ExtensionContext): number {
|
|
743
|
-
return ctx.sessionManager.getBranch().filter((entry) => entry.type === "message" && entry.message.role === "user")
|
|
744
|
-
.length;
|
|
745
|
-
}
|
|
746
|
-
|
|
747
744
|
function isSubscriptionBacked(ctx: ExtensionContext): boolean {
|
|
748
745
|
const model = ctx.model;
|
|
749
746
|
return model !== undefined && (model.provider === "kimi-coding" || ctx.modelRegistry.isUsingOAuth(model));
|
package/src/usage.ts
CHANGED
|
@@ -18,6 +18,31 @@ export interface FooterUsageSummary {
|
|
|
18
18
|
latestCacheHitRate?: number;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
/** Use the latest assistant only: an untimed or incomplete response must not expose an older rate. */
|
|
22
|
+
export function latestTokensPerSecond(branch: readonly SessionEntry[]): number | undefined {
|
|
23
|
+
for (let index = branch.length - 1; index >= 0; index -= 1) {
|
|
24
|
+
const entry = branch[index];
|
|
25
|
+
if (entry?.type !== "message" || entry.message.role !== "assistant") continue;
|
|
26
|
+
const { stopReason, durationMs, usage } = entry.message;
|
|
27
|
+
if (stopReason !== "stop" && stopReason !== "length" && stopReason !== "toolUse") return undefined;
|
|
28
|
+
const output = usage?.output;
|
|
29
|
+
if (
|
|
30
|
+
typeof durationMs !== "number" ||
|
|
31
|
+
!Number.isFinite(durationMs) ||
|
|
32
|
+
durationMs <= 0 ||
|
|
33
|
+
typeof output !== "number" ||
|
|
34
|
+
!Number.isFinite(output) ||
|
|
35
|
+
output < 0
|
|
36
|
+
) {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
// Pi times the complete response, including request latency, not just streamed text.
|
|
40
|
+
const rate = output / (durationMs / 1000);
|
|
41
|
+
return Number.isFinite(rate) ? rate : undefined;
|
|
42
|
+
}
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
|
|
21
46
|
export function summarizeFooterUsage(entries: readonly SessionEntry[]): FooterUsageSummary {
|
|
22
47
|
const totals: FooterUsageSummary = {
|
|
23
48
|
input: 0,
|