@trim21/personal-pi-extensions 0.0.430 → 0.0.431
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/package.json +3 -1
- package/src/bwrap/runtime.ts +15 -32
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trim21/personal-pi-extensions",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.431",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Custom pi coding-agent extensions: bwrap sandbox, workspace guard, opencode edit, and more",
|
|
6
6
|
"keywords": [
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
"@earendil-works/pi-ai": "^0.84.1",
|
|
38
38
|
"@earendil-works/pi-coding-agent": "^0.84.1",
|
|
39
39
|
"@eslint/js": "10.0.1",
|
|
40
|
+
"@types/lodash-es": "^4.17.12",
|
|
40
41
|
"@types/node": "^24.13.3",
|
|
41
42
|
"@types/turndown": "^5.0.6",
|
|
42
43
|
"@typescript/native": "npm:typescript@^7.0.2",
|
|
@@ -94,6 +95,7 @@
|
|
|
94
95
|
"@vscode/tree-sitter-wasm": "^0.3.1",
|
|
95
96
|
"jsonc-parser": "^3.3.1",
|
|
96
97
|
"linkedom": "^0.18.0",
|
|
98
|
+
"lodash-es": "^4.18.1",
|
|
97
99
|
"minimatch": "^10.2.6",
|
|
98
100
|
"turndown": "^7.2.0",
|
|
99
101
|
"vscode-jsonrpc": "^9.0.1",
|
package/src/bwrap/runtime.ts
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
truncateTail,
|
|
14
14
|
type TruncationResult,
|
|
15
15
|
} from "@earendil-works/pi-coding-agent";
|
|
16
|
+
import { throttle } from "lodash-es";
|
|
16
17
|
import { type TObject, Type } from "typebox";
|
|
17
18
|
|
|
18
19
|
import { type CommandSpec, parseCommand } from "../lib/cli.js";
|
|
@@ -379,42 +380,24 @@ export class BwrapRuntime {
|
|
|
379
380
|
await using output = new BashOutput(request.ctx.sessionManager.getSessionId());
|
|
380
381
|
const { onUpdate } = request;
|
|
381
382
|
|
|
382
|
-
//
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
});
|
|
394
|
-
};
|
|
395
|
-
const scheduleUpdate = () => {
|
|
396
|
-
if (!onUpdate) return;
|
|
397
|
-
dirty = true;
|
|
398
|
-
const delay = BASH_UPDATE_THROTTLE_MS - (Date.now() - lastUpdateAt);
|
|
399
|
-
if (delay <= 0) {
|
|
400
|
-
if (updateTimer) clearTimeout(updateTimer);
|
|
401
|
-
updateTimer = undefined;
|
|
402
|
-
emitUpdate();
|
|
403
|
-
return;
|
|
404
|
-
}
|
|
405
|
-
if (updateTimer) return;
|
|
406
|
-
updateTimer = setTimeout(() => {
|
|
407
|
-
updateTimer = undefined;
|
|
408
|
-
emitUpdate();
|
|
409
|
-
}, delay);
|
|
410
|
-
};
|
|
383
|
+
// 流式进度:限流推送尾部快照(对齐 pi 内置 bash 的实时输出体验)
|
|
384
|
+
const emitUpdate = throttle(
|
|
385
|
+
() => {
|
|
386
|
+
onUpdate?.({
|
|
387
|
+
content: [{ type: "text", text: output.tailSnapshot() }],
|
|
388
|
+
details: undefined,
|
|
389
|
+
});
|
|
390
|
+
},
|
|
391
|
+
BASH_UPDATE_THROTTLE_MS,
|
|
392
|
+
{ trailing: true },
|
|
393
|
+
);
|
|
411
394
|
|
|
412
395
|
try {
|
|
413
396
|
if (onUpdate) onUpdate({ content: [], details: undefined });
|
|
414
397
|
const { exitCode } = await operations.exec(request.command, execCwd, {
|
|
415
398
|
onData: (data) => {
|
|
416
399
|
output.append(data);
|
|
417
|
-
|
|
400
|
+
emitUpdate();
|
|
418
401
|
},
|
|
419
402
|
signal: request.signal,
|
|
420
403
|
timeout: request.timeout,
|
|
@@ -451,8 +434,8 @@ export class BwrapRuntime {
|
|
|
451
434
|
}
|
|
452
435
|
throw error;
|
|
453
436
|
} finally {
|
|
454
|
-
|
|
455
|
-
|
|
437
|
+
emitUpdate.flush();
|
|
438
|
+
emitUpdate.cancel();
|
|
456
439
|
}
|
|
457
440
|
}
|
|
458
441
|
|