@pi-in-go/pigpen-subagents

中文文档
0.2.0发布于 2026/11/02MIT零依赖构建来源已验证

Go port of pi-subagents: agent and chain definitions, their discovery, the subagent tool's list and get actions, and single-agent and chain runs through a child pig process (partial: no parallel, async, workflow, worktree or fleet features)

原始使用文档

pi-subagents (Go port, partial)

A Go extension for PiG: delegate work to specialist agents defined in markdown files. It is a port of pi-subagents by Nico Bailon (see CREDITS.md), made with the extension porting Skill, and needs no Node.

Use

Define an agent in .pi/agents/<name>.md (the project) or ~/.pi/agent/agents/<name>.md (you), the original's format:

---
name: helper
description: Helps with things
model: provider/model
tools: read, grep
---

You help.

The model sees two tools. subagents_enable makes the subagent tool available (it is not offered until then, as in the original); then:

  • subagent {action: "list"} lists the agents (agentScope: user, project or both), {action: "get", agent: "helper"} shows one;
  • subagent {agent: "helper", task: "..."} runs one agent in a child pig --print process and returns its answer;
  • /run-chain <chain> <task> runs a .chain.md chain (.pi/chains/ or ~/.pi/agent/chains/): each step's answer flows into the next as {previous}, the request as {task}.

Thirteen agents ship with the package (the original's scout, worker, reviewer, ...). PIG_SUBAGENT_PIG_BINARY names the pig to start for a child; otherwise the pig running this extension, then a pig beside this program, then PATH. A child gets the task on stdin, discovers extensions as the original's background child does (a model provider and its login come from one), and may itself delegate only to depth 2 (PI_SUBAGENT_MAX_DEPTH, as in the original); at most 4 children run at once, and a cancelled call (Escape) stops its child. An agent with systemPromptMode: replace cannot run in a Piglet Binary child (a Binary keeps its own system prompt).

An agent chooses its child's extensions as in the original. extensions: a, b loads only those (an empty extensions: loads none, not even a model provider), and subagentOnlyExtensions: c loads c in the child on top of the rest. Entries are what pig --extension takes: a path (./ and ../ are relative to the agent file), builtin:<name>, or an npm:/git: source. For agents that set neither, subagents.defaultExtensions and subagents.defaultSubagentOnlyExtensions in settings.json are the default: PiG's own files (.pig/settings.json in the cwd, ~/.pig/agent/settings.json) and the original's (.pi/settings.json at the project root, ~/.pi/agent/settings.json) are all read, project over user and PiG's over Pi's at each level:

{ "subagents": { "defaultSubagentOnlyExtensions": ["/path/to/child-only-extension"] } }

A child's model and thinking level come, strongest first, from the call's model, subagents.agentOverrides.<name>.model and .thinking (false clears the agent's own), the agent's frontmatter, then subagents.defaultModel and defaultThinking, read from the same files, each from the first file that sets it. Without any of them the child runs on the host's default model. Other agentOverrides fields, defaultProvider and modelScope are not read:

{ "subagents": { "defaultModel": "provider/small-model", "agentOverrides": { "oracle": { "model": "provider/large-model", "thinking": "high" } } } }
pig install ./components/subagents

What is ported

Frontmatter parsing, agent and chain definitions (discovery in the project, the user's directories and the builtin set, precedence project over user over builtin, packages, aliases, name resolution), markdown chain files (parse and write), the subagent tool's list and get, the subagents_enable loader, and running one agent or a chain through a child process (a Go addition: the original runs children through its own executor and scripted workflows).

Not ported, and refused: parallel, async and background runs, scripted workflows (workflow, workflowScript, workflowScriptPath) and the legacy tasks/chain inputs, council mode, worktree isolation, the fleet and status views, steering and the supervisor channel, the watchdog, missions, profiles, agentOverrides other than model and thinking, .chain.json chains, the management actions other than list and get. The tool honors agent, task, agentScope, cwd, model and async: false (the port always runs in the foreground) and, for list and get, action, agent and agentScope. Any other parameter or action, and the tools bg_wait and subagent_supervisor (declared so the model sees the original's tools), is refused with one message and nothing runs:

@pi-in-go/pigpen-subagents (Go port) does not support async (background) runs (async: true) yet. Install the original extension, npm:[email protected], which runs unchanged in PiG.

The original's slash commands other than the port's own /run-chain (/run, /subagents, /subagents-stop, /prompt-workflow, ...) are not registered, and neither are its skills and prompt templates. See port/PORT.md.

版本与发布记录

@pi-in-go/pigpen-subagents 共发布 4 个版本,首次发布于 2026/10/06;过去 12 个月发布了 4 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.2.0latest2026/11/021 天前
0.1.22026/10/304 天前
0.1.02026/10/0628 天前
0.0.0-stage2026/10/0628 天前

关于 @pi-in-go/pigpen-subagents 的常见问题

@pi-in-go/pigpen-subagents 是什么?

Go端口pi-subagents:代理和链定义,它们的发现,子代理工具的列表和get操作,单代理和链运行通过子pig进程(部分:没有并行,异步,工作流,工作树或舰队功能)

如何安装 @pi-in-go/pigpen-subagents?

在项目目录运行 npm install @pi-in-go/pigpen-subagents,或使用 pnpm add / yarn add / bun add。

@pi-in-go/pigpen-subagents 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/pi-in-go__pigpen-subagents 是否存在。

@pi-in-go/pigpen-subagents 可以商用吗?

@pi-in-go/pigpen-subagents 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@pi-in-go/pigpen-subagents 还在维护吗?

最新版本 0.2.0 发布于 2026/11/02(1 天前);至今共发布 4 个版本,其中过去 12 个月发布了 4 个;首次发布于 2026/10/06。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。