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.
- package/CHANGELOG.md +38 -0
- package/README.md +189 -18
- package/agents/context-builder.md +3 -3
- package/agents/planner.md +1 -1
- package/agents/researcher.md +1 -1
- package/agents/scout.md +1 -1
- package/package.json +7 -7
- package/skills/pi-subagents/SKILL.md +5 -0
- package/src/agents/agent-management.ts +170 -6
- package/src/agents/agent-serializer.ts +31 -13
- package/src/agents/agents.ts +207 -23
- package/src/agents/frontmatter.ts +66 -2
- package/src/agents/skills.ts +117 -20
- package/src/extension/doctor.ts +20 -0
- package/src/extension/fanout-child.ts +1 -0
- package/src/extension/index.ts +58 -4
- package/src/extension/schemas.ts +10 -76
- package/src/intercom/intercom-bridge.ts +27 -4
- package/src/profiles/profiles.ts +637 -0
- package/src/runs/background/async-execution.ts +14 -4
- package/src/runs/background/async-job-tracker.ts +56 -11
- package/src/runs/background/async-resume.ts +11 -13
- package/src/runs/background/control-channel.ts +177 -0
- package/src/runs/background/result-watcher.ts +11 -2
- package/src/runs/background/stale-run-reconciler.ts +9 -4
- package/src/runs/background/subagent-runner.ts +86 -3
- package/src/runs/foreground/chain-execution.ts +26 -2
- package/src/runs/foreground/execution.ts +113 -8
- package/src/runs/foreground/subagent-executor.ts +356 -86
- package/src/runs/shared/acceptance.ts +285 -34
- package/src/runs/shared/completion-guard.ts +1 -1
- package/src/runs/shared/dynamic-fanout.ts +4 -2
- package/src/runs/shared/mcp-direct-tool-allowlist.ts +2 -2
- package/src/runs/shared/parallel-utils.ts +6 -1
- package/src/runs/shared/pi-args.ts +9 -1
- package/src/runs/shared/single-output.ts +15 -1
- package/src/runs/shared/subagent-prompt-runtime.ts +1 -0
- package/src/shared/settings.ts +1 -0
- package/src/shared/types.ts +9 -2
- package/src/shared/utils.ts +19 -1
- package/src/slash/prompt-template-bridge.ts +26 -3
- package/src/slash/slash-commands.ts +642 -43
- package/src/tui/render.ts +265 -13
package/src/shared/utils.ts
CHANGED
|
@@ -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(),
|
|
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
|
|
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
|
-
|
|
218
|
-
|
|
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 {
|