@trim21/personal-pi-extensions 0.0.211 → 0.0.213
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 +2 -4
- package/src/opencode-todo.ts +7 -8
- package/src/spawn-agent.ts +26 -33
- package/src/talk/index.ts +10 -5
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.213",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Custom pi coding-agent extensions: bwrap sandbox, workspace guard, opencode edit, and more",
|
|
6
6
|
"keywords": [
|
|
@@ -28,7 +28,6 @@
|
|
|
28
28
|
"@earendil-works/pi-agent-core": ">=0.84.1",
|
|
29
29
|
"@earendil-works/pi-ai": ">=0.84.1",
|
|
30
30
|
"@earendil-works/pi-coding-agent": ">=0.84.1",
|
|
31
|
-
"@earendil-works/pi-tui": ">=0.84.1",
|
|
32
31
|
"typebox": ">=1.3.1"
|
|
33
32
|
},
|
|
34
33
|
"devDependencies": {
|
|
@@ -36,7 +35,6 @@
|
|
|
36
35
|
"@earendil-works/pi-coding-agent": "^0.84.1",
|
|
37
36
|
"@eslint/js": "10.0.1",
|
|
38
37
|
"@types/node": "^24.13.3",
|
|
39
|
-
"@typescript-eslint/utils": "8.67.0",
|
|
40
38
|
"eslint": "^10.8.1",
|
|
41
39
|
"eslint-config-prettier": "10.1.8",
|
|
42
40
|
"eslint-plugin-erasable-syntax-only": "0.4.2",
|
|
@@ -50,7 +48,7 @@
|
|
|
50
48
|
"prettier": "^3.9.6",
|
|
51
49
|
"typebox": "1.3.1",
|
|
52
50
|
"typescript": "^6.0.3",
|
|
53
|
-
"typescript-eslint": "^8.
|
|
51
|
+
"typescript-eslint": "^8.67.0",
|
|
54
52
|
"vitest": "^4.1.10"
|
|
55
53
|
},
|
|
56
54
|
"pi": {
|
package/src/opencode-todo.ts
CHANGED
|
@@ -23,8 +23,7 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
import { StringEnum } from "@earendil-works/pi-ai";
|
|
26
|
-
import { type ExtensionAPI,
|
|
27
|
-
import { Markdown } from "@earendil-works/pi-tui";
|
|
26
|
+
import { type ExtensionAPI, truncateToVisualLines } from "@earendil-works/pi-coding-agent";
|
|
28
27
|
import { Type } from "typebox";
|
|
29
28
|
|
|
30
29
|
// ── constants ────────────────────────────────────────────────────────────────
|
|
@@ -183,12 +182,12 @@ export default function todowrite(pi: ExtensionAPI) {
|
|
|
183
182
|
},
|
|
184
183
|
|
|
185
184
|
renderResult(result) {
|
|
186
|
-
// 用 buildTodoMarkdown 生成任务列表 markdown
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
185
|
+
// 用 buildTodoMarkdown 生成任务列表 markdown 原文显示(plain,不渲染富文本)
|
|
186
|
+
const markdown = buildTodoMarkdown(result.details.todos);
|
|
187
|
+
return {
|
|
188
|
+
render: (width: number) => truncateToVisualLines(markdown, Infinity, width).visualLines,
|
|
189
|
+
invalidate: (): void => undefined,
|
|
190
|
+
};
|
|
192
191
|
},
|
|
193
192
|
});
|
|
194
193
|
}
|
package/src/spawn-agent.ts
CHANGED
|
@@ -30,13 +30,12 @@ import {
|
|
|
30
30
|
type AgentSessionEvent,
|
|
31
31
|
type ExtensionAPI,
|
|
32
32
|
type ExtensionUIContext,
|
|
33
|
-
getMarkdownTheme,
|
|
34
33
|
type RpcExtensionUIRequest,
|
|
35
34
|
type RpcExtensionUIResponse,
|
|
36
35
|
truncateTail,
|
|
36
|
+
truncateToVisualLines,
|
|
37
37
|
withFileMutationQueue,
|
|
38
38
|
} from "@earendil-works/pi-coding-agent";
|
|
39
|
-
import { Container, Markdown, Spacer, Text } from "@earendil-works/pi-tui";
|
|
40
39
|
import { Type } from "typebox";
|
|
41
40
|
|
|
42
41
|
import { type AgentConfig, discoverAgents, formatAgentList } from "./spawn-agent-agents.js";
|
|
@@ -624,9 +623,14 @@ export default function spawnAgent(pi: ExtensionAPI) {
|
|
|
624
623
|
|
|
625
624
|
renderCall(args, theme) {
|
|
626
625
|
const preview = args.task.length > 60 ? `${args.task.slice(0, 60)}...` : args.task;
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
626
|
+
const line =
|
|
627
|
+
theme.fg("toolTitle", theme.bold("spawn_agent ")) + theme.fg("accent", args.agent);
|
|
628
|
+
const detail = ` ${theme.fg("dim", preview)}`;
|
|
629
|
+
return {
|
|
630
|
+
render: (width: number) =>
|
|
631
|
+
truncateToVisualLines(`${line}\n${detail}`, 2, width).visualLines,
|
|
632
|
+
invalidate: (): void => undefined,
|
|
633
|
+
};
|
|
630
634
|
},
|
|
631
635
|
|
|
632
636
|
renderResult(result, { expanded }, theme) {
|
|
@@ -639,40 +643,29 @@ export default function spawnAgent(pi: ExtensionAPI) {
|
|
|
639
643
|
const finalOutput = getFinalOutput(details.messages);
|
|
640
644
|
const usageStr = formatUsageStats(details.usage, details.model);
|
|
641
645
|
|
|
646
|
+
const lines: string[] = [];
|
|
647
|
+
let header = `${icon} ${theme.fg("toolTitle", theme.bold(details.agent))}`;
|
|
648
|
+
if (details.stopReason) header += ` ${theme.fg("error", `[${details.stopReason}]`)}`;
|
|
649
|
+
lines.push(header);
|
|
650
|
+
if (isError && details.errorMessage) {
|
|
651
|
+
lines.push(theme.fg("error", `Error: ${details.errorMessage}`));
|
|
652
|
+
}
|
|
642
653
|
if (expanded) {
|
|
643
|
-
|
|
644
|
-
const header = `${icon} ${theme.fg("toolTitle", theme.bold(details.agent))}${
|
|
645
|
-
details.stopReason ? ` ${theme.fg("error", `[${details.stopReason}]`)}` : ""
|
|
646
|
-
}`;
|
|
647
|
-
container.addChild(new Text(header, 0, 0));
|
|
648
|
-
if (isError && details.errorMessage) {
|
|
649
|
-
container.addChild(new Text(theme.fg("error", `Error: ${details.errorMessage}`), 0, 0));
|
|
650
|
-
}
|
|
651
|
-
container.addChild(new Spacer(1));
|
|
652
|
-
container.addChild(new Text(theme.fg("muted", "─── Task ───"), 0, 0));
|
|
653
|
-
container.addChild(new Text(theme.fg("dim", details.task), 0, 0));
|
|
654
|
+
lines.push("", theme.fg("muted", "─── Task ───"), theme.fg("dim", details.task));
|
|
654
655
|
if (finalOutput) {
|
|
655
|
-
|
|
656
|
-
container.addChild(new Text(theme.fg("muted", "─── Output ───"), 0, 0));
|
|
657
|
-
container.addChild(new Markdown(finalOutput.trim(), 0, 0, getMarkdownTheme()));
|
|
658
|
-
}
|
|
659
|
-
if (usageStr) {
|
|
660
|
-
container.addChild(new Spacer(1));
|
|
661
|
-
container.addChild(new Text(theme.fg("dim", usageStr), 0, 0));
|
|
656
|
+
lines.push("", theme.fg("muted", "─── Output ───"), finalOutput.trim());
|
|
662
657
|
}
|
|
663
|
-
return container;
|
|
664
|
-
}
|
|
665
|
-
|
|
666
|
-
let text = `${icon} ${theme.fg("toolTitle", theme.bold(details.agent))}`;
|
|
667
|
-
if (isError && details.errorMessage) {
|
|
668
|
-
text += `\n${theme.fg("error", `Error: ${details.errorMessage}`)}`;
|
|
669
658
|
} else if (finalOutput) {
|
|
670
|
-
|
|
659
|
+
lines.push(theme.fg("toolOutput", finalOutput.split("\n").slice(0, 5).join("\n")));
|
|
671
660
|
} else {
|
|
672
|
-
|
|
661
|
+
lines.push(theme.fg("muted", "(no output)"));
|
|
673
662
|
}
|
|
674
|
-
if (usageStr)
|
|
675
|
-
return
|
|
663
|
+
if (usageStr) lines.push(theme.fg("dim", usageStr));
|
|
664
|
+
return {
|
|
665
|
+
render: (width: number) =>
|
|
666
|
+
truncateToVisualLines(lines.join("\n"), Infinity, width).visualLines,
|
|
667
|
+
invalidate: (): void => undefined,
|
|
668
|
+
};
|
|
676
669
|
},
|
|
677
670
|
});
|
|
678
671
|
}
|
package/src/talk/index.ts
CHANGED
|
@@ -14,8 +14,7 @@ import * as path from "node:path";
|
|
|
14
14
|
import { fileURLToPath } from "node:url";
|
|
15
15
|
|
|
16
16
|
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
17
|
-
import { getAgentDir } from "@earendil-works/pi-coding-agent";
|
|
18
|
-
import { Box, Text } from "@earendil-works/pi-tui";
|
|
17
|
+
import { getAgentDir, truncateToVisualLines } from "@earendil-works/pi-coding-agent";
|
|
19
18
|
import { type TObject, Type } from "typebox";
|
|
20
19
|
|
|
21
20
|
import { type CommandResult, type CommandSpec, parseCommand } from "../lib/cli.js";
|
|
@@ -453,8 +452,14 @@ export default function talk(pi: ExtensionAPI) {
|
|
|
453
452
|
if (d.kind === "ask") {
|
|
454
453
|
out.push(theme.fg("dim", `└─ reply via talk-reply, replyTo: "${idTail}"`));
|
|
455
454
|
}
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
return
|
|
455
|
+
// plain 组件:不引入 pi-tui,直接输出带背景色的文本行
|
|
456
|
+
const text = out.join("\n");
|
|
457
|
+
return {
|
|
458
|
+
render: (width: number) =>
|
|
459
|
+
truncateToVisualLines(text, Infinity, width, 1).visualLines.map((line) =>
|
|
460
|
+
theme.bg("customMessageBg", line),
|
|
461
|
+
),
|
|
462
|
+
invalidate: (): void => undefined,
|
|
463
|
+
};
|
|
459
464
|
});
|
|
460
465
|
}
|