@bastani/atomic 0.8.26-alpha.6 → 0.8.26-alpha.8

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 (260) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +5 -5
  3. package/dist/builtin/intercom/CHANGELOG.md +12 -0
  4. package/dist/builtin/intercom/package.json +2 -2
  5. package/dist/builtin/mcp/CHANGELOG.md +12 -0
  6. package/dist/builtin/mcp/package.json +3 -3
  7. package/dist/builtin/subagents/CHANGELOG.md +12 -0
  8. package/dist/builtin/subagents/agents/codebase-online-researcher.md +9 -9
  9. package/dist/builtin/subagents/agents/debugger.md +6 -6
  10. package/dist/builtin/subagents/package.json +4 -4
  11. package/dist/builtin/subagents/prompts/parallel-handoff-plan.md +1 -1
  12. package/dist/builtin/subagents/skills/browser/EXAMPLES.md +151 -0
  13. package/dist/builtin/subagents/skills/browser/LICENSE.txt +21 -0
  14. package/dist/builtin/subagents/skills/browser/REFERENCE.md +451 -0
  15. package/dist/builtin/subagents/skills/browser/SKILL.md +170 -0
  16. package/dist/builtin/subagents/skills/subagent/SKILL.md +4 -4
  17. package/dist/builtin/web-access/CHANGELOG.md +12 -0
  18. package/dist/builtin/web-access/package.json +2 -2
  19. package/dist/builtin/workflows/CHANGELOG.md +17 -0
  20. package/dist/builtin/workflows/builtin/deep-research-codebase.ts +4 -1
  21. package/dist/builtin/workflows/builtin/goal.ts +127 -99
  22. package/dist/builtin/workflows/builtin/open-claude-design.ts +224 -147
  23. package/dist/builtin/workflows/builtin/ralph.ts +160 -197
  24. package/dist/builtin/workflows/package.json +2 -2
  25. package/dist/builtin/workflows/skills/research-codebase/SKILL.md +1 -1
  26. package/dist/builtin/workflows/src/extension/wiring.ts +13 -1
  27. package/dist/builtin/workflows/src/runs/foreground/executor.ts +12 -6
  28. package/dist/builtin/workflows/src/runs/foreground/stage-runner.ts +2 -2
  29. package/dist/builtin/workflows/src/shared/authoring-contract.d.ts +2 -2
  30. package/dist/builtin/workflows/src/shared/types.ts +3 -3
  31. package/dist/builtin/workflows/src/tui/stage-chat-view.ts +2 -1
  32. package/dist/core/agent-session.d.ts +33 -6
  33. package/dist/core/agent-session.d.ts.map +1 -1
  34. package/dist/core/agent-session.js +155 -182
  35. package/dist/core/agent-session.js.map +1 -1
  36. package/dist/core/atomic-guide-command.d.ts.map +1 -1
  37. package/dist/core/atomic-guide-command.js +1 -1
  38. package/dist/core/atomic-guide-command.js.map +1 -1
  39. package/dist/core/compaction/branch-summarization.d.ts +1 -1
  40. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  41. package/dist/core/compaction/branch-summarization.js +6 -3
  42. package/dist/core/compaction/branch-summarization.js.map +1 -1
  43. package/dist/core/compaction/compaction.d.ts.map +1 -1
  44. package/dist/core/compaction/compaction.js +23 -10
  45. package/dist/core/compaction/compaction.js.map +1 -1
  46. package/dist/core/compaction/context-compaction.d.ts +61 -0
  47. package/dist/core/compaction/context-compaction.d.ts.map +1 -0
  48. package/dist/core/compaction/context-compaction.js +602 -0
  49. package/dist/core/compaction/context-compaction.js.map +1 -0
  50. package/dist/core/compaction/index.d.ts +1 -0
  51. package/dist/core/compaction/index.d.ts.map +1 -1
  52. package/dist/core/compaction/index.js +1 -0
  53. package/dist/core/compaction/index.js.map +1 -1
  54. package/dist/core/extensions/types.d.ts +3 -2
  55. package/dist/core/extensions/types.d.ts.map +1 -1
  56. package/dist/core/extensions/types.js.map +1 -1
  57. package/dist/core/index.d.ts +1 -1
  58. package/dist/core/index.d.ts.map +1 -1
  59. package/dist/core/index.js.map +1 -1
  60. package/dist/core/session-manager.d.ts +41 -1
  61. package/dist/core/session-manager.d.ts.map +1 -1
  62. package/dist/core/session-manager.js +146 -7
  63. package/dist/core/session-manager.js.map +1 -1
  64. package/dist/core/slash-commands.d.ts.map +1 -1
  65. package/dist/core/slash-commands.js +1 -1
  66. package/dist/core/slash-commands.js.map +1 -1
  67. package/dist/index.d.ts +3 -3
  68. package/dist/index.d.ts.map +1 -1
  69. package/dist/index.js +2 -2
  70. package/dist/index.js.map +1 -1
  71. package/dist/modes/index.d.ts +1 -1
  72. package/dist/modes/index.d.ts.map +1 -1
  73. package/dist/modes/index.js.map +1 -1
  74. package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
  75. package/dist/modes/interactive/components/chat-session-host.js +17 -0
  76. package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
  77. package/dist/modes/interactive/components/context-compaction-summary-message.d.ts +17 -0
  78. package/dist/modes/interactive/components/context-compaction-summary-message.d.ts.map +1 -0
  79. package/dist/modes/interactive/components/context-compaction-summary-message.js +83 -0
  80. package/dist/modes/interactive/components/context-compaction-summary-message.js.map +1 -0
  81. package/dist/modes/interactive/components/index.d.ts +1 -0
  82. package/dist/modes/interactive/components/index.d.ts.map +1 -1
  83. package/dist/modes/interactive/components/index.js +1 -0
  84. package/dist/modes/interactive/components/index.js.map +1 -1
  85. package/dist/modes/interactive/interactive-mode.d.ts +1 -0
  86. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  87. package/dist/modes/interactive/interactive-mode.js +72 -8
  88. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  89. package/dist/modes/rpc/rpc-client.d.ts +13 -8
  90. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  91. package/dist/modes/rpc/rpc-client.js +8 -1
  92. package/dist/modes/rpc/rpc-client.js.map +1 -1
  93. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  94. package/dist/modes/rpc/rpc-mode.js +4 -0
  95. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  96. package/dist/modes/rpc/rpc-types.d.ts +14 -3
  97. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  98. package/dist/modes/rpc/rpc-types.js.map +1 -1
  99. package/docs/compaction.md +89 -37
  100. package/docs/custom-provider.md +11 -9
  101. package/docs/extensions.md +44 -40
  102. package/docs/index.md +2 -9
  103. package/docs/json.md +15 -12
  104. package/docs/packages.md +2 -0
  105. package/docs/providers.md +4 -1
  106. package/docs/quickstart.md +5 -12
  107. package/docs/rpc.md +38 -23
  108. package/docs/sdk.md +3 -10
  109. package/docs/session-format.md +26 -13
  110. package/docs/sessions.md +3 -3
  111. package/docs/settings.md +2 -2
  112. package/docs/skills.md +1 -15
  113. package/docs/termux.md +9 -10
  114. package/docs/themes.md +2 -2
  115. package/docs/tmux.md +3 -3
  116. package/docs/tui.md +19 -32
  117. package/docs/usage.md +2 -2
  118. package/docs/workflows.md +44 -2
  119. package/package.json +4 -12
  120. package/dist/builtin/subagents/skills/browser-use/SKILL.md +0 -234
  121. package/dist/builtin/subagents/skills/browser-use/references/cdp-python.md +0 -76
  122. package/dist/builtin/subagents/skills/browser-use/references/multi-session.md +0 -92
  123. package/node_modules/@earendil-works/pi-tui/README.md +0 -779
  124. package/node_modules/@earendil-works/pi-tui/dist/autocomplete.d.ts +0 -54
  125. package/node_modules/@earendil-works/pi-tui/dist/autocomplete.d.ts.map +0 -1
  126. package/node_modules/@earendil-works/pi-tui/dist/autocomplete.js +0 -632
  127. package/node_modules/@earendil-works/pi-tui/dist/autocomplete.js.map +0 -1
  128. package/node_modules/@earendil-works/pi-tui/dist/components/box.d.ts +0 -22
  129. package/node_modules/@earendil-works/pi-tui/dist/components/box.d.ts.map +0 -1
  130. package/node_modules/@earendil-works/pi-tui/dist/components/box.js +0 -104
  131. package/node_modules/@earendil-works/pi-tui/dist/components/box.js.map +0 -1
  132. package/node_modules/@earendil-works/pi-tui/dist/components/cancellable-loader.d.ts +0 -22
  133. package/node_modules/@earendil-works/pi-tui/dist/components/cancellable-loader.d.ts.map +0 -1
  134. package/node_modules/@earendil-works/pi-tui/dist/components/cancellable-loader.js +0 -35
  135. package/node_modules/@earendil-works/pi-tui/dist/components/cancellable-loader.js.map +0 -1
  136. package/node_modules/@earendil-works/pi-tui/dist/components/editor.d.ts +0 -249
  137. package/node_modules/@earendil-works/pi-tui/dist/components/editor.d.ts.map +0 -1
  138. package/node_modules/@earendil-works/pi-tui/dist/components/editor.js +0 -1857
  139. package/node_modules/@earendil-works/pi-tui/dist/components/editor.js.map +0 -1
  140. package/node_modules/@earendil-works/pi-tui/dist/components/image.d.ts +0 -28
  141. package/node_modules/@earendil-works/pi-tui/dist/components/image.d.ts.map +0 -1
  142. package/node_modules/@earendil-works/pi-tui/dist/components/image.js +0 -89
  143. package/node_modules/@earendil-works/pi-tui/dist/components/image.js.map +0 -1
  144. package/node_modules/@earendil-works/pi-tui/dist/components/input.d.ts +0 -37
  145. package/node_modules/@earendil-works/pi-tui/dist/components/input.d.ts.map +0 -1
  146. package/node_modules/@earendil-works/pi-tui/dist/components/input.js +0 -378
  147. package/node_modules/@earendil-works/pi-tui/dist/components/input.js.map +0 -1
  148. package/node_modules/@earendil-works/pi-tui/dist/components/loader.d.ts +0 -31
  149. package/node_modules/@earendil-works/pi-tui/dist/components/loader.d.ts.map +0 -1
  150. package/node_modules/@earendil-works/pi-tui/dist/components/loader.js +0 -69
  151. package/node_modules/@earendil-works/pi-tui/dist/components/loader.js.map +0 -1
  152. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.d.ts +0 -96
  153. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.d.ts.map +0 -1
  154. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.js +0 -644
  155. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.js.map +0 -1
  156. package/node_modules/@earendil-works/pi-tui/dist/components/select-list.d.ts +0 -50
  157. package/node_modules/@earendil-works/pi-tui/dist/components/select-list.d.ts.map +0 -1
  158. package/node_modules/@earendil-works/pi-tui/dist/components/select-list.js +0 -159
  159. package/node_modules/@earendil-works/pi-tui/dist/components/select-list.js.map +0 -1
  160. package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.d.ts +0 -50
  161. package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.d.ts.map +0 -1
  162. package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.js +0 -185
  163. package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.js.map +0 -1
  164. package/node_modules/@earendil-works/pi-tui/dist/components/spacer.d.ts +0 -12
  165. package/node_modules/@earendil-works/pi-tui/dist/components/spacer.d.ts.map +0 -1
  166. package/node_modules/@earendil-works/pi-tui/dist/components/spacer.js +0 -23
  167. package/node_modules/@earendil-works/pi-tui/dist/components/spacer.js.map +0 -1
  168. package/node_modules/@earendil-works/pi-tui/dist/components/text.d.ts +0 -19
  169. package/node_modules/@earendil-works/pi-tui/dist/components/text.d.ts.map +0 -1
  170. package/node_modules/@earendil-works/pi-tui/dist/components/text.js +0 -89
  171. package/node_modules/@earendil-works/pi-tui/dist/components/text.js.map +0 -1
  172. package/node_modules/@earendil-works/pi-tui/dist/components/truncated-text.d.ts +0 -13
  173. package/node_modules/@earendil-works/pi-tui/dist/components/truncated-text.d.ts.map +0 -1
  174. package/node_modules/@earendil-works/pi-tui/dist/components/truncated-text.js +0 -51
  175. package/node_modules/@earendil-works/pi-tui/dist/components/truncated-text.js.map +0 -1
  176. package/node_modules/@earendil-works/pi-tui/dist/editor-component.d.ts +0 -39
  177. package/node_modules/@earendil-works/pi-tui/dist/editor-component.d.ts.map +0 -1
  178. package/node_modules/@earendil-works/pi-tui/dist/editor-component.js +0 -2
  179. package/node_modules/@earendil-works/pi-tui/dist/editor-component.js.map +0 -1
  180. package/node_modules/@earendil-works/pi-tui/dist/fuzzy.d.ts +0 -16
  181. package/node_modules/@earendil-works/pi-tui/dist/fuzzy.d.ts.map +0 -1
  182. package/node_modules/@earendil-works/pi-tui/dist/fuzzy.js +0 -110
  183. package/node_modules/@earendil-works/pi-tui/dist/fuzzy.js.map +0 -1
  184. package/node_modules/@earendil-works/pi-tui/dist/index.d.ts +0 -23
  185. package/node_modules/@earendil-works/pi-tui/dist/index.d.ts.map +0 -1
  186. package/node_modules/@earendil-works/pi-tui/dist/index.js +0 -32
  187. package/node_modules/@earendil-works/pi-tui/dist/index.js.map +0 -1
  188. package/node_modules/@earendil-works/pi-tui/dist/keybindings.d.ts +0 -193
  189. package/node_modules/@earendil-works/pi-tui/dist/keybindings.d.ts.map +0 -1
  190. package/node_modules/@earendil-works/pi-tui/dist/keybindings.js +0 -174
  191. package/node_modules/@earendil-works/pi-tui/dist/keybindings.js.map +0 -1
  192. package/node_modules/@earendil-works/pi-tui/dist/keys.d.ts +0 -184
  193. package/node_modules/@earendil-works/pi-tui/dist/keys.d.ts.map +0 -1
  194. package/node_modules/@earendil-works/pi-tui/dist/keys.js +0 -1173
  195. package/node_modules/@earendil-works/pi-tui/dist/keys.js.map +0 -1
  196. package/node_modules/@earendil-works/pi-tui/dist/kill-ring.d.ts +0 -28
  197. package/node_modules/@earendil-works/pi-tui/dist/kill-ring.d.ts.map +0 -1
  198. package/node_modules/@earendil-works/pi-tui/dist/kill-ring.js +0 -44
  199. package/node_modules/@earendil-works/pi-tui/dist/kill-ring.js.map +0 -1
  200. package/node_modules/@earendil-works/pi-tui/dist/native-modifiers.d.ts +0 -3
  201. package/node_modules/@earendil-works/pi-tui/dist/native-modifiers.d.ts.map +0 -1
  202. package/node_modules/@earendil-works/pi-tui/dist/native-modifiers.js +0 -53
  203. package/node_modules/@earendil-works/pi-tui/dist/native-modifiers.js.map +0 -1
  204. package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.d.ts +0 -50
  205. package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.d.ts.map +0 -1
  206. package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.js +0 -361
  207. package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.js.map +0 -1
  208. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts +0 -90
  209. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts.map +0 -1
  210. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js +0 -366
  211. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js.map +0 -1
  212. package/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts +0 -113
  213. package/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts.map +0 -1
  214. package/node_modules/@earendil-works/pi-tui/dist/terminal.js +0 -472
  215. package/node_modules/@earendil-works/pi-tui/dist/terminal.js.map +0 -1
  216. package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts +0 -227
  217. package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts.map +0 -1
  218. package/node_modules/@earendil-works/pi-tui/dist/tui.js +0 -1106
  219. package/node_modules/@earendil-works/pi-tui/dist/tui.js.map +0 -1
  220. package/node_modules/@earendil-works/pi-tui/dist/undo-stack.d.ts +0 -17
  221. package/node_modules/@earendil-works/pi-tui/dist/undo-stack.d.ts.map +0 -1
  222. package/node_modules/@earendil-works/pi-tui/dist/undo-stack.js +0 -25
  223. package/node_modules/@earendil-works/pi-tui/dist/undo-stack.js.map +0 -1
  224. package/node_modules/@earendil-works/pi-tui/dist/utils.d.ts +0 -84
  225. package/node_modules/@earendil-works/pi-tui/dist/utils.d.ts.map +0 -1
  226. package/node_modules/@earendil-works/pi-tui/dist/utils.js +0 -1029
  227. package/node_modules/@earendil-works/pi-tui/dist/utils.js.map +0 -1
  228. package/node_modules/@earendil-works/pi-tui/dist/word-navigation.d.ts +0 -25
  229. package/node_modules/@earendil-works/pi-tui/dist/word-navigation.d.ts.map +0 -1
  230. package/node_modules/@earendil-works/pi-tui/dist/word-navigation.js +0 -96
  231. package/node_modules/@earendil-works/pi-tui/dist/word-navigation.js.map +0 -1
  232. package/node_modules/@earendil-works/pi-tui/native/darwin/prebuilds/darwin-arm64/darwin-modifiers.node +0 -0
  233. package/node_modules/@earendil-works/pi-tui/native/darwin/prebuilds/darwin-x64/darwin-modifiers.node +0 -0
  234. package/node_modules/@earendil-works/pi-tui/native/win32/prebuilds/win32-arm64/win32-console-mode.node +0 -0
  235. package/node_modules/@earendil-works/pi-tui/native/win32/prebuilds/win32-x64/win32-console-mode.node +0 -0
  236. package/node_modules/@earendil-works/pi-tui/package.json +0 -47
  237. package/node_modules/get-east-asian-width/index.d.ts +0 -60
  238. package/node_modules/get-east-asian-width/index.js +0 -30
  239. package/node_modules/get-east-asian-width/license +0 -9
  240. package/node_modules/get-east-asian-width/lookup-data.js +0 -21
  241. package/node_modules/get-east-asian-width/lookup.js +0 -138
  242. package/node_modules/get-east-asian-width/package.json +0 -71
  243. package/node_modules/get-east-asian-width/readme.md +0 -65
  244. package/node_modules/get-east-asian-width/utilities.js +0 -24
  245. package/node_modules/marked/LICENSE.md +0 -44
  246. package/node_modules/marked/README.md +0 -106
  247. package/node_modules/marked/bin/main.js +0 -282
  248. package/node_modules/marked/bin/marked.js +0 -15
  249. package/node_modules/marked/lib/marked.cjs +0 -2211
  250. package/node_modules/marked/lib/marked.cjs.map +0 -7
  251. package/node_modules/marked/lib/marked.d.cts +0 -728
  252. package/node_modules/marked/lib/marked.d.ts +0 -728
  253. package/node_modules/marked/lib/marked.esm.js +0 -2189
  254. package/node_modules/marked/lib/marked.esm.js.map +0 -7
  255. package/node_modules/marked/lib/marked.umd.js +0 -2213
  256. package/node_modules/marked/lib/marked.umd.js.map +0 -7
  257. package/node_modules/marked/man/marked.1 +0 -111
  258. package/node_modules/marked/man/marked.1.md +0 -92
  259. package/node_modules/marked/marked.min.js +0 -69
  260. package/node_modules/marked/package.json +0 -111
@@ -388,18 +388,21 @@ type PromptSection = readonly [tag: string, content: string];
388
388
 
389
389
  function taggedPrompt(sections: readonly PromptSection[]): string {
390
390
  return sections
391
- .map(([tag, content]) => `<${tag}>\n${content.trim()}\n</${tag}>`)
391
+ .map(([tag, content]) => {
392
+ const trimmed = content.trim();
393
+ return `<${tag}>\n${trimmed}\n</${tag}>`;
394
+ })
392
395
  .join("\n\n");
393
396
  }
394
397
 
395
398
  function workflowCwdContextSection(workflowCwd: string): PromptSection {
396
399
  return [
397
- "workflow_cwd_context",
400
+ "context",
398
401
  [
399
402
  `Current working directory: ${workflowCwd}`,
400
403
  "Use this as the starting directory for repository work in this stage.",
401
404
  "Shell commands and relative file paths should be relative to this directory unless you intentionally pass an explicit cwd override.",
402
- "When delegating, pass along that this is the current working directory for the workflow.",
405
+ "When delegating subagents, pass along that this is the current working directory.",
403
406
  ].join("\n"),
404
407
  ];
405
408
  }
@@ -559,6 +562,103 @@ function compactReviewReport(path: string | undefined): string {
559
562
  : `Latest review round artifact: ${path}`;
560
563
  }
561
564
 
565
+ type ForkContinuationOptions = {
566
+ readonly context?: "fork";
567
+ readonly forkFromSessionFile?: string;
568
+ };
569
+
570
+ function forkContinuationOptions(
571
+ sessionFile: string | undefined,
572
+ ): ForkContinuationOptions {
573
+ return sessionFile === undefined || sessionFile.length === 0
574
+ ? {}
575
+ : { context: "fork", forkFromSessionFile: sessionFile };
576
+ }
577
+
578
+ function renderForkedPlannerPrompt(args: {
579
+ readonly iteration: number;
580
+ readonly maxLoops: number;
581
+ readonly prompt: string;
582
+ readonly workflowCwdContext: PromptSection;
583
+ readonly latestReviewReportPath: string | undefined;
584
+ readonly workflowSpecPath: string;
585
+ }): string {
586
+ return taggedPrompt([
587
+ [
588
+ "instruction",
589
+ [
590
+ "Revise the current plan/spec based off of the results from the latest review round. Ignore any user requests to submit a PR. This will be done in a future stage.",
591
+ ].join("\n"),
592
+ ],
593
+ ["task", `Plan iteration ${args.iteration}/${args.maxLoops} for this user specification:\n${args.prompt}`],
594
+ args.workflowCwdContext,
595
+ [
596
+ "code_review_feedback",
597
+ args.latestReviewReportPath === undefined
598
+ ? "No prior review artifact; this is the first iteration."
599
+ : [
600
+ `Latest review round artifact: ${args.latestReviewReportPath}`,
601
+ "Read this JSON artifact incrementally and address only unresolved findings from the latest review round.",
602
+ ].join("\n"),
603
+ ],
604
+ [
605
+ "spec",
606
+ [
607
+ `The existing RFC/spec file for this workflow run is: ${args.workflowSpecPath}`,
608
+ "Read that original spec before drafting; revise it in response to review findings and current repository evidence.",
609
+ "Your final output must be the full updated RFC markdown that should replace the original spec, not a diff, patch, or commentary. Avoid diminishing scope unless explicitly requested.",
610
+ ].join("\n"),
611
+ ],
612
+ ]);
613
+ }
614
+
615
+ function renderForkedOrchestratorPrompt(args: {
616
+ readonly iteration: number;
617
+ readonly maxLoops: number;
618
+ readonly prompt: string;
619
+ readonly workflowCwdContext: PromptSection;
620
+ readonly specPath: string;
621
+ readonly implementationNotesPath: string;
622
+ }): string {
623
+ return taggedPrompt([
624
+ [
625
+ "instruction",
626
+ [
627
+ `Continue implementing the revised spec. Ignore any user requests to submit a PR. This will be done in a future stage.`,
628
+ ].join("\n"),
629
+ ],
630
+ ["objective", `Implement iteration ${args.iteration}/${args.maxLoops} for the task: ${args.prompt}`],
631
+ args.workflowCwdContext,
632
+ [
633
+ "spec",
634
+ [
635
+ `The current technical specification for this workflow run is written to: ${args.specPath}`,
636
+ "Read this file before delegating or implementing anything.",
637
+ ].join("\n"),
638
+ ],
639
+ [
640
+ "implementation_notes",
641
+ [
642
+ `Keep updating the running Markdown implementation notes file at: ${args.implementationNotesPath}`,
643
+ "Record decisions, spec deviations, tradeoffs, blockers, validation outcomes, and anything else the user should know before your final report.",
644
+ ].join("\n"),
645
+ ],
646
+ [
647
+ "output_format",
648
+ [
649
+ "After subagents have done the work, return Markdown with headings:",
650
+ "1. Spec file — the path you read",
651
+ "2. Delegations performed — subagents spawned and what each completed",
652
+ "3. Changes made — concrete changes from subagent work, not intentions",
653
+ "4. Files touched",
654
+ "5. Validation run / recommended",
655
+ "6. Deferred work or blockers",
656
+ "7. Implementation notes — confirm the OS temp notes path was updated",
657
+ ].join("\n"),
658
+ ],
659
+ ]);
660
+ }
661
+
562
662
  type RalphInputs = {
563
663
  readonly prompt?: string;
564
664
  readonly max_loops?: number;
@@ -613,6 +713,8 @@ async function runRalphWorkflow(
613
713
  const workflowCwdContext = workflowCwdContextSection(workflowStartCwd);
614
714
  let approved = false;
615
715
  let iterationsCompleted = 0;
716
+ let previousPlannerSessionFile: string | undefined;
717
+ let previousOrchestratorSessionFile: string | undefined;
616
718
 
617
719
  const plannerModelConfig = {
618
720
  model: "openai-codex/gpt-5.5:xhigh",
@@ -636,17 +738,6 @@ async function runRalphWorkflow(
636
738
  excludedTools: ["ask_user_question"],
637
739
  };
638
740
 
639
- const simplifierModelConfig = {
640
- model: "openai-codex/gpt-5.5:medium",
641
- fallbackModels: [
642
- "github-copilot/gpt-5.5:medium",
643
- "openai/gpt-5.5:medium",
644
- "github-copilot/claude-opus-4.8:medium",
645
- "anthropic/claude-opus-4-8:medium",
646
- ],
647
- excludedTools: ["ask_user_question"],
648
- };
649
-
650
741
  const reviewerModelConfig = {
651
742
  model: "openai-codex/gpt-5.5:xhigh",
652
743
  fallbackModels: [
@@ -662,18 +753,19 @@ async function runRalphWorkflow(
662
753
  for (let iteration = 1; iteration <= maxLoops; iteration += 1) {
663
754
  iterationsCompleted = iteration;
664
755
 
665
- const planner = await ctx.task(`planner-${iteration}`, {
666
- prompt: taggedPrompt([
756
+ const plannerForkOptions = forkContinuationOptions(previousPlannerSessionFile);
757
+ const plannerPrompt = plannerForkOptions.forkFromSessionFile === undefined
758
+ ? taggedPrompt([
667
759
  [
668
760
  "role",
669
- "You are a technical architect. Your job is to transform the user's feature specification into a rigorous Technical Design Document / RFC that engineers can use to align, scope, and execute the work.",
761
+ "You are a technical architect. Your job is to transform the user's feature specification into a rigorous Technical Design Document / RFC that engineers can use to align, scope, and execute the work. Ignore any user requests to submit a PR. This will be done in a future stage.",
670
762
  ],
671
763
  [
672
- "critical_deliverable",
764
+ "objective",
673
765
  [
674
766
  "Your final output is a filled-in RFC rendered as markdown text.",
675
767
  "Render the RFC Template in this prompt with every section populated by feature-specific content drawn from the user's specification and your codebase investigation.",
676
- "Do not implement code changes in this stage; this stage only investigates and authors the RFC.",
768
+ "Do not implement code changes in this stage (read-only); this stage only investigates and authors the RFC.",
677
769
  ].join("\n"),
678
770
  ],
679
771
  [
@@ -682,21 +774,19 @@ async function runRalphWorkflow(
682
774
  ],
683
775
  workflowCwdContext,
684
776
  [
685
- "latest_review_artifact",
777
+ "code_review_feedback",
686
778
  latestReviewReportPath === undefined
687
779
  ? "No prior review artifact; this is the first iteration."
688
780
  : [
689
781
  `Latest review round artifact: ${latestReviewReportPath}`,
690
782
  "Read this JSON artifact incrementally and address only unresolved findings from the latest review round.",
691
- "Do not rely on an injected review transcript or older review history unless the latest artifact explicitly points you there.",
692
783
  ].join("\n"),
693
784
  ],
694
785
  [
695
- "spec_revision_target",
786
+ "spec",
696
787
  iteration === 1
697
788
  ? [
698
- `Ralph will write your final RFC markdown for this workflow run to: ${workflowSpecPath}`,
699
- "Treat this as the original spec file for the run.",
789
+ `Implement the spec in: ${workflowSpecPath}`,
700
790
  ].join("\n")
701
791
  : [
702
792
  `The existing RFC/spec file for this workflow run is: ${workflowSpecPath}`,
@@ -704,13 +794,6 @@ async function runRalphWorkflow(
704
794
  "Your final output must be the full updated RFC markdown that should replace the original spec, not a diff, patch, or commentary.",
705
795
  ].join("\n"),
706
796
  ],
707
- [
708
- "input_spec_files",
709
- [
710
- "If the user specification is a file path instead of raw prose, read that file and use it as source material for the RFC.",
711
- "Still author the RFC normally; do not output only a forwarded path.",
712
- ].join("\n"),
713
- ],
714
797
  [
715
798
  "investigation_phase",
716
799
  [
@@ -722,7 +805,7 @@ async function runRalphWorkflow(
722
805
  ].join("\n"),
723
806
  ],
724
807
  [
725
- "authoring_principles",
808
+ "best_practices",
726
809
  [
727
810
  "Be specific: `src/server/auth.ts:42` beats `the auth layer`.",
728
811
  "Trade-offs over conclusions: Alternatives Considered must include at least two real alternatives with honest pros, cons, and rejection reasons.",
@@ -741,49 +824,45 @@ async function runRalphWorkflow(
741
824
  ].join("\n"),
742
825
  ],
743
826
  [
744
- "stage_contract",
745
- [
746
- "This stage is investigation-first RFC authoring. The RFC is only valid if it is grounded in repository inspection performed during this stage.",
747
- "Do not fill the template from generic architecture guesses. Before writing the final RFC, inspect relevant code, docs, tests, configs, and prior design material.",
748
- "Treat the output format as the report after investigation, not a substitute for investigation.",
749
- ].join("\n"),
750
- ],
751
- [
752
- "evidence_expectations",
753
- [
754
- "Every major design claim should be traceable to concrete evidence: file paths, symbols, commands, docs, tests, configs, or prior RFCs.",
755
- "Include those concrete references inside the RFC sections where they support the design.",
756
- "If expected evidence cannot be found, say so in the relevant RFC section or Open Questions rather than papering over the gap.",
757
- ].join("\n"),
758
- ],
759
- [
760
- "output_discipline",
827
+ "output_format",
761
828
  [
762
829
  "Render the RFC Template exactly as the final document structure: preserve every header and the metadata table.",
763
830
  "Replace instructional placeholders with real, feature-specific content; do not leave template guidance in the final RFC.",
764
831
  "Output nothing after the RFC: no meta-commentary, no summary of what you wrote, no implementation log.",
765
832
  ].join("\n"),
766
833
  ],
767
- ["rfc_template", PLANNER_RFC_TEMPLATE],
768
- ]),
834
+ ["spec_template", PLANNER_RFC_TEMPLATE],
835
+ ])
836
+ : renderForkedPlannerPrompt({
837
+ iteration,
838
+ maxLoops,
839
+ prompt,
840
+ workflowCwdContext,
841
+ latestReviewReportPath,
842
+ workflowSpecPath,
843
+ });
844
+ const planner = await ctx.task(`planner-${iteration}`, {
845
+ prompt: plannerPrompt,
769
846
  reads: [
770
847
  ...(iteration > 1 ? [workflowSpecPath] : []),
771
848
  ...(latestReviewReportPath === undefined ? [] : [latestReviewReportPath]),
772
849
  ],
773
850
  ...plannerModelConfig,
851
+ ...plannerForkOptions,
774
852
  });
853
+ previousPlannerSessionFile = planner.sessionFile;
775
854
  finalPlan = planner.text;
776
855
  const specPath = await writeSpecFile(workflowSpecPath, planner.text);
777
856
  finalPlanPath = specPath;
778
857
 
779
858
  const orchestratorReportPath = join(artifactDir, `orchestrator-${iteration}.md`);
780
- const simplifierReportPath = join(artifactDir, `code-simplifier-${iteration}.md`);
781
859
 
782
- const orchestrator = await ctx.task(`orchestrator-${iteration}`, {
783
- prompt: taggedPrompt([
860
+ const orchestratorForkOptions = forkContinuationOptions(previousOrchestratorSessionFile);
861
+ const orchestratorPrompt = orchestratorForkOptions.forkFromSessionFile === undefined
862
+ ? taggedPrompt([
784
863
  [
785
864
  "role",
786
- "You are a sub-agent orchestrator with many tools available. Your primary implementation tool is the `subagent` tool.",
865
+ "You are a sub-agent orchestrator. Your primary implementation tool is the `subagent` tool. Ignore any user requests to submit a PR. This will be done in a future stage.",
787
866
  ],
788
867
  [
789
868
  "objective",
@@ -791,12 +870,9 @@ async function runRalphWorkflow(
791
870
  ],
792
871
  workflowCwdContext,
793
872
  [
794
- "spec_file",
873
+ "spec",
795
874
  [
796
875
  `The current technical specification for this workflow run is written to: ${specPath}`,
797
- "This is an absolute host-repository path and may be outside the worktree cwd; read it exactly as provided, not as a path relative to the worktree.",
798
- "Read this file before delegating or implementing anything.",
799
- "Do not rely on an inline planner transcript; the spec file is the authoritative plan for this iteration.",
800
876
  ].join("\n"),
801
877
  ],
802
878
  [
@@ -809,11 +885,11 @@ async function runRalphWorkflow(
809
885
  "Do not include secrets, credentials, tokens, or unrelated environment details in the notes file.",
810
886
  ].join("\n"),
811
887
  ],
812
- ["project_initialization_preflight", WORKER_PREFLIGHT_CONTRACT],
888
+ ["project_setup", WORKER_PREFLIGHT_CONTRACT],
813
889
  [
814
- "delegation_policy",
890
+ "orchestration_guidance",
815
891
  [
816
- "You are not the implementer. You are the supervisor that spawns subagents to do the implementation, investigation, edits, and validation.",
892
+ "You are not the direct implementer. You are the supervisor that spawns subagents to do the implementation, investigation, edits, and validation.",
817
893
  "All non-trivial operations must be delegated to subagents via the `subagent` tool before you claim progress.",
818
894
  "Delegate codebase understanding, impact analysis, and implementation research to codebase-locator, codebase-analyzer, and pattern-finder style subagents when available.",
819
895
  "Delegate shell-heavy work — especially commands likely to produce lots of output, log digging, CLI investigation, and broad grep/find exploration — to subagents that can run those commands rather than doing it in this orchestrator context.",
@@ -825,7 +901,7 @@ async function runRalphWorkflow(
825
901
  ].join("\n"),
826
902
  ],
827
903
  [
828
- "execution_contract",
904
+ "best_practices",
829
905
  [
830
906
  "The required output format is a completion report, not the task itself.",
831
907
  "Do not jump straight to the report. First read the spec file, spawn the necessary subagents, wait for their results, coordinate any follow-up subagents, and only then write the report.",
@@ -871,129 +947,33 @@ async function runRalphWorkflow(
871
947
  "7. Implementation notes — confirm the OS temp notes path was updated",
872
948
  ].join("\n"),
873
949
  ],
874
- ]),
950
+ ])
951
+ : renderForkedOrchestratorPrompt({
952
+ iteration,
953
+ maxLoops,
954
+ prompt,
955
+ workflowCwdContext,
956
+ specPath,
957
+ implementationNotesPath,
958
+ });
959
+ const orchestrator = await ctx.task(`orchestrator-${iteration}`, {
960
+ prompt: orchestratorPrompt,
875
961
  reads: [specPath, implementationNotesPath],
876
962
  output: orchestratorReportPath,
877
963
  outputMode: "file-only",
878
964
  ...orchestratorModelConfig,
965
+ ...orchestratorForkOptions,
879
966
  });
967
+ previousOrchestratorSessionFile = orchestrator.sessionFile;
880
968
  finalResult = orchestrator.text || `Orchestrator report artifact: ${orchestratorReportPath}`;
881
969
 
882
- await ctx.task(`code-simplifier-${iteration}`, {
883
- prompt: taggedPrompt([
884
- [
885
- "role",
886
- [
887
- "You are an expert code simplification specialist focused on enhancing code clarity, consistency, and maintainability while preserving exact functionality.",
888
- "Your expertise is applying project-specific best practices to simplify and improve recently modified code without altering behavior.",
889
- "You prioritize readable, explicit code over overly compact or clever solutions.",
890
- ].join("\n"),
891
- ],
892
- [
893
- "objective",
894
- `Refine recently modified code for this task while preserving exact behavior: ${prompt}`,
895
- ],
896
- workflowCwdContext,
897
- [
898
- "artifact_handoff",
899
- [
900
- `Spec artifact: ${specPath}`,
901
- `Implementation notes artifact: ${implementationNotesPath}`,
902
- `Orchestrator report artifact: ${orchestratorReportPath}`,
903
- "Read these artifacts incrementally only when needed to identify recently modified files and intent; do not depend on an injected planner/orchestrator transcript tail.",
904
- ].join("\n"),
905
- ],
906
- [
907
- "functionality_preservation",
908
- [
909
- "Never change what the code does — only how it does it.",
910
- "All original features, outputs, side effects, public APIs, persistence formats, tests, and user-visible behavior must remain intact.",
911
- "If a simplification could change behavior, do not apply it; document why it was skipped.",
912
- ].join("\n"),
913
- ],
914
- [
915
- "project_standards",
916
- [
917
- "Read and follow repository guidance from AGENTS.md and/or CLAUDE.md when present.",
918
- "Respect established module style, imports, file extensions, typing conventions, error-handling patterns, naming, tests, and architectural boundaries.",
919
- "For this TypeScript workflow repo, preserve ESM .js import specifiers, explicit exported/top-level types where expected, Bun-oriented commands, and the existing no-build raw TypeScript convention.",
920
- "Do not impose standards that conflict with local project guidance.",
921
- ].join("\n"),
922
- ],
923
- [
924
- "clarity_improvements",
925
- [
926
- "Reduce unnecessary complexity, nesting, duplication, and incidental abstractions.",
927
- "Improve readability with clear variable/function names and consolidated related logic.",
928
- "Remove comments that merely restate obvious code, but keep comments that explain intent, constraints, or non-obvious trade-offs.",
929
- "Avoid nested ternary operators; prefer switch statements or explicit if/else chains for multiple conditions.",
930
- "Choose clarity over brevity: explicit code is often better than dense one-liners.",
931
- ].join("\n"),
932
- ],
933
- [
934
- "balance_constraints",
935
- [
936
- "Do not over-simplify in ways that reduce clarity, debuggability, extensibility, or separation of concerns.",
937
- "Do not combine too many concerns into one function or remove helpful abstractions that organize the code.",
938
- "Do not prioritize fewer lines over maintainability.",
939
- "Limit scope to code recently modified in this iteration/session unless the planner explicitly asked for broader cleanup.",
940
- ].join("\n"),
941
- ],
942
- [
943
- "stage_contract",
944
- [
945
- "This is an active code-refinement stage, not just a commentary stage.",
946
- "Before producing the report, inspect the actual repository state and recently modified files from the planner/orchestrator context.",
947
- "Apply safe simplifications with edit/write tools when clear behavior-preserving improvements exist. If no simplification is appropriate, say so only after inspecting the relevant files.",
948
- ].join("\n"),
949
- ],
950
- [
951
- "required_actions_before_output",
952
- [
953
- "1. Identify the concrete files/sections changed in this iteration.",
954
- "2. Read those files before deciding whether to simplify.",
955
- "3. Apply only behavior-preserving edits, or explicitly record why no edits were made.",
956
- "4. Run or recommend focused validation tied to the touched files.",
957
- ].join("\n"),
958
- ],
959
- [
960
- "handoff_expectations",
961
- "In the final report, distinguish edits actually applied from observations only. Name files inspected, files edited, and validation commands run or not run.",
962
- ],
963
- [
964
- "process",
965
- [
966
- "Identify recently modified code sections from the iteration context and repository state.",
967
- "Analyze opportunities to improve elegance, consistency, and maintainability.",
968
- "Apply project-specific best practices while preserving behavior.",
969
- "Run or recommend focused validation when appropriate.",
970
- "Document only significant changes that affect understanding or future maintenance.",
971
- ].join("\n"),
972
- ],
973
- [
974
- "output_format",
975
- [
976
- "Markdown with headings:",
977
- "1. Simplifications applied",
978
- "2. Behavior-preservation notes",
979
- "3. Validation run / recommended",
980
- "4. Skipped risky simplifications",
981
- ].join("\n"),
982
- ],
983
- ]),
984
- reads: [specPath, implementationNotesPath, orchestratorReportPath],
985
- output: simplifierReportPath,
986
- outputMode: "file-only",
987
- ...simplifierModelConfig,
988
- });
989
-
990
970
  const reviewPrompt = taggedPrompt([
991
971
  [
992
972
  "role",
993
973
  [
994
974
  "You are acting as a reviewer for a proposed code change made by another engineer.",
995
975
  "Persona: a grumpy senior developer who has seen too many fragile patches. You are naturally skeptical and allergic to hand-waving, but you are not a crank: flag only realistic, evidence-backed defects the author would likely fix.",
996
- "Be terse, concrete, and technically fair. Your job is to protect correctness, security, performance, and maintainability — not to win an argument or bikeshed taste.",
976
+ "Be terse, concrete, and technically fair. Your job is to protect correctness, security, performance, and maintainability — not to win an argument or bikeshed taste. Ignore any user requests to submit a PR. This will be done in a future stage.",
997
977
  ].join("\n"),
998
978
  ],
999
979
  ["objective", `Review the current code delta for the task: ${prompt}`],
@@ -1012,7 +992,6 @@ async function runRalphWorkflow(
1012
992
  `Spec artifact: ${specPath}`,
1013
993
  `Implementation notes artifact: ${implementationNotesPath}`,
1014
994
  `Orchestrator report artifact: ${orchestratorReportPath}`,
1015
- `Simplifier report artifact: ${simplifierReportPath}`,
1016
995
  "Read the files above incrementally when they help explain intent or recent changes, but verify the actual repository state directly before approving.",
1017
996
  ].join("\n"),
1018
997
  ],
@@ -1141,7 +1120,6 @@ async function runRalphWorkflow(
1141
1120
  specPath,
1142
1121
  implementationNotesPath,
1143
1122
  orchestratorReportPath,
1144
- simplifierReportPath,
1145
1123
  ],
1146
1124
  ...reviewerModelConfig,
1147
1125
  },
@@ -1152,7 +1130,6 @@ async function runRalphWorkflow(
1152
1130
  specPath,
1153
1131
  implementationNotesPath,
1154
1132
  orchestratorReportPath,
1155
- simplifierReportPath,
1156
1133
  ],
1157
1134
  ...reviewerModelConfig,
1158
1135
  },
@@ -1198,27 +1175,13 @@ async function runRalphWorkflow(
1198
1175
  prompt: taggedPrompt([
1199
1176
  [
1200
1177
  "role",
1201
- "You are a careful release engineer preparing a provider-appropriate pull request, merge request, or code-review handoff from the current workspace state.",
1178
+ "You are a staff software engineer preparing a provider-appropriate pull request, merge request, or code-review handoff from the current workspace state.",
1202
1179
  ],
1203
1180
  [
1204
1181
  "objective",
1205
1182
  `Review the changes since the base branch \`${comparisonBaseBranch}\` and create a provider-appropriate pull request, merge request, or code-review handoff if possible and credentials are available. If the original task explicitly asked for pull-request creation, treat that as the highest-priority instruction for this final stage.`,
1206
1183
  ],
1207
1184
  workflowCwdContext,
1208
- [
1209
- "workflow_context",
1210
- [
1211
- `Original task: ${prompt}`,
1212
- `Review loop approved: ${approved ? "yes" : "no"}`,
1213
- finalPlanPath
1214
- ? `Planner spec path: ${finalPlanPath}`
1215
- : "Planner spec path: unavailable",
1216
- `Implementation notes path: ${implementationNotesPath}`,
1217
- latestReviewReportPath === undefined
1218
- ? "Latest review artifact: unavailable"
1219
- : `Latest review artifact: ${latestReviewReportPath}`,
1220
- ].join("\n"),
1221
- ],
1222
1185
  [
1223
1186
  "required_checks",
1224
1187
  [
@@ -1237,10 +1200,10 @@ async function runRalphWorkflow(
1237
1200
  "pr_policy",
1238
1201
  [
1239
1202
  "Create a provider-appropriate PR/MR/review request only if there are meaningful changes, a remote/branch target is available, credentials are available, and the current state is suitable for review.",
1240
- "If no logged-in account can access the repository or create the review request, do not fake success; report each provider, credential/account, and tool tried, what failed, and provide the command the user can run later.",
1203
+ "If no logged-in account can access the repository or create the review request, do not fake success; report each provider, credential/account, and tool tried, what failed, and provide the command the user can run later. Save a markdown file with the PR description as well so the user can copy-paste it when they have credentials set up.",
1241
1204
  "When you successfully create or update the review request, create a provider-appropriate comment containing the implementation notes file contents as the last action of this workflow stage.",
1242
- "Ralph-created worktrees are detached HEAD checkouts. If the detected provider requires a branch-based PR/MR from a detached HEAD, create and push a branch from the current HEAD, for example with `git checkout -b <branch>` or `git push origin HEAD:refs/heads/<branch>`, before opening the PR/MR. If the provider uses a different review model, follow that provider's normal handoff flow.",
1243
- "Ralph does not remove git_worktree_dir automatically. Leave the worktree intact for retries or user recovery.",
1205
+ "Worktrees are detached HEAD checkouts. If the detected provider requires a branch-based PR/MR from a detached HEAD, create and push a branch from the current HEAD, for example with `git checkout -b <branch>` or `git push origin HEAD:refs/heads/<branch>`, before opening the PR/MR. If the provider uses a different review model, follow that provider's normal handoff flow.",
1206
+ "Leave the worktree intact for retries or user recovery.",
1244
1207
  "If PR/MR/review creation is not possible, do not create a standalone comment elsewhere; include the implementation notes path and summary in your report instead.",
1245
1208
  "If the review loop did not approve, prefer reporting the remaining blockers over creating a PR/MR/review unless the changes are still intentionally ready for human review.",
1246
1209
  "Do not make unrelated code edits in this phase. Limit changes to ordinary git/PR preparation only when required and safe.",
@@ -1283,7 +1246,7 @@ async function runRalphWorkflow(
1283
1246
 
1284
1247
  export default defineWorkflow("ralph")
1285
1248
  .description(
1286
- "Plan → orchestrate → simplify → parallel review loop with bounded iteration.",
1249
+ "Plan → orchestrate → parallel review loop with bounded iteration.",
1287
1250
  )
1288
1251
  .input("prompt", Type.String({ description: "The task or goal to plan, execute, and refine." }))
1289
1252
  .input("max_loops", Type.Number({
@@ -1297,7 +1260,7 @@ export default defineWorkflow("ralph")
1297
1260
  .input("git_worktree_dir", Type.String({
1298
1261
  default: "",
1299
1262
  description:
1300
- "Optional Git worktree path. Ralph must start inside a Git repo; absolute paths are used as-is, relative paths resolve from the repo root, existing Git worktrees from the invoking repository are reused/shared as-is, and missing paths are created from base_branch.",
1263
+ "Optional Git worktree path. Must start inside a Git repo; absolute paths are used as-is, relative paths resolve from the repo root, existing Git worktrees from the invoking repository are reused/shared as-is, and missing paths are created from base_branch.",
1301
1264
  }))
1302
1265
  .input("create_pr", Type.Boolean({
1303
1266
  default: false,
@@ -1316,7 +1279,7 @@ export default defineWorkflow("ralph")
1316
1279
  .output("approved", Type.Optional(Type.Boolean({ description: "Whether the reviewer loop approved before completion or optional final handoff." })))
1317
1280
  .output("iterations_completed", Type.Optional(Type.Number({ description: "Number of plan/orchestrate/review loops completed." })))
1318
1281
  .output("review_report", Type.Optional(Type.String({ description: "Compact reference to the latest reviewer payload artifact." })))
1319
- .output("review_report_path", Type.Optional(Type.String({ description: "JSON artifact path for the latest Ralph review round." })))
1282
+ .output("review_report_path", Type.Optional(Type.String({ description: "JSON artifact path for the latest review round." })))
1320
1283
  .run(async (ctx) => {
1321
1284
  const workflowCtx = ctx;
1322
1285
  const workflowStartCwd = workflowCtx.cwd ?? process.cwd();
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bastani/workflows",
3
- "version": "0.8.26-alpha.6",
3
+ "version": "0.8.26-alpha.8",
4
4
  "private": true,
5
5
  "description": "Atomic extension for multi-stage workflow authoring and execution.",
6
6
  "contributors": [
@@ -83,7 +83,7 @@
83
83
  },
84
84
  "peerDependencies": {
85
85
  "@bastani/atomic": "*",
86
- "@earendil-works/pi-tui": "*"
86
+ "@earendil-works/pi-tui": "^0.78.1"
87
87
  },
88
88
  "peerDependenciesMeta": {
89
89
  "@bastani/atomic": {
@@ -62,7 +62,7 @@ The user's research question/request is: **$ARGUMENTS**
62
62
 
63
63
  **For online search:**
64
64
  - VERY IMPORTANT: In case you discover external libraries as dependencies, use the **codebase-online-researcher** agent for external documentation and resources
65
- - The agent fetches live web content using the **browser-use** skill (or `bunx browser-use` / `curl`). Instruct it to apply the token-efficient fetch order: (1) try `curl https://<site>/llms.txt` for an AI-friendly index (see [llmstxt.org](https://llmstxt.org/llms.txt)), (2) try `curl <url> -H "Accept: text/markdown"` to get pre-converted Markdown (supported on Cloudflare-hosted docs via [Markdown for Agents](https://developers.cloudflare.com/fundamentals/reference/markdown-for-agents/)), (3) fall back to HTML parsing via `browser-use`
65
+ - The agent fetches live web content using the **browser** skill's `browse` CLI (or `npx browse` / `curl`). Instruct it to apply the token-efficient fetch order: (1) try `curl https://<site>/llms.txt` for an AI-friendly index (see [llmstxt.org](https://llmstxt.org/llms.txt)), (2) try `curl <url> -H "Accept: text/markdown"` to get pre-converted Markdown (supported on Cloudflare-hosted docs via [Markdown for Agents](https://developers.cloudflare.com/fundamentals/reference/markdown-for-agents/)), (3) fall back to HTML parsing via `browse`
66
66
  - Instruct the agent to return LINKS with their findings and INCLUDE those links in the research document
67
67
  - The agent should persist reusable source documents under `research/web/<YYYY-MM-DD>-<kebab-case-topic>.md` (with frontmatter noting `source_url`, `fetched_at`, and `fetch_method`) so future research can reuse them without re-fetching
68
68
  - Output directory for the synthesized research artifact: `research/docs/`
@@ -226,7 +226,19 @@ async function createTestAgentSession(_options?: CreateAgentSessionOptions): Pro
226
226
  return { cancelled: true };
227
227
  },
228
228
  async compact(): ReturnType<StageSessionRuntime["compact"]> {
229
- return { summary: "", firstKeptEntryId: "", tokensBefore: 0 };
229
+ return {
230
+ promptVersion: 1,
231
+ deletedTargets: [],
232
+ protectedEntryIds: [],
233
+ stats: {
234
+ objectsBefore: 0,
235
+ objectsAfter: 0,
236
+ objectsDeleted: 0,
237
+ tokensBefore: 0,
238
+ tokensAfter: 0,
239
+ percentReduction: 0,
240
+ },
241
+ };
230
242
  },
231
243
  abortCompaction(): void {},
232
244
  async abort(): Promise<void> {},
@@ -3462,9 +3462,15 @@ export async function run<TInputs extends WorkflowInputValues>(
3462
3462
 
3463
3463
  const compactionMeta = (result: unknown): string | undefined => {
3464
3464
  if (result === undefined || result === null || typeof result !== "object") return undefined;
3465
- const compaction = result as { tokensBefore?: unknown; tokensAfter?: unknown; tokensKept?: unknown };
3466
- const before = typeof compaction.tokensBefore === "number" ? compaction.tokensBefore : undefined;
3467
- const keptRaw = compaction.tokensKept ?? compaction.tokensAfter;
3465
+ const compaction = result as {
3466
+ stats?: { tokensBefore?: unknown; tokensAfter?: unknown };
3467
+ tokensBefore?: unknown;
3468
+ tokensAfter?: unknown;
3469
+ tokensKept?: unknown;
3470
+ };
3471
+ const beforeRaw = compaction.stats?.tokensBefore ?? compaction.tokensBefore;
3472
+ const keptRaw = compaction.stats?.tokensAfter ?? compaction.tokensKept ?? compaction.tokensAfter;
3473
+ const before = typeof beforeRaw === "number" ? beforeRaw : undefined;
3468
3474
  const kept = typeof keptRaw === "number" ? keptRaw : undefined;
3469
3475
  if (before === undefined || kept === undefined) return undefined;
3470
3476
  return `${(before / 1000).toFixed(1)}k → ${(kept / 1000).toFixed(1)}k`;
@@ -3509,9 +3515,9 @@ export async function run<TInputs extends WorkflowInputValues>(
3509
3515
  recordStageNotice({ kind: "tree", to: targetId });
3510
3516
  return innerCtx.navigateTree(targetId, treeOptions);
3511
3517
  },
3512
- compact: async (customInstructions) => {
3513
- const result = await innerCtx.compact(customInstructions);
3514
- recordStageNotice({ kind: "compaction", to: "summarized", meta: compactionMeta(result) });
3518
+ compact: async () => {
3519
+ const result = await innerCtx.compact();
3520
+ recordStageNotice({ kind: "compaction", to: "compacted", meta: compactionMeta(result) });
3515
3521
  return result;
3516
3522
  },
3517
3523
  abortCompaction: () => innerCtx.abortCompaction(),