@yalieny/pi-better-cost-display-footer 2.3.0 → 2.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/README.md
CHANGED
|
@@ -98,10 +98,12 @@ pi install npm:@yalieny/pi-better-cost-display-footer
|
|
|
98
98
|
## 测试
|
|
99
99
|
|
|
100
100
|
```bash
|
|
101
|
-
npm install && npm test #
|
|
101
|
+
npm install && npm test # 单测 + 用本仓库安装的 pi 内置 footer 真实渲染一遍
|
|
102
102
|
node --experimental-strip-types test/drift-probe.ts # 端到端:守卫重试与自愈(用系统临时目录隔离配置)
|
|
103
103
|
```
|
|
104
104
|
|
|
105
|
+
`npm test` 最后一条渲染测试用的是 `node_modules` 里那个 pi。它验证本插件的 session 视图能喂饱**该版本**的内置 footer。`peerDependencies` 是 `*`,所以 `npm install` 会把 pi 装到最新版。升级 pi 后重跑一次 `npm install`,否则本地测的还是旧版(2.3.1 修的那个故障就是这样漏掉的:本地装 0.84.2,实际跑 0.99.1)。
|
|
106
|
+
|
|
105
107
|
## 说明
|
|
106
108
|
|
|
107
109
|
- 顶层仅配置全局 `cacheHitRatePrecision`;`timezone`/`effectiveFrom`/`currencySymbol`/`tierFn`/`defaultTier`/`labels`/`models` 均配置在对应 provider 下。
|
|
@@ -143,6 +145,7 @@ pi 没有“叠加 footer”的扩展点。两家扩展都调 `setFooter` 时,
|
|
|
143
145
|
|
|
144
146
|
## 变更记录
|
|
145
147
|
|
|
148
|
+
- **2.3.1** 修复 pi 0.99.x 下 footer 增强整体失效:「复用内置 footer 失败,改用 pi 自带 footer:sessionManager.getEntryCount is not a function」。原因:本插件给内置 `FooterComponent` 传的是手工转发的 session 替身,只实现了 3 个方法;pi 0.99.0 给内置 footer 加了用量缓存,渲染时新增调用 `getEntryCount()` / `getSessionId()` / `getLeafId()`,替身缺方法即抛错。改法:改用转发 pi **真实** `SessionManager` 实例(pi 只读视图是 `Pick<...>` 子集,`getEntryCount` 不在其中,故需转型),内置 footer 按当前运行版本自己取所需方法。实测 pi 0.84.2 与 0.99.1 均通过;旧替身在新版抛错。新增回归检查:session 视图恒等断言(`sessionManager` 必须是真实例,与 pi 版本无关)+ 用本仓库安装的 pi 内置 footer 真实渲染一遍(跟随 `npm install` 装到的版本)。
|
|
146
149
|
- **2.3.0** footer 改为“增量补丁”而非整段复刻:加载并包装 pi 自己的 `FooterComponent`,只在渲染结果上换金额符号、改 CH 小数位、加 context 占用条、加档位标签与 tok/s;pwd 行改为“`⎇ 分支` 底色 chip + git 变更行数”,右侧模型上 chip、thinking 上色(分隔符沿用内置)。占用条抄 `pi-cc-extensions` 的 `barGauge`,分支图标与分隔符抄 look pack,git 变更行数(含 10s 轮询与分支变化重查)抄 cc。pi 升级 footer(新字段、新布局)自动跟随,不再覆盖。拿不到内置组件或布局变化时降级为 pi 自带 footer 并提醒一次。
|
|
147
150
|
- **2.2.0** footer 新增 tok/s 速率(思考/正文分相位):流式中显示当前相位实时值 `⚡45.2t/s`(无前缀,2s 滚动窗口),assistant `message_end` 用真实 `usage` 冻结为固定三档 `⚡(175.1/r31.8/o613.4)t/s`(总/思考/正文,无值打 `-` 占位);分母从各相位首 delta 起算,不含首 token 延迟与工具执行时长(定稿用 message_end 而非 turn_end)。实时值为估算,思考/正文各自的折算比由真实 token EMA 自校准(初始 4,限幅 0.5~8);异常速率(>1000 t/s)丢弃;无效 `usage`(失败/中止)不覆盖定稿值。/cost-tier 新增两档折算比。
|
|
148
151
|
- **2.1.2** 修复"档位标签正确但计费金额按错档结算":注册守卫改为按实际计费 cost 判定漂移(不再只看档位字符串),注册失败不再写入守卫(下一轮自动重试);漂移 3 次未收敛转为 footer 可见告警(`≈` + 标签 `?`);新增 `/cost-tier` 诊断命令与注册失败一次性提示。方案见 `docs/fix-plan-stale-cost-tier.md`。
|
|
@@ -638,6 +638,17 @@ interface BaseFooterModule {
|
|
|
638
638
|
) => { render(width: number): string[] };
|
|
639
639
|
}
|
|
640
640
|
|
|
641
|
+
/**
|
|
642
|
+
* 内置 footer 用到的 SessionManager 方法。pi 0.99.1 起新增 getEntryCount / getSessionId /
|
|
643
|
+
* getLeafId,扩展侧的 ReadonlySessionManager 不含这些(只读视图是子集)→ 用真实实例前必须转型。
|
|
644
|
+
*/
|
|
645
|
+
type FooterSessionManager = {
|
|
646
|
+
getEntries: () => unknown[];
|
|
647
|
+
getEntryCount: () => number;
|
|
648
|
+
getCwd: () => string;
|
|
649
|
+
getSessionName: () => string | undefined;
|
|
650
|
+
};
|
|
651
|
+
|
|
641
652
|
/** 加载结果:null = 未加载成功(footer 保持 pi 内置) */
|
|
642
653
|
let baseFooter: BaseFooterModule | null = null;
|
|
643
654
|
/** 只尝试加载一次 */
|
|
@@ -698,16 +709,19 @@ function baseFooterStatusText(): string {
|
|
|
698
709
|
* 内置 FooterComponent 需要的 session 视图,数据全部来自扩展 ctx。
|
|
699
710
|
* modelRuntime 未对扩展暴露 → 订阅制保留内置的 kimi-coding 特例。
|
|
700
711
|
*/
|
|
701
|
-
function footerSessionView(ctx: ExtensionContext) {
|
|
712
|
+
export function footerSessionView(ctx: ExtensionContext) {
|
|
702
713
|
const c = () => activeCtx ?? ctx;
|
|
703
714
|
return {
|
|
704
715
|
get state() {
|
|
705
716
|
return { model: c().model, thinkingLevel: c().thinkingLevel };
|
|
706
717
|
},
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
718
|
+
get model() {
|
|
719
|
+
return c().model;
|
|
720
|
+
},
|
|
721
|
+
// 直接把 pi 真实的 SessionManager 交出去:内置 footer 自己取它需要的方法,
|
|
722
|
+
// 不再手工转发(每次 pi 加一个方法就要跟着改一次)。
|
|
723
|
+
get sessionManager() {
|
|
724
|
+
return c().sessionManager as unknown as FooterSessionManager;
|
|
711
725
|
},
|
|
712
726
|
getContextUsage: () => c().getContextUsage(),
|
|
713
727
|
modelRuntime: { isUsingSubscription: (providerId: string) => providerId === "kimi-coding" },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yalieny/pi-better-cost-display-footer",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"description": "pi extension: scriptable peak/off-peak tier rules per provider with an enhanced footer (tier label, cache-hit-rate precision, custom currency symbol)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|