@bastani/atomic 0.9.16-alpha.1 → 0.9.16-alpha.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 (88) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/builtin/intercom/package.json +1 -1
  3. package/dist/builtin/mcp/package.json +1 -1
  4. package/dist/builtin/subagents/CHANGELOG.md +13 -0
  5. package/dist/builtin/subagents/README.md +17 -105
  6. package/dist/builtin/subagents/package.json +1 -5
  7. package/dist/builtin/subagents/skills/subagent/SKILL.md +18 -88
  8. package/dist/builtin/subagents/src/extension/tool-description.ts +1 -3
  9. package/dist/builtin/subagents/src/intercom/intercom-bridge.ts +0 -53
  10. package/dist/builtin/subagents/src/runs/foreground/subagent-executor.ts +3 -40
  11. package/dist/builtin/subagents/src/shared/types-runtime.ts +1 -1
  12. package/dist/builtin/subagents/src/slash/slash-commands.ts +4 -468
  13. package/dist/builtin/web-access/package.json +1 -1
  14. package/dist/builtin/workflows/CHANGELOG.md +6 -0
  15. package/dist/builtin/workflows/package.json +1 -1
  16. package/dist/builtin/workflows/skills/bro/LICENSE.txt +21 -0
  17. package/dist/builtin/workflows/skills/bro/SKILL.md +14 -0
  18. package/dist/builtin/workflows/skills/how/LICENSE.txt +21 -0
  19. package/dist/builtin/workflows/skills/how/SKILL.md +162 -0
  20. package/dist/builtin/workflows/skills/how/references/critic-prompt.md +59 -0
  21. package/dist/builtin/workflows/skills/how/references/critique-rubric.md +58 -0
  22. package/dist/builtin/workflows/skills/how/references/explainer-prompt.md +55 -0
  23. package/dist/builtin/workflows/skills/how/references/explorer-prompt.md +52 -0
  24. package/dist/builtin/workflows/skills/teach/LICENSE.txt +21 -0
  25. package/dist/builtin/workflows/skills/teach/SKILL.md +28 -0
  26. package/dist/builtin/workflows/skills/unslop/LICENSE.txt +21 -0
  27. package/dist/builtin/workflows/skills/unslop/SKILL.md +87 -0
  28. package/dist/builtin/workflows/skills/why/LICENSE.txt +21 -0
  29. package/dist/builtin/workflows/skills/why/SKILL.md +267 -0
  30. package/dist/builtin/workflows/skills/why/references/epistemics.md +144 -0
  31. package/dist/builtin/workflows/skills/why/references/investigator-prompt.md +103 -0
  32. package/dist/builtin/workflows/skills/why/references/source-playbook.md +17 -0
  33. package/dist/builtin/workflows/skills/why/references/sources/code-archaeology.md +88 -0
  34. package/dist/builtin/workflows/skills/why/references/sources/databricks.md +70 -0
  35. package/dist/builtin/workflows/skills/why/references/sources/datadog.md +99 -0
  36. package/dist/builtin/workflows/skills/why/references/sources/incident-postmortem.md +15 -0
  37. package/dist/builtin/workflows/skills/why/references/sources/linear.md +48 -0
  38. package/dist/builtin/workflows/skills/why/references/sources/notion.md +55 -0
  39. package/dist/builtin/workflows/skills/why/references/sources/sentry.md +100 -0
  40. package/dist/builtin/workflows/skills/why/references/sources/slack.md +54 -0
  41. package/dist/builtin/workflows/skills/why/references/synthesizer-prompt.md +135 -0
  42. package/dist/builtin/workflows/src/extension/companions.ts +1 -1
  43. package/dist/builtin/workflows/src/extension/index.bundle.mjs +1 -1
  44. package/dist/core/agent-session-auto-compaction.js +10 -10
  45. package/dist/core/agent-session-auto-compaction.js.map +1 -1
  46. package/dist/core/agent-session-events.d.ts.map +1 -1
  47. package/dist/core/agent-session-events.js +11 -13
  48. package/dist/core/agent-session-events.js.map +1 -1
  49. package/dist/core/agent-session-methods.d.ts +1 -1
  50. package/dist/core/agent-session-methods.d.ts.map +1 -1
  51. package/dist/core/agent-session-methods.js.map +1 -1
  52. package/dist/core/agent-session-models.d.ts.map +1 -1
  53. package/dist/core/agent-session-models.js +5 -7
  54. package/dist/core/agent-session-models.js.map +1 -1
  55. package/dist/core/agent-session-prompt.js +4 -4
  56. package/dist/core/agent-session-prompt.js.map +1 -1
  57. package/dist/core/agent-session-retry.d.ts +4 -4
  58. package/dist/core/agent-session-retry.d.ts.map +1 -1
  59. package/dist/core/agent-session-retry.js +8 -34
  60. package/dist/core/agent-session-retry.js.map +1 -1
  61. package/dist/core/agent-session-tool-hooks.js +4 -4
  62. package/dist/core/agent-session-tool-hooks.js.map +1 -1
  63. package/dist/core/atomic-guide-command.d.ts.map +1 -1
  64. package/dist/core/atomic-guide-command.js +3 -10
  65. package/dist/core/atomic-guide-command.js.map +1 -1
  66. package/dist/core/slash-commands.d.ts.map +1 -1
  67. package/dist/core/slash-commands.js +0 -3
  68. package/dist/core/slash-commands.js.map +1 -1
  69. package/dist/core/system-prompt.d.ts.map +1 -1
  70. package/dist/core/system-prompt.js +0 -12
  71. package/dist/core/system-prompt.js.map +1 -1
  72. package/dist/modes/interactive-engine/remote-command-catalog.d.ts +1 -1
  73. package/dist/modes/interactive-engine/remote-command-catalog.js +1 -1
  74. package/dist/modes/interactive-engine/remote-command-catalog.js.map +1 -1
  75. package/docs/intercom.md +1 -1
  76. package/docs/settings.md +2 -2
  77. package/docs/subagents.md +6 -7
  78. package/docs/usage.md +0 -9
  79. package/npm-shrinkwrap.json +32 -32
  80. package/package.json +3 -3
  81. package/dist/builtin/subagents/prompts/gather-context-and-clarify.md +0 -27
  82. package/dist/builtin/subagents/prompts/parallel-cleanup.md +0 -61
  83. package/dist/builtin/subagents/prompts/parallel-context-build.md +0 -43
  84. package/dist/builtin/subagents/prompts/parallel-handoff-plan.md +0 -47
  85. package/dist/builtin/subagents/prompts/parallel-research.md +0 -34
  86. package/dist/builtin/subagents/prompts/parallel-review.md +0 -47
  87. package/dist/builtin/subagents/prompts/review-loop.md +0 -39
  88. package/dist/builtin/subagents/src/extension/doctor.ts +0 -188
package/CHANGELOG.md CHANGED
@@ -2,6 +2,18 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.9.16-alpha.2] - 2026-08-23
6
+
7
+ ### Changed
8
+
9
+ - Main-chat model fallback is now session-sticky: after failover, later turns keep using the selected fallback model and thinking level until an explicit `/model` selection or model cycle changes it.
10
+
11
+ ### Removed
12
+
13
+ - Removed the bundled writing-rule set from the default system prompt's `Guidelines` section. The unrelated "Be concise in your responses" and "Show file paths clearly when working with files" guidelines remain.
14
+ - Removed the bundled `/subagents-doctor`, `/run`, and `/parallel` entries from the slash-command catalog, and dropped `/parallel-review` and `/parallel-cleanup` suggestions from the `/atomic` guide. Launch children with the `subagent` tool.
15
+
16
+
5
17
  ## [0.9.16-alpha.1] - 2026-08-23
6
18
 
7
19
  ### Fixed
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bastani/intercom",
3
- "version": "0.9.16-alpha.1",
3
+ "version": "0.9.16-alpha.2",
4
4
  "private": true,
5
5
  "description": "Atomic extension providing a private coordination channel between parent and child agent sessions. Fork of: https://github.com/nicobailon/pi-intercom",
6
6
  "contributors": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bastani/mcp",
3
- "version": "0.9.16-alpha.1",
3
+ "version": "0.9.16-alpha.2",
4
4
  "private": true,
5
5
  "description": "Atomic extension that adapts MCP (Model Context Protocol) servers into the coding agent. Fork of: https://github.com/nicobailon/pi-mcp-adapter",
6
6
  "contributors": [
@@ -2,6 +2,19 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.9.16-alpha.2] - 2026-08-23
6
+
7
+ ### Breaking Changes
8
+
9
+ - Removed the `subagent({ action: "doctor" })` management action and the `/subagents-doctor` slash command. `doctor` is no longer a valid `action` value, and the observing management actions available to a child are now `list`, `get`, and `status`. Agent discovery still reports invalid-frontmatter files through its load diagnostics; use `intercom({ action: "status" })` to inspect intercom bridge state.
10
+ - Removed the `/run` and `/parallel` slash commands. Launch children with the `subagent` tool (`{ agent, task }` or `{ tasks: [...] }`).
11
+ - Removed `diagnoseIntercomBridge` and the `IntercomBridgeDiagnostic` type. Use `resolveIntercomBridge` when you need bridge availability.
12
+
13
+ ### Removed
14
+
15
+ - Removed every packaged subagent prompt template, including `/parallel-review`, `/parallel-handoff-plan`, `/gather-context-and-clarify`, `/review-loop`, `/parallel-research`, `/parallel-context-build`, and `/parallel-cleanup`. Compose those passes directly with `subagent(...)` or a workflow.
16
+
17
+
5
18
  ## [0.9.16-alpha.1] - 2026-08-23
6
19
 
7
20
  ### Breaking Changes
@@ -127,12 +127,13 @@ There is no generic `reviewer` or `planner` agent; pick the specialist whose ang
127
127
 
128
128
  Builtin agents inherit your current Pi default model by default. This keeps new installs from depending on a provider you may not have configured. If you want a role to use a specific model, set an override instead of copying the bundled agent file.
129
129
 
130
- For one run, put the override in the command:
130
+ For one run, pass `model` on the `subagent` call:
131
131
 
132
- ```text
133
- /run codebase-analyzer[model=anthropic/claude-sonnet-4:high] "Review this diff"
132
+ ```typescript
133
+ subagent({ agent: "codebase-analyzer", task: "Review this diff", model: "anthropic/claude-sonnet-4:high" })
134
134
  ```
135
135
 
136
+
136
137
  For a persistent override, edit settings. This example pins the codebase-analyzer everywhere, adds a backup model for provider failures, and keeps the other builtins on your normal default model:
137
138
 
138
139
  ```json
@@ -169,18 +170,6 @@ You can ask naturally:
169
170
  Show me the current subagent status.
170
171
  ```
171
172
 
172
- If something feels misconfigured, run:
173
-
174
- ```text
175
- /subagents-doctor
176
- ```
177
-
178
- or ask:
179
-
180
- ```text
181
- Check whether subagents and intercom are set up correctly.
182
- ```
183
-
184
173
  ## Recommended orchestration pattern (scaffolding)
185
174
 
186
175
  Use orchestration as parent-agent guidance, not as a runtime workflow mode. For implementation work, the recommended loop is:
@@ -189,27 +178,13 @@ Use orchestration as parent-agent guidance, not as a runtime workflow mode. For
189
178
  clarify → gather context → worker → fresh reviewers → worker
190
179
  ```
191
180
 
192
- Use the optional prompt shortcuts below when you want the pattern to be repeatable.
193
-
194
- Packaged `worker` defaults to forked context when a launch omits `context`; every other builtin runs fresh. Pass `context: "fresh"` when you intentionally want a fresh `worker` run.
195
181
 
196
- Child-safety boundaries are enforced at runtime by typed admission policy. In-process child sessions load bundled extensions through normal discovery. The `subagent` tool may therefore be registered when the child's active tool selection permits it, including the default no-allowlist case; an explicit allowlist may omit it. Tool presence does not grant fanout: fanout is authorized only when the resolved builtin `tools` list includes `subagent`. Typed admission policy lets a non-fanout child use only `list`, `get`, `status`, and `doctor`; delegation and `interrupt` receive the fanout refusal. A management-restricted child is also refused `create`, `update`, and `delete`. The bundled `pi-subagents` skill remains parent-only and is stripped from child prompts, including fanout-authorized children. No admitted child may delegate or control another child: launches and `interrupt` are refused for every child regardless of its fanout authorization. Children receive boundary instructions that they are not the parent orchestrator and must complete their assigned task directly. Forked child context filtering also removes parent-only subagent artifacts (including old hidden orchestration-instruction messages, slash/status/control messages, and prior parent `subagent` tool-call/tool-result history) while preserving ordinary prose and unrelated tool calls/results.
197
182
 
198
- ## Optional shortcuts
183
+ Packaged `worker` defaults to forked context when a launch omits `context`; every other builtin runs fresh. Pass `context: "fresh"` when you intentionally want a fresh `worker` run.
199
184
 
200
- The package includes reusable prompt templates for common workflows. You do not need them, but they are handy when you want the same shape every time:
185
+ Child-safety boundaries are enforced at runtime by typed admission policy. In-process child sessions load bundled extensions through normal discovery. The `subagent` tool may therefore be registered when the child's active tool selection permits it, including the default no-allowlist case; an explicit allowlist may omit it. Tool presence does not grant fanout: fanout is authorized only when the resolved builtin `tools` list includes `subagent`. Typed admission policy lets a non-fanout child use only `list`, `get`, and `status`; delegation and `interrupt` receive the fanout refusal. A management-restricted child is also refused `create`, `update`, and `delete`. The bundled `pi-subagents` skill remains parent-only and is stripped from child prompts, including fanout-authorized children. No admitted child may delegate or control another child: launches and `interrupt` are refused for every child regardless of its fanout authorization. Children receive boundary instructions that they are not the parent orchestrator and must complete their assigned task directly. Forked child context filtering also removes parent-only subagent artifacts (including old hidden orchestration-instruction messages, slash/status/control messages, and prior parent `subagent` tool-call/tool-result history) while preserving ordinary prose and unrelated tool calls/results.
201
186
 
202
- | Prompt | Use it for |
203
- |--------|------------|
204
- | `/parallel-review` | Launch fresh-context reviewers with distinct angles, then synthesize what to fix. |
205
- | `/review-loop` | Run parent-controlled write, review, and fix cycles until clean or capped. `debugger` writes fixes for bugs, `code-simplifier` for cleanup. |
206
- | `/parallel-research` | Combine `codebase-online-researcher` with local code specialists for external evidence, local context, and practical tradeoffs. |
207
- | `/parallel-context-build` | Run local code and research specialists in parallel to produce handoff context and meta-prompts. |
208
- | `/parallel-handoff-plan` | Combine external research with local context passes into an implementation handoff plan and meta-prompt. |
209
- | `/gather-context-and-clarify` | Locate and analyze first, then ask the user the clarification questions that matter. |
210
- | `/parallel-cleanup` | Run review-only cleanup passes after implementation. |
211
187
 
212
- Add `autofix` to `/parallel-review` or `/parallel-cleanup` to apply only the synthesized fixes worth doing now after reviewers return.
213
188
 
214
189
  ## Optional intercom companion
215
190
 
@@ -245,78 +220,16 @@ Parent-side Atomic still sends grouped completion results through Intercom: one
245
220
 
246
221
  If a child appears stalled, needs-attention notices can show up in the parent session with useful next actions, such as checking `subagent({ action: "status" })`, interrupting the run, or nudging the child.
247
222
 
248
- If messages do not show up, run:
249
-
250
- ```text
251
- /subagents-doctor
252
- ```
223
+ If messages do not show up, check the bridge from the intercom side with `intercom({ action: "status" })`.
253
224
 
254
225
  For normal use, you do not need to configure anything. Advanced users can tune the bridge with `intercomBridge` in the configuration section below.
255
226
 
256
- At this point, you know enough to use the plugin. The rest of this README is reference material for exact command syntax, custom agents, worktrees, and configuration.
257
-
258
- ## Direct commands
259
-
260
- Skip this section until you want exact syntax.
261
-
262
- | Command | Description |
263
- |---------|-------------|
264
- | `/run <agent> [task]` | Run one agent; omit the task for self-contained agents |
265
- | `/parallel agent1 "task1" -> agent2 "task2"` | Run agents in parallel |
266
- | `/subagents-doctor` | Show read-only setup diagnostics |
267
-
268
- Commands validate agent names locally, support tab completion, and send results back into the conversation.
269
-
270
- ### Parallel tasks
271
-
272
- Use `->` to separate tasks and give each task its own prompt:
273
-
274
- ```text
275
- /parallel codebase-pattern-finder "find security issues" -> codebase-analyzer "check code style"
276
- ```
277
-
278
- Both double and single quotes work. You can also use `--` as a delimiter:
279
-
280
- ```text
281
- /parallel codebase-locator codebase-analyzer -- check for security issues
282
- ```
283
-
284
- Tasks without a prompt use the first available task as a fallback.
285
-
286
- ### Inline per-step config
287
-
288
- Append `[key=value,...]` to an agent name to override defaults for that step:
289
-
290
- ```text
291
- /run codebase-locator[model=anthropic/claude-sonnet-4] summarize this codebase
292
- /parallel codebase-analyzer[skills=code-review+security] "review backend" -> codebase-analyzer[model=openai/gpt-5-mini] "review frontend"
293
- ```
294
-
295
- | Key | Example | Description |
296
- |-----|---------|-------------|
297
- | `output` | `output=context.md` | Write results to a file. For `/parallel`, relative paths resolve against the child working directory; for `/run`, relative paths resolve against cwd. |
298
- | `outputMode` | `outputMode=file-only` | Return only a concise file reference for saved output instead of the full saved content. Requires `output`; default is `inline`. |
299
- | `reads` | `reads=a.md+b.md` | Read files before executing. `+` separates multiple paths. `/run` forwards these through the same resolver as tool-based foreground launches, so relative paths use the effective child working directory. |
300
- | `model` | `model=anthropic/claude-sonnet-4` | Override model for this step. |
301
- | `skills` | `skills=planning+review` | Override injected skills. `+` separates multiple skills. |
302
- | `progress` | `progress` | Enable progress tracking. |
303
-
304
- Set `output=false`, `reads=false`, or `skills=false` to disable that behavior explicitly. Do not use `output=false` for file-only returns; use `outputMode=file-only` with an `output` path.
305
-
306
- ### Forked runs
307
-
308
- Add `--fork` to start each child from a real branched session created from the parent’s current leaf:
309
-
310
- ```text
311
- /run codebase-analyzer "review this diff" --fork
312
- /parallel codebase-locator "audit frontend" -> codebase-analyzer "audit backend" --fork
313
- ```
314
-
315
- `worker` is designed for an explicit decision loop. A typical pattern is to ask a read-only specialist such as `codebase-analyzer` or `debugger` for diagnosis and a recommended execution prompt, then only run `worker` after the main agent approves that direction.
227
+ At this point, you know enough to use the plugin. The rest of this README is reference material for custom agents, worktrees, and configuration.
316
228
 
317
229
  ## Non-interactive execution
318
230
 
319
- Every supported subagent launch starts immediately without opening a preview/editor prompt or waiting for terminal input. This applies to single, parallel, forked, fanout, prompt-template, and human-entered `/run` and `/parallel` execution. Gather any needed context and ask the user questions in the parent conversation before launching.
231
+ Every supported subagent launch starts immediately without opening a preview/editor prompt or waiting for terminal input. This applies to single, parallel, forked, fanout, and prompt-template execution. Gather any needed context and ask the user questions in the parent conversation before launching.
232
+
320
233
 
321
234
  ## Agents
322
235
 
@@ -408,7 +321,7 @@ interactive: true
408
321
  Your system prompt goes here.
409
322
  ```
410
323
 
411
- Frontmatter is parsed with a real YAML parser, so it must be valid YAML: a file whose frontmatter does not parse (for example a colon-space inside an unquoted scalar like `description: Deploy: fast`, duplicate keys, or tab-indented block lists) is skipped during discovery. `subagent({ action: "doctor" })` lists every skipped file with the parser's message, so a bad file never disappears silently.
324
+ Frontmatter is parsed with a real YAML parser, so it must be valid YAML: a file whose frontmatter does not parse (for example a colon-space inside an unquoted scalar like `description: Deploy: fast`, duplicate keys, or tab-indented block lists) is skipped during discovery. Discovery records the parser's message for every skipped file, so a bad file never disappears silently.
412
325
 
413
326
  Important fields:
414
327
 
@@ -499,11 +412,11 @@ The package bundles a `subagent` skill that is automatically available to the pa
499
412
 
500
413
  What the bundled skill covers:
501
414
  - **Delegation patterns**: when to launch which agent, whether to use single or parallel mode, and whether to use fresh or forked context
502
- - **Prompt workflow recipes**: how to apply the packaged techniques directly with `subagent(...)` when the user describes the workflow in natural language instead of invoking a slash command. This includes parallel review, review-loop, parallel research, parallel context-build, parallel handoff-plan, gather-context-and-clarify, and parallel cleanup
415
+ - **Prompt workflow recipes**: how to apply the packaged techniques directly with `subagent(...)` when the user describes the workflow in natural language instead of invoking a slash command. This includes parallel research, parallel context-build, and parallel cleanup
503
416
  - **Role-agent prompting guidance**: compact contract prompts instead of long scripts, what to include in role-specific meta prompts, and retrieval budgets for researchers
504
417
  - **Safety boundaries**: child agents must not run subagents, must not invent intercom targets, and must escalate unapproved decisions
505
418
  - **Intercom conventions**: when to ask vs send, and how parent-side result delivery works with `pi-intercom`
506
- - **Control and diagnostics**: attention signals, soft interrupts, status, and the `doctor` action
419
+ - **Control signals**: attention signals, soft interrupts, and status
507
420
 
508
421
  If you are writing an agent that orchestrates subagents, the bundled skill helps it behave correctly without guessing the patterns. If you are a human user, you do not need to read it directly; the README and prompt shortcuts encode the same workflows in user-facing form.
509
422
 
@@ -593,7 +506,7 @@ Agent definitions are not loaded into context by default. Management actions let
593
506
  |-------|------|---------|-------------|
594
507
  | `agent` | string | - | Agent name for single mode, or target for management actions. |
595
508
  | `task` | string | - | Task string for single mode. |
596
- | `action` | string | - | `list`, `get`, `create`, `update`, `delete`, `status`, `interrupt`, or `doctor`. |
509
+ | `action` | string | - | `list`, `get`, `create`, `update`, `delete`, `status`, or `interrupt`. |
597
510
  | `config` | object/string | - | Agent config for create/update. |
598
511
  | `output` | `string \| false` | agent default | Override single-agent output file. |
599
512
  | `outputMode` | `"inline" \| "file-only"` | `inline` | Return saved output inline or as a concise saved-file reference. `file-only` requires an `output` path. |
@@ -624,7 +537,6 @@ Status and control actions:
624
537
  subagent({ action: "status" })
625
538
  subagent({ action: "status", id: "<run-id>" })
626
539
  subagent({ action: "interrupt", id: "<run-id>" })
627
- subagent({ action: "doctor" })
628
540
  ```
629
541
 
630
542
  Completed, interrupted, and parent-question children are terminal for continuation. A prior run ID cannot revive a child or parallel sibling set. Start a fresh subagent call with an explicit context handoff for follow-up work.
@@ -783,7 +695,7 @@ This is disabled by default. Session data may contain source code, paths, enviro
783
695
 
784
696
  ## Delegation boundary
785
697
 
786
- Delegation is exactly one level deep, and nothing configures it. A top-level session — main chat or a workflow stage — may call `subagent`. A session that was itself admitted as a subagent child may not: every launch and `interrupt` it attempts is refused with guidance to complete its assigned task directly. The observing actions `list`, `get`, `status`, and `doctor` stay available to a child.
698
+ Delegation is exactly one level deep, and nothing configures it. A top-level session — main chat or a workflow stage — may call `subagent`. A session that was itself admitted as a subagent child may not: every launch and `interrupt` it attempts is refused with guidance to complete its assigned task directly. The observing actions `list`, `get`, and `status` stay available to a child.
787
699
 
788
700
  There is no configuration option, agent frontmatter field, or tool parameter for the delegation level. The rule is enforced twice: the subagent executor refuses a child before any run starts, and the Rust `SubagentControl` admission door refuses a child deeper than the single permitted level. Admitted depth is typed admission state and is not inherited through an environment variable.
789
701
 
@@ -840,13 +752,13 @@ The main runtime files are:
840
752
  |------|---------|
841
753
  | `src/extension/index.ts` | Extension registration, tool registration, message/render wiring. |
842
754
  | `src/agents/agents.ts` | Agent discovery and frontmatter parsing. |
843
- | `src/runs/foreground/subagent-executor.ts` | Main execution routing for single, parallel, management, status, interrupt, and doctor actions. |
755
+ | `src/runs/foreground/subagent-executor.ts` | Main execution routing for single, parallel, management, status, and interrupt actions. |
844
756
  | `src/runs/foreground/execution.ts` | Core foreground `runSync` handling. |
845
757
  | `src/runs/foreground/notify.ts` | Completion-notification delivery for a detached Intercom child. |
846
758
  | `src/runs/foreground/completion-notification.ts` | Local completion acknowledgement and ordering barrier for detached children. |
847
759
  | `src/shared/settings.ts` | Shared task behavior, instructions, and config helpers. |
848
760
  | `src/runs/shared/worktree.ts` | Git worktree isolation. |
849
- | `src/intercom/intercom-bridge.ts` | Runtime intercom bridge instructions and diagnostics. |
761
+ | `src/intercom/intercom-bridge.ts` | Runtime intercom bridge instructions. |
850
762
  | `src/extension/schemas.ts` / `src/shared/types.ts` | Tool schemas, shared types, and event constants. |
851
763
  | `test/unit/` / `test/integration/` | Unit and loader-based integration tests. |
852
764
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bastani/subagents",
3
- "version": "0.9.16-alpha.1",
3
+ "version": "0.9.16-alpha.2",
4
4
  "private": true,
5
5
  "description": "Atomic extension for delegating tasks to subagents with parallel execution. Fork of: https://github.com/nicobailon/pi-subagents",
6
6
  "contributors": [
@@ -21,7 +21,6 @@
21
21
  "src/**/*.ts",
22
22
  "agents/",
23
23
  "skills/**/*",
24
- "prompts/**/*",
25
24
  "README.md",
26
25
  "CHANGELOG.md"
27
26
  ],
@@ -31,9 +30,6 @@
31
30
  ],
32
31
  "skills": [
33
32
  "./skills"
34
- ],
35
- "prompts": [
36
- "./prompts"
37
33
  ]
38
34
  },
39
35
  "peerDependencies": {
@@ -25,38 +25,16 @@ Use this skill when bounded specialist delegation adds value and the parent shou
25
25
  - **Subagent control**: watch needs-attention signals and soft-interrupt only when a delegated run is genuinely blocked.
26
26
  - **Agent authoring**: create, update, or override agents for a project.
27
27
 
28
- ## Tool vs Slash Commands
28
+ ## Tool
29
29
 
30
- Agents can use the `subagent(...)` tool directly for execution, management, status, and control.
31
- Humans often use the slash-command layer instead:
30
+ Use the `subagent(...)` tool for execution, management, status, and control. There is no bundled slash-command launcher.
32
31
 
33
- - `/run` launch a single agent
34
- - `/parallel` — launch top-level parallel tasks
35
- - `/subagents-doctor` — diagnose setup, execution paths, current session, and intercom bridge state
32
+ When the user asks for research, context-build, or cleanup shapes, apply the same pattern directly with `subagent(...)`.
36
33
 
37
- Prefer the tool when you are writing agent logic. Prefer the slash commands when you are guiding a human through an interactive flow.
34
+ ## Applying Prompt Techniques
38
35
 
39
- Packaged prompt shortcuts are also available for repeatable workflows. Treat them as reusable orchestration recipes, not just human slash commands. When the user asks for one of these shapes, or when the workflow clearly fits, apply the same pattern directly with `subagent(...)`:
36
+ If the user provides a URL, issue, PR, plan, local file, screenshot, or freeform target, treat that target as the primary scope: read or fetch it before launching children, then include it explicitly in every child task. Do not depend on the parent conversation history when the recipe calls for fresh context.
40
37
 
41
- - `/parallel-review` — fresh-context specialists (analyzer, debugger inspect-only, pattern-finder) with distinct review angles, then parent synthesis
42
- - `/review-loop` — parent-orchestrated writer (`debugger` or `code-simplifier`) + specialist reviewer cycles until clean or capped
43
- - `/parallel-research` — combine `codebase-online-researcher` with local locator/analyzer/pattern-finder/research-analyzer specialists
44
- - `/parallel-context-build` — parallel codebase specialist passes that produce planning handoff context
45
- - `/parallel-handoff-plan` — external-reference research plus local specialist passes, followed by a parent-side handoff plan and implementation-ready meta-prompt
46
- - `/gather-context-and-clarify` — locate/analyze/research first, then ask the user clarifying questions with `interview`
47
- - `/parallel-cleanup` — two read-only specialist scouts (deslop + verbosity) followed by an optional `code-simplifier` writer pass
48
-
49
- ## Applying Prompt Techniques Without Slash Commands
50
-
51
- The prompt templates in `prompts/` encode workflows the parent agent can run on demand. If the user provides a URL, issue, PR, plan, local file, screenshot, or freeform target, treat that target as the primary scope: read or fetch it before launching children, then include it explicitly in every child task. Do not depend on the parent conversation history when the recipe calls for fresh context.
52
-
53
- ### Parallel review technique
54
-
55
- Use this when the user wants adversarial review of a diff, plan, issue, file, or implemented work. There is no generic `reviewer` agent — assemble the review from read-only specialists with distinct angles. Common angles: correctness/regressions (`codebase-analyzer`), failure-mode hunt (`debugger` in inspect-only mode), pattern fit (`codebase-pattern-finder`), prior decisions (`codebase-research-locator` + `codebase-research-analyzer`), and external-spec conformance (`codebase-online-researcher`). Specialists inspect files and diffs directly from `git diff`/`git status` and return concise evidence-backed findings with file/line references. They must not edit files — even `debugger`, which can write, must be told to inspect and report only in this pass. The parent synthesizes fixes worth doing now, optional improvements, and feedback to ignore/defer before applying anything.
56
-
57
- ### Review-loop technique
58
-
59
- Use this when the user wants implementation or current diff review to continue until reviewers stop finding fixes worth doing now. Keep the loop in the parent session: one writer (`debugger` for correctness-shaped work or `code-simplifier` for refinement-shaped work), fresh-context specialist reviewers inspect the actual repo and diff, the parent synthesizes accepted fixes, and one writer applies them. Run each bounded call in the foreground so the parent receives the result before the next step. Programmatic runs are non-interactive, so resolve only material unanswered questions before launching. Treat a writer handoff as an intermediate state, not final completion, unless the user explicitly asked for writer-only work, review-only output, or to stop after implementation. Stop when reviewers find no blockers or fixes worth doing now, remaining feedback is optional or deferred, an unapproved product/scope/architecture decision appears, or the max review-round cap is reached. Default to 3 review rounds unless I set another cap. Do not loop for optional polish, and do not let children launch subagents or decide the loop outcome.
60
38
 
61
39
  ### Parallel research technique
62
40
 
@@ -79,29 +57,6 @@ subagent({
79
57
  })
80
58
  ```
81
59
 
82
- ### Parallel handoff-plan technique
83
-
84
- Use this when the user needs a solution brief or implementation-ready handoff from an external reference plus local code context. Run one top-level parallel discovery call; the parent synthesizes the final handoff afterward. The discovery group usually includes `codebase-online-researcher` for external projects/docs/prompt guidance, `codebase-locator` and `codebase-analyzer` for local code, and optionally `codebase-pattern-finder` and `codebase-research-*` for transferable conventions and prior decisions. Use distinct output paths under `handoff/`, then write `handoff/final-handoff-plan.md` yourself with the recommended approach, likely files, constraints, non-goals, validation, risks, unresolved questions, and final compact implementation-ready meta-prompt.
85
-
86
- Example shape:
87
-
88
- ```typescript
89
- subagent({
90
- tasks: [
91
- { agent: "codebase-online-researcher", task: "Research the external reference and transferable implementation ideas for: ...", output: "handoff/external-reference.md" },
92
- { agent: "codebase-locator", task: "Map local files that would change for: ...", output: "handoff/local-files.md" },
93
- { agent: "codebase-analyzer", task: "Trace current behavior of those files: ...", output: "handoff/local-flow.md" },
94
- { agent: "codebase-pattern-finder", task: "Find analogous local patterns for: ...", output: "handoff/local-patterns.md" }
95
- ],
96
- context: "fresh"
97
- })
98
- // Parent then writes handoff/final-handoff-plan.md from the outputs.
99
- ```
100
-
101
- ### Gather-context-and-clarify technique
102
-
103
- Use this when unresolved requirements and genuinely missing repository context justify a discovery pass. Launch `codebase-locator` and `codebase-analyzer` for local context, `codebase-pattern-finder` when conventions matter, `codebase-research-locator` + `codebase-research-analyzer` when prior docs likely apply, and `codebase-online-researcher` only when external docs would materially improve understanding. Ask children for concise findings plus remaining clarification questions. Then synthesize what is known and use `interview` to ask the unresolved questions needed for shared understanding before planning or implementing.
104
-
105
60
  ### Parallel cleanup technique
106
61
 
107
62
  Use this after implementation when the user wants cleanup review or when a final pass would reduce AI-slop. Launch two fresh-context `codebase-analyzer` scouts with `output: false` and `progress: false`: one deslop pass and one verbosity pass. If the `deslop` or `verbosity-cleaner` skills are available, pass the relevant skill to that scout; otherwise inline the criteria. Both scouts are read-only and should flag concrete issues with severity, file/line references, and smallest safe fixes. Phrase the constraint as “Do not modify project/source files; returning findings through the configured output artifact is allowed” when you use `output` or `outputMode: "file-only"`. The parent decides what to apply and asks before making changes unless cleanup was already authorized. When the user opts to autofix, the parent launches one foreground `code-simplifier` writer with the synthesized fixes as its explicit scope.
@@ -124,10 +79,11 @@ Builtin agents load at the lowest priority. Project agents override user agents,
124
79
 
125
80
  Each builtin declares an explicit `model` and `fallbackModels` sequence (typically `github-copilot/<same>`, then `anthropic/claude-opus-4-8`, then `github-copilot/claude-opus-4.7`). The current user-selected model is automatically appended as the last fallback and de-duplicated. Override per run with inline config:
126
81
 
127
- ```text
128
- /run codebase-analyzer[model=anthropic/claude-sonnet-4] "Trace the auth flow"
82
+ ```typescript
83
+ subagent({ agent: "codebase-analyzer", task: "Trace the auth flow", model: "anthropic/claude-sonnet-4" })
129
84
  ```
130
85
 
86
+
131
87
  For persistent tweaks, edit `subagents.agentOverrides` in user or project settings. User overrides apply everywhere. Project overrides apply only in that repo and win over user overrides.
132
88
 
133
89
  The builtin `debugger` and `worker` agents declare both `intercom` and `contact_supervisor`, so they can send progress or ask the parent for a decision when the bridge is active. Other builtin specialists finish their pass and return without live coordination. Custom agents can coordinate when they declare `intercom` or when the runtime bridge injects `contact_supervisor`; see [Subagent + Intercom Coordination](#subagent--intercom-coordination).
@@ -263,14 +219,6 @@ subagent({ agent: "worker", task: "[TASK_CONTEXT] Continue with this supervisor
263
219
 
264
220
  A parent-ask handoff supplies the original question, ordered attachments, previous agent identity, and dynamic task context. The fresh launch receives a new run identity.
265
221
 
266
- Use diagnostics when setup or child startup looks wrong:
267
-
268
- ```typescript
269
- subagent({ action: "doctor" })
270
- ```
271
-
272
- Humans can use `/subagents-doctor` for the same read-only report. It checks runtime paths, discovery counts, current session context, and intercom bridge state.
273
-
274
222
  ### Subagent control
275
223
 
276
224
  Subagent control is the runtime visibility and intervention layer for delegated runs. Lifecycle status distinguishes queued and running children from terminal completed, failed, or interrupted results. Activity reporting is factual: it tracks the last observed activity time and the current tool when known. It does not pretend to know that a child is truly stuck.
@@ -308,9 +256,10 @@ If the run already has an active intercom bridge target, needs-attention notific
308
256
 
309
257
  ## Non-Interactive Execution
310
258
 
311
- Every supported subagent launch starts immediately without a preview/editor prompt or terminal input. This applies to single, parallel, forked, fanout, prompt-template, and human-entered `/run` and `/parallel` execution.
259
+ Every supported subagent launch starts immediately without a preview/editor prompt or terminal input. This applies to single, parallel, forked, fanout, and prompt-template execution.
260
+
261
+ Resolve questions in the parent conversation before launching children. Use `interview` when the user must answer a question, then put the resolved scope and validation contract in the child task.
312
262
 
313
- Resolve questions in the parent conversation before launching children. Use `interview` when the user must answer a question, then put the resolved scope and validation contract in the child task. Human slash commands retain their separate parsing and event-bridge path.
314
263
 
315
264
  ## Worktree Isolation
316
265
 
@@ -362,7 +311,7 @@ Message conventions:
362
311
 
363
312
  Most agents should not call generic `intercom` directly unless bridge instructions provide a target and `contact_supervisor` is unavailable. Do not invent a target.
364
313
 
365
- If intercom messages do not show up, run `subagent({ action: "doctor" })` or `/subagents-doctor`.
314
+ If intercom messages do not show up, check the bridge from the intercom side with `intercom({ action: "status" })`.
366
315
 
367
316
  ## Management Mode
368
317
 
@@ -444,17 +393,14 @@ That is only a starting point. Omit `package` for the traditional unqualified ru
444
393
 
445
394
  For many customizations, builtin overrides in settings are lower-friction than copying a full builtin file.
446
395
 
447
- ## Prompt Template Integration
396
+ If a prompt-template extension is installed, additional user prompt templates can delegate into subagents.
448
397
 
449
- The package includes prompt shortcuts for common workflows: `/parallel-review`, `/review-loop`, `/parallel-research`, `/parallel-context-build`, `/parallel-handoff-plan`, `/gather-context-and-clarify`, and `/parallel-cleanup`. Use them when the user wants repeatable review, review/fix loops, research, context handoff, implementation handoff, clarification, or cleanup-review patterns. `/parallel-review autofix` launches a `debugger` or `code-simplifier` writer (depending on feedback shape) to apply the synthesized fixes worth doing now. `/parallel-cleanup autofix` launches one `code-simplifier` writer to apply the synthesized cleanup fixes. Parent agents can also apply the same recipes directly with `subagent(...)` when the user describes the workflow in natural language instead of invoking a slash command.
450
-
451
- If a prompt-template extension is installed, additional user prompt templates can delegate into subagents. This is useful when a slash command should always run through a particular agent or with forked context.
452
398
 
453
399
  ## Important Constraints
454
400
 
455
401
  - **Forking requires a persisted parent session.** If the current session does not have a persisted session file, forked runs fail.
456
402
  - **Forked runs inherit parent history.** They are branched threads, not fresh filtered contexts. Use fresh context for adversarial review unless the user explicitly asks for forked context.
457
- - **Delegation is one level deep and not configurable.** A subagent cannot call `subagent`: every launch and `interrupt` from inside a child is refused. Only `list`, `get`, `status`, and `doctor` stay available to a child.
403
+ - **Delegation is one level deep and not configurable.** A subagent cannot call `subagent`: every launch and `interrupt` from inside a child is refused. Only `list`, `get`, and `status` stay available to a child.
458
404
  - **Attention signals are not lifecycle state.** `needs_attention` means no activity has been observed past the configured threshold. `interrupted` means the child turn ended before completion; it is terminal for continuation and is not the same as `failed`.
459
405
  - **Builtin coordination varies by agent.** `debugger` and `worker` declare `intercom` and `contact_supervisor`; the other builtin specialists do not. For agents without bridge tools, decide the task up front or use a custom agent when mid-run coordination is required.
460
406
  - **Intercom asks are blocking.** A session can only maintain one pending outbound ask wait state at a time.
@@ -515,19 +461,10 @@ await subagent({ agent: "debugger", task: "Reproduce the failure and patch the r
515
461
 
516
462
  ### Clarify → Discover → Implement → Review (self-orchestrated workflow)
517
463
 
518
- When the user requests one of these bounded orchestration shapes, factor in the packaged prompt recipes without literally invoking slash commands. Use the same patterns through tools and subagents.
519
-
520
- Keep builtin agent defaults unless the user explicitly asks for a different model, thinking level, skills, output behavior, context mode, or other override. Do not add overrides just because you are orchestrating; the defaults encode the intended role behavior.
464
+ When the user requests a bounded orchestration shape, apply it through the `subagent` tool. Keep builtin agent defaults unless the user explicitly asks for a different model, thinking level, skills, output behavior, context mode, or other override.
521
465
 
522
466
  When the user approves launching a subagent to carry out a workflow, treat that as approval to generate a proper role-specific meta prompt for that subagent. Include the approved plan path or summary, clarified requirements, non-goals, relevant context, role boundaries, files or areas to inspect, completion criteria, expected output, and validation expectations. Do not pass vague instructions like "implement the change fully" or "review this" by themselves.
523
467
 
524
- - `/gather-context-and-clarify` maps to: launch locator/analyzer/research specialists; synthesize findings; then use `interview` to ask every clarification question needed for shared understanding.
525
- - `/parallel-review` maps to: launch fresh-context specialist reviewers with distinct review angles; synthesize the feedback before applying anything.
526
- - `/review-loop` maps to: keep the parent in charge of writer → fresh specialist reviewers → synthesized fix writer cycles until no fixes worth doing now remain, an unapproved decision appears, or the review-round cap is reached.
527
- - `/parallel-research` maps to: combine local locator/analyzer/pattern-finder/research-analyzer context with external `codebase-online-researcher` evidence when current docs, ecosystem behavior, or API details matter.
528
- - `/parallel-context-build` maps to: run a top-level parallel group of codebase specialists with distinct output paths, then synthesize their context and meta-prompt sections.
529
- - `/parallel-handoff-plan` maps to: run external `codebase-online-researcher` plus local locator/analyzer/pattern-finder/research passes, then synthesize the final handoff plan and implementation-ready meta-prompt yourself.
530
- - `/parallel-cleanup` maps to: read-only `codebase-analyzer` scouts (deslop + verbosity) followed by an optional `code-simplifier` writer when the user authorizes autofix.
531
468
 
532
469
  For feature work, use this sequence as scaffolding for parent-agent behavior:
533
470
 
@@ -543,7 +480,7 @@ For complex or risky changes, increase review and validation fanout when user in
543
480
 
544
481
  For very large work, split into serial milestones instead of launching a swarm of writers. Each milestone gets one writer, a validation contract, fresh-context review, a fix pass, and parent approval before the next milestone starts. Use parallel subagents inside a milestone for read-only context, research, and review only.
545
482
 
546
- Keep orchestration authority in the parent session. Child subagents cannot launch more subagents or run their own orchestration loops: delegation is one level deep and nothing configures it. This skill is parent-only and is stripped from every child prompt. A child may still have the `subagent` extension tool registered, because bundled extensions load through normal discovery; registration is not authority. Typed admission policy lets a child use only `list`, `get`, `status`, and `doctor`, and refuses delegation and `interrupt`. Spawned children also do not receive parent-only status/control/slash messages or prior parent `subagent` tool-call/tool-result artifacts, and child context filtering strips old hidden orchestration-instruction messages when they appear in inherited history. Every child also receives a boundary instruction that says the parent owns orchestration, that the `subagent` tool refuses every launch and `interrupt` from inside a subagent, and that writer children must call real edit/write tools instead of printing pseudo tool calls. Pass children concrete role-specific work instead.
483
+ Keep orchestration authority in the parent session. Child subagents cannot launch more subagents or run their own orchestration loops: delegation is one level deep and nothing configures it. This skill is parent-only and is stripped from every child prompt. A child may still have the `subagent` extension tool registered, because bundled extensions load through normal discovery; registration is not authority. Typed admission policy lets a child use only `list`, `get`, and `status`, and refuses delegation and `interrupt`. Spawned children also do not receive parent-only status/control/slash messages or prior parent `subagent` tool-call/tool-result artifacts, and child context filtering strips old hidden orchestration-instruction messages when they appear in inherited history. Every child also receives a boundary instruction that says the parent owns orchestration, that the `subagent` tool refuses every launch and `interrupt` from inside a subagent, and that writer children must call real edit/write tools instead of printing pseudo tool calls. Pass children concrete role-specific work instead.
547
484
 
548
485
  1. Clarify only when needed. Use existing context first; gather missing code or research context selectively, then ask only unresolved questions that materially affect scope, completion criteria, constraints, or non-goals.
549
486
  2. Define the validation contract. State completion expectations before implementation: expected behavior, checks to run, user flows to exercise, and evidence required in the writer handoff. For UI, CLI, integration, or workflow changes, include at least one validator angle that uses the product the way a user would rather than only reading code.
@@ -593,7 +530,7 @@ When implementation review is part of the requested shape, do not treat the firs
593
530
 
594
531
  When a writer completes, treat its handoff as an intermediate state when review is part of the requested shape. The next parent action is bounded review, then synthesis, then a fix writer if reviewers found fixes worth doing now. Keep these calls in the foreground so each handoff is available before the next action.
595
532
 
596
- For explicit review-loop requests, repeat writer → fresh-specialist-reviewers → synthesized-fix-writer cycles until reviewers find no blockers or fixes worth doing now, remaining feedback is optional or intentionally deferred, an unapproved product/scope/architecture decision needs the user, or the max review-round cap is reached. Default to 3 review rounds unless the user sets a different cap.
533
+ When the user explicitly asks to keep reviewing until the work is clean, repeat writer → fresh-specialist-reviewers → synthesized-fix-writer cycles until reviewers find no blockers or fixes worth doing now, remaining feedback is optional or intentionally deferred, an unapproved product/scope/architecture decision needs the user, or the max review-round cap is reached. Default to 3 review rounds unless the user sets a different cap.
597
534
 
598
535
  ### Parallel non-conflicting analysis
599
536
 
@@ -616,13 +553,6 @@ subagent({ action: "list" })
616
553
  // Check available agents, then confirm scope and precedence.
617
554
  ```
618
555
 
619
- **Setup, discovery, or intercom confusion**
620
-
621
- ```typescript
622
- subagent({ action: "doctor" })
623
- // Check runtime paths, execution support, discovery counts, current session, and intercom bridge state.
624
- ```
625
-
626
556
  **"Subagent delegation is not available inside a subagent"**
627
557
 
628
558
  ```typescript
@@ -659,7 +589,7 @@ subagent({ action: "doctor" })
659
589
  **Child fails before starting**
660
590
 
661
591
  ```typescript
662
- // Inspect `subagent({ action: "status", id: "..." })`, artifact metadata/output logs, and run doctor. Extension loader errors usually appear in child output logs.
592
+ // Inspect `subagent({ action: "status", id: "..." })` plus artifact metadata and output logs. Extension loader errors usually appear in child output logs.
663
593
  ```
664
594
 
665
595
  ## Suffix-first reasoning levels
@@ -14,6 +14,4 @@ MANAGEMENT (use action field, omit agent/task/tasks):
14
14
  • { action: "delete", agent: "code-analysis.custom-agent" }
15
15
  CONTROL:
16
16
  • { action: "status", id: "..." } - inspect an in-process run by id or prefix
17
- • { action: "interrupt", id?: "..." } - soft-interrupt the current child turn; the child is terminal for continuation, so follow-up work starts a fresh launch
18
- DIAGNOSTICS:
19
- • { action: "doctor" } - read-only report for runtime paths, discovery, sessions, and intercom`;
17
+ • { action: "interrupt", id?: "..." } - soft-interrupt the current child turn; the child is terminal for continuation, so follow-up work starts a fresh launch`;
@@ -52,19 +52,6 @@ export interface IntercomBridgeState {
52
52
  instruction: string;
53
53
  }
54
54
 
55
- export interface IntercomBridgeDiagnostic {
56
- active: boolean;
57
- mode: IntercomBridgeMode;
58
- wantsIntercom: boolean;
59
- piIntercomAvailable: boolean;
60
- extensionDir: string;
61
- configPath?: string;
62
- orchestratorTarget?: string;
63
- reason?: string;
64
- intercomConfigEnabled?: boolean;
65
- intercomConfigError?: string;
66
- }
67
-
68
55
  interface ResolveIntercomBridgeInput {
69
56
  config: ExtensionConfig["intercomBridge"];
70
57
  context: "fresh" | "fork" | undefined;
@@ -317,46 +304,6 @@ function buildIntercomBridgeInstruction(orchestratorTarget: string, template: st
317
304
  ${instruction}`;
318
305
  }
319
306
 
320
- export function diagnoseIntercomBridge(input: ResolveIntercomBridgeInput): IntercomBridgeDiagnostic {
321
- const config = resolveIntercomBridgeConfig(input.config);
322
- const mode = config.mode;
323
- const agentDir = path.resolve(input.agentDir ?? defaultAgentDir());
324
- const extensionDir = resolveIntercomExtensionDir(input, agentDir);
325
- const orchestratorTarget = input.orchestratorTarget?.trim();
326
- const configPath = path.resolve(input.configPath ?? defaultIntercomConfigPath(agentDir));
327
- const wantsIntercom = mode !== "off" && !(mode === "fork-only" && input.context !== "fork");
328
- const piIntercomAvailable = fs.existsSync(extensionDir);
329
- let configStatus: ReturnType<typeof intercomConfigStatus> | undefined;
330
- let reason: string | undefined;
331
- if (mode === "off") reason = "bridge mode is off";
332
- else if (mode === "fork-only" && input.context !== "fork")
333
- reason = "bridge mode is fork-only and context is not fork";
334
- else if (!orchestratorTarget) reason = "orchestrator target is not available";
335
- else if (!piIntercomAvailable) reason = "pi-intercom extension was not found";
336
- else {
337
- configStatus = intercomConfigStatus(configPath);
338
- if (!configStatus.enabled) reason = "intercom config is disabled";
339
- }
340
- let intercomConfigError: string | undefined;
341
- if (configStatus?.error) {
342
- const error = configStatus.error;
343
- intercomConfigError = error instanceof Error ? `${error.name}: ${error.message}` : String(error);
344
- }
345
-
346
- return {
347
- active: reason === undefined,
348
- mode,
349
- wantsIntercom,
350
- piIntercomAvailable,
351
- extensionDir,
352
- configPath,
353
- ...(orchestratorTarget ? { orchestratorTarget } : {}),
354
- ...(reason ? { reason } : {}),
355
- ...(configStatus ? { intercomConfigEnabled: configStatus.enabled } : {}),
356
- ...(intercomConfigError ? { intercomConfigError } : {}),
357
- };
358
- }
359
-
360
307
  export function resolveIntercomBridge(input: ResolveIntercomBridgeInput): IntercomBridgeState {
361
308
  const config = resolveIntercomBridgeConfig(input.config);
362
309
  const mode = config.mode;