pi-ptc-meter 1.0.1 → 1.0.3
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 +1 -1
- package/index.ts +9 -5
- package/package.json +3 -2
package/README.md
CHANGED
package/index.ts
CHANGED
|
@@ -147,9 +147,10 @@ export function appendRow(row: Record<string, unknown>): void {
|
|
|
147
147
|
try {
|
|
148
148
|
appendFileSync(LOG, JSON.stringify(row) + "\n");
|
|
149
149
|
if (statSync(LOG).size > MAX_LOG) {
|
|
150
|
-
const
|
|
151
|
-
const
|
|
152
|
-
|
|
150
|
+
const buf = readFileSync(LOG);
|
|
151
|
+
const keep = buf.subarray(Math.max(0, buf.length - MAX_LOG));
|
|
152
|
+
const cut = keep.indexOf(10);
|
|
153
|
+
writeFileSync(LOG, cut >= 0 ? keep.subarray(cut + 1) : keep);
|
|
153
154
|
}
|
|
154
155
|
} catch { /* 静默:计量不该影响会话 */ }
|
|
155
156
|
}
|
|
@@ -205,7 +206,10 @@ function statsLine(th: number, med: number, rows: Row[]): string {
|
|
|
205
206
|
parts.push(`预计 ${lastTurnEst}s / 实际 ${secs}s(偏差 ${dev >= 0 ? "+" : ""}${dev}%)`);
|
|
206
207
|
} else {
|
|
207
208
|
const base = Math.round(median(rows.map((r) => r.ms)) / 1000);
|
|
208
|
-
|
|
209
|
+
// 借鉴 think-anchor 的自适应:声明率已高时不再每轮催(实测 88.9% 声明率下这句话是纯噪音)
|
|
210
|
+
const declRate = rows.length ? rows.filter((r) => typeof r.estCalls === "number" && (r.estCalls as number) > 0).length / rows.length : 0;
|
|
211
|
+
const nudge = declRate < 0.6 ? " → 本轮开工前先报「预计 N 次」" : "";
|
|
212
|
+
parts.push((base > 0 ? "预计未声明(同类中位 " + base + "s)" : "预计未声明") + nudge);
|
|
209
213
|
}
|
|
210
214
|
}
|
|
211
215
|
// 校正指引(回路自动纠偏):近若干轮系统性偏离时,直接给出本轮该报的倍数——不靠自觉。
|
|
@@ -341,7 +345,7 @@ export default function ptcMeter(pi: ExtensionAPI) {
|
|
|
341
345
|
// 数字移到对话尾部后 system 永久字节稳定,前缀命中恢复。
|
|
342
346
|
pi.on("before_agent_start", async (event, ctx: ExtensionContext) => {
|
|
343
347
|
try {
|
|
344
|
-
lastTurnCalls = lastCompletedCalls
|
|
348
|
+
lastTurnCalls = lastCompletedCalls; // -1 = 无完成记录(首轮 / session_start 后)
|
|
345
349
|
callsThisTurn = 0;
|
|
346
350
|
turnStartedAt = Date.now();
|
|
347
351
|
const c = loadConf();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-ptc-meter",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
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",
|
|
@@ -22,5 +22,6 @@
|
|
|
22
22
|
],
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"@earendil-works/pi-coding-agent": "*"
|
|
25
|
-
}
|
|
25
|
+
},
|
|
26
|
+
"author": "15066212pp"
|
|
26
27
|
}
|