@gotgenes/pi-subagents 13.2.0 → 13.2.2

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.
Files changed (43) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +21 -10
  3. package/dist/public.d.ts +34 -35
  4. package/docs/architecture/architecture.md +58 -148
  5. package/docs/architecture/history/phase-16-invert-dependencies.md +144 -0
  6. package/docs/decisions/0003-publish-bundled-type-declarations.md +3 -1
  7. package/docs/plans/0051-update-adr-0001-hard-fork.md +8 -6
  8. package/docs/plans/0257-extract-child-session-factory.md +3 -1
  9. package/docs/plans/0262-add-workspace-provider-seam.md +41 -39
  10. package/docs/plans/0264-remove-extension-lifecycle-control.md +100 -98
  11. package/docs/plans/0265-born-complete-subagent-session.md +5 -2
  12. package/docs/plans/0270-type-consumable-public-surface.md +3 -1
  13. package/docs/plans/0280-rename-agent-to-subagent.md +197 -0
  14. package/docs/retro/0051-update-adr-0001-hard-fork.md +4 -2
  15. package/docs/retro/0257-extract-child-session-factory.md +3 -1
  16. package/docs/retro/0262-add-workspace-provider-seam.md +3 -1
  17. package/docs/retro/0264-remove-extension-lifecycle-control.md +3 -1
  18. package/docs/retro/0270-type-consumable-public-surface.md +4 -2
  19. package/docs/retro/0277-encapsulate-agent-session.md +41 -0
  20. package/docs/retro/0280-rename-agent-to-subagent.md +96 -0
  21. package/package.json +1 -1
  22. package/src/index.ts +9 -9
  23. package/src/lifecycle/create-subagent-session.ts +1 -1
  24. package/src/lifecycle/{agent-manager.ts → subagent-manager.ts} +27 -27
  25. package/src/lifecycle/subagent-session.ts +2 -2
  26. package/src/lifecycle/{agent.ts → subagent.ts} +28 -28
  27. package/src/lifecycle/turn-limits.ts +1 -1
  28. package/src/lifecycle/workspace.ts +2 -2
  29. package/src/observation/notification.ts +9 -9
  30. package/src/observation/record-observer.ts +9 -9
  31. package/src/runtime.ts +1 -1
  32. package/src/service/service-adapter.ts +10 -10
  33. package/src/service/service.ts +5 -9
  34. package/src/tools/agent-tool.ts +5 -5
  35. package/src/tools/background-spawner.ts +3 -3
  36. package/src/tools/foreground-runner.ts +5 -5
  37. package/src/tools/get-result-tool.ts +2 -2
  38. package/src/tools/steer-tool.ts +2 -2
  39. package/src/types.ts +1 -1
  40. package/src/ui/agent-creation-wizard.ts +2 -2
  41. package/src/ui/agent-menu.ts +5 -5
  42. package/src/ui/agent-widget.ts +2 -2
  43. package/src/ui/conversation-viewer.ts +3 -3
@@ -7,13 +7,13 @@ issue_title: "Remove isolated / extensions:false / noSkills from core"
7
7
 
8
8
  ## Problem Statement
9
9
 
10
- The core still carries an extension-lifecycle-control axis `isolated`, `extensions: false`, and `noSkills` that lets a spawn blanket-disable a child's extensions and skills.
11
- Per ADR 0002, this is policy that does not belong in a minimal orchestrator.
10
+ The core still carries an extension-lifecycle-control axis - `isolated`, `extensions: false`, and `noSkills` - that lets a spawn blanket-disable a child's extensions and skills.
11
+ Per [ADR-0002], this is policy that does not belong in a minimal orchestrator.
12
12
  Deny-at-use (the in-child permission layer, shipped in Step 1 / #261) already covers what `isolated` pretended to do for tools.
13
- Prevent-load (refusing to bind an extension for true sandboxing) is genuinely generative and is deliberately left as a *latent, un-built* provider seam we do not ship a vacant hook.
13
+ Prevent-load (refusing to bind an extension for true sandboxing) is genuinely generative and is deliberately left as a *latent, un-built* provider seam - we do not ship a vacant hook.
14
14
 
15
15
  This is Phase 16, Step 4.
16
- With the axis gone, children always load the parent's extensions and skills, and the recursion guard which currently gates on `cfg.extensions` becomes unconditional.
16
+ With the axis gone, children always load the parent's extensions and skills, and the recursion guard - which currently gates on `cfg.extensions` - becomes unconditional.
17
17
 
18
18
  ## Goals
19
19
 
@@ -22,47 +22,47 @@ With the axis gone, children always load the parent's extensions and skills, and
22
22
  - Remove `noSkills` from the assembler and the resource-loader options.
23
23
  - Collapse the skill-curation axis symmetrically: remove `AgentConfig.skills` and the skill-**preload** path (`skill-loader.ts`, `safe-fs.ts`, `preloadSkills`, `PromptExtras`, `extras.skillBlocks`).
24
24
  Children always load Pi's full skill system, exactly as `skills: true` does today.
25
- - Make the recursion guard unconditional it always strips `subagent` / `get_subagent_result` / `steer_subagent` from children, keyed off the core's own tool names.
25
+ - Make the recursion guard unconditional - it always strips `subagent` / `get_subagent_result` / `steer_subagent` from children, keyed off the core's own tool names.
26
26
  - This is a **breaking** change: the public `SpawnOptions.isolated` field and the `isolated:` / `extensions:` / `skills:` custom-agent frontmatter keys are removed.
27
27
  Suggested commits use `feat!:`.
28
28
 
29
29
  ## Non-Goals
30
30
 
31
- - Born-complete child execution / dissolving the runner that is Step 5 (#265) and depends on this step.
31
+ - Born-complete child execution / dissolving the runner - that is Step 5 (#265) and depends on this step.
32
32
  `RunOptions`, `runAgent`, `ConcreteAgentRunner`, and `Agent.run()` survive this issue (with `isolated` removed from them).
33
- - Shipping a prevent-load provider seam — ADR 0002 leaves it latent until a real consumer needs it.
34
- - Changing `builtinToolNames` (the `tools:` frontmatter allowlist) that is a separate, surviving concern.
35
- - Changing deny-at-use behavior in `@gotgenes/pi-permission-system` already in place from #261.
33
+ - Shipping a prevent-load provider seam — [ADR-0002] leaves it latent until a real consumer needs it.
34
+ - Changing `builtinToolNames` (the `tools:` frontmatter allowlist) - that is a separate, surviving concern.
35
+ - Changing deny-at-use behavior in `@gotgenes/pi-permission-system` - already in place from #261.
36
36
 
37
37
  ## Background
38
38
 
39
39
  Relevant modules and how they relate:
40
40
 
41
- - `src/types.ts` declares `AgentConfig` (`extensions`, `skills`, `isolated`) and `AgentInvocation` (`isolated`).
42
- - `src/config/default-agents.ts` the three embedded agents set `extensions: true`, `skills: true`.
43
- - `src/config/custom-agents.ts` parses `extensions` / `skills` / `isolated` from `.md` frontmatter via `resolveBoolExtensions` and `inheritField`.
44
- - `src/config/invocation-config.ts` merges `isolated` from agent config + tool params.
45
- - `src/config/agent-types.ts` an absolute-fallback `AgentConfig` literal sets `extensions: true`, `skills: true`.
46
- - `src/session/session-config.ts` `assembleSessionConfig` derives `extensions`/`skills` from `options.isolated`, calls `io.preloadSkills` when `skills` is `string[]`, and computes `noSkills`.
41
+ - `src/types.ts` - declares `AgentConfig` (`extensions`, `skills`, `isolated`) and `AgentInvocation` (`isolated`).
42
+ - `src/config/default-agents.ts` - the three embedded agents set `extensions: true`, `skills: true`.
43
+ - `src/config/custom-agents.ts` - parses `extensions` / `skills` / `isolated` from `.md` frontmatter via `resolveBoolExtensions` and `inheritField`.
44
+ - `src/config/invocation-config.ts` - merges `isolated` from agent config + tool params.
45
+ - `src/config/agent-types.ts` - an absolute-fallback `AgentConfig` literal sets `extensions: true`, `skills: true`.
46
+ - `src/session/session-config.ts` - `assembleSessionConfig` derives `extensions`/`skills` from `options.isolated`, calls `io.preloadSkills` when `skills` is `string[]`, and computes `noSkills`.
47
47
  Returns `SessionConfig.{ extensions, noSkills, extras }`.
48
- - `src/session/prompts.ts` `buildAgentPrompt` injects `extras.skillBlocks` as `# Preloaded Skill:` sections; `PromptExtras` carries only `skillBlocks` (memory was removed in #185).
49
- - `src/session/skill-loader.ts` `preloadSkills` reads named skill files from disk; consumes `safe-fs.ts`.
50
- - `src/session/safe-fs.ts` symlink/path-traversal guards; **only consumer is `skill-loader.ts`**.
51
- - `src/lifecycle/agent-runner.ts` `RunOptions.isolated` flows into the assembler; `createResourceLoader` is called with `noExtensions: !cfg.extensions` and `noSkills: cfg.noSkills`; the recursion guard runs only `if (cfg.extensions)`.
48
+ - `src/session/prompts.ts` - `buildAgentPrompt` injects `extras.skillBlocks` as `# Preloaded Skill:` sections; `PromptExtras` carries only `skillBlocks` (memory was removed in #185).
49
+ - `src/session/skill-loader.ts` - `preloadSkills` reads named skill files from disk; consumes `safe-fs.ts`.
50
+ - `src/session/safe-fs.ts` - symlink/path-traversal guards; **only consumer is `skill-loader.ts`**.
51
+ - `src/lifecycle/agent-runner.ts` - `RunOptions.isolated` flows into the assembler; `createResourceLoader` is called with `noExtensions: !cfg.extensions` and `noSkills: cfg.noSkills`; the recursion guard runs only `if (cfg.extensions)`.
52
52
  `ResourceLoaderOptions` (a local narrow interface, not the SDK type) declares `noExtensions?` / `noSkills?`.
53
- - `src/lifecycle/agent.ts` `AgentInit.isolated`, the `_isolated` field, and `isolated:` in the `runner.run(...)` call.
54
- - `src/lifecycle/agent-manager.ts` `AgentSpawnConfig.isolated` and its pass-through to `new Agent(...)`.
55
- - `src/tools/{agent-tool,spawn-config,foreground-runner,background-spawner}.ts` tool schema `isolated`, `SpawnExecution.isolated`, and pass-through.
56
- - `src/service/{service,service-adapter}.ts` public `SpawnOptions.isolated` and its pass-through to the manager.
57
- - `src/ui/{display,agent-config-editor,agent-creation-wizard}.ts` `isolated` tag, eject-content emission, and generation-prompt template text.
58
- - `src/index.ts` wires `preloadSkills` and `buildAgentPrompt` into `assemblerIO`.
53
+ - `src/lifecycle/agent.ts` - `AgentInit.isolated`, the `_isolated` field, and `isolated:` in the `runner.run(...)` call.
54
+ - `src/lifecycle/agent-manager.ts` - `AgentSpawnConfig.isolated` and its pass-through to `new Agent(...)`.
55
+ - `src/tools/{agent-tool,spawn-config,foreground-runner,background-spawner}.ts` - tool schema `isolated`, `SpawnExecution.isolated`, and pass-through.
56
+ - `src/service/{service,service-adapter}.ts` - public `SpawnOptions.isolated` and its pass-through to the manager.
57
+ - `src/ui/{display,agent-config-editor,agent-creation-wizard}.ts` - `isolated` tag, eject-content emission, and generation-prompt template text.
58
+ - `src/index.ts` - wires `preloadSkills` and `buildAgentPrompt` into `assemblerIO`.
59
59
 
60
60
  AGENTS.md constraints that apply:
61
61
 
62
62
  - Conventional Commits; breaking changes use `feat!:`.
63
63
  - Do not edit `CHANGELOG.md` (release-please owns it).
64
64
  - When removing an export, grep all `src/` and `test/` for the symbol before finalizing (done below).
65
- - When adding/removing a module, check `docs/architecture/` for layout listings and complexity tables that reference it (done below Mermaid + tree + field tables).
65
+ - When adding/removing a module, check `docs/architecture/` for layout listings and complexity tables that reference it (done below - Mermaid + tree + field tables).
66
66
  - One-sentence-per-line markdown; sequential numbering restarting per heading.
67
67
 
68
68
  ## Design Overview
@@ -76,8 +76,8 @@ Two parallel axes leave the core together:
76
76
  | Skills | `skills: true \| string[] \| false`; `isolated` forces `false` | always inherit full skill system (field gone) |
77
77
 
78
78
  The `skills` field collapses for the same reason `extensions` does: `noSkills` is the single mechanism behind **both** restriction modes (`skills: false` → no skills; `skills: string[]` → only those, preloaded into the prompt with the SDK loader suppressed).
79
- Removing `noSkills` without removing `AgentConfig.skills` would leave a field that silently stops restricting a `string[]` agent would get its baked-in skills *plus* the full system.
80
- ADR 0002 says children always load the parent's skills, which is exactly the `skills: true` path; the other two values are skill curation/policy and leave the core.
79
+ Removing `noSkills` without removing `AgentConfig.skills` would leave a field that silently stops restricting - a `string[]` agent would get its baked-in skills *plus* the full system.
80
+ [ADR-0002] says children always load the parents skills, which is exactly the `skills: true` path; the other two values are skill curation/policy and leave the core.
81
81
 
82
82
  ### Assembler after collapse
83
83
 
@@ -121,16 +121,16 @@ const loader = deps.io.createResourceLoader({
121
121
  });
122
122
  // ...
123
123
  await session.bindExtensions({});
124
- // Recursion guard now unconditional (children always load extensions).
124
+ // Recursion guard - now unconditional (children always load extensions).
125
125
  const filtered = filterActiveTools(session.getActiveToolNames());
126
126
  session.setActiveToolsByName(filtered);
127
127
  ```
128
128
 
129
- `ResourceLoaderOptions` drops `noExtensions?` / `noSkills?` (a local narrow interface removing the latent fields keeps us honest per ADR 0002's "no vacant hooks").
129
+ `ResourceLoaderOptions` drops `noExtensions?` / `noSkills?` (a local narrow interface - removing the latent fields keeps us honest per [ADR-0002]’s no vacant hooks).
130
130
 
131
- ### Call-site sketch recursion guard (Tell-Don't-Ask check)
131
+ ### Call-site sketch - recursion guard (Tell-Don't-Ask check)
132
132
 
133
- The guard already asks the session for its active tools and tells it the filtered set unchanged except for removing the `if`.
133
+ The guard already asks the session for its active tools and tells it the filtered set - unchanged except for removing the `if`.
134
134
  No new collaborator, no reach-through; the only structural change is that `cfg.extensions` is no longer consulted, so `SessionConfig` no longer needs to expose it.
135
135
  This is a narrowing of the assembler's output contract, which is the desired direction.
136
136
 
@@ -143,91 +143,91 @@ This is a narrowing of the assembler's output contract, which is the desired dir
143
143
 
144
144
  ## Module-Level Changes
145
145
 
146
- ### Source `isolated` axis
147
-
148
- - `src/types.ts` remove `AgentConfig.isolated`, `AgentInvocation.isolated`.
149
- - `src/config/invocation-config.ts` remove `isolated` from `AgentInvocationParams` and the return object.
150
- - `src/config/custom-agents.ts` remove the `isolated:` frontmatter parse.
151
- - `src/session/session-config.ts` remove `AssemblerOptions.isolated` and the `options.isolated ? false : ...` derivation (read `agentConfig.extensions`/`agentConfig.skills` directly, for now).
152
- - `src/lifecycle/agent-runner.ts` remove `RunOptions.isolated` and the `isolated:` argument passed to `assembleSessionConfig`.
153
- - `src/lifecycle/agent.ts` remove `AgentInit.isolated`, the `_isolated` field + constructor assignment, and `isolated:` in the `runner.run(...)` call.
154
- - `src/lifecycle/agent-manager.ts` remove `AgentSpawnConfig.isolated` and its pass-through to `new Agent(...)`.
155
- - `src/tools/agent-tool.ts` remove the `isolated` schema property.
156
- - `src/tools/spawn-config.ts` remove `SpawnExecution.isolated`, the `const isolated = resolvedConfig.isolated`, `isolated` in `agentInvocation`, and `isolated` in the `execution` return.
157
- - `src/tools/foreground-runner.ts` / `src/tools/background-spawner.ts` remove `isolated: execution.isolated`.
158
- - `src/service/service.ts` remove `SpawnOptions.isolated`.
159
- - `src/service/service-adapter.ts` remove `isolated: options?.isolated` from the `manager.spawn(...)` call.
160
- - `src/ui/display.ts` remove `if (invocation.isolated) tags.push("isolated")` and the `isolated` mention in the JSDoc example.
161
- - `src/ui/agent-config-editor.ts` remove the `isolated: true` line from `buildEjectContent`.
162
- - `src/ui/agent-creation-wizard.ts` remove the `isolated:` template line and the "Set isolated: true " guideline.
163
-
164
- ### Source `extensions` axis + unconditional guard
165
-
166
- - `src/types.ts` remove `AgentConfig.extensions`.
167
- - `src/config/default-agents.ts` remove `extensions: true` from all three agents.
168
- - `src/config/agent-types.ts` remove `extensions: true` from the absolute-fallback literal.
169
- - `src/config/custom-agents.ts` remove the `extensions:` frontmatter parse and delete `resolveBoolExtensions`.
170
- - `src/session/session-config.ts` remove `SessionConfig.extensions` and stop assigning it.
171
- - `src/lifecycle/agent-runner.ts` remove `ResourceLoaderOptions.noExtensions`, drop `noExtensions` from the `createResourceLoader` call, and make the recursion guard unconditional (delete `if (cfg.extensions)`); update the explanatory comment.
172
- - `src/ui/agent-config-editor.ts` remove the `extensions: false` line from `buildEjectContent`.
173
- - `src/ui/agent-creation-wizard.ts` remove the `extensions:` template line.
174
-
175
- ### Source `skills` axis + preload path
176
-
177
- - `src/types.ts` remove `AgentConfig.skills`.
178
- - `src/config/default-agents.ts` remove `skills: true` from all three agents.
179
- - `src/config/agent-types.ts` remove `skills: true` from the absolute-fallback literal.
180
- - `src/config/custom-agents.ts` remove the `skills:` frontmatter parse and delete `inheritField` (its only remaining callers are `skills`/`extensions`; `csvList`, `parseCsvField`, `str`, `nonNegativeInt` stay `csvList` still serves `tools:`).
181
- - `src/session/session-config.ts` remove `AssemblerIO.preloadSkills`, `SessionConfig.noSkills`, `SessionConfig.extras`, the `extras`/`preloadSkills` block, and the `extras` argument to `buildAgentPrompt`.
182
- - `src/session/prompts.ts` remove `PromptExtras`, the `extras` parameter, and the `extrasSuffix` logic.
183
- - `src/session/skill-loader.ts` **delete** (export `preloadSkills`, `PreloadedSkill`).
184
- - `src/session/safe-fs.ts` **delete** (sole consumer was `skill-loader.ts`).
185
- - `src/lifecycle/agent-runner.ts` remove `ResourceLoaderOptions.noSkills` and drop `noSkills` from the `createResourceLoader` call.
186
- - `src/index.ts` remove the `preloadSkills` import and its `assemblerIO.preloadSkills` wiring.
187
- - `src/ui/agent-config-editor.ts` remove the `skills: false` / `skills: <list>` lines from `buildEjectContent`.
188
- - `src/ui/agent-creation-wizard.ts` remove the `skills:` template line.
146
+ ### Source - `isolated` axis
147
+
148
+ - `src/types.ts` - remove `AgentConfig.isolated`, `AgentInvocation.isolated`.
149
+ - `src/config/invocation-config.ts` - remove `isolated` from `AgentInvocationParams` and the return object.
150
+ - `src/config/custom-agents.ts` - remove the `isolated:` frontmatter parse.
151
+ - `src/session/session-config.ts` - remove `AssemblerOptions.isolated` and the `options.isolated ? false : ...` derivation (read `agentConfig.extensions`/`agentConfig.skills` directly, for now).
152
+ - `src/lifecycle/agent-runner.ts` - remove `RunOptions.isolated` and the `isolated:` argument passed to `assembleSessionConfig`.
153
+ - `src/lifecycle/agent.ts` - remove `AgentInit.isolated`, the `_isolated` field + constructor assignment, and `isolated:` in the `runner.run(...)` call.
154
+ - `src/lifecycle/agent-manager.ts` - remove `AgentSpawnConfig.isolated` and its pass-through to `new Agent(...)`.
155
+ - `src/tools/agent-tool.ts` - remove the `isolated` schema property.
156
+ - `src/tools/spawn-config.ts` - remove `SpawnExecution.isolated`, the `const isolated = resolvedConfig.isolated`, `isolated` in `agentInvocation`, and `isolated` in the `execution` return.
157
+ - `src/tools/foreground-runner.ts` / `src/tools/background-spawner.ts` - remove `isolated: execution.isolated`.
158
+ - `src/service/service.ts` - remove `SpawnOptions.isolated`.
159
+ - `src/service/service-adapter.ts` - remove `isolated: options?.isolated` from the `manager.spawn(...)` call.
160
+ - `src/ui/display.ts` - remove `if (invocation.isolated) tags.push("isolated")` and the `isolated` mention in the JSDoc example.
161
+ - `src/ui/agent-config-editor.ts` - remove the `isolated: true` line from `buildEjectContent`.
162
+ - `src/ui/agent-creation-wizard.ts` - remove the `isolated:` template line and the "Set isolated: true ..." guideline.
163
+
164
+ ### Source - `extensions` axis + unconditional guard
165
+
166
+ - `src/types.ts` - remove `AgentConfig.extensions`.
167
+ - `src/config/default-agents.ts` - remove `extensions: true` from all three agents.
168
+ - `src/config/agent-types.ts` - remove `extensions: true` from the absolute-fallback literal.
169
+ - `src/config/custom-agents.ts` - remove the `extensions:` frontmatter parse and delete `resolveBoolExtensions`.
170
+ - `src/session/session-config.ts` - remove `SessionConfig.extensions` and stop assigning it.
171
+ - `src/lifecycle/agent-runner.ts` - remove `ResourceLoaderOptions.noExtensions`, drop `noExtensions` from the `createResourceLoader` call, and make the recursion guard unconditional (delete `if (cfg.extensions)`); update the explanatory comment.
172
+ - `src/ui/agent-config-editor.ts` - remove the `extensions: false` line from `buildEjectContent`.
173
+ - `src/ui/agent-creation-wizard.ts` - remove the `extensions:` template line.
174
+
175
+ ### Source - `skills` axis + preload path
176
+
177
+ - `src/types.ts` - remove `AgentConfig.skills`.
178
+ - `src/config/default-agents.ts` - remove `skills: true` from all three agents.
179
+ - `src/config/agent-types.ts` - remove `skills: true` from the absolute-fallback literal.
180
+ - `src/config/custom-agents.ts` - remove the `skills:` frontmatter parse and delete `inheritField` (its only remaining callers are `skills`/`extensions`; `csvList`, `parseCsvField`, `str`, `nonNegativeInt` stay - `csvList` still serves `tools:`).
181
+ - `src/session/session-config.ts` - remove `AssemblerIO.preloadSkills`, `SessionConfig.noSkills`, `SessionConfig.extras`, the `extras`/`preloadSkills` block, and the `extras` argument to `buildAgentPrompt`.
182
+ - `src/session/prompts.ts` - remove `PromptExtras`, the `extras` parameter, and the `extrasSuffix` logic.
183
+ - `src/session/skill-loader.ts` - **delete** (export `preloadSkills`, `PreloadedSkill`).
184
+ - `src/session/safe-fs.ts` - **delete** (sole consumer was `skill-loader.ts`).
185
+ - `src/lifecycle/agent-runner.ts` - remove `ResourceLoaderOptions.noSkills` and drop `noSkills` from the `createResourceLoader` call.
186
+ - `src/index.ts` - remove the `preloadSkills` import and its `assemblerIO.preloadSkills` wiring.
187
+ - `src/ui/agent-config-editor.ts` - remove the `skills: false` / `skills: <list>` lines from `buildEjectContent`.
188
+ - `src/ui/agent-creation-wizard.ts` - remove the `skills:` template line.
189
189
 
190
190
  ### Tests
191
191
 
192
- - `test/session/skill-loader.test.ts` **delete**.
193
- - `test/session/safe-fs.test.ts` **delete**.
194
- - `test/session/session-config.test.ts` remove the `isolated`-mode `describe`, the `noSkills` assertions, and the preload tests; keep model-resolution and prompt-assembly assertions.
195
- - `test/session/prompts.test.ts` remove `isolated`/`extensions`/`skills` from `AgentConfig` fixtures and any `skillBlocks`/`extras` cases.
196
- - `test/config/invocation-config.test.ts` remove `isolated` cases and fixture fields.
197
- - `test/config/custom-agents.test.ts` remove `extensions` / `skills` / `isolated` frontmatter-parsing tests.
198
- - `test/config/agent-types.test.ts` remove `extensions` / `skills` / `isolated` from fixtures.
199
- - `test/lifecycle/agent-runner-extension-tools.test.ts` remove `extensions`/`skills`/`isolated` from the mock config; delete the "extensions: false skips the filter entirely" test; keep/adjust the post-bind guard tests to assert the guard runs unconditionally.
200
- - `test/tools/spawn-config.test.ts` remove the "sets isolated from params" test and `isolated` fixture fields.
201
- - `test/tools/background-spawner.test.ts` / `test/tools/foreground-runner.test.ts` remove `isolated` from fixtures and `agentInvocation` assertions.
202
- - `test/tools/result-renderer.test.ts` remove the `"isolated"` tag case.
203
- - `test/ui/agent-config-editor.test.ts` remove the `isolated` / `extensions: false` eject-emission tests.
204
- - `test/display.test.ts` remove `extensions`/`skills` from `AgentConfig` fixtures.
205
- - `test/helpers/runner-io.ts` remove `extensions`/`skills`/`isolated` from `DEFAULT_AGENT_CONFIG`.
206
- - `test/helpers/runner-io.test.ts` remove the `config.extensions`/`config.skills` assertions and the `extensions: true` override case.
207
- - `test/helpers/ui-stubs.ts` remove `extensions: true` / `skills: true` from the stub `AgentConfig`.
192
+ - `test/session/skill-loader.test.ts` - **delete**.
193
+ - `test/session/safe-fs.test.ts` - **delete**.
194
+ - `test/session/session-config.test.ts` - remove the `isolated`-mode `describe`, the `noSkills` assertions, and the preload tests; keep model-resolution and prompt-assembly assertions.
195
+ - `test/session/prompts.test.ts` - remove `isolated`/`extensions`/`skills` from `AgentConfig` fixtures and any `skillBlocks`/`extras` cases.
196
+ - `test/config/invocation-config.test.ts` - remove `isolated` cases and fixture fields.
197
+ - `test/config/custom-agents.test.ts` - remove `extensions` / `skills` / `isolated` frontmatter-parsing tests.
198
+ - `test/config/agent-types.test.ts` - remove `extensions` / `skills` / `isolated` from fixtures.
199
+ - `test/lifecycle/agent-runner-extension-tools.test.ts` - remove `extensions`/`skills`/`isolated` from the mock config; delete the "extensions: false skips the filter entirely" test; keep/adjust the post-bind guard tests to assert the guard runs unconditionally.
200
+ - `test/tools/spawn-config.test.ts` - remove the "sets isolated from params" test and `isolated` fixture fields.
201
+ - `test/tools/background-spawner.test.ts` / `test/tools/foreground-runner.test.ts` - remove `isolated` from fixtures and `agentInvocation` assertions.
202
+ - `test/tools/result-renderer.test.ts` - remove the `"isolated"` tag case.
203
+ - `test/ui/agent-config-editor.test.ts` - remove the `isolated` / `extensions: false` eject-emission tests.
204
+ - `test/display.test.ts` - remove `extensions`/`skills` from `AgentConfig` fixtures.
205
+ - `test/helpers/runner-io.ts` - remove `extensions`/`skills`/`isolated` from `DEFAULT_AGENT_CONFIG`.
206
+ - `test/helpers/runner-io.test.ts` - remove the `config.extensions`/`config.skills` assertions and the `extensions: true` override case.
207
+ - `test/helpers/ui-stubs.ts` - remove `extensions: true` / `skills: true` from the stub `AgentConfig`.
208
208
 
209
209
  ### Docs
210
210
 
211
- - `docs/architecture/architecture.md`
211
+ - `docs/architecture/architecture.md` -
212
212
  remove the `SafeFs` and `SkillLoader` nodes from the session-domain Mermaid subgraph;
213
213
  remove `safe-fs.ts` and `skill-loader.ts` from the directory-tree listing;
214
214
  drop `isolated` from the `SpawnOptions` field list (≈ line 418) and the `RunOptions` field list (≈ line 651);
215
215
  mark Phase 16 Step 4 (#264) done in the roadmap and update the "Children always load the parent's extensions and skills" note;
216
216
  reflect the smaller session domain (8 → 6 modules).
217
- - `.pi/skills/package-pi-subagents/SKILL.md` update the Session domain row (module count 8 → 6, drop `safe-fs.ts` / `skill-loader.ts` from the file list).
217
+ - `.pi/skills/package-pi-subagents/SKILL.md` - update the Session domain row (module count 8 → 6, drop `safe-fs.ts` / `skill-loader.ts` from the file list).
218
218
 
219
219
  ## Test Impact Analysis
220
220
 
221
- 1. New coverage enabled minimal (this is a removal).
221
+ 1. New coverage enabled - minimal (this is a removal).
222
222
  The one behavioral assertion worth strengthening: the post-bind recursion guard now runs **unconditionally**.
223
223
  Update `agent-runner-extension-tools.test.ts` so a case that previously relied on `extensions: true` instead asserts the guard always calls `setActiveToolsByName` and always excludes `EXCLUDED_TOOL_NAMES`, with no config dependence.
224
- 2. Tests that become redundant and are removed
224
+ 2. Tests that become redundant and are removed -
225
225
  `skill-loader.test.ts` and `safe-fs.test.ts` (modules deleted);
226
226
  the `isolated`-mode `describe` in `session-config.test.ts`;
227
227
  the "extensions: false skips the filter entirely" case;
228
228
  `isolated` parameter tests in `spawn-config.test.ts` / `invocation-config.test.ts`;
229
229
  `extensions` / `skills` frontmatter-parsing tests in `custom-agents.test.ts`.
230
- 3. Tests that must stay (genuinely exercise surviving layers)
230
+ 3. Tests that must stay (genuinely exercise surviving layers) -
231
231
  prompt assembly (`prompts.test.ts`, minus `extras`);
232
232
  model resolution in `session-config.test.ts`;
233
233
  the post-bind guard ordering tests (adjusted, not removed);
@@ -260,7 +260,7 @@ The three axes are split so each commit stays reviewable and leaves the repo com
260
260
  - Risk: deleting `safe-fs.ts` orphans an import.
261
261
  Mitigation: grep confirms `skill-loader.ts` is its sole consumer; `safe-fs.test.ts` is deleted in the same cycle.
262
262
  - Risk: removing `SpawnOptions.isolated` breaks a published consumer of the service.
263
- Mitigation: this is an intentional breaking change (ADR 0002); `feat!:` triggers a major bump via release-please.
263
+ Mitigation: this is an intentional breaking change ([ADR-0002]); `feat!:` triggers a major bump via release-please.
264
264
  The public type surface is verified by `pnpm run verify:public-types` after Step 3.
265
265
  - Risk: skill behavior silently changes for agents that relied on `skills: string[]` curation.
266
266
  Mitigation: documented in Goals as breaking; children now inherit the full skill system, which is strictly more capable, and deny-at-use governs what they may act on.
@@ -272,4 +272,6 @@ The three axes are split so each commit stays reviewable and leaves the repo com
272
272
  - Should custom-agent `.md` files with now-defunct `extensions:` / `skills:` / `isolated:` frontmatter emit a one-time deprecation warning, or be silently ignored?
273
273
  Deferred: silent-ignore matches the Phase 14 precedent for the removed `disallowed_tools` field; revisit only if users report confusion.
274
274
  - Does `verify:public-types` need a new negative assertion that `isolated` is absent from `SpawnOptions`?
275
- Deferred to Step 3 implementation the existing consumer type-check will fail if a stale field lingers.
275
+ Deferred to Step 3 implementation - the existing consumer type-check will fail if a stale field lingers.
276
+
277
+ [ADR-0002]: ../decisions/0002-extensions-on-a-minimal-core.md
@@ -7,7 +7,7 @@ issue_title: "Born-complete child execution; dissolve the runner"
7
7
 
8
8
  ## Problem Statement
9
9
 
10
- Phase 16, Step 5 of ADR 0002.
10
+ Phase 16, Step 5 of [ADR-0002].
11
11
  Today a subagent run is assembled by a monolithic `runAgent()` (the "runner") in `src/lifecycle/agent-runner.ts`: it creates the child session, binds extensions, drives the turn loop, collects the result, and emits the child-execution lifecycle events.
12
12
  `Agent` then sequences workspace teardown and status transitions around it through an injected `AgentRunner` interface.
13
13
  With the cwd now resolved through the `WorkspaceProvider` seam (Step 2) and worktrees evicted to a sibling package (Step 3), there is nothing left for a separate runner layer to assemble.
@@ -72,7 +72,7 @@ The workspace therefore stays a separate `Agent`-sequenced resource (prepare at
72
72
 
73
73
  AGENTS.md constraints that apply:
74
74
 
75
- - Ship-source package with a public type bundle (ADR 0003): none of the dissolved types (`RunOptions`, `RunResult`, `AgentRunner`) are part of `service.ts`, so `public.d.ts` is unaffected.
75
+ - Ship-source package with a public type bundle ([ADR-0003]): none of the dissolved types (`RunOptions`, `RunResult`, `AgentRunner`) are part of `service.ts`, so `public.d.ts` is unaffected.
76
76
  Run `pnpm run verify:public-types` is **not** required (no public-surface change), but `pnpm run check` is.
77
77
  - fallow dead-code: new exports (`SubagentSession`, `createSubagentSession`) must have a production consumer by the end of the work; transient intermediate commits where they are consumed only by tests are acceptable because fallow runs at pre-completion, against the final state.
78
78
  - `#src/` path-alias imports only; ES2024 target.
@@ -328,3 +328,6 @@ Each step compiles and the suite passes; run `pnpm run check` after every step t
328
328
  This needs `WorkspaceProvider` support for resume and is out of scope; capture as a follow-up if it becomes a real need.
329
329
  - Whether `completed` should also fire on resume (it does not today).
330
330
  Deferred — preserve current behavior; revisit only with a concrete consumer.
331
+
332
+ [ADR-0002]: ../decisions/0002-extensions-on-a-minimal-core.md
333
+ [ADR-0003]: ../decisions/0003-publish-bundled-type-declarations.md
@@ -57,7 +57,7 @@ Relevant modules and facts:
57
57
  Constraints from `AGENTS.md` and the package skill:
58
58
 
59
59
  - Ship-source model: every package ships raw `.ts` executed directly by Pi; there is no build step today.
60
- ADR 0002 frames pi-subagents as a minimal core.
60
+ [ADR-0002] frames pi-subagents as a minimal core.
61
61
  Introducing the repo's **first build step** is a deliberate decision and warrants an ADR.
62
62
  - `eslint`'s `no-parent-relative-imports` rule forbids `../` imports inside `packages/*/src`; same-directory `./` is allowed.
63
63
  This (plus the deep type entanglement above) is why the alias-free-entry alternative was rejected.
@@ -200,3 +200,5 @@ This is a tooling/config change with a verification harness (not red→green→r
200
200
  - Whether to add a fast vitest self-containment assertion in addition to the shell harness, or keep the guard inside the script only — defer to the build stage.
201
201
  - Whether the ADR should add a short "build process" subsection to `docs/architecture/architecture.md` — defer; the ADR is sufficient.
202
202
  - Exact `files` allowlist entries — finalize against `pnpm pack --dry-run` in Step 2.
203
+
204
+ [ADR-0002]: ../decisions/0002-extensions-on-a-minimal-core.md
@@ -0,0 +1,197 @@
1
+ ---
2
+ issue: 280
3
+ issue_title: "Rename the internal Agent class to Subagent"
4
+ ---
5
+
6
+ # Rename the internal `Agent` class to `Subagent`
7
+
8
+ ## Problem Statement
9
+
10
+ The internal lifecycle class `Agent` (`src/lifecycle/agent.ts`) models a single spawned subagent, but the bare name `Agent` collides with two unrelated concepts in the same code: the parent Pi agent that invokes our tooling, and the SDK's `AgentSession` that each subagent wraps.
11
+ The public API already standardized on the `Subagent*` family (`SubagentsService`, `SubagentRecord`, `SubagentStatus`, `SubagentType`, and — after [#265] — `SubagentSession` / `createSubagentSession`).
12
+ The internal lifecycle layer is the lone holdout still using bare `Agent*`.
13
+ Renaming the subagent-instance cluster closes that inconsistency and removes the parent/child/SDK ambiguity.
14
+
15
+ ## Goals
16
+
17
+ - Rename the subagent-instance cluster in `src/lifecycle/` to the `Subagent*` family: `Agent` → `Subagent`, `AgentManager` → `SubagentManager`, `AgentInit` → `SubagentInit`, `AgentLifecycleObserver` → `SubagentLifecycleObserver`, `AgentManagerObserver` → `SubagentManagerObserver`, `AgentManagerOptions` → `SubagentManagerOptions`, `AgentObserverOptions` → `SubagentObserverOptions`, `AgentManagerLike` → `SubagentManagerLike`.
18
+ - Consolidate the duplicate `AgentStatus` union into the existing public `SubagentStatus`, deleting the duplicate and re-pointing `WorkspaceDisposeOutcome.status`.
19
+ - Rename the lifecycle module files to match their primary export: `agent.ts` → `subagent.ts`, `agent-manager.ts` → `subagent-manager.ts`, plus the matching test files and the `make-agent.ts` test helper.
20
+ - Extend the rename to adjacent identifiers in the same cluster for full consistency: the `subscribeAgentObserver` function → `subscribeSubagentObserver`, the `SubagentManagerObserver` methods `onAgent*` → `onSubagent*`, and the `createTestAgent` helper → `createTestSubagent`.
21
+ - Update residual bare `Agent` / `AgentManager` references in lifecycle comments, JSDoc, and error strings — the acceptance grep matches these, not just symbols.
22
+ - Update `docs/architecture/architecture.md` to the new names.
23
+ - This is internal-only and non-breaking — the exported surface is unchanged apart from `WorkspaceDisposeOutcome.status` reading `SubagentStatus` (an identical union), so commits use `refactor:`, never `feat!:`.
24
+
25
+ ## Non-Goals
26
+
27
+ - The agent-type/config axis stays untouched: `AgentConfig`, `AgentType`, `AgentTypeRegistry`, `AgentConfigLookup`, `AgentInvocation`, `AgentPromptConfig`, `AgentCategories`.
28
+ - The UI/tool surface stays untouched: `AgentTool` (+ `AgentTool*` variants), `AgentSpawnConfig`, `AgentWidget`, `AgentsMenuHandler`, `AgentActivityTracker`, `AgentDetails`, `AgentCreationWizard`, `AgentConfigEditor`, `AgentFileOps`.
29
+ - SDK types stay untouched: `AgentSession`, `AgentSessionEvent`.
30
+ - Internal field/method names that do not contain the bare `Agent` word — `listAgents`, `getRecord`, the `agents` map, and `record:` parameters — are left as-is; they are not bare-`Agent` symbols and the acceptance grep does not flag them.
31
+ - No behavior changes: this is a pure rename plus a structurally no-op type consolidation.
32
+
33
+ ## Background
34
+
35
+ Relevant modules (Lifecycle domain unless noted):
36
+
37
+ - `src/lifecycle/agent.ts` — defines `Agent`, `AgentInit`, `AgentLifecycleObserver`, and the duplicate `AgentStatus` union; owns the full execution lifecycle (`run`, `resume`, `abort`, `steer`, status transitions, workspace disposal).
38
+ Contains bare-`Agent` JSDoc and two error strings (`"Agent not configured for execution …"`, `"Agent not configured for resume …"`).
39
+ - `src/lifecycle/agent-manager.ts` — defines `AgentManager`, `AgentManagerObserver` (methods `onAgentStarted` / `onAgentCompleted` / `onAgentCompacted` / `onAgentCreated`), `AgentManagerOptions`, and `AgentSpawnConfig` (out of scope).
40
+ - `src/lifecycle/workspace.ts` — `WorkspaceDisposeOutcome.status` is typed as the internal `AgentStatus`, imported from `#src/lifecycle/agent`.
41
+ - `src/observation/record-observer.ts` — defines `AgentObserverOptions` and the `subscribeAgentObserver` function.
42
+ - `src/service/service.ts` — defines the public `SubagentStatus` union (verbatim duplicate of `AgentStatus`) and re-exports `LifetimeUsage`, `Workspace`, and the four workspace collaborator types from the lifecycle layer.
43
+ - `src/service/service-adapter.ts` — defines the `AgentManagerLike` test seam.
44
+ - `src/types.ts` — barrel that re-exports `Agent` from `#src/lifecycle/agent`; most consumers import `Agent` via this barrel.
45
+ - `test/helpers/make-agent.ts` — exports `createTestAgent`, imported by ~16 test files.
46
+
47
+ Blast radius is mechanical but wide (~360 occurrences, dominated by the `Agent` class via the `types.ts` barrel).
48
+ `typescript` + `tsserver` are available, so each rename is a scope-aware language-service pass verified by `pnpm run check`; the occurrence count does not drive scope.
49
+
50
+ Constraints from AGENTS.md and skills that apply:
51
+
52
+ - Within a package, import siblings via `#src/` / `#test/` aliases (eslint enforces this) — the file moves must preserve alias imports, not introduce relative paths.
53
+ - After a barrel rename, verify at least one consumer still imports the renamed symbol from the barrel — many consumers import `Subagent` from `#src/types`, so this holds.
54
+ - The public `dist/public.d.ts` bundle is rolled from `src/service/service.ts`; run `pnpm run verify:public-types` after touching the public surface or the status consolidation.
55
+ - Load the `mermaid` skill before editing the architecture doc's class/sequence diagrams.
56
+
57
+ ## Design Overview
58
+
59
+ ### Status consolidation and the layering constraint
60
+
61
+ `AgentStatus` (in `agent.ts`) and `SubagentStatus` (in `service.ts`) are identical seven-member unions (`queued | running | completed | steered | aborted | stopped | error`).
62
+ The issue asks `WorkspaceDisposeOutcome.status` to point at the public `SubagentStatus`.
63
+
64
+ A naive fix — importing `SubagentStatus` from `service.ts` into `workspace.ts` — would create a circular dependency: `service.ts` already imports the workspace collaborator types (`WorkspaceDisposeOutcome`, …) from `workspace.ts`, so `workspace.ts → service.ts` reverses an existing arrow.
65
+ The correct single home is the lifecycle layer, mirroring how `service.ts` already re-exports `LifetimeUsage` from `#src/lifecycle/usage` and the workspace types from `#src/lifecycle/workspace`:
66
+
67
+ - Keep the union defined in the lifecycle layer (in the renamed `subagent.ts`), renamed `AgentStatus` → `SubagentStatus`.
68
+ - `service.ts` deletes its local definition and adds `export type { SubagentStatus } from "#src/lifecycle/subagent";` alongside its existing re-exports.
69
+ - `workspace.ts` imports `SubagentStatus` from `#src/lifecycle/subagent` (it already imports `AgentStatus` from the same module today — only the symbol name and, after the file move, the path change).
70
+
71
+ The `subagent ↔ workspace` relationship is type-only and already exists (`subagent.ts` imports `Workspace` / `WorkspaceProvider` from `workspace.ts`; `workspace.ts` imports the status union from `subagent.ts`), so no new runtime cycle is introduced — type-only imports are erased.
72
+
73
+ `rollup-plugin-dts` inlines `#src/*` types, so `dist/public.d.ts` still emits the same `SubagentStatus` union literal — structurally a no-op for consumers, confirmed by `verify:public-types`.
74
+
75
+ ```typescript
76
+ // src/lifecycle/subagent.ts (renamed from agent.ts)
77
+ export type SubagentStatus =
78
+ | "queued" | "running" | "completed" | "steered"
79
+ | "aborted" | "stopped" | "error";
80
+
81
+ // src/service/service.ts — delete local def, re-export instead
82
+ export type { SubagentStatus } from "#src/lifecycle/subagent";
83
+
84
+ // src/lifecycle/workspace.ts
85
+ import type { SubagentStatus } from "#src/lifecycle/subagent";
86
+ export interface WorkspaceDisposeOutcome {
87
+ status: SubagentStatus;
88
+ description: string;
89
+ }
90
+ ```
91
+
92
+ ### Rename mechanics
93
+
94
+ Each symbol rename is an atomic, scope-aware language-service operation (the API behind LSP "Rename Symbol"); after each, `pnpm run check` verifies the tree compiles.
95
+ Because a rename updates every reference in one pass and leaves the build green, each logical rename is its own commit with the repository in a valid state — no lift-and-shift staging is required (a rename is not a type replacement; old and new names never coexist).
96
+
97
+ Symbol renames do not touch comments, JSDoc, or string literals.
98
+ There are 26 bare `Agent` and 4 bare `AgentManager` word-occurrences in `src/lifecycle/` comments/strings (e.g. the two `"Agent not configured …"` error messages and cross-file JSDoc in `turn-limits.ts`, `create-subagent-session.ts`, `subagent-session.ts`).
99
+ The acceptance criterion greps `src/lifecycle/` for bare `Agent` / `AgentManager`, so each rename step must also sweep residual comment/string occurrences.
100
+ Compound names (`AgentSession`, `AgentInvocation`, `AgentTypeRegistry`) are not bare-word matches and stay.
101
+
102
+ ### Full-consistency adjacent identifiers
103
+
104
+ Per the scope decision, the rename extends to the rest of the cluster's naming so no `Agent`-as-subagent identifier survives:
105
+
106
+ - `src/observation/record-observer.ts`: `subscribeAgentObserver` → `subscribeSubagentObserver`, `AgentObserverOptions` → `SubagentObserverOptions`.
107
+ - `src/lifecycle/subagent-manager.ts`: `SubagentManagerObserver` methods `onAgentStarted` / `onAgentCompleted` / `onAgentCompacted` / `onAgentCreated` → `onSubagentStarted` / `onSubagentCompleted` / `onSubagentCompacted` / `onSubagentCreated` (8 + 11 + 6 + 14 call sites across `src/` and `test/`, all updated by the language-service rename).
108
+ - `test/helpers/make-agent.ts`: `createTestAgent` → `createTestSubagent`, file → `make-subagent.ts` (~16 importers, including `make-deps.ts` and `ui-stubs.ts`).
109
+
110
+ ## Module-Level Changes
111
+
112
+ Renamed files (git move, preserving `#src/` / `#test/` alias imports):
113
+
114
+ - `src/lifecycle/agent.ts` → `src/lifecycle/subagent.ts`
115
+ - `src/lifecycle/agent-manager.ts` → `src/lifecycle/subagent-manager.ts`
116
+ - `test/lifecycle/agent.test.ts` → `test/lifecycle/subagent.test.ts`
117
+ - `test/lifecycle/agent-manager.test.ts` → `test/lifecycle/subagent-manager.test.ts`
118
+ - `test/helpers/make-agent.ts` → `test/helpers/make-subagent.ts`
119
+ - `test/helpers/make-agent.test.ts` → `test/helpers/make-subagent.test.ts`
120
+
121
+ Changed (symbols, members, imports, comments/strings):
122
+
123
+ - `src/lifecycle/subagent.ts` — `Agent` → `Subagent`, `AgentInit` → `SubagentInit`, `AgentLifecycleObserver` → `SubagentLifecycleObserver`, `AgentStatus` → `SubagentStatus` (kept here as the single home); update JSDoc and the two error strings.
124
+ - `src/lifecycle/subagent-manager.ts` — `AgentManager` → `SubagentManager`, `AgentManagerObserver` → `SubagentManagerObserver` (+ `onAgent*` methods → `onSubagent*`), `AgentManagerOptions` → `SubagentManagerOptions`; `AgentSpawnConfig` unchanged; update header comment.
125
+ - `src/lifecycle/workspace.ts` — import `SubagentStatus` from `#src/lifecycle/subagent`; `WorkspaceDisposeOutcome.status` retyped.
126
+ - `src/service/service.ts` — delete local `SubagentStatus` definition; add `export type { SubagentStatus } from "#src/lifecycle/subagent";`.
127
+ - `src/service/service-adapter.ts` — `AgentManagerLike` → `SubagentManagerLike`; update header comment referencing `AgentManager`.
128
+ - `src/observation/record-observer.ts` — `subscribeAgentObserver` → `subscribeSubagentObserver`, `AgentObserverOptions` → `SubagentObserverOptions`; update header comment.
129
+ - `src/types.ts` — barrel re-export `export { Agent } from "#src/lifecycle/agent";` → `export { Subagent } from "#src/lifecycle/subagent";`.
130
+ - All consumers of the renamed symbols across `src/` and `test/` (tools, UI, runtime, `index.ts`, session, observation, and their tests) — updated transitively by each language-service rename.
131
+ Out-of-scope `Agent*` symbols in these files are untouched.
132
+ - `test/helpers/make-subagent.ts`, `make-deps.ts`, `ui-stubs.ts`, and ~16 test importers — `createTestAgent` → `createTestSubagent` and updated import paths.
133
+ - `docs/architecture/architecture.md` — file-listing entries (`agent.ts`, `agent-manager.ts`), class/sequence Mermaid diagrams, the type-complexity table row (`AgentInit` → `SubagentInit`, module `agent` → `subagent`), and current-state prose naming the renamed cluster.
134
+ Out-of-scope `Agent*` names (`AgentTool`, `AgentSession`, `AgentTypeRegistry`, …) and historical phase narrative stay as written.
135
+
136
+ No exports are removed from the public surface; the barrel rename swaps one name for another with many live consumers.
137
+ Also swept for the `package-pi-subagents` SKILL.md, which documents internals (`AgentManager`, `Agent`, `make-agent`): update its dependency-flow sketch and module table to the new names.
138
+
139
+ ## Test Impact Analysis
140
+
141
+ This is a pure rename plus a no-op type consolidation, so the extraction-style test questions resolve simply:
142
+
143
+ 1. New tests enabled: none — no new seams or behavior are introduced.
144
+ 2. Tests made redundant: none — no test is duplicated or subsumed.
145
+ 3. Tests that must stay as-is (renamed/retargeted only): all of them.
146
+ `test/lifecycle/subagent.test.ts`, `subagent-manager.test.ts`, `record-observer.test.ts`, `service-adapter.test.ts`, and every `createTestSubagent` consumer continue to exercise the same behavior under the new names.
147
+ The status consolidation leaves `WorkspaceDisposeOutcome` behavior identical, so workspace/service tests are unchanged beyond the symbol name.
148
+
149
+ ## TDD Order
150
+
151
+ This is a refactor with no red phase; each step is a green checkpoint verified by `pnpm run check` && `pnpm -r run test` (and `verify:public-types` where the public surface is touched) before committing.
152
+ Steps are independent renames ordered smallest-blast-first where practical; any order keeps the tree green.
153
+
154
+ 1. Consolidate the status union.
155
+ In `agent.ts` rename `AgentStatus` → `SubagentStatus` and keep the definition there; delete the duplicate in `service.ts` and re-export from the lifecycle module; retype `workspace.ts`.
156
+ Run `pnpm run check`, tests, and `pnpm run verify:public-types` to confirm the bundle is unchanged.
157
+ Commit: `refactor: consolidate AgentStatus into public SubagentStatus (#280)`.
158
+ 2. Rename the `Agent` class cluster.
159
+ `Agent` → `Subagent`, `AgentInit` → `SubagentInit`, `AgentLifecycleObserver` → `SubagentLifecycleObserver`; git-move `agent.ts` → `subagent.ts` and `test/lifecycle/agent.test.ts` → `subagent.test.ts`; update the `types.ts` barrel re-export and the `workspace.ts` / `service.ts` import paths to `#src/lifecycle/subagent`; sweep residual bare-`Agent` JSDoc and the two error strings in `subagent.ts`.
160
+ Commit: `refactor: rename Agent class to Subagent (#280)`.
161
+ 3. Rename the manager cluster.
162
+ `AgentManager` → `SubagentManager`, `AgentManagerObserver` → `SubagentManagerObserver` (+ `onAgent*` methods → `onSubagent*`), `AgentManagerOptions` → `SubagentManagerOptions`; git-move `agent-manager.ts` → `subagent-manager.ts` and its test file; sweep residual bare-`AgentManager` comments.
163
+ `AgentSpawnConfig` left untouched.
164
+ Commit: `refactor: rename AgentManager cluster to SubagentManager (#280)`.
165
+ 4. Rename the observation seam.
166
+ `subscribeAgentObserver` → `subscribeSubagentObserver`, `AgentObserverOptions` → `SubagentObserverOptions` in `record-observer.ts`; update its test and header comment.
167
+ Commit: `refactor: rename subscribeAgentObserver to subscribeSubagentObserver (#280)`.
168
+ 5. Rename the adapter seam.
169
+ `AgentManagerLike` → `SubagentManagerLike` in `service-adapter.ts`; update its test and header comment.
170
+ Commit: `refactor: rename AgentManagerLike to SubagentManagerLike (#280)`.
171
+ 6. Rename the test helper.
172
+ `createTestAgent` → `createTestSubagent`; git-move `make-agent.ts` → `make-subagent.ts` and `make-agent.test.ts` → `make-subagent.test.ts`; update all importers and `#test/helpers/make-agent` paths.
173
+ Commit: `test: rename createTestAgent to createTestSubagent (#280)`.
174
+ 7. Update docs.
175
+ Architecture doc current-state references (file listing, Mermaid diagrams, complexity table, prose) and the `package-pi-subagents` SKILL.md internals; load the `mermaid` skill before editing diagrams.
176
+ Final verification: `pnpm run check`, `pnpm run lint`, `pnpm -r run test`, `pnpm fallow dead-code`, `pnpm run verify:public-types`, and `grep -rnE '\bAgent(Manager|Init)?\b' src/lifecycle/` returns no bare in-scope matches.
177
+ Commit: `docs: update architecture and skill docs for Subagent rename (#280)`.
178
+
179
+ ## Risks and Mitigations
180
+
181
+ - Risk: a symbol rename misses string literals or comments, leaving bare `Agent` that the acceptance grep flags.
182
+ Mitigation: each rename step explicitly sweeps comments/strings; the final grep gate in step 7 is the backstop.
183
+ - Risk: pointing `workspace.ts` at the public `SubagentStatus` introduces a `lifecycle → service` cycle.
184
+ Mitigation: keep the union's home in the lifecycle layer (`subagent.ts`) and re-export from `service.ts`, mirroring the existing `LifetimeUsage` / workspace re-export pattern — no new arrow.
185
+ - Risk: the public type bundle changes shape.
186
+ Mitigation: `verify:public-types` after step 1 and step 7; the union is identical, so the bundle differs only in provenance, not content.
187
+ - Risk: a file move accidentally rewrites `#src/` alias imports to relative paths.
188
+ Mitigation: use `git mv` and rely on the language service for import updates; eslint's no-relative-sibling rule catches regressions during `pnpm run lint`.
189
+ - Risk: over-reach into out-of-scope `Agent*` names.
190
+ Mitigation: the rename is symbol-scoped (not text find-replace); the Non-Goals list enumerates the protected names, and the acceptance grep targets only bare `Agent` / `AgentManager` / `AgentInit` / `Agent*Observer`.
191
+
192
+ ## Open Questions
193
+
194
+ - Whether to later lowercase incidental prose uses of "Agent" (meaning subagent) in the architecture doc's event tables and history sections — deferred; this plan updates symbol/file names and current-state references, leaving historical narrative as written.
195
+ - Whether `listAgents` / `getRecord` / the `agents` map deserve a follow-up naming pass — deferred; they are not bare-`Agent` symbols and fall outside the approved scope.
196
+
197
+ [#265]: https://github.com/gotgenes/pi-packages/issues/265
@@ -3,13 +3,13 @@ issue: 51
3
3
  issue_title: "docs: update ADR 0001 to reflect hard-fork decision"
4
4
  ---
5
5
 
6
- # Retro: #51 — docs: update ADR 0001 to reflect hard-fork decision
6
+ # Retro: #51 — docs: update ADR-0001 to reflect hard-fork decision
7
7
 
8
8
  ## Final Retrospective (2026-05-16)
9
9
 
10
10
  ### Session summary
11
11
 
12
- Updated ADR 0001 (`docs/decisions/0001-deferred-patches.md`) to reflect the hard-fork decision documented in `docs/architecture/architecture.md`.
12
+ Updated [ADR-0001] to reflect the hard-fork decision documented in `docs/architecture/architecture.md`.
13
13
  The change was planned, implemented, shipped, and released as `pi-subagents-v1.0.2` in a single clean pass with no rework.
14
14
 
15
15
  ### Observations
@@ -35,3 +35,5 @@ The change was planned, implemented, shipped, and released as `pi-subagents-v1.0
35
35
  - The `package-pi-subagents` skill (`.pi/skills/package-pi-subagents/SKILL.md`) still frames the fork as "a friendly fork… carrying a small number of patches" with priorities like "stays as close to upstream as possible."
36
36
  This framing is now stale given the hard-fork commitment.
37
37
  A separate issue should update the skill to reflect the architecture document's posture.
38
+
39
+ [ADR-0001]: ../decisions/0001-deferred-patches.md
@@ -5,7 +5,7 @@ issue_title: "Extract ChildSessionFactory from runner"
5
5
 
6
6
  # Retro: #257 — Extract ChildSessionFactory from runner
7
7
 
8
- > Superseded — #257 closed `not_planned`; the work was reframed as Phase 16 "invert dependencies" (ADR 0002, issues #261–#265).
8
+ > Superseded — #257 closed `not_planned`; the work was reframed as Phase 16 "invert dependencies" ([ADR-0002], issues #261–#265).
9
9
 
10
10
  ## Stage: Planning (2026-05-29T00:32:12Z)
11
11
 
@@ -29,3 +29,5 @@ The plan is a lift-and-shift: `runAgent()` keeps its `(snapshot, type, prompt, o
29
29
  - `RunResult.sessionFile` shifts from a late `sessionManager.getSessionFile()` to the factory's `outputFile` — same value (stable after `newSession()`); the existing `/sessions/child.jsonl` assertion is the guard.
30
30
  - Did not invoke `ask_user`: the issue's "Proposed change" is prescriptive, and the two deviations are forced/justified rather than open-ended.
31
31
  - IO interfaces (`RunnerIO`, `RunnerDeps`, etc.) intentionally stay in `agent-runner.ts` for this step to minimize churn; their relocation to the factory module is flagged as an Open Question for Step 4 when the runner dissolves.
32
+
33
+ [ADR-0002]: ../decisions/0002-extensions-on-a-minimal-core.md
@@ -9,7 +9,7 @@ issue_title: "Add WorkspaceProvider extension seam"
9
9
 
10
10
  ### Session summary
11
11
 
12
- Produced a numbered implementation plan for the Phase 16, Step 2 `WorkspaceProvider` seam (ADR 0002).
12
+ Produced a numbered implementation plan for the Phase 16, Step 2 `WorkspaceProvider` seam ([ADR-0002]).
13
13
  The plan adds the seam additively — `WorkspaceProvider` / `Workspace` interfaces, `SubagentsService.registerWorkspaceProvider`, run-start consultation, and `dispose` with a verbatim `resultAddendum` — while leaving the existing `isolation: "worktree"` path untouched for #263 to evict.
14
14
  Three TDD steps (two `feat`, one `docs`).
15
15
 
@@ -85,3 +85,5 @@ Across all stages the plan's risk predictions held and TDD verification was incr
85
85
 
86
86
  1. `AGENTS.md` (Pre-completion reviewer subsection) — added a one-line guardrail: agent `model:` frontmatter must use the `provider/id` alias form the Pi CLI/UI accepts, because an ID absent from the model registry silently falls back to the parent session model.
87
87
  2. `packages/pi-subagents/docs/retro/0262-add-workspace-provider-seam.md` — this Final Retrospective stage entry.
88
+
89
+ [ADR-0002]: ../decisions/0002-extensions-on-a-minimal-core.md