pi-ptc-meter 1.0.30 → 1.0.31

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.
Files changed (2) hide show
  1. package/index.ts +6 -3
  2. package/package.json +1 -1
package/index.ts CHANGED
@@ -87,6 +87,7 @@ export function median(xs: number[]): number {
87
87
  if (!xs.length) return 0;
88
88
  const s = [...xs].sort((a, b) => a - b);
89
89
  const m = Math.floor(s.length / 2);
90
+ // 偶数长度取整到整数毫秒:该值只用于展示(ms / 次数),保留小数无意义
90
91
  return s.length % 2 ? s[m] : Math.round((s[m - 1] + s[m]) / 2);
91
92
  }
92
93
 
@@ -198,10 +199,11 @@ function statsLine(th: number, med: number, rows: Row[]): string {
198
199
  const parts: string[] = [`上一轮 ${last} 次工具调用`];
199
200
  if (secs !== null) {
200
201
  parts.push(`实际 ${secs}s`);
201
- if (lastTurnHit !== null) parts.push(`命中 ${lastTurnHit}%${lastTurnHit < 90 ? "(低)" : ""}`);
202
+ if (lastTurnHit !== null && lastTurnHit < 90) parts.push(`命中 ${lastTurnHit}%(低)`);
202
203
  if (lastTurnEstCalls !== null && lastTurnEstCalls > 0) {
203
204
  const dc = Math.round(((last - lastTurnEstCalls) / lastTurnEstCalls) * 100);
204
- parts.push(`预计 ${lastTurnEstCalls} 次 / 实际 ${last} 次(偏差 ${dc >= 0 ? "+" : ""}${dc}%)`);
205
+ if (Math.abs(dc) <= 10) parts.push(`预计 ${lastTurnEstCalls} / 实际 ${last} 次(基本吻合)`);
206
+ else parts.push(`预计 ${lastTurnEstCalls} 次 / 实际 ${last} 次(偏差 ${dc >= 0 ? "+" : ""}${dc}%)`);
205
207
  }
206
208
  if (lastTurnEst !== null) {
207
209
  const dev = Math.round(((lastTurnMs / 1000 - lastTurnEst) / lastTurnEst) * 100);
@@ -223,7 +225,8 @@ function statsLine(th: number, med: number, rows: Row[]): string {
223
225
  const mdc = median(dcs);
224
226
  if (mdc <= -20 || mdc >= 20) {
225
227
  const f = Math.min(3, Math.max(0.2, Math.round((1 + mdc / 100) * 100) / 100)); // 夹在 0.2–3:极端中位(声明失真)不放大成荒谬倍数
226
- parts.push(`近 ${ecRows.length} 轮调用数系统性${mdc < 0 ? "高估" : "低估"}(中位 ${mdc > 0 ? "+" : ""}${Math.round(mdc)}%)→ 本轮按约 ${f} 倍报`);
228
+ const lastEst = ecRows[ecRows.length - 1].estCalls as number;
229
+ parts.push(`近 ${ecRows.length} 轮调用数系统性${mdc < 0 ? "高估" : "低估"}(中位 ${mdc > 0 ? "+" : ""}${Math.round(mdc)}%)→ 本轮按约 ${f} 倍报(≈ ${Math.max(1, Math.round(lastEst * f))} 次)`);
227
230
  }
228
231
  }
229
232
  } catch { /* 静默 */ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-ptc-meter",
3
- "version": "1.0.30",
3
+ "version": "1.0.31",
4
4
  "description": "Measures tool-call batching per turn and feeds the numbers back to the model.",
5
5
  "type": "module",
6
6
  "license": "MIT",