pi-herdr-subagents-lite 0.5.1 → 0.6.0

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/README.md CHANGED
@@ -1,57 +1,118 @@
1
1
  # pi-herdr-subagents-lite
2
2
 
3
- English | [简体中文](README.zh-CN.md)
3
+ [简体中文](README.zh-CN.md) | **English**
4
4
 
5
- A pi extension that runs subagents as separate pi processes in herdr panes. One tool, two actions: `run` starts a subagent, `send` continues it, results come back asynchronously.
6
-
7
- Behavior is defined by the [v1 contract](docs/specs/0001-v1-contract.md). Project docs are in Chinese.
5
+ The extension runs subagents as separate pi processes in herdr panes. One tool has two actions: `run` starts a subagent, and `send` continues a subagent. Results come back asynchronously. The behavior follows the [v1 contract](docs/specs/0001-v1-contract.md).
8
6
 
9
7
  ## Features
10
8
 
11
- - **Separate process, human takeover**: each subagent is its own pi process in a herdr pane. Same cwd as the parent opens a tab in the same workspace, otherwise a new workspace. Switch into the pane and take over at any time.
12
- - **Profile layers**: Markdown + frontmatter profiles, global and per project.
13
- - **Async, merged results**: `run` returns at once. Each finished turn reports one `subagent_result` message; results inside `aggregateWindowMs` merge into one. Oversize results go to an artifact file.
14
- - **Questions stay with the human**: a child prompt marks its pane `herdr:blocked` and nothing goes to the parent. The human answers in the child pane; no model relays the answer.
15
- - **No nesting by default, no sandbox**: child tool sets drop this tool unless the profile names it. The profile picks tools; the extension does not restrict writes.
9
+ - Separate process, human takeover: each subagent is its own pi process in a herdr pane. If the subagent cwd equals the parent cwd, the subagent opens a tab in the same workspace. Otherwise the subagent opens a new workspace.
10
+ - Two profile layers: Markdown with frontmatter, one global profile layer and one profile layer per project.
11
+ - Async, merged results: `run` returns at once. Each finished turn reports one `subagent_result`. Results inside `aggregateWindowMs` merge into one result. Oversize results go to an artifact file.
12
+ - Questions stay with the human: a child prompt only emits `herdr:blocked`. Nothing reaches the parent. The human answers in the child pane.
13
+ - No nesting by default, no sandbox: if the profile does not name this tool, child tool sets drop this tool.
16
14
 
17
- ## Requirements
15
+ ## Install
18
16
 
19
- Tested with herdr `0.9.5` and pi `1.4.0`. Node `>= 22.19`. The parent must run inside a herdr pane, otherwise calls fail with `not_in_herdr`.
17
+ ```bash
18
+ pi install npm:pi-herdr-subagents-lite # npm
19
+ pi install /path/to/pi-herdr-subagents-lite # local checkout
20
+ pi -e /path/to/pi-herdr-subagents-lite/src/index.ts # this process only
21
+ ```
20
22
 
21
- ## Install
23
+ The old repository moved into this monorepo. Install from npm.
22
24
 
23
- Pick one source, then restart pi.
25
+ Do not pass `-l`. `-l` writes project settings only, so children started in another workspace never load the package. `pi -e` is single-process too.
24
26
 
25
- ```bash
26
- pi install npm:pi-herdr-subagents-lite # npm
27
- pi install git:github.com/setwhite/pi-herdr-subagents-lite # git
28
- pi install /path/to/pi-herdr-subagents-lite # local checkout
29
- pi -e /path/to/pi-herdr-subagents-lite/src/index.ts # this process only
27
+ Tested with herdr `0.9.5` and pi `1.4.0`, Node `>= 22.19`. The parent must run inside a herdr pane. Otherwise calls fail with `not_in_herdr`. Upgrade with `pi update --extensions`. Remove with `pi remove <source>`.
28
+
29
+ ## Configuration
30
+
31
+ One global file holds the configuration: `<agent-dir>/pi-herdr-subagents-lite/config.json`. `<agent-dir>` defaults to `~/.pi/agent`. `PI_CODING_AGENT_DIR` sets `<agent-dir>`. The extension does not read a project config.
32
+
33
+ Defaults and clamp boundaries: `src/config/index.ts` and `test/config/config.test.ts`. Key meaning: [contract §1](docs/specs/0001-v1-contract.md#1-配置).
34
+
35
+ ### Minimal config
36
+
37
+ A missing file means all defaults. To change one value, write only that value:
38
+
39
+ ```json
40
+ {
41
+ "maxConcurrent": 4
42
+ }
30
43
  ```
31
44
 
32
- Do not pass `-l`: it writes project settings only, so children started in another workspace never load the package and both the inbox pump and the bridge stop working. `pi -e` is single-process too.
45
+ ### Full configuration
33
46
 
34
- Upgrade with `pi update --extensions`, remove with `pi remove <source>`. After a restart the tool list shows `subagent` (or your `toolName`).
47
+ The block below lists every key. Each value is the default.
35
48
 
36
- ## Quick start
49
+ ```jsonc
50
+ {
51
+ // Default true. false = no subagent tool for the model. The bridge has its own switch.
52
+ "enabled": true,
53
+ // Default "subagent". Must match ^[a-z][a-z0-9_]{0,31}$. The name prefixes each guideline line.
54
+ "toolName": "subagent",
55
+ // Default "herdr". A plain name resolves from PATH; an absolute path pins a version.
56
+ "herdrBin": "herdr",
57
+ // Default 16, range 1 and up. At the limit run returns max_concurrent. A child with auto-exit: false keeps its slot after it settles.
58
+ "maxConcurrent": 16,
59
+ // Default 16384, range 1024 to 1048576. A longer text goes to an artifact file; the message keeps a truncated head and the path.
60
+ "maxResultChars": 16384,
61
+ // Default 500, range 0 to 10000 milliseconds. 0 = deliver each result at once. A larger value merges more results.
62
+ "aggregateWindowMs": 500,
63
+ // Default empty = never close. Values: new, resume, fork, quit, reload. A listed reason closes the child tabs on parent shutdown.
64
+ "closeChildrenOn": [],
65
+ // Default 250, range 50 to 5000 milliseconds. A larger value wakes less often and delivers later.
66
+ "inboxPollMs": 250,
67
+ // Default 1000, range 100 to 60000 milliseconds. Use while a child works or blocks, or within 30 s of run or send.
68
+ "pollIntervalMs": 1000,
69
+ // Default 8000, range 100 to 60000 milliseconds. Use when every live child only waits for send. A larger value notices a dead pane later.
70
+ "idlePollIntervalMs": 8000,
71
+ // Tool text overrides. Each key defaults to unset, which keeps the built-in text shown below.
72
+ "prompts": {
73
+ // Replaces the built-in description.
74
+ "description": "Run subagents and send them messages.",
75
+ // The one-line entry in Available tools. Empty = keep the tool out of that list.
76
+ "snippet": "",
77
+ // Replaces the built-in guideline lines. Keep {{profiles}} to list the profiles.
78
+ "guidelines": [
79
+ "The parent handles user interaction, cross-task synthesis, and decisions; subagents execute.",
80
+ "run only starts; it does not wait. The result arrives later as a message.",
81
+ "send only delivers; no state tracking.",
82
+ "Available profiles:\n{{profiles}}"
83
+ ]
84
+ },
85
+ // Turn pi prompt events into herdr:blocked events.
86
+ "bridge": {
87
+ // Default true. false = no herdr:blocked events.
88
+ "enabled": true,
89
+ // Default all five. Prompt kinds that count as blocked: custom, select, confirm, input, editor.
90
+ "blockedOn": ["custom", "select", "confirm", "input", "editor"]
91
+ }
92
+ }
93
+ ```
94
+
95
+ The file is strict JSON and the extension reads it once, so delete the comments and restart pi after a change. An unknown key, a wrong type or an unknown enum value stops the extension at load: pi prints `invalid config <path>: <field>: unknown key` and exits. A number outside its range clamps to the boundary.
96
+
97
+ ## Usage
37
98
 
38
99
  1. Start `pi` in a herdr pane.
39
- 2. Write a profile (next section); `run` takes its frontmatter `name`.
100
+ 2. Write a profile (next section). `run` takes the frontmatter `name` of the profile.
40
101
  3. Ask the model to call the tool:
41
102
 
42
103
  ```json
43
104
  {"action":"run","profile":"explore","task":"Read README.md and answer with its first heading."}
44
105
  ```
45
106
 
46
- It returns `{"state":"running",...}`, runs in its own tab, and a `[subagent explore-1] done` message arrives later. Do not wait for it in the same turn. Continue that child with:
107
+ The call returns `{"state":"running",...}`. The subagent runs in its own tab. A `[subagent explore-1] done` message arrives later. Do not wait for the message in the same turn. Continue that child with:
47
108
 
48
109
  ```json
49
110
  {"action":"send","name":"explore-1","message":"Also check the Windows branch."}
50
111
  ```
51
112
 
52
- ## Profile
113
+ ### Profile
53
114
 
54
- Global profiles live in `<agent-dir>/pi-herdr-subagents-lite/profiles/*.md`, project profiles in `.pi/pi-herdr-subagents-lite/profiles/*.md` (read once the project is trusted); the project wins on the same `name`.
115
+ Global profiles live in `<agent-dir>/pi-herdr-subagents-lite/profiles/*.md`. Project profiles live in `.pi/pi-herdr-subagents-lite/profiles/*.md` and load once the project is trusted. If a project profile and a global profile share a `name`, the project profile wins.
55
116
 
56
117
  ```markdown
57
118
  ---
@@ -84,52 +145,15 @@ disable-model-invocation: false
84
145
  You are a read-only explorer. Answer with file paths and line numbers.
85
146
  ```
86
147
 
87
- Error codes: [contract section 2](docs/specs/0001-v1-contract.md#2-profile). Defaults: `src/profile/frontmatter.ts` and `test/profile/`. A file without `name`, or with an invalid field, stays out of the list; duplicate names in one layer are all rejected. `run` returns `profile_invalid` with the file, field and reason.
148
+ Error codes: [contract section 2](docs/specs/0001-v1-contract.md#2-profile). Defaults: `src/profile/frontmatter.ts` and `test/profile/`. A file without `name` or with an invalid field stays out of the list. The extension rejects all duplicate names in one layer. `run` returns `profile_invalid` with the file, the field and the reason.
88
149
 
89
- A bundled example ships with the extension; its file name and `name` are both `domain`. Loading reads `profiles/*.md` only and the example is written only when missing, so copy it one level up:
150
+ The extension ships a bundled example. The file name and the `name` of the example are both `domain`. Loading reads `profiles/*.md` only. The extension writes the example only when the example is missing, so copy the example one level up:
90
151
 
91
152
  ```bash
92
153
  cd <agent-dir>/pi-herdr-subagents-lite/profiles && cp examples/domain.md domain.md
93
154
  ```
94
155
 
95
- ## Configuration
96
-
97
- One global file: `<agent-dir>/pi-herdr-subagents-lite/config.json`. `<agent-dir>` defaults to `~/.pi/agent` and follows `PI_CODING_AGENT_DIR`. Project config is not read.
98
-
99
- Defaults and clamp boundaries: `src/config/index.ts`, `test/config/config.test.ts`. Key meaning: [contract §1](docs/specs/0001-v1-contract.md#1-配置).
100
-
101
- ### Minimal config
102
-
103
- A missing file means all defaults. To change one value, write only that value:
104
-
105
- ```json
106
- {
107
- "maxConcurrent": 4
108
- }
109
- ```
110
-
111
- ### Keys
112
-
113
- | Key | Meaning |
114
- |---|---|
115
- | `enabled` | Gates tool registration only; the bridge has its own switch |
116
- | `toolName` | Name the model sees; `^[a-z][a-z0-9_]{0,31}$` |
117
- | `herdrBin` | herdr executable; a plain name resolves from PATH, an absolute path pins a version |
118
- | `maxConcurrent` | Live children per parent session; an `auto-exit: false` child keeps its slot after settling |
119
- | `maxResultChars` | Per-result character limit; beyond it the full text goes to an artifact and the message keeps a truncated head plus the path |
120
- | `aggregateWindowMs` | Merge window in milliseconds; 0 = deliver each result at once |
121
- | `closeChildrenOn` | Parent shutdown reasons that close its child tabs: `new` / `resume` / `fork` / `quit` / `reload`; empty = never |
122
- | `inboxPollMs` | Child inbox polling interval |
123
- | `pollIntervalMs` | Parent `agent list` interval while a child is working or blocked, or within 30 s of `run` / `send` |
124
- | `idlePollIntervalMs` | Parent interval when every live child only waits for `send`; it bounds how late a vanished pane is noticed (a killed child whose pane lives is fixed at 10 s) |
125
- | `prompts` | Tool text overrides: `description`, `snippet`, `guidelines`; omitted keys keep the built-in text; `snippet: ""` hides the tool from Available tools; keep `{{profiles}}` to list profiles |
126
- | `bridge` | `enabled` turns pi prompt events into `herdr:blocked`; `blockedOn` lists the prompt kinds that count as blocked |
127
-
128
- Strict JSON: an unknown key, a wrong type or a bad enum makes the extension fail to load, and pi exits naming the field. Out-of-range numbers clamp to the boundary. The config is read once, so restart pi after editing.
129
-
130
- ## Reference projects
131
-
132
- The design is based on these projects. Thank you.
156
+ ## Credits
133
157
 
134
158
  | Project | Borrowed |
135
159
  |---|---|
@@ -138,27 +162,17 @@ The design is based on these projects. Thank you.
138
162
  | [modem-dev/pi-herdr-subagents](https://github.com/modem-dev/pi-herdr-subagents) | herdr launch and lifecycle; derived end states |
139
163
  | [purboo/pi-durable-subagents](https://github.com/purboo/pi-durable-subagents) | Async delivery, idempotency, report-once results |
140
164
 
141
- ## Docs
142
-
143
- - [ARCHITECTURE](docs/ARCHITECTURE.md): module boundaries, dependency direction, test seams
144
- - [GLOSSARY](docs/GLOSSARY.md): the only source for terms
145
- - [Modules](docs/modules/): usage and trade-offs per module
165
+ Thank you for the code.
146
166
 
147
- ## Development
148
-
149
- ```bash
150
- pnpm install # dependencies
151
- pnpm check # the four checks below
152
- pnpm test # unit tests (vitest)
153
- pnpm lint # biome
154
- pnpm typecheck # tsc --noEmit
155
- pnpm check:imports # dependency direction, per docs/ARCHITECTURE.md
156
- pnpm test:e2e # real herdr plus real pi children, not part of pnpm check
157
- ```
158
-
159
- Run `git config core.hooksPath .githooks` once to run `pnpm check` on every commit.
167
+ ## Docs
160
168
 
161
- E2E starts an isolated herdr session and agent directory, and skips the suite with a reason when herdr, pi or `auth.json` is missing. `PI_E2E_MODEL` picks another model; `PI_E2E_KEEP=1` keeps the temp directories.
169
+ | Document | Content |
170
+ |---|---|
171
+ | [docs/specs/0001-v1-contract.md](docs/specs/0001-v1-contract.md) | The v1 contract |
172
+ | [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) | Module boundaries, dependency direction, test seams |
173
+ | [docs/modules/](docs/modules/) | Usage and trade-offs per module |
174
+ | [docs/GLOSSARY.md](docs/GLOSSARY.md) | The only source for terms |
175
+ | [CHANGELOG.md](CHANGELOG.md) | Release notes |
162
176
 
163
177
  ## License
164
178
 
package/README.zh-CN.md CHANGED
@@ -1,57 +1,118 @@
1
1
  # pi-herdr-subagents-lite
2
2
 
3
- [English](README.md) | 简体中文
3
+ **[简体中文](README.zh-CN.md)** | [English](README.md)
4
4
 
5
- pi 扩展:让子代理作为独立 pi 进程跑在 herdr pane 里。一个工具,两个 action:`run` 起子代理,`send` 续聊,结果异步回投。
6
-
7
- 行为以 [v1 契约](docs/specs/0001-v1-contract.md) 为准。
5
+ 让子代理作为独立 pi 进程跑在 herdr pane 里。一个工具有两个 action:`run` 起子代理,`send` 续聊,结果异步回投。行为以 [v1 契约](docs/specs/0001-v1-contract.md) 为准。
8
6
 
9
7
  ## 功能
10
8
 
11
- - **独立进程,可人工接管**:每个子代理是 herdr pane 里独立的 pi 进程。cwd 与父相同则同 workspace 新开 tab,否则新建 workspace。随时切进去接管。
12
- - **两层 profile**:Markdown + frontmatter,全局一层、项目一层。
13
- - **异步、可合并的结果**:`run` 立即返回。每次收工投一条 `subagent_result`;落在 `aggregateWindowMs` 内的结果合并成一条。超长结果落 artifact 文件。
14
- - **反问留在人这边**:子代理弹出对话框时只发出 `herdr:blocked` 事件,父侧什么也收不到。人在子 pane 里回答,不经模型转达。
15
- - **默认不嵌套,也不是沙箱**:子代理的工具集默认去掉本工具,profile 里点名才授予。工具由 profile 决定,扩展不限制写操作。
9
+ - 独立进程可接管:每个子代理是 herdr pane 里的独立 pi 进程。如果 cwd 与父相同,就在同一个 workspace 新开 tab。否则新建 workspace。
10
+ - 两层 profile:Markdown + frontmatter,全局一层、项目一层。
11
+ - 结果异步可合并:`run` 立即返回。每次收工投一条 `subagent_result`。落在 `aggregateWindowMs` 内的结果合并成一条。超长结果落 artifact 文件。
12
+ - 反问留在人这边:子代理弹对话框只发 `herdr:blocked`。父侧收不到这个消息。人在子 pane 里回答。
13
+ - 默认不嵌套,也不是沙箱。子代理工具集默认去掉本工具。只有 profile 点名才授予本工具。
16
14
 
17
- ## 要求
15
+ ## 安装
18
16
 
19
- 在 herdr `0.9.5` 与 pi `1.4.0` 上测过。Node `>= 22.19`。父会话必须在 herdr pane 里,否则调用返回 `not_in_herdr`。
17
+ ```bash
18
+ pi install npm:pi-herdr-subagents-lite # npm
19
+ pi install /path/to/pi-herdr-subagents-lite # 本地源码
20
+ pi -e /path/to/pi-herdr-subagents-lite/src/index.ts # 只对当前进程生效
21
+ ```
20
22
 
21
- ## 安装
23
+ 旧仓已并入 monorepo。请用 npm 安装。
22
24
 
23
- 选一种来源,装完重启 pi。
25
+ 不要加 `-l`。`-l` 只写项目设置,在别的 workspace 里起的子代理就加载不到。`pi -e` 同样是单进程。
24
26
 
25
- ```bash
26
- pi install npm:pi-herdr-subagents-lite # npm
27
- pi install git:github.com/setwhite/pi-herdr-subagents-lite # git
28
- pi install /path/to/pi-herdr-subagents-lite # 本地源码
29
- pi -e /path/to/pi-herdr-subagents-lite/src/index.ts # 只对当前进程生效
27
+ 在 herdr `0.9.5` 与 pi `1.4.0` 上测过,Node `>= 22.19`。父会话必须在 herdr pane 里。如果不在,就返回 `not_in_herdr`。升级用 `pi update --extensions`。卸载用 `pi remove <source>`。
28
+
29
+ ## 配置
30
+
31
+ 只有一个全局文件:`<agent-dir>/pi-herdr-subagents-lite/config.json`。`<agent-dir>` 默认 `~/.pi/agent`,跟随 `PI_CODING_AGENT_DIR`。扩展不读项目级配置。
32
+
33
+ 默认值与 clamp 边界:`src/config/index.ts`、`test/config/config.test.ts`。键与语义:[契约 §1](docs/specs/0001-v1-contract.md#1-配置)。
34
+
35
+ ### 最小配置
36
+
37
+ 如果文件不存在,全部用默认值。只改一项,就只写这一项:
38
+
39
+ ```json
40
+ {
41
+ "maxConcurrent": 4
42
+ }
30
43
  ```
31
44
 
32
- 不要加 `-l`:它只写项目设置,在别的 workspace 里起的子代理就加载不到,inbox 泵和 bridge 都会失效。`pi -e` 同样是单进程。
45
+ ### 完整配置
33
46
 
34
- 升级用 `pi update --extensions`,卸载用 `pi remove <source>`。重启后工具列表里出现 `subagent`(或你配的 `toolName`)。
47
+ 下面这份列出全部键。每个取值就是默认值。
35
48
 
36
- ## 快速开始
49
+ ```jsonc
50
+ {
51
+ // 默认 true。false = 模型看不到本工具。bridge 有独立开关。
52
+ "enabled": true,
53
+ // 默认 "subagent"。须匹配 ^[a-z][a-z0-9_]{0,31}$。它会作为每条 guideline 的前缀。
54
+ "toolName": "subagent",
55
+ // 默认 "herdr"。裸名从 PATH 解析;绝对路径锁定版本。
56
+ "herdrBin": "herdr",
57
+ // 默认 16,下限 1。到上限时 run 返回 max_concurrent。auto-exit: false 的子代理收工后仍占槽。
58
+ "maxConcurrent": 16,
59
+ // 默认 16384,范围 1024 到 1048576。超上限时全文落 artifact 文件;消息里留截断的头和路径。
60
+ "maxResultChars": 16384,
61
+ // 默认 500,范围 0 到 10000,单位毫秒。0 = 逐条立即投递。调大合并更多结果。
62
+ "aggregateWindowMs": 500,
63
+ // 默认空 = 从不关。取值:new、resume、fork、quit、reload。列出的原因会在父会话退出时关掉子 tab。
64
+ "closeChildrenOn": [],
65
+ // 默认 250,范围 50 到 5000,单位毫秒。调大省唤醒,投递变慢。
66
+ "inboxPollMs": 250,
67
+ // 默认 1000,范围 100 到 60000,单位毫秒。用于:子代理在 working 或 blocked,或刚 run / send 的 30 秒内。
68
+ "pollIntervalMs": 1000,
69
+ // 默认 8000,范围 100 到 60000,单位毫秒。用于:所有 live 子代理都只在等 send。调大更晚发现 pane 消失。
70
+ "idlePollIntervalMs": 8000,
71
+ // 工具文案覆盖。每个键默认未设置,用下面这份内置文案。
72
+ "prompts": {
73
+ // 替换内置描述。
74
+ "description": "Run subagents and send them messages.",
75
+ // Available tools 里的那一行。空 = 不出现在该列表。
76
+ "snippet": "",
77
+ // 替换内置 guideline 各行。保留 {{profiles}} 才会列出 profile。
78
+ "guidelines": [
79
+ "The parent handles user interaction, cross-task synthesis, and decisions; subagents execute.",
80
+ "run only starts; it does not wait. The result arrives later as a message.",
81
+ "send only delivers; no state tracking.",
82
+ "Available profiles:\n{{profiles}}"
83
+ ]
84
+ },
85
+ // 把 pi 对话框事件转成 herdr:blocked 事件。
86
+ "bridge": {
87
+ // 默认 true。false = 不发 herdr:blocked。
88
+ "enabled": true,
89
+ // 默认全五种。算作 blocked 的对话框类型:custom、select、confirm、input、editor。
90
+ "blockedOn": ["custom", "select", "confirm", "input", "editor"]
91
+ }
92
+ }
93
+ ```
94
+
95
+ 必须是严格 JSON,扩展只读一次,所以保存前删掉注释,改完重启 pi。未知键、类型不对或枚举值非法都会让扩展加载失败:pi 打出 `invalid config <路径>: <字段>: unknown key` 后退出。超范围的数字会被夹到边界,不报错。
96
+
97
+ ## 用法
37
98
 
38
99
  1. 在 herdr pane 里启动 `pi`。
39
- 2. 写一个 profile(下一节);frontmatter `name` 就是 `run` 的寻址名。
100
+ 2. 写一个 profile(下一节)。frontmatter 的 `name` 就是 `run` 的寻址名。
40
101
  3. 让模型调用工具:
41
102
 
42
103
  ```json
43
104
  {"action":"run","profile":"explore","task":"读 README.md,回答它的第一个标题。"}
44
105
  ```
45
106
 
46
- 它返回 `{"state":"running",...}`,子代理在自己的 tab 里跑,稍后收到 `[subagent explore-1] done` 消息。不要在同一轮里等结果。续聊那个子代理:
107
+ 工具返回 `{"state":"running",...}`。子代理在自己的 tab 里跑。稍后收到 `[subagent explore-1] done` 消息。不要在同一轮里等结果。续聊那个子代理:
47
108
 
48
109
  ```json
49
110
  {"action":"send","name":"explore-1","message":"也看一下 Windows 那条分支。"}
50
111
  ```
51
112
 
52
- ## Profile
113
+ ### Profile
53
114
 
54
- 全局 profile 在 `<agent-dir>/pi-herdr-subagents-lite/profiles/*.md`,项目 profile 在 `.pi/pi-herdr-subagents-lite/profiles/*.md`(项目受信任后才读);`name` 相同时项目覆盖全局。
115
+ 全局 profile 在 `<agent-dir>/pi-herdr-subagents-lite/profiles/*.md`,项目 profile 在 `.pi/pi-herdr-subagents-lite/profiles/*.md`(项目受信任后才读)。如果 `name` 相同,项目覆盖全局。
55
116
 
56
117
  ```markdown
57
118
  ---
@@ -84,53 +145,16 @@ disable-model-invocation: false
84
145
  你是一名只读探索者,回答时给出文件路径与行号。
85
146
  ```
86
147
 
87
- 错误码见 [契约 §2](docs/specs/0001-v1-contract.md#2-profile);默认值见 `src/profile/frontmatter.ts` 与 `test/profile/`。没写 `name`、字段非法或同层同名的文件都不进列表;对它 `run` 返回 `profile_invalid`,带文件、字段与原因。
148
+ 错误码见 [契约 §2](docs/specs/0001-v1-contract.md#2-profile)。默认值见 `src/profile/frontmatter.ts` 与 `test/profile/`。没写 `name`、字段非法或同层同名的文件都不进列表。对它 `run` 返回 `profile_invalid`,带文件、字段与原因。
88
149
 
89
- 扩展自带一个示例 profile,文件名和 `name` 都是 `domain`。加载只读 `profiles/*.md`,示例也只在缺失时写入,所以复制一层上去即可:
150
+ 扩展自带一个示例 profile,文件名和 `name` 都是 `domain`。加载只读 `profiles/*.md`。示例也只在缺失时写入。所以复制一份到上一层即可:
90
151
 
91
152
  ```bash
92
153
  cd <agent-dir>/pi-herdr-subagents-lite/profiles && cp examples/domain.md domain.md
93
154
  ```
94
155
 
95
- ## 配置
96
-
97
- 只有一个全局文件:`<agent-dir>/pi-herdr-subagents-lite/config.json`。`<agent-dir>` 默认 `~/.pi/agent`,跟随 `PI_CODING_AGENT_DIR`。项目级配置不读。
98
-
99
- 默认值与 clamp 边界:`src/config/index.ts`、`test/config/config.test.ts`。键与语义:[契约 §1](docs/specs/0001-v1-contract.md#1-配置)。
100
-
101
- ### 最小配置
102
-
103
- 文件不存在就全用默认值。只改一项,就只写这一项:
104
-
105
- ```json
106
- {
107
- "maxConcurrent": 4
108
- }
109
- ```
110
-
111
- ### 键
112
-
113
- | 键 | 含义 |
114
- |---|---|
115
- | `enabled` | 只管工具注册;bridge 有自己的开关 |
116
- | `toolName` | 模型看到的工具名;`^[a-z][a-z0-9_]{0,31}$` |
117
- | `herdrBin` | herdr 可执行文件;裸名从 PATH 解析,绝对路径锁定版本 |
118
- | `maxConcurrent` | 每个父会话并存的子代理数;`auto-exit: false` 的子代理收工后仍占槽 |
119
- | `maxResultChars` | 单条结果字符上限;超了全文落 artifact,消息里留截断的头和路径 |
120
- | `aggregateWindowMs` | 合并窗口,毫秒;0 = 逐条立即投递 |
121
- | `closeChildrenOn` | 父会话以这些原因退出时关掉子 tab:`new` / `resume` / `fork` / `quit` / `reload`;空 = 从不关 |
122
- | `inboxPollMs` | 子侧 inbox 轮询间隔 |
123
- | `pollIntervalMs` | 父侧 `agent list` 间隔;有子代理在 working 或 blocked,或刚 `run` / `send` 的 30 秒内用 |
124
- | `idlePollIntervalMs` | 所有 live 子代理都只是在等 `send` 时的间隔;它决定 pane 消失最晚多久被发现(pane 还在、进程被杀的那类固定 10 秒) |
125
- | `prompts` | 覆盖工具文案:`description`、`snippet`、`guidelines`;省略的键用内置文案;`snippet: ""` 让工具从 Available tools 消失;保留 `{{profiles}}` 才会列出 profile |
126
- | `bridge` | `enabled` 把 pi 对话框事件转成 `herdr:blocked`;`blockedOn` 列出算 blocked 的对话框类型 |
127
-
128
- 必须是严格 JSON:未知键、类型不对、枚举非法都会让扩展加载失败,pi 报出字段名退出。超范围的数字会被夹到边界,不报错。配置只读一次,改完重启 pi。
129
-
130
156
  ## 参考项目
131
157
 
132
- 设计参考了这些项目,感谢作者。
133
-
134
158
  | 项目 | 借鉴内容 |
135
159
  |---|---|
136
160
  | [earendil-works/pi](https://github.com/earendil-works/pi) | 扩展 API、包布局、官方示例 |
@@ -138,28 +162,18 @@ cd <agent-dir>/pi-herdr-subagents-lite/profiles && cp examples/domain.md domain.
138
162
  | [modem-dev/pi-herdr-subagents](https://github.com/modem-dev/pi-herdr-subagents) | herdr 启动与生命周期;终态归类 |
139
163
  | [purboo/pi-durable-subagents](https://github.com/purboo/pi-durable-subagents) | 异步投递、幂等、只上报一次 |
140
164
 
141
- ## 文档
142
-
143
- - [ARCHITECTURE](docs/ARCHITECTURE.md):模块边界、依赖方向、测试 seam
144
- - [GLOSSARY](docs/GLOSSARY.md):术语唯一来源
145
- - [模块](docs/modules/):各模块的用法与取舍
165
+ 感谢这些项目的代码。
146
166
 
147
- ## 开发
148
-
149
- ```bash
150
- pnpm install # 装依赖
151
- pnpm check # 下面四项
152
- pnpm test # 单测(vitest)
153
- pnpm lint # biome
154
- pnpm typecheck # tsc --noEmit
155
- pnpm check:imports # 依赖方向,按 docs/ARCHITECTURE.md 校验
156
- pnpm test:e2e # 真 herdr + 真 pi 子进程,不在 pnpm check 里
157
- ```
158
-
159
- 跑一次 `git config core.hooksPath .githooks`,之后每次提交都会跑 `pnpm check`。
167
+ ## 文档
160
168
 
161
- E2E 自己起隔离的 herdr session 与 agent 目录,缺 herdr、pi 或 `auth.json` 时整组跳过并给出原因。`PI_E2E_MODEL` 换模型;`PI_E2E_KEEP=1` 保留临时目录。
169
+ | 文档 | 内容 |
170
+ |---|---|
171
+ | [docs/specs/0001-v1-contract.md](docs/specs/0001-v1-contract.md) | v1 契约 |
172
+ | [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) | 模块边界、依赖方向、测试 seam |
173
+ | [docs/modules/](docs/modules/) | 各模块的用法与取舍 |
174
+ | [docs/GLOSSARY.md](docs/GLOSSARY.md) | 术语唯一来源 |
175
+ | [CHANGELOG.md](CHANGELOG.md) | 发布记录 |
162
176
 
163
- ## 许可
177
+ ## License
164
178
 
165
179
  MIT,见 [LICENSE](LICENSE)。
package/package.json CHANGED
@@ -1,16 +1,24 @@
1
1
  {
2
2
  "name": "pi-herdr-subagents-lite",
3
- "version": "0.5.1",
3
+ "version": "0.6.0",
4
4
  "description": "Run pi subagents in herdr panes.",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "author": "setwhite",
8
8
  "repository": {
9
9
  "type": "git",
10
- "url": "git+https://github.com/setwhite/pi-herdr-subagents-lite.git"
10
+ "url": "git+https://github.com/setwhite/pi-extensions.git",
11
+ "directory": "packages/pi-herdr-subagents-lite"
11
12
  },
12
- "keywords": ["pi-package", "pi-extension", "herdr", "subagent"],
13
- "files": ["src"],
13
+ "keywords": [
14
+ "pi-package",
15
+ "pi-extension",
16
+ "herdr",
17
+ "subagent"
18
+ ],
19
+ "files": [
20
+ "src"
21
+ ],
14
22
  "packageManager": "pnpm@12.3.4",
15
23
  "engines": {
16
24
  "node": ">=22.19.0"
@@ -22,11 +30,11 @@
22
30
  },
23
31
  "scripts": {
24
32
  "lint": "biome check --error-on-warnings .",
25
- "check:imports": "node scripts/check-imports.mjs",
33
+ "lint:fix": "biome check --write .",
34
+ "check:imports": "node ../../scripts/check-imports.mjs",
26
35
  "typecheck": "tsc --noEmit",
27
36
  "test": "vitest run",
28
- "test:e2e": "vitest run --config vitest.e2e.config.ts",
29
- "check": "pnpm lint && pnpm check:imports && pnpm typecheck && pnpm test"
37
+ "test:e2e": "vitest run --config vitest.e2e.config.ts"
30
38
  },
31
39
  "peerDependencies": {
32
40
  "@earendil-works/pi-coding-agent": "*",
package/src/tool/text.ts CHANGED
@@ -5,9 +5,10 @@ import { profileLabel } from "../run/index.ts";
5
5
  const DEFAULT_DESCRIPTION = "Run subagents and send them messages.";
6
6
  const DEFAULT_SNIPPET = "";
7
7
  const DEFAULT_GUIDELINES = [
8
+ "The parent handles user interaction, cross-task synthesis, and decisions; subagents execute.",
9
+ "run only starts; it does not wait. The result arrives later as a message.",
10
+ "send only delivers; no state tracking.",
8
11
  "Available profiles:\n{{profiles}}",
9
- "run only starts the subagent; the result comes back automatically as a message.",
10
- "send only delivers; state tracking is not needed.",
11
12
  ];
12
13
 
13
14
  export function toolText(config: Config, profiles: Profile[]) {