@trim21/personal-pi-extensions 0.0.285 → 0.0.286

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/package.json +1 -1
  2. package/src/spawn-agent.ts +25 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trim21/personal-pi-extensions",
3
- "version": "0.0.285",
3
+ "version": "0.0.286",
4
4
  "type": "module",
5
5
  "description": "Custom pi coding-agent extensions: bwrap sandbox, workspace guard, opencode edit, and more",
6
6
  "keywords": [
@@ -42,6 +42,7 @@ import {
42
42
  } from "@earendil-works/pi-coding-agent";
43
43
  import { Type } from "typebox";
44
44
 
45
+ import { type ToolPendant } from "./lib/pendant.js";
45
46
  import { type AgentConfig, discoverAgents, formatAgentList } from "./spawn-agent-agents.js";
46
47
 
47
48
  // ── constants ────────────────────────────────────────────────────────────────
@@ -114,6 +115,8 @@ interface SubagentDetails {
114
115
  model?: string;
115
116
  stopReason?: string;
116
117
  errorMessage?: string;
118
+ /** 折叠 markdown 面板:父 agent 的 prompt 与父 agent 看到的子 agent 结果。 */
119
+ pendant?: ToolPendant;
117
120
  }
118
121
 
119
122
  // ── helpers ──────────────────────────────────────────────────────────────────
@@ -160,6 +163,11 @@ function formatUsageStats(usage: UsageStats, model?: string): string {
160
163
  return parts.join(" ");
161
164
  }
162
165
 
166
+ /** 子 agent 结果的折叠面板 markdown:父 agent 的 prompt 与父 agent 看到的结果。 */
167
+ function formatPendantMarkdown(task: string, response: string): string {
168
+ return `# prompt:\n${task.trim()}\n# response\n${response.trim()}`;
169
+ }
170
+
163
171
  /**
164
172
  * Resolve how to spawn the subagent process. Running through the current
165
173
  * entry script (when available) keeps model/tool/extension config identical
@@ -669,7 +677,13 @@ export default function spawnAgent(pi: ExtensionAPI) {
669
677
  content: [
670
678
  { type: "text", text: `Subagent "${result.agent}" failed (${reason}): ${message}` },
671
679
  ],
672
- details: result,
680
+ details: {
681
+ ...result,
682
+ pendant: {
683
+ markdown: formatPendantMarkdown(params.task, message),
684
+ expanded: true,
685
+ } satisfies ToolPendant,
686
+ },
673
687
  isError: true,
674
688
  };
675
689
  }
@@ -679,7 +693,16 @@ export default function spawnAgent(pi: ExtensionAPI) {
679
693
  const text = truncation.truncated
680
694
  ? `${truncation.content}\n\n[Output truncated to ${formatTokens(truncation.content.length)} bytes. Full result preserved in tool details.]`
681
695
  : output;
682
- return { content: [{ type: "text", text }], details: result };
696
+ return {
697
+ content: [{ type: "text", text }],
698
+ details: {
699
+ ...result,
700
+ pendant: {
701
+ markdown: formatPendantMarkdown(params.task, text),
702
+ expanded: false,
703
+ } satisfies ToolPendant,
704
+ },
705
+ };
683
706
  },
684
707
 
685
708
  renderCall(args, theme) {