Add 5 pi extensions: pi-subagents, pi-crew, rpiv-pi, pi-interactive-shell, pi-intercom

This commit is contained in:
2026-05-08 15:59:25 +10:00
parent d0d1d9b045
commit 31b4110c87
457 changed files with 85157 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
/**
* context.ts — Extract parent conversation context for subagent inheritance.
*/
import type { ExtensionContext } from "@mariozechner/pi-coding-agent";
/** Extract text from a message content block array. */
export function extractText(content: unknown[]): string {
return content
.filter((c: any) => c.type === "text")
.map((c: any) => c.text ?? "")
.join("\n");
}
/**
* Build a text representation of the parent conversation context.
* Used when inherit_context is true to give the subagent visibility
* into what has been discussed/done so far.
*/
export function buildParentContext(ctx: ExtensionContext): string {
const entries = ctx.sessionManager.getBranch();
if (!entries || entries.length === 0) return "";
const parts: string[] = [];
for (const entry of entries) {
if (entry.type === "message") {
const msg = entry.message;
if (msg.role === "user") {
const text = typeof msg.content === "string"
? msg.content
: extractText(msg.content);
if (text.trim()) parts.push(`[User]: ${text.trim()}`);
} else if (msg.role === "assistant") {
const text = extractText(msg.content);
if (text.trim()) parts.push(`[Assistant]: ${text.trim()}`);
}
// Skip toolResult messages — too verbose for context
} else if (entry.type === "compaction") {
// Include compaction summaries — they're already condensed
if (entry.summary) {
parts.push(`[Summary]: ${entry.summary}`);
}
}
}
if (parts.length === 0) return "";
return `# Parent Conversation Context
The following is the conversation history from the parent session that spawned you.
Use this context to understand what has been discussed and decided so far.
${parts.join("\n\n")}
---
# Your Task (below)
`;
}