|
| 1 | +import type { HostConfig } from '../scripts/host-config'; |
| 2 | + |
| 3 | +/** Pi package installed by setup to provide the `subagent` tool and builtin agents. */ |
| 4 | +export const PI_SUBAGENTS_PACKAGE = 'npm:pi-subagents'; |
| 5 | + |
| 6 | +/** Role mapping used by generated Pi delegation instructions. */ |
| 7 | +export const PI_SUBAGENT_ROLES = { |
| 8 | + review: 'reviewer', |
| 9 | + implementation: 'worker', |
| 10 | + reconnaissance: 'scout', |
| 11 | + secondOpinion: 'oracle', |
| 12 | + general: 'delegate', |
| 13 | +} as const; |
| 14 | + |
| 15 | +function piSingleWorkflow(agent: string, key = 'main'): string { |
| 16 | + return `Call the \`subagent\` tool with this input: {"workflowScript":"return runs.run('${key}', { agent: '${agent}', context: 'fresh', task: '<task>' })","async":false}.`; |
| 17 | +} |
| 18 | + |
| 19 | +function piParallelWorkflow(agent: string): string { |
| 20 | + return `Call the \`subagent\` tool with this input: {"workflowScript":"const [first, second] = await runs.all([{ key: 'first', agent: '${agent}', task: '<first task>' }, { key: 'second', agent: '${agent}', task: '<second task>' }]); return [first.output, second.output]","async":false}. Add one runs.all item for each selected task and return the collected outputs.`; |
| 21 | +} |
| 22 | + |
| 23 | +const pi: HostConfig = { |
| 24 | + name: 'pi', |
| 25 | + displayName: 'Pi', |
| 26 | + cliCommand: 'pi', |
| 27 | + cliAliases: [], |
| 28 | + |
| 29 | + globalRoot: '.pi/agent/skills/gstack', |
| 30 | + localSkillRoot: '.pi/skills/gstack', |
| 31 | + hostSubdir: '.pi', |
| 32 | + usesEnvVars: true, |
| 33 | + |
| 34 | + frontmatter: { |
| 35 | + mode: 'allowlist', |
| 36 | + keepFields: ['name', 'description'], |
| 37 | + descriptionLimit: 1024, |
| 38 | + }, |
| 39 | + |
| 40 | + generation: { |
| 41 | + generateMetadata: false, |
| 42 | + skipSkills: ['codex'], |
| 43 | + }, |
| 44 | + |
| 45 | + pathRewrites: [ |
| 46 | + { from: '~/.claude/skills/gstack', to: '~/.pi/agent/skills/gstack' }, |
| 47 | + { from: '~/.claude/skills', to: '~/.pi/agent/skills' }, |
| 48 | + { from: '$HOME/.claude/skills/gstack', to: '$HOME/.pi/agent/skills/gstack' }, |
| 49 | + { from: '$HOME/.claude/skills', to: '$HOME/.pi/agent/skills' }, |
| 50 | + { from: '.claude/skills/gstack', to: '.pi/skills/gstack' }, |
| 51 | + { from: '.claude/skills', to: '.pi/skills' }, |
| 52 | + // Pi uses AGENTS.md for project instructions. |
| 53 | + { from: 'CLAUDE.md', to: 'AGENTS.md' }, |
| 54 | + // Identity rewrites keep generated instructions host-neutral. |
| 55 | + { from: 'Claude Code', to: 'Pi' }, |
| 56 | + { from: 'claude code', to: 'Pi' }, |
| 57 | + { from: 'this Pi window', to: 'this Pi session' }, |
| 58 | + ], |
| 59 | + |
| 60 | + toolRewrites: { |
| 61 | + 'AskUserQuestion': 'ask the user in chat', |
| 62 | + 'WebSearch': 'web search (if available)', |
| 63 | + 'use the Bash tool': 'use the bash tool', |
| 64 | + 'use the Write tool': 'use the write tool', |
| 65 | + 'use the Read tool': 'use the read tool', |
| 66 | + 'use the Edit tool': 'use the edit tool', |
| 67 | + 'use the Grep tool': 'use the grep tool', |
| 68 | + 'use the Glob tool': 'use the find tool', |
| 69 | + 'the Bash tool': 'the bash tool', |
| 70 | + 'the Read tool': 'the read tool', |
| 71 | + 'the Write tool': 'the write tool', |
| 72 | + 'the Edit tool': 'the edit tool', |
| 73 | + 'the Grep tool': 'the grep tool', |
| 74 | + 'the Glob tool': 'the find tool', |
| 75 | + |
| 76 | + // pi-subagents exposes a workflowScript API rather than Claude's Agent |
| 77 | + // tool. Handle the complete high-value instructions before the generic |
| 78 | + // replacements below so the generated prose retains its intent. |
| 79 | + '**Launch N Agent subagents in a single message** (parallel execution). Use the Agent\ntool with `subagent_type: "general-purpose"` for each variant. Each agent is independent\nand handles its own generation, quality check, verification, and retry.': `**Launch N child agents in one workflowScript** (parallel execution). ${piParallelWorkflow(PI_SUBAGENT_ROLES.general)} Each child is independent and handles its own generation, quality check, verification, and retry.`, |
| 80 | + '**Dispatch this step as a subagent** using the Agent tool with `subagent_type: "general-purpose"`.': `**Dispatch this step with the subagent tool.** ${piSingleWorkflow(PI_SUBAGENT_ROLES.review)}`, |
| 81 | + '**Dispatch the fetch + classification as a subagent** using the Agent tool with `subagent_type: "general-purpose"`.': `**Dispatch the fetch + classification with the subagent tool.** ${piSingleWorkflow(PI_SUBAGENT_ROLES.reconnaissance)}`, |
| 82 | + '**Dispatch /document-release as a subagent** using the Agent tool with `subagent_type: "general-purpose"`.': `**Dispatch /document-release with the subagent tool.** ${piSingleWorkflow(PI_SUBAGENT_ROLES.implementation)}`, |
| 83 | + 'For each selected specialist, launch an independent subagent via the Agent tool.\n**Launch ALL selected specialists in a single message** (multiple Agent tool calls)\nso they run in parallel. Each subagent has fresh context — no prior review bias.': `For each selected specialist, add a fresh reviewer child to one workflowScript. ${piParallelWorkflow(PI_SUBAGENT_ROLES.review)} Each child has fresh context — no prior review bias.`, |
| 84 | + 'If activated, dispatch one more subagent via the Agent tool (foreground, not background).': `If activated, run one more reviewer child in a foreground workflow. ${piSingleWorkflow(PI_SUBAGENT_ROLES.review, 'red-team')}`, |
| 85 | + 'For each candidate finding, launch an independent verification sub-task using the Agent tool. The verifier has fresh context and cannot see the initial scan\'s reasoning — only the finding itself and the FP filtering rules.': `For each candidate finding, add an independent reviewer child to a workflowScript. ${piParallelWorkflow(PI_SUBAGENT_ROLES.review)} Each verifier has fresh context and cannot see the initial scan's reasoning — only the finding itself and the FP filtering rules.`, |
| 86 | + 'Launch all verifiers in parallel.': `Use a workflowScript with runs.all([...]) to launch all verifiers in parallel. ${piParallelWorkflow(PI_SUBAGENT_ROLES.review)}`, |
| 87 | + 'Use the Agent tool to dispatch an independent reviewer. The reviewer has fresh context': `Use the subagent tool with a workflowScript. ${piSingleWorkflow(PI_SUBAGENT_ROLES.review)} The reviewer child has fresh context`, |
| 88 | + '**If CODEX_NOT_AVAILABLE (or Codex errored):**\n\nDispatch via the Agent tool. The subagent has fresh context — genuine independence.': `**If CODEX_NOT_AVAILABLE (or Codex errored):**\n\nUse the \`subagent\` tool with a workflowScript. ${piSingleWorkflow(PI_SUBAGENT_ROLES.secondOpinion)} The oracle child has fresh context — genuine independence.`, |
| 89 | + 'Dispatch via the Agent tool. The subagent has fresh context': `Use the \`subagent\` tool with a workflowScript. ${piSingleWorkflow(PI_SUBAGENT_ROLES.review)} The reviewer child has fresh context`, |
| 90 | + 'Dispatch via the Agent tool with the same prompt.': `Use the \`subagent\` tool with a workflowScript. ${piSingleWorkflow(PI_SUBAGENT_ROLES.review)} Pass it the same prompt and bound it at a 5-minute timeout.`, |
| 91 | + 'Dispatch via the Agent tool.': `Use the \`subagent\` tool with a workflowScript. ${piSingleWorkflow(PI_SUBAGENT_ROLES.review)} `, |
| 92 | + |
| 93 | + // The autoplan and design templates describe the Agent tool in several |
| 94 | + // shorter forms. Keep those instructions, but point them at Pi's API. |
| 95 | + 'via Agent tool': `via the \`subagent\` tool. ${piSingleWorkflow(PI_SUBAGENT_ROLES.review)}`, |
| 96 | + 'foreground Agent tool': 'foreground `subagent` workflow (`async: false`)', |
| 97 | + 'Agent tool,': '`subagent` tool with a `workflowScript`,', |
| 98 | + 'Agent tool)': '`subagent` tool with a `workflowScript`)', |
| 99 | + 'Claude subagent': 'Pi reviewer subagent', |
| 100 | + 'Claude adversarial subagent': 'Pi adversarial reviewer subagent', |
| 101 | + 'Claude design subagent': 'Pi design reviewer subagent', |
| 102 | + 'Claude CEO subagent': 'Pi CEO reviewer subagent', |
| 103 | + 'Claude eng subagent': 'Pi eng reviewer subagent', |
| 104 | + 'Claude DX subagent': 'Pi DX reviewer subagent', |
| 105 | + 'Claude-only': 'Pi-only', |
| 106 | + 'Claude ': 'Pi ', |
| 107 | + 'CLAUDE SUBAGENT': 'PI REVIEWER SUBAGENT', |
| 108 | + 'Subagent prompt': 'Child-agent prompt', |
| 109 | + 'subagent prompt': 'child-agent prompt', |
| 110 | + 'subagent_type: "general-purpose"': 'agent: "delegate"', |
| 111 | + 'do NOT use run_in_background': 'set `async: false` for this foreground run', |
| 112 | + 'run_in_background': '`async: true`', |
| 113 | + 'Claude Code\'s Agent tool': 'Pi\'s `subagent` tool', |
| 114 | + 'agents do NOT inherit': 'child agents do NOT inherit', |
| 115 | + 'Agent subagents': 'subagent children', |
| 116 | + 'Agent tool': '`subagent` tool', |
| 117 | + }, |
| 118 | + |
| 119 | + // Unlike Pi's bare CLI, pi-subagents provides the child sessions needed by |
| 120 | + // these workflows. Keep the delegation and outside-voice resolvers enabled; |
| 121 | + // setup installs the package before Pi skills are generated. |
| 122 | + suppressedResolvers: [], |
| 123 | + |
| 124 | + runtimeRoot: { |
| 125 | + globalSymlinks: [ |
| 126 | + 'bin', 'browse/dist', 'browse/bin', 'design/dist', 'make-pdf/dist', |
| 127 | + 'extension', 'lib/diagram-render', 'gstack-upgrade', 'ETHOS.md', |
| 128 | + ], |
| 129 | + globalFiles: { |
| 130 | + 'review': ['checklist.md', 'TODOS-format.md'], |
| 131 | + }, |
| 132 | + }, |
| 133 | + |
| 134 | + install: { |
| 135 | + prefixable: false, |
| 136 | + linkingStrategy: 'symlink-generated', |
| 137 | + }, |
| 138 | + |
| 139 | + learningsMode: 'basic', |
| 140 | +}; |
| 141 | + |
| 142 | +export default pi; |
0 commit comments