pi-subagents 0.30.0 → 0.31.1

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 (43) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +189 -18
  3. package/agents/context-builder.md +3 -3
  4. package/agents/planner.md +1 -1
  5. package/agents/researcher.md +1 -1
  6. package/agents/scout.md +1 -1
  7. package/package.json +7 -7
  8. package/skills/pi-subagents/SKILL.md +5 -0
  9. package/src/agents/agent-management.ts +170 -6
  10. package/src/agents/agent-serializer.ts +31 -13
  11. package/src/agents/agents.ts +207 -23
  12. package/src/agents/frontmatter.ts +66 -2
  13. package/src/agents/skills.ts +117 -20
  14. package/src/extension/doctor.ts +20 -0
  15. package/src/extension/fanout-child.ts +1 -0
  16. package/src/extension/index.ts +58 -4
  17. package/src/extension/schemas.ts +10 -76
  18. package/src/intercom/intercom-bridge.ts +27 -4
  19. package/src/profiles/profiles.ts +637 -0
  20. package/src/runs/background/async-execution.ts +14 -4
  21. package/src/runs/background/async-job-tracker.ts +56 -11
  22. package/src/runs/background/async-resume.ts +11 -13
  23. package/src/runs/background/control-channel.ts +177 -0
  24. package/src/runs/background/result-watcher.ts +11 -2
  25. package/src/runs/background/stale-run-reconciler.ts +9 -4
  26. package/src/runs/background/subagent-runner.ts +86 -3
  27. package/src/runs/foreground/chain-execution.ts +26 -2
  28. package/src/runs/foreground/execution.ts +113 -8
  29. package/src/runs/foreground/subagent-executor.ts +356 -86
  30. package/src/runs/shared/acceptance.ts +285 -34
  31. package/src/runs/shared/completion-guard.ts +1 -1
  32. package/src/runs/shared/dynamic-fanout.ts +4 -2
  33. package/src/runs/shared/mcp-direct-tool-allowlist.ts +2 -2
  34. package/src/runs/shared/parallel-utils.ts +6 -1
  35. package/src/runs/shared/pi-args.ts +9 -1
  36. package/src/runs/shared/single-output.ts +15 -1
  37. package/src/runs/shared/subagent-prompt-runtime.ts +1 -0
  38. package/src/shared/settings.ts +1 -0
  39. package/src/shared/types.ts +9 -2
  40. package/src/shared/utils.ts +19 -1
  41. package/src/slash/prompt-template-bridge.ts +26 -3
  42. package/src/slash/slash-commands.ts +642 -43
  43. package/src/tui/render.ts +265 -13
@@ -5,6 +5,7 @@
5
5
  import * as fs from "node:fs";
6
6
  import * as os from "node:os";
7
7
  import * as path from "node:path";
8
+ import * as piCodingAgent from "@earendil-works/pi-coding-agent";
8
9
  import type { Message } from "@earendil-works/pi-ai";
9
10
  import { formatToolCall } from "./formatters.ts";
10
11
  import type { AgentProgress, AsyncStatus, Details, DisplayItem, ErrorInfo, SingleResult, ToolCallSummary } from "./types.ts";
@@ -13,11 +14,28 @@ import type { AgentProgress, AsyncStatus, Details, DisplayItem, ErrorInfo, Singl
13
14
  // File System Utilities
14
15
  // ============================================================================
15
16
 
17
+ const DEFAULT_CONFIG_DIR_NAME = ".pi";
18
+
19
+ export function resolveConfigDirName(codingAgentModule: unknown = piCodingAgent): string {
20
+ const value = codingAgentModule && typeof codingAgentModule === "object"
21
+ ? (codingAgentModule as { CONFIG_DIR_NAME?: unknown }).CONFIG_DIR_NAME
22
+ : undefined;
23
+ return typeof value === "string" && value.trim() ? value : DEFAULT_CONFIG_DIR_NAME;
24
+ }
25
+
26
+ export function getConfigDirName(): string {
27
+ return resolveConfigDirName();
28
+ }
29
+
30
+ export function getProjectConfigDir(projectRoot: string): string {
31
+ return path.join(projectRoot, getConfigDirName());
32
+ }
33
+
16
34
  export function getAgentDir(): string {
17
35
  const configured = process.env.PI_CODING_AGENT_DIR;
18
36
  if (configured === "~") return os.homedir();
19
37
  if (configured?.startsWith("~/")) return path.join(os.homedir(), configured.slice(2));
20
- return configured || path.join(os.homedir(), ".pi", "agent");
38
+ return configured || path.join(os.homedir(), getConfigDirName(), "agent");
21
39
  }
22
40
 
23
41
  const statusCache = new Map<string, { mtime: number; status: AsyncStatus }>();
@@ -79,6 +79,7 @@ interface PromptTemplateBridgeResult {
79
79
  agent?: string;
80
80
  messages?: unknown[];
81
81
  finalOutput?: string;
82
+ toolCalls?: Array<{ text?: string; expandedText?: string }>;
82
83
  exitCode?: number;
83
84
  error?: string;
84
85
  model?: string;
@@ -209,13 +210,35 @@ function resolveProgressModel(
209
210
  return firstWithModel?.model;
210
211
  }
211
212
 
212
- function buildDelegationMessages(result: { messages?: unknown[]; finalOutput?: string }, fallbackText?: string): unknown[] {
213
+ function toolCallNameFromSummary(summary: { text?: string; expandedText?: string }): string | undefined {
214
+ const text = typeof summary.expandedText === "string" && summary.expandedText.trim().length > 0
215
+ ? summary.expandedText.trim()
216
+ : typeof summary.text === "string"
217
+ ? summary.text.trim()
218
+ : "";
219
+ if (!text) return undefined;
220
+ if (text.startsWith("$ ")) return "bash";
221
+ return text.match(/^[A-Za-z_][\w.-]*/)?.[0];
222
+ }
223
+
224
+ function buildDelegationMessages(
225
+ result: { messages?: unknown[]; finalOutput?: string; toolCalls?: Array<{ text?: string; expandedText?: string }> },
226
+ fallbackText?: string,
227
+ ): unknown[] {
213
228
  if (Array.isArray(result.messages) && result.messages.length > 0) return result.messages;
229
+ const toolCallParts = (result.toolCalls ?? []).flatMap((summary) => {
230
+ const name = toolCallNameFromSummary(summary);
231
+ return name ? [{ type: "toolCall", name, arguments: { summary: summary.expandedText ?? summary.text ?? "" } }] : [];
232
+ });
214
233
  const text = typeof result.finalOutput === "string" && result.finalOutput.trim().length > 0
215
234
  ? result.finalOutput.trim()
216
235
  : fallbackText;
217
- if (!text) return [];
218
- return [{ role: "assistant", content: [{ type: "text", text }] }];
236
+ const content = [
237
+ ...toolCallParts,
238
+ ...(text ? [{ type: "text", text }] : []),
239
+ ];
240
+ if (content.length === 0) return [];
241
+ return [{ role: "assistant", content }];
219
242
  }
220
243
 
221
244
  function toDelegationUpdate(requestId: string, update: PromptTemplateBridgeResult): PromptTemplateDelegationUpdate | undefined {