@bastani/atomic 0.8.24-alpha.2 → 0.8.24-alpha.3

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 (55) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +2 -1
  3. package/dist/builtin/intercom/CHANGELOG.md +6 -0
  4. package/dist/builtin/intercom/package.json +1 -1
  5. package/dist/builtin/mcp/CHANGELOG.md +6 -0
  6. package/dist/builtin/mcp/package.json +1 -1
  7. package/dist/builtin/subagents/CHANGELOG.md +10 -0
  8. package/dist/builtin/subagents/README.md +132 -21
  9. package/dist/builtin/subagents/package.json +1 -1
  10. package/dist/builtin/subagents/prompts/parallel-context-build.md +4 -2
  11. package/dist/builtin/subagents/prompts/parallel-handoff-plan.md +3 -1
  12. package/dist/builtin/subagents/skills/subagent/SKILL.md +49 -11
  13. package/dist/builtin/subagents/src/agents/agent-management.ts +79 -16
  14. package/dist/builtin/subagents/src/agents/agents.ts +47 -16
  15. package/dist/builtin/subagents/src/agents/chain-serializer.ts +114 -0
  16. package/dist/builtin/subagents/src/extension/schemas.ts +139 -3
  17. package/dist/builtin/subagents/src/runs/background/async-execution.ts +92 -6
  18. package/dist/builtin/subagents/src/runs/background/async-status.ts +11 -1
  19. package/dist/builtin/subagents/src/runs/background/run-status.ts +4 -1
  20. package/dist/builtin/subagents/src/runs/background/subagent-runner.ts +529 -32
  21. package/dist/builtin/subagents/src/runs/foreground/chain-execution.ts +361 -118
  22. package/dist/builtin/subagents/src/runs/foreground/execution.ts +75 -7
  23. package/dist/builtin/subagents/src/runs/foreground/subagent-executor.ts +33 -0
  24. package/dist/builtin/subagents/src/runs/shared/acceptance.ts +611 -0
  25. package/dist/builtin/subagents/src/runs/shared/chain-outputs.ts +101 -0
  26. package/dist/builtin/subagents/src/runs/shared/dynamic-fanout.ts +293 -0
  27. package/dist/builtin/subagents/src/runs/shared/parallel-utils.ts +29 -1
  28. package/dist/builtin/subagents/src/runs/shared/pi-args.ts +11 -0
  29. package/dist/builtin/subagents/src/runs/shared/structured-output.ts +79 -0
  30. package/dist/builtin/subagents/src/runs/shared/subagent-prompt-runtime.ts +52 -2
  31. package/dist/builtin/subagents/src/runs/shared/workflow-graph.ts +206 -0
  32. package/dist/builtin/subagents/src/shared/formatters.ts +2 -2
  33. package/dist/builtin/subagents/src/shared/settings.ts +53 -4
  34. package/dist/builtin/subagents/src/shared/types.ts +226 -0
  35. package/dist/builtin/subagents/src/shared/utils.ts +2 -1
  36. package/dist/builtin/subagents/src/slash/slash-commands.ts +41 -3
  37. package/dist/builtin/subagents/src/tui/render.ts +152 -34
  38. package/dist/builtin/web-access/CHANGELOG.md +6 -0
  39. package/dist/builtin/web-access/package.json +1 -1
  40. package/dist/builtin/workflows/CHANGELOG.md +6 -0
  41. package/dist/builtin/workflows/package.json +1 -1
  42. package/dist/builtin/workflows/skills/create-spec/SKILL.md +1 -1
  43. package/dist/builtin/workflows/src/tui/stage-chat-view.ts +0 -1
  44. package/dist/core/slash-commands.d.ts.map +1 -1
  45. package/dist/core/slash-commands.js +1 -0
  46. package/dist/core/slash-commands.js.map +1 -1
  47. package/dist/core/system-prompt.d.ts.map +1 -1
  48. package/dist/core/system-prompt.js +4 -3
  49. package/dist/core/system-prompt.js.map +1 -1
  50. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  51. package/dist/modes/interactive/interactive-mode.js +1 -1
  52. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  53. package/docs/usage.md +1 -0
  54. package/docs/workflows.md +173 -0
  55. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.8.24-alpha.3] - 2026-06-03
6
+
7
+ ### Added
8
+
9
+ - Added `/exit` as a built-in interactive slash command alias for graceful app shutdown from the main chat.
10
+
5
11
  ## [0.8.24-alpha.2] - 2026-06-03
6
12
 
7
13
  ### Added
package/README.md CHANGED
@@ -186,7 +186,8 @@ Type `/` in the editor to trigger commands. [Extensions](#extensions) can regist
186
186
  | `/reload` | Reload keybindings, extensions, skills, prompts, and context files (themes hot-reload automatically) |
187
187
  | `/hotkeys` | Show all keyboard shortcuts |
188
188
  | `/changelog` | Display version history |
189
- | `/quit` | Quit pi |
189
+ | `/exit` | Exit Atomic |
190
+ | `/quit` | Quit Atomic |
190
191
 
191
192
  ### Keyboard Shortcuts
192
193
 
@@ -4,6 +4,12 @@ All notable changes to the `pi-intercom` extension will be documented in this fi
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.8.24-alpha.3] - 2026-06-03
8
+
9
+ ### Changed
10
+
11
+ - Bumped package version for the Atomic 0.8.24-alpha.3 prerelease.
12
+
7
13
  ## [0.8.24-alpha.2] - 2026-06-03
8
14
 
9
15
  ### Changed
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bastani/intercom",
3
- "version": "0.8.24-alpha.2",
3
+ "version": "0.8.24-alpha.3",
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": [
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.8.24-alpha.3] - 2026-06-03
11
+
12
+ ### Changed
13
+
14
+ - Bumped package version for the Atomic 0.8.24-alpha.3 prerelease.
15
+
10
16
  ## [0.8.24-alpha.2] - 2026-06-03
11
17
 
12
18
  ### Changed
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bastani/mcp",
3
- "version": "0.8.24-alpha.2",
3
+ "version": "0.8.24-alpha.3",
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,16 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.8.24-alpha.3] - 2026-06-03
6
+
7
+ ### Added
8
+
9
+ - Synced upstream dynamic fanout and acceptance-gate support for subagent chains, including `.chain.json` discovery, named chain outputs, structured subagent output capture, workflow graph status rendering, and explicit acceptance contracts.
10
+
11
+ ### Fixed
12
+
13
+ - Synced the upstream final-output fix so multi-part assistant responses use the last non-empty text part as the subagent's final output.
14
+
5
15
  ## [0.8.24-alpha.2] - 2026-06-03
6
16
 
7
17
  ### Changed
@@ -250,7 +250,7 @@ Skip this section until you want exact syntax.
250
250
  | `/run <agent> [task]` | Run one agent; omit the task for self-contained agents |
251
251
  | `/chain agent1 "task1" -> agent2 "task2"` | Run agents in sequence |
252
252
  | `/parallel agent1 "task1" -> agent2 "task2"` | Run agents in parallel |
253
- | `/run-chain <chainName> -- <task>` | Launch a saved `.chain.md` workflow |
253
+ | `/run-chain <chainName> -- <task>` | Launch a saved `.chain.md` or `.chain.json` workflow |
254
254
  | `/subagents-doctor` | Show read-only setup diagnostics |
255
255
 
256
256
  Commands validate agent names locally, support tab completion, and send results back into the conversation.
@@ -494,14 +494,14 @@ When `extensions` is present, it takes precedence over extension paths implied b
494
494
 
495
495
  ## Chain files
496
496
 
497
- Chains are reusable `.chain.md` workflows stored separately from agent files.
497
+ Chains are reusable workflows stored separately from agent files. Use `.chain.md` for simple sequential saved chains. Use `.chain.json` when a chain needs dynamic fanout.
498
498
 
499
499
  | Scope | Path |
500
500
  |-------|------|
501
- | User | `~/.atomic/agent/chains/**/*.chain.md` |
502
- | Project | `.atomic/chains/**/*.chain.md` |
501
+ | User | `~/.atomic/agent/chains/**/*.chain.md`, `~/.atomic/agent/chains/**/*.chain.json` |
502
+ | Project | `.atomic/chains/**/*.chain.md`, `.atomic/chains/**/*.chain.json` |
503
503
 
504
- Nested subdirectories are discovered recursively. If user and project scopes define the same parsed runtime chain name, the project chain wins. Chains support the same optional `package` frontmatter as agents; `name: review-flow` plus `package: code-analysis` runs as `code-analysis.review-flow`.
504
+ Nested subdirectories are discovered recursively. If both `.chain.md` and `.chain.json` define the same parsed runtime chain name in the same scope, `.chain.json` wins. If user and project scopes define the same parsed runtime chain name, the project chain wins. Chains support the same optional `package` frontmatter as agents; `name: review-flow` plus `package: code-analysis` runs as `code-analysis.review-flow`.
505
505
 
506
506
  Example:
507
507
 
@@ -512,23 +512,67 @@ description: Gather context then plan implementation
512
512
  ---
513
513
 
514
514
  ## scout
515
+ phase: Context
516
+ label: Map auth flow
517
+ as: context
515
518
  output: context.md
516
519
 
517
520
  Analyze the codebase for {task}
518
521
 
519
522
  ## planner
523
+ phase: Planning
524
+ label: Implementation plan
520
525
  reads: context.md
521
526
  model: anthropic/claude-sonnet-4-5:high
522
527
  progress: true
523
528
 
524
- Create an implementation plan based on {previous}
529
+ Create an implementation plan based on {outputs.context}
525
530
  ```
526
531
 
527
- Each `## agent-name` section is a step. Config lines such as `output`, `outputMode`, `reads`, `model`, `skills`, and `progress` go immediately after the header. A blank line separates config from task text.
532
+ Each `.chain.md` `## agent-name` section is a step. Config lines such as `phase`, `label`, `as`, `outputSchema`, `output`, `outputMode`, `reads`, `model`, `skills`, and `progress` go immediately after the header. A blank line separates config from task text. In saved `.chain.md` files, `outputSchema` is a path to a JSON Schema file; direct tool calls and `.chain.json` files can pass the schema object inline.
528
533
 
529
534
  For `output`, `reads`, `skills`, and `progress`, chain behavior is three-state: omitted inherits from the agent, a value overrides, and `false` disables.
530
535
 
531
- Create chains by writing `.chain.md` files directly or with the `subagent({ action: "create", config: ... })` management action. Run them with natural language or:
536
+ Use `phase` to group related work in status output, `label` for a readable step name, and `as` to store a successful step or parallel task result for later `{outputs.name}` references. Duplicate `as` names, invalid identifiers, and unknown output references fail before child execution.
537
+
538
+ Dynamic fanout is available only through direct `subagent({ chain: [...] })` JSON or saved `.chain.json` files. It expands an array from a prior structured named output, runs one child template per item, and stores the ordered collection under `collect.as`. The source must be structured output; prose is never parsed. `expand.maxItems` is required, over-limit arrays fail, nested fanout and arbitrary expressions are not supported, and `.chain.md` has no dynamic syntax in this release.
539
+
540
+ ```json
541
+ {
542
+ "name": "dynamic-review",
543
+ "description": "Find review targets, fan out reviewers, then synthesize.",
544
+ "chain": [
545
+ {
546
+ "agent": "scout",
547
+ "task": "Return {\"items\":[{\"path\":\"...\",\"reason\":\"...\"}]} via structured_output.",
548
+ "as": "targets",
549
+ "outputSchema": { "type": "object" }
550
+ },
551
+ {
552
+ "expand": {
553
+ "from": { "output": "targets", "path": "/items" },
554
+ "item": "target",
555
+ "key": "/path",
556
+ "maxItems": 12
557
+ },
558
+ "parallel": {
559
+ "agent": "reviewer",
560
+ "label": "Review {target.path}",
561
+ "task": "Review {target.path}. Reason: {target.reason}",
562
+ "outputSchema": { "type": "object" }
563
+ },
564
+ "collect": { "as": "reviews" },
565
+ "concurrency": 4
566
+ },
567
+ {
568
+ "agent": "worker",
569
+ "task": "Synthesize fixes from {outputs.reviews}"
570
+ }
571
+ ]
572
+ }
573
+ ```
574
+
575
+ Create simple `.chain.md` chains by writing files directly or with the `subagent({ action: "create", config: ... })` management action. Create dynamic `.chain.json` chains by writing the JSON file directly. Run saved chains with natural language or:
532
576
 
533
577
  ```text
534
578
  /run-chain scout-planner -- refactor authentication
@@ -543,6 +587,7 @@ Task templates support:
543
587
  | `{task}` | Original task from the first step. |
544
588
  | `{previous}` | Output from the prior step, or aggregated output from a parallel step. |
545
589
  | `{chain_dir}` | Path to the chain artifact directory. |
590
+ | `{outputs.name}` | Text value from a prior step or completed parallel task with `as: "name"`. |
546
591
 
547
592
  Parallel outputs are aggregated with clear separators before being passed to the next step:
548
593
 
@@ -638,14 +683,49 @@ These are the parameters the LLM passes when it calls the `subagent` tool. Most
638
683
 
639
684
  // Chain with fan-out/fan-in
640
685
  { chain: [
641
- { agent: "scout", task: "Gather context" },
686
+ { agent: "scout", task: "Gather context", phase: "Context", label: "Map code", as: "context" },
642
687
  { parallel: [
643
- { agent: "worker", task: "Implement feature A from {previous}" },
644
- { agent: "worker", task: "Implement feature B from {previous}" }
688
+ { agent: "worker", task: "Implement feature A from {outputs.context}", label: "Feature A", as: "featureA" },
689
+ { agent: "worker", task: "Implement feature B from {outputs.context}", label: "Feature B", as: "featureB" }
645
690
  ], concurrency: 2, failFast: true },
646
- { agent: "reviewer", task: "Review all changes from {previous}" }
691
+ { agent: "reviewer", task: "Review {outputs.featureA} and {outputs.featureB}" }
647
692
  ]}
648
693
 
694
+ // Dynamic fanout from structured output
695
+ { chain: [
696
+ {
697
+ agent: "scout",
698
+ task: "Return review targets as structured_output: { items: [{ path, reason }] }",
699
+ as: "targets",
700
+ outputSchema: { type: "object" }
701
+ },
702
+ {
703
+ expand: { from: { output: "targets", path: "/items" }, item: "target", key: "/path", maxItems: 12 },
704
+ parallel: { agent: "reviewer", task: "Review {target.path}. Reason: {target.reason}", outputSchema: { type: "object" } },
705
+ collect: { as: "reviews" },
706
+ concurrency: 4
707
+ },
708
+ { agent: "worker", task: "Synthesize fixes from {outputs.reviews}" }
709
+ ] }
710
+
711
+ // Strict structured output for reliable handoff data
712
+ { chain: [
713
+ {
714
+ agent: "scout",
715
+ task: "Return the key files and risks for {task}",
716
+ as: "scan",
717
+ outputSchema: {
718
+ type: "object",
719
+ required: ["files", "risks"],
720
+ properties: {
721
+ files: { type: "array", items: { type: "string" } },
722
+ risks: { type: "array", items: { type: "string" } }
723
+ }
724
+ }
725
+ },
726
+ { agent: "planner", task: "Plan from this scan: {outputs.scan}" }
727
+ ] }
728
+
649
729
  // Worktree isolation
650
730
  { tasks: [
651
731
  { agent: "worker", task: "Implement auth" },
@@ -715,10 +795,10 @@ Agent definitions are not loaded into context by default. Management actions let
715
795
  | `outputMode` | `"inline" \| "file-only"` | `inline` | Return saved output inline or as a concise saved-file reference. `file-only` requires an `output` path. |
716
796
  | `skill` | `string \| string[] \| false` | agent default | Override skills or disable all. |
717
797
  | `model` | string | agent default | Override model. |
718
- | `tasks` | array | - | Top-level parallel tasks. Supports `agent`, `task`, `cwd`, `count`, `output`, `outputMode`, `reads`, `progress`, `skill`, and `model`. |
798
+ | `tasks` | array | - | Top-level parallel tasks. Supports `agent`, `task`, `cwd`, `count`, `output`, `outputMode`, `reads`, `progress`, `skill`, `model`, and `acceptance`. |
719
799
  | `concurrency` | number | config or `4` | Top-level parallel concurrency. |
720
800
  | `worktree` | boolean | false | Create isolated git worktrees for parallel tasks. |
721
- | `chain` | array | - | Sequential and parallel chain steps. |
801
+ | `chain` | array | - | Sequential, static parallel, and dynamic fanout chain steps. Steps and chain parallel tasks support `phase`, `label`, `as`, `outputSchema`, and `acceptance` in addition to the usual execution fields. Dynamic fanout uses `expand`, one child `parallel` template, and `collect`. |
722
802
  | `context` | `fresh \| fork` | agent default or `fresh` | `fork` creates real branched sessions from the parent leaf. Packaged `planner`, `worker`, and `oracle` default to `fork`. |
723
803
  | `chainDir` | string | temp chain dir | Persistent directory for chain artifacts. |
724
804
  | `clarify` | boolean | true for chains | Show TUI preview/edit flow. |
@@ -730,12 +810,13 @@ Agent definitions are not loaded into context by default. Management actions let
730
810
  | `includeProgress` | boolean | false | Include full progress in result. |
731
811
  | `share` | boolean | false | Upload session export to GitHub Gist. |
732
812
  | `sessionDir` | string | derived | Override session log directory. |
813
+ | `acceptance` | string/object/false | inferred | Override the run's inferred acceptance gates. Use `"auto"`, `"attested"`, `"checked"`, `"verified"`, `"reviewed"`, or `{ level: "none", reason: "..." }`. |
733
814
 
734
815
  `context: "fork"` fails fast when the parent session is not persisted, the current leaf is missing, or the branched child session cannot be created. It never silently downgrades to `fresh`. In multi-agent runs, if any requested agent has `defaultContext: fork` and the launch omits `context`, the whole invocation uses forked context; pass `context: "fresh"` when you intentionally want a fresh run.
735
816
 
736
817
  Use `outputMode: "file-only"` when a saved output may be large and the parent only needs a pointer. The returned text is a compact reference like `Output saved to: /abs/report.md (48.2 KB, 2847 lines). Read this file if needed.` Failed runs and save errors still return normal inline output for debugging. In chains, later `{previous}` steps receive the same compact reference when the prior step used file-only mode.
737
818
 
738
- Sequential and parallel chain tasks accept `agent`, `task`, `cwd`, `output`, `outputMode`, `reads`, `progress`, `skill`, and `model`. Parallel tasks also accept `count`. Parallel step groups accept `parallel`, `concurrency`, `failFast`, and `worktree`.
819
+ Sequential and parallel chain tasks accept `agent`, `task`, `phase`, `label`, `as`, `outputSchema`, `cwd`, `output`, `outputMode`, `reads`, `progress`, `skill`, and `model`. Parallel tasks also accept `count`. Parallel step groups accept `parallel`, `concurrency`, `failFast`, and `worktree`. If `outputSchema` is present, the child must call `structured_output` with schema-valid JSON; prose-only completion or invalid JSON fails the step. Validated structured values are preserved on the step result, and `as` also exposes a compact text representation through `{outputs.name}`.
739
820
 
740
821
  Status and control actions:
741
822
 
@@ -905,13 +986,43 @@ Async runs write:
905
986
 
906
987
  `status.json` powers the widget and `subagent({ action: "status" })` output. `events.jsonl` contains wrapper events plus child Pi JSON events annotated with run and step metadata. `output-<n>.log` is a live human-readable tail. Fallback information is persisted so background runs are debuggable after completion.
907
988
 
989
+ ## Acceptance Gates
990
+
991
+ Every run resolves an effective acceptance policy. Callers may omit `acceptance` for the inferred default, or set it on single runs, top-level parallel task items, chain steps, static parallel tasks, and dynamic fanout templates.
992
+
993
+ ```ts
994
+ {
995
+ agent: "worker",
996
+ task: "Implement the fix",
997
+ acceptance: {
998
+ level: "verified",
999
+ criteria: ["Patch the bug without widening scope"],
1000
+ evidence: ["changed-files", "tests-added", "commands-run", "residual-risks", "no-staged-files"],
1001
+ verify: [{ id: "focused", command: "npm test", timeoutMs: 120000 }]
1002
+ }
1003
+ }
1004
+ ```
1005
+
1006
+ Accepted levels are `auto`, `none`, `attested`, `checked`, `verified`, and `reviewed`. `acceptance: "auto"` is the default. Read-only reviewer/scout tasks infer lightweight attestation, normal writer tasks infer checked evidence, and async/risky/dynamic writer contexts infer a reviewed gate. To disable gates, prefer `{ level: "none", reason: "..." }`.
1007
+
1008
+ Acceptance provenance is stored separately from child prose:
1009
+
1010
+ - `claimed`: child finished but did not provide structured evidence.
1011
+ - `attested`: child returned a structured acceptance report.
1012
+ - `checked`: runtime structural checks passed, such as required evidence and no staged files.
1013
+ - `verified`: configured runtime verification commands passed. Child-reported command success does not count.
1014
+ - `reviewed`: an independent reviewer result is present.
1015
+ - `rejected`: attestation, structural checks, verification, or review failed.
1016
+
1017
+ For `attested` or stricter levels, the child prompt includes a standardized acceptance section and asks for a fenced `acceptance-report` JSON block. Explicit failed gates fail the run. Inferred gates are persisted for observability without breaking older calls that omit `acceptance`.
1018
+
908
1019
  ## Live progress
909
1020
 
910
- Foreground runs show compact live progress for single, chain, and parallel modes: current tool, recent output, token counts, duration, activity freshness, and current-tool duration.
1021
+ Foreground runs show compact live progress for single, chain, and parallel modes: current tool, recent output, token counts, duration, activity freshness, current-tool duration, and chain graph metadata when available.
911
1022
 
912
1023
  Press `CTRL+O` to expand the full streaming view with complete output per step.
913
1024
 
914
- Sequential chains show a flow line like `done scout → running planner`. Chains with parallel steps show per-step cards instead.
1025
+ Sequential chains show a flow line like `done scout → running planner`. Chains with parallel steps show per-step cards instead. Chain status uses `label` and `phase` metadata when present, while falling back to agent names for older chains.
915
1026
 
916
1027
  ## Session sharing
917
1028
 
@@ -936,12 +1047,12 @@ Configure the limit with:
936
1047
  3. `maxSubagentDepth` in agent frontmatter, which can only tighten the inherited limit
937
1048
 
938
1049
  ```bash
939
- export PI_SUBAGENT_MAX_DEPTH=3
940
- export PI_SUBAGENT_MAX_DEPTH=1
941
- export PI_SUBAGENT_MAX_DEPTH=0
1050
+ export ATOMIC_SUBAGENT_MAX_DEPTH=3
1051
+ export ATOMIC_SUBAGENT_MAX_DEPTH=1
1052
+ export ATOMIC_SUBAGENT_MAX_DEPTH=0
942
1053
  ```
943
1054
 
944
- `PI_SUBAGENT_DEPTH` is internal and propagated automatically. Do not set it manually.
1055
+ `ATOMIC_SUBAGENT_DEPTH` is internal and propagated automatically. Do not set it manually. Legacy `PI_SUBAGENT_MAX_DEPTH` and `PI_SUBAGENT_DEPTH` are still read for compatibility.
945
1056
 
946
1057
  ## Events
947
1058
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bastani/subagents",
3
- "version": "0.8.24-alpha.2",
3
+ "version": "0.8.24-alpha.3",
4
4
  "private": true,
5
5
  "description": "Atomic extension for delegating tasks to subagents with chains, parallel execution, and TUI clarification. Fork of: https://github.com/nicobailon/pi-subagents",
6
6
  "contributors": [
@@ -4,14 +4,16 @@ description: Parallel codebase specialists building handoff context for planning
4
4
 
5
5
  Launch fresh-context codebase specialists in parallel to build grounded handoff context for planning or implementation.
6
6
 
7
- Use the `subagent` tool in chain mode with a single parallel step, not top-level parallel tasks, so relative output files live under the temporary chain directory. Use `context: "fresh"` unless I explicitly ask for forked context. Give every parallel task a distinct `output` path, for example:
7
+ Use the `subagent` tool in chain mode with a single parallel step, not top-level parallel tasks, so relative output files live under the temporary chain directory. Use `context: "fresh"` unless I explicitly ask for forked context. Give every parallel task a distinct `output` path, `label`, and `as` name, for example:
8
8
 
9
9
  - `context-build/where-it-lives.md`
10
10
  - `context-build/how-it-works.md`
11
11
  - `context-build/existing-patterns.md`
12
12
  - `context-build/prior-research.md`
13
13
 
14
- Do not write these artifacts into the repository unless I explicitly ask for persistent files.
14
+ Use one phase such as `phase: "Context build"` for the parallel tasks so async status is readable. A later synthesis step can reference specific outputs with `{outputs.requestScope}`, `{outputs.codebasePatterns}`, and `{outputs.validationRisks}` instead of relying only on `{previous}`.
15
+
16
+ Do not write these context artifacts into the repository unless I explicitly ask for persistent files.
15
17
 
16
18
  Treat the slash command arguments as the primary request, target, or focus:
17
19
 
@@ -20,7 +20,7 @@ Parallel discovery step. Choose the specialists that apply:
20
20
  - `codebase-pattern-finder` — add when transferable conventions or analogous implementations would shape the plan.
21
21
  - `codebase-research-locator` and `codebase-research-analyzer` — add when prior `research/` or `specs/` docs likely apply. Run them sequentially (locator first, then analyzer) or pair them inside the parallel step with distinct output paths.
22
22
 
23
- Use distinct output paths under the chain directory. Example outputs:
23
+ Use distinct output paths, `label` values, and `as` names under the chain directory. Example outputs:
24
24
 
25
25
  - `handoff/external-reference.md`
26
26
  - `handoff/local-files.md`
@@ -28,6 +28,8 @@ Use distinct output paths under the chain directory. Example outputs:
28
28
  - `handoff/local-patterns.md`
29
29
  - `handoff/prior-research.md`
30
30
 
31
+ Use phases such as `Research`, `Local context`, and `Synthesis` so async status is readable. Prefer `{outputs.externalReference}`, `{outputs.localContext}`, and `{outputs.implementationStrategy}` in the synthesis task when those specific inputs are available; keep `{previous}` only when the whole parallel fan-in summary is the desired input.
32
+
31
33
  Do not write these artifacts into the repository unless I explicitly ask for persistent files.
32
34
 
33
35
  Role guidance:
@@ -35,7 +35,7 @@ Humans often use the slash-command layer instead:
35
35
  - `/run` — launch a single agent
36
36
  - `/chain` — launch a chain of steps
37
37
  - `/parallel` — launch top-level parallel tasks
38
- - `/run-chain` — launch a saved `.chain.md` workflow
38
+ - `/run-chain` — launch a saved `.chain.md` or `.chain.json` workflow
39
39
  - `/subagents-doctor` — diagnose setup, discovery, async paths, and intercom bridge state
40
40
 
41
41
  Prefer the tool when you are writing agent logic. Prefer the slash commands when you are guiding a human through an interactive flow.
@@ -112,7 +112,40 @@ Use this at the start of non-trivial work. Launch `codebase-locator` and `codeba
112
112
 
113
113
  ### Parallel cleanup technique
114
114
 
115
- 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. 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 async `code-simplifier` writer with the synthesized fixes as its explicit scope.
115
+ 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 async `code-simplifier` writer with the synthesized fixes as its explicit scope.
116
+
117
+ ### Staged fix orchestration technique
118
+
119
+ Use this when a broad diff has known reviewer findings across several items and the user wants the parent to coordinate a safe multi-stage fix. Keep the active worktree safe with a three-stage chain:
120
+
121
+ 1. A parallel read-only planning fanout, one specialist per issue cluster. Use `codebase-analyzer`, `debugger` in inspect-only mode, or `codebase-pattern-finder` based on the angle. Each child inspects the real diff and returns exact files, line refs, proposed fixes, and focused validation. They must not edit.
122
+ 2. One writer worker (`debugger` for correctness fixes or `code-simplifier` for cleanup fixes). It receives the planner summaries through `{previous}` or named `{outputs.name}` values, the parent’s accepted scope, stop rules, and verification contract. It is the only child allowed to edit the active worktree.
123
+ 3. A parallel read-only validation fanout. Validators inspect the worker diff from fresh context with distinct angles, report pass/fail, remaining blockers, and missing verification.
124
+
125
+ Prefer `async: true`, `context: "fresh"` for planners/validators, `outputMode: "file-only"` for large summaries, and per-stage output names that will not collide. Add `phase` and `label` to make async status readable, and use `as` plus `{outputs.name}` when a later step needs a specific earlier result instead of the whole `{previous}` blob. Use this pattern instead of launching several writer workers into a dirty worktree. Include non-blocking suggestions in the writer prompt only when they are small, safe, and do not expand product scope; otherwise record them as deferred.
126
+
127
+ When the first step can return a structured target list, prefer dynamic fanout instead of hand-authoring a static parallel group. Use `outputSchema` and `as` on the producer, then an `expand` step with `from: { output, path }`, an explicit `maxItems`, one `parallel` child template, and `collect.as`. Item templates may use `{item}` or a named item such as `{target.path}`. Do not use dynamic fanout for prose outputs, nested fanout, dynamic agent selection, reducers, `when` conditions, or arbitrary expressions; `.chain.md` does not support this syntax, so use direct JSON or a saved `.chain.json`.
128
+
129
+ Example shape:
130
+
131
+ ```typescript
132
+ subagent({
133
+ async: true,
134
+ context: "fresh",
135
+ chain: [
136
+ { parallel: [
137
+ { agent: "codebase-analyzer", phase: "Planning", label: "Deploy docs", as: "deployPlan", task: "Plan fixes for deploy docs/workflow. Inspect the current diff. Do not modify project/source files; returning findings via the configured output artifact is allowed.", output: "plans/deploy.md", outputMode: "file-only" },
138
+ { agent: "debugger", phase: "Planning", label: "Scheduler contract", as: "schedulerPlan", task: "Inspect-only plan for scheduler contract fixes. Do not edit. Return exact fixes and focused validation.", output: "plans/scheduler.md", outputMode: "file-only" },
139
+ { agent: "codebase-pattern-finder", phase: "Planning", label: "Sandbox patterns", as: "sandboxPlan", task: "Find existing patterns relevant to sandbox/security fixes. Do not edit.", output: "plans/sandbox.md", outputMode: "file-only" }
140
+ ], concurrency: 3 },
141
+ { agent: "debugger", phase: "Implementation", label: "Apply accepted fixes", as: "workerResult", task: "Apply only the accepted fixes from these planning summaries. You are the sole writer for the active worktree. Run focused validation and report changed files, commands, failures, and remaining issues.\n\nDeploy plan:\n{outputs.deployPlan}\n\nScheduler plan:\n{outputs.schedulerPlan}\n\nSandbox plan:\n{outputs.sandboxPlan}", output: "worker/fixes.md", outputMode: "file-only", progress: true },
142
+ { parallel: [
143
+ { agent: "codebase-analyzer", phase: "Validation", label: "Deploy/scheduler validation", task: "Validate the post-worker diff for deploy and scheduler fixes. Start from the worker result: {outputs.workerResult}. Do not modify project/source files; returning findings via the configured output artifact is allowed.", output: "validation/deploy-scheduler.md", outputMode: "file-only" },
144
+ { agent: "debugger", phase: "Validation", label: "Failure-mode validation", task: "Inspect-only failure-mode hunt on the post-worker diff. Start from the worker result: {outputs.workerResult}. Do not edit.", output: "validation/failure-modes.md", outputMode: "file-only" }
145
+ ], concurrency: 2 }
146
+ ]
147
+ })
148
+ ```
116
149
 
117
150
  ## Builtin Agents
118
151
 
@@ -189,11 +222,10 @@ Agent files can live in:
189
222
  - legacy `.agents/**/*.md` and `.pi/agents/**/*.md` — still read for compatibility, but `.atomic/agents/` wins on conflicts
190
223
 
191
224
  Chains live in:
225
+ - `~/.atomic/agent/chains/**/*.chain.md` and `~/.atomic/agent/chains/**/*.chain.json` — user scope
226
+ - `.atomic/chains/**/*.chain.md` and `.atomic/chains/**/*.chain.json` — project scope
192
227
 
193
- - `~/.atomic/agent/chains/**/*.chain.md` user scope
194
- - `.atomic/chains/**/*.chain.md` — project scope
195
-
196
- Discovery is recursive. `.chain.md` files do not define agents. Agents and chains can set optional frontmatter `package: code-analysis`; `name: codebase-analyzer` plus `package: code-analysis` registers as runtime name `code-analysis.codebase-analyzer` while serialization keeps `name` and `package` separate.
228
+ Discovery is recursive. `.chain.md` files do not define agents. Use `.chain.md` for simple saved chains and `.chain.json` for dynamic fanout or inline schema objects. Agents and chains can set optional frontmatter/package metadata; `name: codebase-analyzer` plus `package: code-analysis` registers as runtime name `code-analysis.codebase-analyzer` while serialization keeps `name` and `package` separate.
197
229
 
198
230
  Precedence is by parsed runtime name:
199
231
 
@@ -264,7 +296,7 @@ subagent({
264
296
  })
265
297
  ```
266
298
 
267
- Chain steps can use templated variables such as `{task}`, `{previous}`, and `{chain_dir}`. This is the main way to pass structured summaries between steps without forcing each step to rediscover everything.
299
+ Chain steps can use templated variables such as `{task}`, `{previous}`, `{chain_dir}`, and `{outputs.name}`. Use `as: "name"` on a successful step or parallel task to make that output available to later steps. Prefer named outputs when a later step needs one specific result; keep `{previous}` for simple linear handoffs or full fan-in summaries. Use `phase` and `label` for status readability. Use `outputSchema` when later steps need reliable structured data; the child must call `structured_output` with schema-valid JSON, or the step fails.
268
300
 
269
301
  ### Async/background
270
302
 
@@ -599,7 +631,9 @@ For feature work, use this sequence as scaffolding for parent-agent behavior:
599
631
  clarify → validation contract → parallel discovery → async writer (debugger or code-simplifier) → parallel async fresh-context specialist reviewers → async fix writer → follow-up review when warranted → parent review
600
632
  ```
601
633
 
602
- The validation contract defines what done means before code is written: expected behavior, acceptance checks, commands or user flows to exercise, and evidence the writer should return. Keep it lightweight for small tasks, but make it explicit enough that reviewers are checking the intended outcome rather than the writer's own assumptions.
634
+ The validation contract defines acceptance before code is written: expected behavior, acceptance checks, commands or user flows to exercise, and evidence the writer should return. Keep it lightweight for small tasks, but make it explicit enough that reviewers and validators are checking the intended outcome rather than the writers own assumptions.
635
+
636
+ Use the structured `acceptance` field when the run should carry an explicit acceptance contract. If omitted, subagents infer an effective acceptance policy from role, mode, and risk. Use `level: "checked"` for ordinary writer evidence gates, `level: "verified"` when the runtime should run explicit validation commands, and `level: "reviewed"` only when an independent reviewer result is expected. Do not call a run reviewed just because the writer says it is done; reviewed means a reviewer gate returned a result. Child-reported command success is evidence, not runtime verification.
603
637
 
604
638
  The first writer implements the approved change. The parent continues with independent inspection or validation prep while it runs, not parallel edits to the same worktree. When the async writer completes, treat its handoff as the transition into review, not as final completion, unless the user explicitly asked for writer-only work, review-only output, or to stop after implementation. Parallel specialist reviewers inspect the resulting diff from fresh context. The final fix writer applies synthesized review fixes, then the parent looks over the final diff before completing. The parent may launch these steps as an initial async chain when the workflow is already clear, or as follow-up subagent runs after each async completion. Initial chains should pass `async: true` so the main chat is unblocked; avoid `clarify: true` unless the user asked for foreground clarification. Do not stop after parallel review unless the user explicitly asked for review-only output or the review surfaced a decision that needs approval first.
605
639
 
@@ -609,8 +643,8 @@ For very large work, split into serial milestones instead of launching a swarm o
609
643
 
610
644
  Keep orchestration authority in the parent session. Child subagents should not launch more subagents, read this skill, or run their own orchestration loops unless the parent intentionally selected an explicit fanout agent whose resolved builtin `tools` includes `subagent` for that assigned fanout. Spawned non-fanout subagents do not receive the `subagent` skill, parent-only status/control/slash messages, prior parent `subagent` tool-call/tool-result artifacts, or the `subagent` extension tool. Child context filtering also 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, the child must not propose or run subagents unless explicitly authorized for fanout, and writer children must call real edit/write tools instead of printing pseudo tool calls. Pass children concrete role-specific work instead.
611
645
 
612
- 1. Clarify first. Gather code context with `codebase-locator`, `codebase-analyzer`, `codebase-pattern-finder`, and prior research specialists; add `codebase-online-researcher` only when external evidence matters; then ask the user clarifying questions with `interview` until scope, acceptance criteria, constraints, and non-goals are clear.
613
- 2. Define the validation contract. State what done means 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.
646
+ 1. Clarify first. This is mandatory. Gather code context with `codebase-locator`, `codebase-analyzer`, `codebase-pattern-finder`, and prior research specialists; add `codebase-online-researcher` only when external evidence matters; then ask the user clarifying questions with `interview` until scope, acceptance criteria, constraints, and non-goals are clear.
647
+ 2. Define the validation contract. State acceptance 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.
614
648
  3. Plan when useful. For complex work, write a plan doc yourself and get approval before implementation. For simple work, confirm shared understanding and explicitly note why planning is skipped.
615
649
  4. Implement with one writer. After approval, launch `debugger` (for correctness-shaped work) or `code-simplifier` (for refinement-shaped work) asynchronously with a proper meta prompt that includes clarified requirements, relevant context, plan path or summary, the validation contract, and output expectations. While it runs, prepare validation or inspect adjacent code instead of editing the same worktree.
616
650
  5. Require a useful writer handoff. Ask the writer to report changed files, what was implemented, what was left undone, commands run with exit codes, validation evidence, surprises or new risks, decisions made inside approved scope, and decisions needing parent approval.
@@ -625,6 +659,10 @@ Example writer handoff after clarification and optional planning:
625
659
  subagent({
626
660
  agent: "debugger",
627
661
  task: "Implement the approved fix.\n\nClarified requirements:\n- ...\n\nPlan: see ~/Documents/docs/...-plan.md\n\nValidation contract:\n- ...\n\nReturn a handoff with changed files, what was implemented, what was left undone, commands run with exit codes, validation evidence, surprises/new risks, and decisions needing parent approval.",
662
+ acceptance: {
663
+ level: "checked",
664
+ evidence: ["changed-files", "tests-added", "commands-run", "residual-risks", "no-staged-files"]
665
+ },
628
666
  async: true
629
667
  })
630
668
  ```
@@ -679,7 +717,7 @@ subagent({
679
717
  /run-chain review-chain -- review this branch
680
718
  ```
681
719
 
682
- Use saved `.chain.md` workflows when the user wants a repeatable multi-agent flow without rewriting the chain each time.
720
+ Use saved `.chain.md` or `.chain.json` workflows when the user wants a repeatable multi-agent flow without rewriting the chain each time. Prefer `.chain.json` for dynamic fanout or inline `outputSchema` objects; `.chain.md` remains the simple sequential/static authoring format.
683
721
 
684
722
  ## Error Handling
685
723