@bastani/atomic 0.9.15 → 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 (151) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/builtin/intercom/CHANGELOG.md +10 -0
  3. package/dist/builtin/intercom/README.md +8 -8
  4. package/dist/builtin/intercom/contact-supervisor-tool.ts +68 -32
  5. package/dist/builtin/intercom/index-heavy.ts +1 -0
  6. package/dist/builtin/intercom/index.ts +21 -15
  7. package/dist/builtin/intercom/intercom-tool.ts +66 -10
  8. package/dist/builtin/intercom/package.json +1 -1
  9. package/dist/builtin/intercom/parent-ask-handoff.ts +72 -0
  10. package/dist/builtin/mcp/package.json +1 -1
  11. package/dist/builtin/subagents/CHANGELOG.md +26 -0
  12. package/dist/builtin/subagents/README.md +37 -114
  13. package/dist/builtin/subagents/agents/worker.md +2 -2
  14. package/dist/builtin/subagents/package.json +1 -5
  15. package/dist/builtin/subagents/skills/subagent/SKILL.md +26 -103
  16. package/dist/builtin/subagents/src/extension/index.ts +5 -30
  17. package/dist/builtin/subagents/src/extension/notification-content.ts +1 -1
  18. package/dist/builtin/subagents/src/extension/schemas.ts +2 -14
  19. package/dist/builtin/subagents/src/extension/tool-description.ts +1 -4
  20. package/dist/builtin/subagents/src/extension/tool-rendering.ts +53 -0
  21. package/dist/builtin/subagents/src/intercom/intercom-bridge.ts +1 -54
  22. package/dist/builtin/subagents/src/intercom/result-intercom.ts +4 -4
  23. package/dist/builtin/subagents/src/runs/foreground/execution-parent-ask-handoff.ts +78 -0
  24. package/dist/builtin/subagents/src/runs/foreground/inprocess-run-sync.ts +7 -5
  25. package/dist/builtin/subagents/src/runs/foreground/notify.ts +5 -6
  26. package/dist/builtin/subagents/src/runs/foreground/parent-ask-output.ts +48 -0
  27. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-burst-display.ts +46 -0
  28. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-burst.ts +403 -0
  29. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-context.ts +48 -9
  30. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-input.ts +3 -1
  31. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-live-update.ts +11 -0
  32. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel-task.ts +164 -93
  33. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel.ts +36 -29
  34. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parent-ask-projection.ts +11 -0
  35. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-single.ts +42 -17
  36. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-status.ts +3 -121
  37. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-types.ts +7 -2
  38. package/dist/builtin/subagents/src/runs/foreground/subagent-executor.ts +30 -257
  39. package/dist/builtin/subagents/src/runs/inprocess/control-status.ts +0 -34
  40. package/dist/builtin/subagents/src/runs/inprocess/index.ts +0 -12
  41. package/dist/builtin/subagents/src/runs/inprocess/prompt-behavior.ts +1 -1
  42. package/dist/builtin/subagents/src/runs/inprocess/runner.ts +2 -141
  43. package/dist/builtin/subagents/src/runs/shared/parallel-utils.ts +8 -0
  44. package/dist/builtin/subagents/src/shared/status-format.ts +3 -3
  45. package/dist/builtin/subagents/src/shared/types-config.ts +41 -0
  46. package/dist/builtin/subagents/src/shared/types-foreground-state.ts +7 -15
  47. package/dist/builtin/subagents/src/shared/types-results.ts +3 -1
  48. package/dist/builtin/subagents/src/shared/types-runtime.ts +1 -11
  49. package/dist/builtin/subagents/src/slash/slash-commands.ts +4 -468
  50. package/dist/builtin/subagents/src/tui/render-progress.ts +2 -2
  51. package/dist/builtin/subagents/src/tui/render-result-compact.ts +2 -2
  52. package/dist/builtin/subagents/src/tui/render-result.ts +38 -14
  53. package/dist/builtin/subagents/src/tui/render-status-progress.ts +1 -1
  54. package/dist/builtin/web-access/package.json +1 -1
  55. package/dist/builtin/workflows/CHANGELOG.md +16 -0
  56. package/dist/builtin/workflows/README.md +1 -1
  57. package/dist/builtin/workflows/package.json +1 -1
  58. package/dist/builtin/workflows/skills/bro/LICENSE.txt +21 -0
  59. package/dist/builtin/workflows/skills/bro/SKILL.md +14 -0
  60. package/dist/builtin/workflows/skills/how/LICENSE.txt +21 -0
  61. package/dist/builtin/workflows/skills/how/SKILL.md +162 -0
  62. package/dist/builtin/workflows/skills/how/references/critic-prompt.md +59 -0
  63. package/dist/builtin/workflows/skills/how/references/critique-rubric.md +58 -0
  64. package/dist/builtin/workflows/skills/how/references/explainer-prompt.md +55 -0
  65. package/dist/builtin/workflows/skills/how/references/explorer-prompt.md +52 -0
  66. package/dist/builtin/workflows/skills/teach/LICENSE.txt +21 -0
  67. package/dist/builtin/workflows/skills/teach/SKILL.md +28 -0
  68. package/dist/builtin/workflows/skills/unslop/LICENSE.txt +21 -0
  69. package/dist/builtin/workflows/skills/unslop/SKILL.md +87 -0
  70. package/dist/builtin/workflows/skills/why/LICENSE.txt +21 -0
  71. package/dist/builtin/workflows/skills/why/SKILL.md +267 -0
  72. package/dist/builtin/workflows/skills/why/references/epistemics.md +144 -0
  73. package/dist/builtin/workflows/skills/why/references/investigator-prompt.md +103 -0
  74. package/dist/builtin/workflows/skills/why/references/source-playbook.md +17 -0
  75. package/dist/builtin/workflows/skills/why/references/sources/code-archaeology.md +88 -0
  76. package/dist/builtin/workflows/skills/why/references/sources/databricks.md +70 -0
  77. package/dist/builtin/workflows/skills/why/references/sources/datadog.md +99 -0
  78. package/dist/builtin/workflows/skills/why/references/sources/incident-postmortem.md +15 -0
  79. package/dist/builtin/workflows/skills/why/references/sources/linear.md +48 -0
  80. package/dist/builtin/workflows/skills/why/references/sources/notion.md +55 -0
  81. package/dist/builtin/workflows/skills/why/references/sources/sentry.md +100 -0
  82. package/dist/builtin/workflows/skills/why/references/sources/slack.md +54 -0
  83. package/dist/builtin/workflows/skills/why/references/synthesizer-prompt.md +135 -0
  84. package/dist/builtin/workflows/src/durable/dbos-embedded-postgres-root.ts +548 -39
  85. package/dist/builtin/workflows/src/durable/dbos-embedded-postgres.ts +529 -65
  86. package/dist/builtin/workflows/src/durable/dbos-lifecycle.ts +30 -8
  87. package/dist/builtin/workflows/src/durable/dbos-local-postgres.ts +36 -3
  88. package/dist/builtin/workflows/src/durable/local-command.ts +68 -10
  89. package/dist/builtin/workflows/src/extension/companions.ts +1 -1
  90. package/dist/builtin/workflows/src/extension/dispatcher.ts +7 -1
  91. package/dist/builtin/workflows/src/extension/extension-factory.ts +2 -2
  92. package/dist/builtin/workflows/src/extension/index.bundle.mjs +1094 -298
  93. package/dist/builtin/workflows/src/extension/public-types.ts +2 -2
  94. package/dist/builtin/workflows/src/extension/render-result.ts +16 -2
  95. package/dist/builtin/workflows/src/extension/runtime.ts +8 -1
  96. package/dist/builtin/workflows/src/extension/workflow-request-abort.ts +15 -0
  97. package/dist/builtin/workflows/src/extension/workflow-tool-content.ts +4 -3
  98. package/dist/builtin/workflows/src/extension/workflow-tool-registration.ts +107 -13
  99. package/dist/builtin/workflows/src/extension/workflow-tool.ts +22 -12
  100. package/dist/builtin/workflows/src/tui/widget.ts +25 -6
  101. package/dist/core/agent-session-auto-compaction.js +10 -10
  102. package/dist/core/agent-session-auto-compaction.js.map +1 -1
  103. package/dist/core/agent-session-events.d.ts.map +1 -1
  104. package/dist/core/agent-session-events.js +11 -13
  105. package/dist/core/agent-session-events.js.map +1 -1
  106. package/dist/core/agent-session-methods.d.ts +1 -1
  107. package/dist/core/agent-session-methods.d.ts.map +1 -1
  108. package/dist/core/agent-session-methods.js.map +1 -1
  109. package/dist/core/agent-session-models.d.ts.map +1 -1
  110. package/dist/core/agent-session-models.js +5 -7
  111. package/dist/core/agent-session-models.js.map +1 -1
  112. package/dist/core/agent-session-prompt.js +4 -4
  113. package/dist/core/agent-session-prompt.js.map +1 -1
  114. package/dist/core/agent-session-retry.d.ts +4 -4
  115. package/dist/core/agent-session-retry.d.ts.map +1 -1
  116. package/dist/core/agent-session-retry.js +8 -34
  117. package/dist/core/agent-session-retry.js.map +1 -1
  118. package/dist/core/agent-session-tool-hooks.js +4 -4
  119. package/dist/core/agent-session-tool-hooks.js.map +1 -1
  120. package/dist/core/atomic-guide-command.d.ts.map +1 -1
  121. package/dist/core/atomic-guide-command.js +3 -10
  122. package/dist/core/atomic-guide-command.js.map +1 -1
  123. package/dist/core/event-bus.d.ts.map +1 -1
  124. package/dist/core/event-bus.js +19 -3
  125. package/dist/core/event-bus.js.map +1 -1
  126. package/dist/core/slash-commands.d.ts.map +1 -1
  127. package/dist/core/slash-commands.js +0 -3
  128. package/dist/core/slash-commands.js.map +1 -1
  129. package/dist/core/system-prompt.d.ts.map +1 -1
  130. package/dist/core/system-prompt.js +0 -12
  131. package/dist/core/system-prompt.js.map +1 -1
  132. package/dist/modes/interactive-engine/remote-command-catalog.d.ts +1 -1
  133. package/dist/modes/interactive-engine/remote-command-catalog.js +1 -1
  134. package/dist/modes/interactive-engine/remote-command-catalog.js.map +1 -1
  135. package/docs/intercom.md +29 -27
  136. package/docs/settings.md +2 -2
  137. package/docs/subagents.md +18 -15
  138. package/docs/usage.md +0 -9
  139. package/docs/workflows.md +27 -10
  140. package/npm-shrinkwrap.json +32 -32
  141. package/package.json +3 -3
  142. package/dist/builtin/subagents/prompts/gather-context-and-clarify.md +0 -27
  143. package/dist/builtin/subagents/prompts/parallel-cleanup.md +0 -61
  144. package/dist/builtin/subagents/prompts/parallel-context-build.md +0 -43
  145. package/dist/builtin/subagents/prompts/parallel-handoff-plan.md +0 -47
  146. package/dist/builtin/subagents/prompts/parallel-research.md +0 -34
  147. package/dist/builtin/subagents/prompts/parallel-review.md +0 -47
  148. package/dist/builtin/subagents/prompts/review-loop.md +0 -39
  149. package/dist/builtin/subagents/src/extension/doctor.ts +0 -188
  150. package/dist/builtin/subagents/src/runs/inprocess/attempt-handles.ts +0 -104
  151. /package/dist/builtin/subagents/src/runs/foreground/{subagent-executor-resume.ts → subagent-executor-cwd.ts} +0 -0
@@ -1,47 +0,0 @@
1
- ---
2
- description: Parallel external + local research builders into an implementation handoff plan
3
- ---
4
-
5
- ## Goal
6
-
7
- Produce a grounded implementation handoff plan and implementation-ready meta-prompt by comparing applicable external evidence, local behavior, established patterns, and prior decisions.
8
-
9
- Primary request, target, or focus:
10
-
11
- $@
12
-
13
- ## Constraints and tools
14
-
15
- First read or fetch every URL, issue, PR, screenshot, plan, doc, or local file named in the request; these define primary scope. Use a top-level parallel call with `context: "fresh"` unless I explicitly request forked context, then synthesize parent-side rather than launching a synthesizer subagent.
16
-
17
- Choose specialists by evidence need:
18
-
19
- - Use `codebase-online-researcher` when external projects, libraries, docs, APIs, recent changes, or best practices could shape the plan. It should inspect linked projects, docs, issues, examples, source, or prompt guidance; identify behavior, APIs, implementation files, constraints, and transferable ideas; use `fetch_content` first, then `/llms.txt`, then `Accept: text/markdown`, and fall back to `playwright-cli` only for required JS or auth; persist high-value sources to `research/web/<YYYY-MM-DD>-<topic>.md`; and return links, repo paths, evidence, risks, and implementation implications.
20
- - Use `codebase-locator` for non-trivial code changes to map relevant local files, tests, fixtures, and configs by purpose.
21
- - Use `codebase-analyzer` when local behavior matters to trace the located implementation, control flow, transformations, and constraints with `file:line` citations. Locator and analyzer cover where the work lives and how it works without overlap.
22
- - Add `codebase-pattern-finder` when analogous implementations or conventions could shape the plan; include useful snippets with `file:line` references.
23
- - Add `codebase-research-locator` then `codebase-research-analyzer` when prior `research/` or `specs/` may apply. The locator finds relevant dated docs; the analyzer extracts current decisions, constraints, and lessons while flagging superseded guidance. Run them sequentially, or pair them in the parallel step with distinct outputs when the dependency is already resolved.
24
-
25
- Give tasks distinct `output` paths, for example:
26
-
27
- - `handoff/external-reference.md`
28
- - `handoff/local-files.md`
29
- - `handoff/local-flow.md`
30
- - `handoff/local-patterns.md`
31
- - `handoff/prior-research.md`
32
-
33
- In synthesis, use the saved task outputs when available. Do not persist these artifacts in the repository unless I explicitly request it.
34
-
35
- Delegate only independent work too large for a handful of tool calls; do not delegate auditing your own work, and prefer one subagent over several. Parallelize independent reads; stay sequential when one result determines the next; synthesize after retrieval. Keep work within the requested scope.
36
-
37
- ## Output
38
-
39
- Compare external evidence with local architecture and write `handoff/final-handoff-plan.md` yourself, or summarize inline when no persisted artifact was requested. The downstream writer needs roughly 700–1,200 words covering: intended behavior; lessons from external references; local implications; recommended approach; likely files; constraints and non-goals; edge cases, validation commands, risks, and approval decisions; unresolved questions; and a compact implementation-ready meta-prompt.
40
-
41
- Then give the user a concise summary with the recommendation, artifact paths, final meta-prompt, and remaining questions or assumptions. Lead with the outcome; keep facts, decisions, caveats, and next steps; drop background and repetition; stay readable rather than compressed into fragments.
42
-
43
- Before reporting progress, audit each claim against a tool result from this session. Report only work you can point to evidence for; say so explicitly when something is unverified.
44
-
45
- ## Stop rule
46
-
47
- Done means discovery evidence has been compared, the final handoff exists at the requested destination or inline, and the user has the recommendation, paths, meta-prompt, and unresolved decisions. Do not start implementation unless I explicitly ask.
@@ -1,34 +0,0 @@
1
- ---
2
- description: Parallel research specialists for grounded answers
3
- ---
4
-
5
- ## Goal
6
-
7
- Build a grounded answer to the current question or decision from distinct external, local, convention, or prior-decision evidence.
8
-
9
- Primary question or focus:
10
-
11
- $@
12
-
13
- ## Constraints and tools
14
-
15
- Use fresh context unless I explicitly request forked context; specialists inspect sources directly rather than relying on the main conversation. Choose two or three strong specialists with distinct applicable angles, using my specified angles when provided:
16
-
17
- - **External evidence — `codebase-online-researcher`:** current authoritative sources such as official docs, standards, release notes, benchmarks, issue threads, and primary explanations.
18
- - **Local context — `codebase-locator` and/or `codebase-analyzer`:** relevant repository files and how they work, with `file:line` references.
19
- - **Local conventions — `codebase-pattern-finder`:** analogous implementations and patterns the answer should respect.
20
- - **Prior decisions — `codebase-research-locator` then `codebase-research-analyzer`:** applicable decisions and constraints from `research/` or `specs/`, with locator preceding analyzer.
21
-
22
- For library/API questions, include official docs and recent examples. For architecture decisions, cover module boundaries and dependency direction. For debugging, cover call paths and authoritative information about the error. For UI/product questions, cover analogous components and design precedent. For time-sensitive topics, have the online researcher prefer 2026/2025 sources and persist findings to `research/web/`.
23
-
24
- This is read-only research unless I explicitly request implementation. Delegate only independent work too large for a handful of tool calls; do not delegate auditing your own work, and prefer one subagent over several. Parallelize independent reads; stay sequential when one result determines the next; synthesize after retrieval. Keep work within the requested scope.
25
-
26
- ## Output
27
-
28
- Each specialist returns concise evidence: local paths and line ranges or external links, confidence and gaps, and the decision implication or next step. Synthesize a user-facing answer of roughly 400–800 words covering what is known, local implications, tradeoffs and risks, gaps or assumptions, and the recommended move. Name disagreements rather than smoothing them over. Lead with the outcome; keep facts, decisions, caveats, and next steps; drop background and repetition; stay readable rather than compressed into fragments.
29
-
30
- Before reporting progress, audit each claim against a tool result from this session. Report only work you can point to evidence for; say so explicitly when something is unverified.
31
-
32
- ## Stop rule
33
-
34
- Done means applicable specialists have returned direct evidence and the synthesis answers the question, identifies material uncertainty or disagreement, and recommends the next move. Do not edit files unless implementation was explicitly requested.
@@ -1,47 +0,0 @@
1
- ---
2
- description: Parallel specialist review of the current work
3
- ---
4
-
5
- ## Goal
6
-
7
- Produce an adversarial, evidence-backed review of the current work, separating fixes worth doing now from optional or inapplicable feedback. Apply fixes only when authorized.
8
-
9
- Additional review target or focus from the slash command invocation:
10
-
11
- $@
12
-
13
- If this supplies a URL, issue, file, plan, or freeform focus, treat it as primary scope: read or fetch it before assigning angles and pass it into every specialist task.
14
-
15
- ## Constraints and tools
16
-
17
- Use fresh context unless I explicitly request forked context. Specialists inspect repository instructions, relevant files, and the current diff through direct reads and commands, not main-conversation history. There is no generic `reviewer`; choose read-only specialists with distinct angles derived from user intent, the plan, implementation, and diff. Use my angles when supplied; otherwise select three applicable angles:
18
-
19
- - **Correctness and regressions — `codebase-analyzer`:** trace the diff and surrounding flow against the request, preserved behavior, edge cases, and hidden runtime failures; cite `file:line` for every claim.
20
- - **Bug and failure modes — `debugger`:** reproduce relevant behavior where possible, assess how the suspect diff could break, and report evidence.
21
- - **Pattern fit — `codebase-pattern-finder`:** compare analogous code and conventions, identifying structural drift or missed reuse with `file:line` snippets.
22
- - **Prior constraints — `codebase-research-locator` then `codebase-research-analyzer`:** surface applicable research or specs and the decisions the change must honor.
23
- - **External conformance — `codebase-online-researcher`:** compare an external API, RFC, or library contract with its authoritative source.
24
-
25
- Use `/parallel-cleanup` instead for simplicity, slop, or verbosity angles. Every specialist gets a task naming its angle and returns concise review findings with evidence, `file:line`, and suggested fixes—not a context summary. Every specialist is read-only, including agent types that can edit. While they run, perform a narrow inspection if useful.
26
-
27
- Synthesize fixes worth doing now, optional improvements, and ignored or deferred feedback with a short reason; assess findings rather than applying them blindly. Delegate only independent work too large for a handful of tool calls; do not delegate auditing your own work, and prefer one subagent over several. Parallelize independent reads; stay sequential when one result determines the next; synthesize after retrieval. Keep work within the requested scope.
28
-
29
- In **autofix** mode, an invocation containing the exact word `autofix` uses it as workflow control, not review scope; remove it before identifying the target. After synthesis, launch one foreground writer—`debugger` for correctness/regression fixes or `code-simplifier` for cleanup-shaped feedback—with only the explicit fixes-worth-doing-now list as scope. Validate and summarize. Do not apply optional improvements unless explicitly requested; if no fixes are worth doing now, do not edit.
30
-
31
- Without autofix mode, ask before applying fixes unless I already authorized addressing review feedback. End that request with a compact numbered menu, including when applicable:
32
-
33
- ```text
34
- Reply with [1], [2], or further instructions:
35
- [1] Apply only the fixes worth doing now.
36
- [2] Apply the fixes worth doing now plus optional improvements.
37
- ```
38
-
39
- ## Output
40
-
41
- Return a concise, user-facing review of roughly 400–800 words: outcome, evidence-backed fixes worth doing now, optional improvements, ignored or deferred feedback with reasons, and any authorized edits and validation. Lead with the outcome; keep facts, decisions, caveats, and next steps; drop background and repetition; stay readable rather than compressed into fragments.
42
-
43
- Before reporting progress, audit each claim against a tool result from this session. Report only work you can point to evidence for; say so explicitly when something is unverified.
44
-
45
- ## Stop rule
46
-
47
- Done means the specialist evidence has been assessed and synthesized, then either authorized fixes were validated, no worthwhile fixes exist, or the numbered approval menu was presented. Stop without editing when authorization is absent.
@@ -1,39 +0,0 @@
1
- ---
2
- description: Specialist review/fix loop until clean
3
- ---
4
-
5
- ## Goal
6
-
7
- Run a parent-orchestrated review-and-fix loop for the requested work until the current scope is clean, blocked on an unapproved decision, or capped. The parent controls the loop and makes final decisions; children receive concrete role-specific tasks and must not launch subagents or manage the loop.
8
-
9
- Additional target, implementation request, max-iteration cap, or review focus from the slash command invocation:
10
-
11
- $@
12
-
13
- ## Constraints and tools
14
-
15
- Use the `subagent` tool and specialist roles rather than a generic worker or reviewer. Use one writer per pass: `debugger` for bugs, correctness/regression fixes, or behavior changes; `code-simplifier` for cleanup, refinement, or simplification. Reviewer options are `codebase-analyzer` for correctness and flow, `debugger` in inspect-only mode for failure modes, `codebase-pattern-finder` for consistency, `codebase-online-researcher` for external conformance, and `codebase-research-locator` then `codebase-research-analyzer` for prior decisions.
16
-
17
- Default to at most 3 review rounds unless I set another cap. A round is a fresh-context inspection of the current diff after a writer pass.
18
-
19
- If the invocation requests implementation, first launch one foreground writer for the approved scope: `debugger` for correctness-shaped work or `code-simplifier` for refinement-shaped work. If the current diff is already the target, begin with review. Continue with follow-up runs after each completion. Because launches are non-interactive, resolve questions with me first. Use one writer against the active worktree at a time unless I explicitly request isolated worktrees.
20
-
21
- Each review round uses fresh context. Reviewers inspect repository instructions, relevant files, and the current diff directly, without main-conversation history, and cannot edit; explicitly put `debugger` in inspect-only mode. Choose angles from the change. Common angles are correctness/regressions, failure modes, and pattern fit; add external-spec or prior-decision coverage when applicable. Prefer three strong reviewers over many vague ones.
22
-
23
- Delegate only independent work too large for a handful of tool calls; do not delegate auditing your own work, and prefer one subagent over several. Parallelize independent reads; stay sequential when one result determines the next; synthesize after retrieval. Keep work within the requested scope.
24
-
25
- After each round, synthesize blockers or scope/product/architecture decisions needing approval, fixes worth doing now, optional improvements, and feedback to ignore or defer with a short reason. Assess findings rather than applying them blindly. Pause for my approval before a writer acts on any unapproved product, scope, or architecture decision.
26
-
27
- The implementation writer's handoff transitions into review; it is not final completion unless I requested writer-only work, review-only output, or a stop after implementation. When implementation is authorized and fixes are worth doing now, launch one foreground writer to apply only the synthesized fixes—`debugger` for correctness or `code-simplifier` for cleanup. Require it to preserve approved scope, run focused validation, and report changed files, commands with exit codes, validation evidence, surprises, and unfinished work.
28
-
29
- Run another review round after a fix only when it made material changes or addressed non-trivial findings. Do not loop for optional polish, speculative improvements, or already deferred findings.
30
-
31
- ## Output
32
-
33
- On completion, inspect the final diff and run or confirm appropriate focused validation. Return a concise, user-facing summary of roughly 300–700 words: why the loop stopped, rounds run, fixes applied, validation, remaining blockers or deferred items, and next steps. Lead with the outcome; keep facts, decisions, caveats, and next steps; drop background and repetition; stay readable rather than compressed into fragments.
34
-
35
- Before reporting progress, audit each claim against a tool result from this session. Report only work you can point to evidence for; say so explicitly when something is unverified.
36
-
37
- ## Stop rule
38
-
39
- Stop and summarize when reviewers find no blockers or fixes worth doing now; remaining feedback is optional, speculative, or intentionally deferred; an unapproved decision needs me; or the review-round cap is reached. The loop is done only after the final diff and focused validation have been inspected or explicitly reported as unverified.
@@ -1,188 +0,0 @@
1
- import * as fs from "node:fs";
2
- import * as path from "node:path";
3
- import { type AgentSource, discoverAgentsAll } from "../agents/agents.js";
4
- import { discoverAvailableSkills, type SkillSource } from "../agents/skills.js";
5
- import { diagnoseIntercomBridge, type IntercomBridgeDiagnostic } from "../intercom/intercom-bridge.js";
6
- import { type ExtensionConfig, type SubagentState, TEMP_ROOT_DIR } from "../shared/types.js";
7
-
8
- interface DoctorPaths {
9
- tempRootDir: string;
10
- }
11
-
12
- interface DoctorDeps {
13
- discoverAgentsAll: typeof discoverAgentsAll;
14
- discoverAvailableSkills: typeof discoverAvailableSkills;
15
- diagnoseIntercomBridge: typeof diagnoseIntercomBridge;
16
- }
17
-
18
- interface DoctorReportInput {
19
- cwd: string;
20
- config: ExtensionConfig;
21
- state: SubagentState;
22
- context?: "fresh" | "fork";
23
- requestedSessionDir?: string;
24
- currentSessionFile?: string | null;
25
- currentSessionId?: string | null;
26
- orchestratorTarget?: string;
27
- sessionError?: string;
28
- expandTilde?: (value: string) => string;
29
- paths?: DoctorPaths;
30
- deps?: Partial<DoctorDeps>;
31
- }
32
-
33
- const DEFAULT_PATHS: DoctorPaths = { tempRootDir: TEMP_ROOT_DIR };
34
-
35
- const DEFAULT_DEPS: DoctorDeps = {
36
- discoverAgentsAll,
37
- discoverAvailableSkills,
38
- diagnoseIntercomBridge,
39
- };
40
-
41
- function errorText(error: unknown): string {
42
- return error instanceof Error ? `${error.name}: ${error.message}` : String(error);
43
- }
44
-
45
- function lineFromCheck(label: string, check: () => string): string {
46
- try {
47
- return check();
48
- } catch (error) {
49
- return `- ${label}: failed — ${errorText(error)}`;
50
- }
51
- }
52
-
53
- function formatExistingDirectory(label: string, dirPath: string): string {
54
- try {
55
- if (!fs.existsSync(dirPath)) return `- ${label}: missing (${dirPath})`;
56
- const stats = fs.statSync(dirPath);
57
- if (!stats.isDirectory()) throw new Error(`not a directory: ${dirPath}`);
58
- fs.accessSync(dirPath, fs.constants.R_OK | fs.constants.W_OK);
59
- return `- ${label}: ok (${dirPath})`;
60
- } catch (error) {
61
- return `- ${label}: failed (${dirPath}) — ${errorText(error)}`;
62
- }
63
- }
64
-
65
- function formatSourceCounts(counts: Record<AgentSource, number>): string {
66
- return `builtin ${counts.builtin}, user ${counts.user}, project ${counts.project}`;
67
- }
68
-
69
- function formatSkillSourceCounts(skills: Array<{ source: SkillSource }>): string {
70
- const counts = new Map<SkillSource, number>();
71
- for (const skill of skills) counts.set(skill.source, (counts.get(skill.source) ?? 0) + 1);
72
- const ordered: SkillSource[] = [
73
- "project",
74
- "project-settings",
75
- "project-package",
76
- "user",
77
- "user-settings",
78
- "user-package",
79
- "extension",
80
- "builtin",
81
- "unknown",
82
- ];
83
- const parts = ordered.map((source) => `${source} ${counts.get(source) ?? 0}`).filter((part) => !part.endsWith(" 0"));
84
- return parts.length > 0 ? parts.join(", ") : "none";
85
- }
86
-
87
- function formatConfiguredSessionDir(input: DoctorReportInput): string {
88
- if (input.requestedSessionDir) {
89
- return path.resolve(input.expandTilde?.(input.requestedSessionDir) ?? input.requestedSessionDir);
90
- }
91
- if (input.config.defaultSessionDir) {
92
- return path.resolve(input.expandTilde?.(input.config.defaultSessionDir) ?? input.config.defaultSessionDir);
93
- }
94
- return "not configured";
95
- }
96
-
97
- function formatSessionLines(input: DoctorReportInput): string[] {
98
- const sessionFile = input.currentSessionFile ?? null;
99
- const lines = [
100
- lineFromCheck("configured session dir", () => `- configured session dir: ${formatConfiguredSessionDir(input)}`),
101
- `- current session file: ${sessionFile ?? "not available"}`,
102
- `- current session dir: ${sessionFile ? path.dirname(sessionFile) : "not available"}`,
103
- `- current session id: ${input.currentSessionId ?? input.state.currentSessionId ?? "not available"}`,
104
- ];
105
- if (input.sessionError) lines.push(`- session manager: failed — ${input.sessionError}`);
106
- return lines;
107
- }
108
-
109
- function formatDiscovery(input: DoctorReportInput, deps: DoctorDeps): string[] {
110
- return [
111
- lineFromCheck("agents", () => {
112
- const discovered = deps.discoverAgentsAll(input.cwd);
113
- const agentCounts = {
114
- builtin: discovered.builtin.length,
115
- user: discovered.user.length,
116
- project: discovered.project.length,
117
- };
118
- const lines = [
119
- `- agents: total ${agentCounts.builtin + agentCounts.user + agentCounts.project} (${formatSourceCounts(agentCounts)})`,
120
- ];
121
- // A file whose frontmatter is invalid YAML is skipped by discovery;
122
- // without these lines it would vanish with no signal at all.
123
- for (const diagnostic of discovered.diagnostics) {
124
- lines.push(
125
- `- agents: warning — ${diagnostic.path}: invalid YAML frontmatter (${diagnostic.message}); file skipped`,
126
- );
127
- }
128
- return lines.join("\n");
129
- }),
130
- lineFromCheck("skills", () => {
131
- const skills = deps.discoverAvailableSkills(input.cwd);
132
- return `- skills: total ${skills.length} (${formatSkillSourceCounts(skills)})`;
133
- }),
134
- ];
135
- }
136
-
137
- function formatIntercomDiagnostic(
138
- diagnostic: IntercomBridgeDiagnostic,
139
- context: "fresh" | "fork" | undefined,
140
- ): string[] {
141
- const lines = [
142
- `- bridge: ${diagnostic.active ? "active" : "inactive"}${diagnostic.reason ? ` (${diagnostic.reason})` : ""}`,
143
- `- mode: ${diagnostic.mode}; context: ${context ?? "unspecified"}`,
144
- `- orchestrator target: ${diagnostic.orchestratorTarget ?? "not available"}`,
145
- `- pi-intercom: ${diagnostic.piIntercomAvailable ? "available" : "unavailable"} at ${diagnostic.extensionDir}`,
146
- ];
147
- if (diagnostic.configPath && diagnostic.intercomConfigEnabled !== undefined) {
148
- lines.push(
149
- `- intercom config: ${diagnostic.intercomConfigEnabled === false ? "disabled" : "enabled or absent"} (${diagnostic.configPath})`,
150
- );
151
- }
152
- if (diagnostic.intercomConfigError) {
153
- lines.push(`- intercom config warning: ${diagnostic.intercomConfigError}; runtime assumes enabled`);
154
- }
155
- return lines;
156
- }
157
-
158
- export function buildDoctorReport(input: DoctorReportInput): string {
159
- const paths = input.paths ?? DEFAULT_PATHS;
160
- const deps = { ...DEFAULT_DEPS, ...input.deps };
161
- const lines = [
162
- "Subagents doctor report",
163
- "",
164
- "Runtime",
165
- `- cwd: ${input.cwd}`,
166
- ...formatSessionLines(input),
167
- "",
168
- "Filesystem",
169
- formatExistingDirectory("temp root", paths.tempRootDir),
170
- "",
171
- "Discovery",
172
- ...formatDiscovery(input, deps),
173
- "",
174
- "Intercom bridge",
175
- ...lineFromCheck("intercom bridge", () =>
176
- formatIntercomDiagnostic(
177
- deps.diagnoseIntercomBridge({
178
- config: input.config.intercomBridge,
179
- context: input.context,
180
- orchestratorTarget: input.orchestratorTarget,
181
- cwd: input.cwd,
182
- }),
183
- input.context,
184
- ).join("\n"),
185
- ).split("\n"),
186
- ];
187
- return lines.join("\n");
188
- }
@@ -1,104 +0,0 @@
1
- /**
2
- * In-process attempt handles for a top-level session's direct children.
3
- *
4
- * Delegation is one level deep, so this registry only ever holds a parent's own
5
- * children. A live child is addressed by its run id or canonical task path, and
6
- * interrupt/resume reach it through the handle registered when its attempt
7
- * started — never through a request file, a capability token, or a poller.
8
- */
9
-
10
- export interface InProcessAttemptResumeOutcome {
11
- readonly status: "ok" | "error" | "interrupted" | "continued";
12
- readonly path: string;
13
- readonly sessionFile?: string;
14
- readonly envelope?: string;
15
- }
16
-
17
- export interface InProcessAttemptHandle {
18
- readonly runId: string;
19
- readonly path: string;
20
- readonly status: () => string;
21
- readonly interrupt: () => Promise<void>;
22
- readonly resume: (message: string) => Promise<InProcessAttemptResumeOutcome>;
23
- }
24
-
25
- export interface InProcessAttemptControlResult {
26
- readonly ok: boolean;
27
- readonly message: string;
28
- readonly outcome?: InProcessAttemptResumeOutcome;
29
- }
30
-
31
- const attemptHandles = new Map<string, Map<string, InProcessAttemptHandle>>();
32
-
33
- function attemptKey(id: string): string {
34
- return id.trim();
35
- }
36
-
37
- export function registerInProcessAttempt(handle: InProcessAttemptHandle): () => void {
38
- const key = attemptKey(handle.runId);
39
- let handles = attemptHandles.get(key);
40
- if (!handles) {
41
- handles = new Map();
42
- attemptHandles.set(key, handles);
43
- }
44
- handles.set(handle.path, handle);
45
- const pathKey = attemptKey(handle.path);
46
- if (pathKey !== key) {
47
- let byPath = attemptHandles.get(pathKey);
48
- if (!byPath) {
49
- byPath = new Map();
50
- attemptHandles.set(pathKey, byPath);
51
- }
52
- byPath.set(handle.path, handle);
53
- }
54
- return () => {
55
- for (const lookupKey of [key, pathKey]) {
56
- const current = attemptHandles.get(lookupKey);
57
- if (!current || current.get(handle.path) !== handle) continue;
58
- current.delete(handle.path);
59
- if (current.size === 0) attemptHandles.delete(lookupKey);
60
- }
61
- };
62
- }
63
-
64
- function handlesFor(id: string): InProcessAttemptHandle[] {
65
- return [...(attemptHandles.get(attemptKey(id))?.values() ?? [])];
66
- }
67
-
68
- export async function interruptInProcessAttempt(targetId: string): Promise<InProcessAttemptControlResult | undefined> {
69
- const handles = handlesFor(targetId);
70
- if (handles.length === 0) return undefined;
71
- const active = handles.filter((handle) => handle.status() === "running" || handle.status() === "continued");
72
- if (active.length === 0) {
73
- return { ok: false, message: `Run ${targetId} has no active child attempt to interrupt.` };
74
- }
75
- await Promise.all(active.map((handle) => handle.interrupt()));
76
- return { ok: true, message: `Interrupt requested for run ${targetId}.` };
77
- }
78
-
79
- export async function resumeInProcessAttempt(
80
- targetId: string,
81
- message: string,
82
- ): Promise<InProcessAttemptControlResult | undefined> {
83
- const handles = handlesFor(targetId);
84
- if (handles.length === 0) return undefined;
85
- const handle =
86
- handles.find((candidate) => candidate.status() === "interrupted" || candidate.status() === "error") ?? handles[0];
87
- if (!handle) return undefined;
88
- if (handle.status() === "running" || handle.status() === "continued") {
89
- return { ok: false, message: `Run ${targetId} is still running; resume is not required.` };
90
- }
91
- const outcome = await handle.resume(message);
92
- return {
93
- ok: outcome.status === "ok" || outcome.status === "continued",
94
- message:
95
- outcome.status === "ok"
96
- ? `Reloaded run ${targetId} through the in-process control plane.`
97
- : `Run ${targetId} resume ended with status '${outcome.status}'.`,
98
- outcome,
99
- };
100
- }
101
-
102
- export function clearInProcessAttemptHandles(): void {
103
- attemptHandles.clear();
104
- }