pi-ptc-meter 1.0.2 → 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/index.ts +5 -4
- package/package.json +3 -2
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
|
}
|
|
@@ -344,7 +345,7 @@ export default function ptcMeter(pi: ExtensionAPI) {
|
|
|
344
345
|
// 数字移到对话尾部后 system 永久字节稳定,前缀命中恢复。
|
|
345
346
|
pi.on("before_agent_start", async (event, ctx: ExtensionContext) => {
|
|
346
347
|
try {
|
|
347
|
-
lastTurnCalls = lastCompletedCalls
|
|
348
|
+
lastTurnCalls = lastCompletedCalls; // -1 = 无完成记录(首轮 / session_start 后)
|
|
348
349
|
callsThisTurn = 0;
|
|
349
350
|
turnStartedAt = Date.now();
|
|
350
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
|
}
|