@bastani/atomic 0.5.11 → 0.5.12-0

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 (506) hide show
  1. package/.agents/skills/adapt/SKILL.md +199 -0
  2. package/.agents/skills/advanced-evaluation/SKILL.md +402 -0
  3. package/.agents/skills/advanced-evaluation/references/bias-mitigation.md +288 -0
  4. package/.agents/skills/advanced-evaluation/references/evaluation-pipeline.md +43 -0
  5. package/.agents/skills/advanced-evaluation/references/implementation-patterns.md +315 -0
  6. package/.agents/skills/advanced-evaluation/references/metrics-guide.md +331 -0
  7. package/.agents/skills/advanced-evaluation/scripts/evaluation_example.py +392 -0
  8. package/.agents/skills/animate/SKILL.md +175 -0
  9. package/.agents/skills/arrange/SKILL.md +124 -0
  10. package/.agents/skills/audit/SKILL.md +148 -0
  11. package/.agents/skills/bdi-mental-states/SKILL.md +311 -0
  12. package/.agents/skills/bdi-mental-states/references/bdi-ontology-core.md +207 -0
  13. package/.agents/skills/bdi-mental-states/references/framework-integration.md +582 -0
  14. package/.agents/skills/bdi-mental-states/references/rdf-examples.md +315 -0
  15. package/.agents/skills/bdi-mental-states/references/sparql-competency.md +420 -0
  16. package/.agents/skills/bolder/SKILL.md +117 -0
  17. package/.agents/skills/bun/SKILL.md +199 -0
  18. package/.agents/skills/clarify/SKILL.md +183 -0
  19. package/.agents/skills/colorize/SKILL.md +143 -0
  20. package/.agents/skills/context-compression/SKILL.md +272 -0
  21. package/.agents/skills/context-compression/references/evaluation-framework.md +213 -0
  22. package/.agents/skills/context-compression/scripts/compression_evaluator.py +862 -0
  23. package/.agents/skills/context-compression/tests/test_compression_evaluator.py +56 -0
  24. package/.agents/skills/context-degradation/SKILL.md +206 -0
  25. package/.agents/skills/context-degradation/references/patterns.md +314 -0
  26. package/.agents/skills/context-degradation/scripts/degradation_detector.py +614 -0
  27. package/.agents/skills/context-fundamentals/SKILL.md +201 -0
  28. package/.agents/skills/context-fundamentals/references/context-components.md +283 -0
  29. package/.agents/skills/context-fundamentals/scripts/context_manager.py +533 -0
  30. package/.agents/skills/context-optimization/SKILL.md +195 -0
  31. package/.agents/skills/context-optimization/references/optimization_techniques.md +272 -0
  32. package/.agents/skills/context-optimization/scripts/compaction.py +562 -0
  33. package/.agents/skills/create-spec/SKILL.md +244 -0
  34. package/.agents/skills/critique/SKILL.md +225 -0
  35. package/.agents/skills/critique/reference/cognitive-load.md +106 -0
  36. package/.agents/skills/critique/reference/heuristics-scoring.md +234 -0
  37. package/.agents/skills/critique/reference/personas.md +178 -0
  38. package/.agents/skills/delight/SKILL.md +304 -0
  39. package/.agents/skills/distill/SKILL.md +122 -0
  40. package/.agents/skills/docx/LICENSE.txt +30 -0
  41. package/.agents/skills/docx/SKILL.md +590 -0
  42. package/.agents/skills/docx/scripts/__init__.py +1 -0
  43. package/.agents/skills/docx/scripts/accept_changes.py +135 -0
  44. package/.agents/skills/docx/scripts/comment.py +318 -0
  45. package/.agents/skills/docx/scripts/office/helpers/__init__.py +0 -0
  46. package/.agents/skills/docx/scripts/office/helpers/merge_runs.py +199 -0
  47. package/.agents/skills/docx/scripts/office/helpers/simplify_redlines.py +197 -0
  48. package/.agents/skills/docx/scripts/office/pack.py +159 -0
  49. package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
  50. package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
  51. package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
  52. package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
  53. package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
  54. package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
  55. package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
  56. package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
  57. package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
  58. package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
  59. package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
  60. package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
  61. package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
  62. package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
  63. package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
  64. package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
  65. package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
  66. package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
  67. package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
  68. package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
  69. package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
  70. package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
  71. package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
  72. package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
  73. package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
  74. package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
  75. package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
  76. package/.agents/skills/docx/scripts/office/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
  77. package/.agents/skills/docx/scripts/office/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
  78. package/.agents/skills/docx/scripts/office/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
  79. package/.agents/skills/docx/scripts/office/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
  80. package/.agents/skills/docx/scripts/office/schemas/mce/mc.xsd +75 -0
  81. package/.agents/skills/docx/scripts/office/schemas/microsoft/wml-2010.xsd +560 -0
  82. package/.agents/skills/docx/scripts/office/schemas/microsoft/wml-2012.xsd +67 -0
  83. package/.agents/skills/docx/scripts/office/schemas/microsoft/wml-2018.xsd +14 -0
  84. package/.agents/skills/docx/scripts/office/schemas/microsoft/wml-cex-2018.xsd +20 -0
  85. package/.agents/skills/docx/scripts/office/schemas/microsoft/wml-cid-2016.xsd +13 -0
  86. package/.agents/skills/docx/scripts/office/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
  87. package/.agents/skills/docx/scripts/office/schemas/microsoft/wml-symex-2015.xsd +8 -0
  88. package/.agents/skills/docx/scripts/office/soffice.py +183 -0
  89. package/.agents/skills/docx/scripts/office/unpack.py +132 -0
  90. package/.agents/skills/docx/scripts/office/validate.py +111 -0
  91. package/.agents/skills/docx/scripts/office/validators/__init__.py +15 -0
  92. package/.agents/skills/docx/scripts/office/validators/base.py +847 -0
  93. package/.agents/skills/docx/scripts/office/validators/docx.py +446 -0
  94. package/.agents/skills/docx/scripts/office/validators/pptx.py +275 -0
  95. package/.agents/skills/docx/scripts/office/validators/redlining.py +247 -0
  96. package/.agents/skills/docx/scripts/templates/comments.xml +3 -0
  97. package/.agents/skills/docx/scripts/templates/commentsExtended.xml +3 -0
  98. package/.agents/skills/docx/scripts/templates/commentsExtensible.xml +3 -0
  99. package/.agents/skills/docx/scripts/templates/commentsIds.xml +3 -0
  100. package/.agents/skills/docx/scripts/templates/people.xml +3 -0
  101. package/.agents/skills/evaluation/SKILL.md +251 -0
  102. package/.agents/skills/evaluation/references/metrics.md +339 -0
  103. package/.agents/skills/evaluation/scripts/evaluator.py +627 -0
  104. package/.agents/skills/explain-code/SKILL.md +230 -0
  105. package/.agents/skills/extract/SKILL.md +91 -0
  106. package/.agents/skills/filesystem-context/SKILL.md +287 -0
  107. package/.agents/skills/filesystem-context/references/implementation-patterns.md +549 -0
  108. package/.agents/skills/filesystem-context/scripts/filesystem_context.py +425 -0
  109. package/.agents/skills/find-skills/SKILL.md +142 -0
  110. package/.agents/skills/frontend-design/SKILL.md +147 -0
  111. package/.agents/skills/frontend-design/reference/color-and-contrast.md +132 -0
  112. package/.agents/skills/frontend-design/reference/interaction-design.md +195 -0
  113. package/.agents/skills/frontend-design/reference/motion-design.md +99 -0
  114. package/.agents/skills/frontend-design/reference/responsive-design.md +114 -0
  115. package/.agents/skills/frontend-design/reference/spatial-design.md +100 -0
  116. package/.agents/skills/frontend-design/reference/typography.md +133 -0
  117. package/.agents/skills/frontend-design/reference/ux-writing.md +107 -0
  118. package/.agents/skills/gh-commit/SKILL.md +243 -0
  119. package/.agents/skills/gh-create-pr/SKILL.md +93 -0
  120. package/.agents/skills/harden/SKILL.md +354 -0
  121. package/.agents/skills/hosted-agents/SKILL.md +260 -0
  122. package/.agents/skills/hosted-agents/references/infrastructure-patterns.md +700 -0
  123. package/.agents/skills/hosted-agents/scripts/sandbox_manager.py +590 -0
  124. package/.agents/skills/impeccable/SKILL.md +365 -0
  125. package/.agents/skills/impeccable/reference/color-and-contrast.md +105 -0
  126. package/.agents/skills/impeccable/reference/craft.md +70 -0
  127. package/.agents/skills/impeccable/reference/extract.md +70 -0
  128. package/.agents/skills/impeccable/reference/interaction-design.md +195 -0
  129. package/.agents/skills/impeccable/reference/motion-design.md +99 -0
  130. package/.agents/skills/impeccable/reference/responsive-design.md +114 -0
  131. package/.agents/skills/impeccable/reference/spatial-design.md +100 -0
  132. package/.agents/skills/impeccable/reference/typography.md +142 -0
  133. package/.agents/skills/impeccable/reference/ux-writing.md +107 -0
  134. package/.agents/skills/impeccable/scripts/cleanup-deprecated.mjs +214 -0
  135. package/.agents/skills/init/SKILL.md +138 -0
  136. package/.agents/skills/layout/SKILL.md +125 -0
  137. package/.agents/skills/liteparse/SKILL.md +222 -0
  138. package/.agents/skills/memory-systems/SKILL.md +219 -0
  139. package/.agents/skills/memory-systems/references/implementation.md +551 -0
  140. package/.agents/skills/memory-systems/scripts/memory_store.py +616 -0
  141. package/.agents/skills/multi-agent-patterns/SKILL.md +257 -0
  142. package/.agents/skills/multi-agent-patterns/references/frameworks.md +433 -0
  143. package/.agents/skills/multi-agent-patterns/scripts/coordination.py +613 -0
  144. package/.agents/skills/normalize/SKILL.md +70 -0
  145. package/.agents/skills/onboard/SKILL.md +245 -0
  146. package/.agents/skills/opentui/SKILL.md +201 -0
  147. package/.agents/skills/opentui/references/animation/REFERENCE.md +431 -0
  148. package/.agents/skills/opentui/references/components/REFERENCE.md +144 -0
  149. package/.agents/skills/opentui/references/components/code-diff.md +672 -0
  150. package/.agents/skills/opentui/references/components/containers.md +417 -0
  151. package/.agents/skills/opentui/references/components/inputs.md +531 -0
  152. package/.agents/skills/opentui/references/components/text-display.md +386 -0
  153. package/.agents/skills/opentui/references/core/REFERENCE.md +145 -0
  154. package/.agents/skills/opentui/references/core/api.md +543 -0
  155. package/.agents/skills/opentui/references/core/configuration.md +168 -0
  156. package/.agents/skills/opentui/references/core/gotchas.md +393 -0
  157. package/.agents/skills/opentui/references/core/patterns.md +449 -0
  158. package/.agents/skills/opentui/references/keyboard/REFERENCE.md +617 -0
  159. package/.agents/skills/opentui/references/layout/REFERENCE.md +337 -0
  160. package/.agents/skills/opentui/references/layout/patterns.md +444 -0
  161. package/.agents/skills/opentui/references/react/REFERENCE.md +174 -0
  162. package/.agents/skills/opentui/references/react/api.md +436 -0
  163. package/.agents/skills/opentui/references/react/configuration.md +302 -0
  164. package/.agents/skills/opentui/references/react/gotchas.md +443 -0
  165. package/.agents/skills/opentui/references/react/patterns.md +501 -0
  166. package/.agents/skills/opentui/references/solid/REFERENCE.md +201 -0
  167. package/.agents/skills/opentui/references/solid/api.md +564 -0
  168. package/.agents/skills/opentui/references/solid/configuration.md +316 -0
  169. package/.agents/skills/opentui/references/solid/gotchas.md +427 -0
  170. package/.agents/skills/opentui/references/solid/patterns.md +560 -0
  171. package/.agents/skills/opentui/references/testing/REFERENCE.md +614 -0
  172. package/.agents/skills/optimize/SKILL.md +266 -0
  173. package/.agents/skills/overdrive/SKILL.md +142 -0
  174. package/.agents/skills/pdf/LICENSE.txt +30 -0
  175. package/.agents/skills/pdf/SKILL.md +314 -0
  176. package/.agents/skills/pdf/forms.md +294 -0
  177. package/.agents/skills/pdf/reference.md +612 -0
  178. package/.agents/skills/pdf/scripts/check_bounding_boxes.py +65 -0
  179. package/.agents/skills/pdf/scripts/check_fillable_fields.py +11 -0
  180. package/.agents/skills/pdf/scripts/convert_pdf_to_images.py +33 -0
  181. package/.agents/skills/pdf/scripts/create_validation_image.py +37 -0
  182. package/.agents/skills/pdf/scripts/extract_form_field_info.py +122 -0
  183. package/.agents/skills/pdf/scripts/extract_form_structure.py +115 -0
  184. package/.agents/skills/pdf/scripts/fill_fillable_fields.py +98 -0
  185. package/.agents/skills/pdf/scripts/fill_pdf_form_with_annotations.py +107 -0
  186. package/.agents/skills/playwright-cli/SKILL.md +344 -0
  187. package/.agents/skills/playwright-cli/references/element-attributes.md +23 -0
  188. package/.agents/skills/playwright-cli/references/playwright-tests.md +39 -0
  189. package/.agents/skills/playwright-cli/references/request-mocking.md +87 -0
  190. package/.agents/skills/playwright-cli/references/running-code.md +231 -0
  191. package/.agents/skills/playwright-cli/references/session-management.md +169 -0
  192. package/.agents/skills/playwright-cli/references/storage-state.md +275 -0
  193. package/.agents/skills/playwright-cli/references/test-generation.md +88 -0
  194. package/.agents/skills/playwright-cli/references/tracing.md +139 -0
  195. package/.agents/skills/playwright-cli/references/video-recording.md +143 -0
  196. package/.agents/skills/polish/SKILL.md +224 -0
  197. package/.agents/skills/pptx/LICENSE.txt +30 -0
  198. package/.agents/skills/pptx/SKILL.md +232 -0
  199. package/.agents/skills/pptx/editing.md +205 -0
  200. package/.agents/skills/pptx/pptxgenjs.md +420 -0
  201. package/.agents/skills/pptx/scripts/__init__.py +0 -0
  202. package/.agents/skills/pptx/scripts/add_slide.py +195 -0
  203. package/.agents/skills/pptx/scripts/clean.py +286 -0
  204. package/.agents/skills/pptx/scripts/office/helpers/__init__.py +0 -0
  205. package/.agents/skills/pptx/scripts/office/helpers/merge_runs.py +199 -0
  206. package/.agents/skills/pptx/scripts/office/helpers/simplify_redlines.py +197 -0
  207. package/.agents/skills/pptx/scripts/office/pack.py +159 -0
  208. package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
  209. package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
  210. package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
  211. package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
  212. package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
  213. package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
  214. package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
  215. package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
  216. package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
  217. package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
  218. package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
  219. package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
  220. package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
  221. package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
  222. package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
  223. package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
  224. package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
  225. package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
  226. package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
  227. package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
  228. package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
  229. package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
  230. package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
  231. package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
  232. package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
  233. package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
  234. package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
  235. package/.agents/skills/pptx/scripts/office/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
  236. package/.agents/skills/pptx/scripts/office/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
  237. package/.agents/skills/pptx/scripts/office/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
  238. package/.agents/skills/pptx/scripts/office/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
  239. package/.agents/skills/pptx/scripts/office/schemas/mce/mc.xsd +75 -0
  240. package/.agents/skills/pptx/scripts/office/schemas/microsoft/wml-2010.xsd +560 -0
  241. package/.agents/skills/pptx/scripts/office/schemas/microsoft/wml-2012.xsd +67 -0
  242. package/.agents/skills/pptx/scripts/office/schemas/microsoft/wml-2018.xsd +14 -0
  243. package/.agents/skills/pptx/scripts/office/schemas/microsoft/wml-cex-2018.xsd +20 -0
  244. package/.agents/skills/pptx/scripts/office/schemas/microsoft/wml-cid-2016.xsd +13 -0
  245. package/.agents/skills/pptx/scripts/office/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
  246. package/.agents/skills/pptx/scripts/office/schemas/microsoft/wml-symex-2015.xsd +8 -0
  247. package/.agents/skills/pptx/scripts/office/soffice.py +183 -0
  248. package/.agents/skills/pptx/scripts/office/unpack.py +132 -0
  249. package/.agents/skills/pptx/scripts/office/validate.py +111 -0
  250. package/.agents/skills/pptx/scripts/office/validators/__init__.py +15 -0
  251. package/.agents/skills/pptx/scripts/office/validators/base.py +847 -0
  252. package/.agents/skills/pptx/scripts/office/validators/docx.py +446 -0
  253. package/.agents/skills/pptx/scripts/office/validators/pptx.py +275 -0
  254. package/.agents/skills/pptx/scripts/office/validators/redlining.py +247 -0
  255. package/.agents/skills/pptx/scripts/thumbnail.py +289 -0
  256. package/.agents/skills/project-development/SKILL.md +291 -0
  257. package/.agents/skills/project-development/references/case-studies.md +388 -0
  258. package/.agents/skills/project-development/references/pipeline-patterns.md +610 -0
  259. package/.agents/skills/project-development/scripts/pipeline_template.py +796 -0
  260. package/.agents/skills/prompt-engineer/SKILL.md +263 -0
  261. package/.agents/skills/prompt-engineer/references/advanced_patterns.md +271 -0
  262. package/.agents/skills/prompt-engineer/references/core_prompting.md +137 -0
  263. package/.agents/skills/prompt-engineer/references/quality_improvement.md +193 -0
  264. package/.agents/skills/quieter/SKILL.md +103 -0
  265. package/.agents/skills/research-codebase/SKILL.md +227 -0
  266. package/.agents/skills/shape/SKILL.md +96 -0
  267. package/.agents/skills/skill-creator/LICENSE.txt +202 -0
  268. package/.agents/skills/skill-creator/SKILL.md +485 -0
  269. package/.agents/skills/skill-creator/agents/analyzer.md +274 -0
  270. package/.agents/skills/skill-creator/agents/comparator.md +202 -0
  271. package/.agents/skills/skill-creator/agents/grader.md +223 -0
  272. package/.agents/skills/skill-creator/assets/eval_review.html +146 -0
  273. package/.agents/skills/skill-creator/eval-viewer/generate_review.py +471 -0
  274. package/.agents/skills/skill-creator/eval-viewer/viewer.html +1325 -0
  275. package/.agents/skills/skill-creator/references/schemas.md +430 -0
  276. package/.agents/skills/skill-creator/scripts/__init__.py +0 -0
  277. package/.agents/skills/skill-creator/scripts/aggregate_benchmark.py +401 -0
  278. package/.agents/skills/skill-creator/scripts/generate_report.py +326 -0
  279. package/.agents/skills/skill-creator/scripts/improve_description.py +247 -0
  280. package/.agents/skills/skill-creator/scripts/package_skill.py +136 -0
  281. package/.agents/skills/skill-creator/scripts/quick_validate.py +103 -0
  282. package/.agents/skills/skill-creator/scripts/run_eval.py +310 -0
  283. package/.agents/skills/skill-creator/scripts/run_loop.py +328 -0
  284. package/.agents/skills/skill-creator/scripts/utils.py +47 -0
  285. package/.agents/skills/sl-commit/SKILL.md +51 -0
  286. package/.agents/skills/sl-submit-diff/SKILL.md +55 -0
  287. package/.agents/skills/teach-impeccable/SKILL.md +71 -0
  288. package/.agents/skills/test-driven-development/SKILL.md +371 -0
  289. package/.agents/skills/test-driven-development/testing-anti-patterns.md +299 -0
  290. package/.agents/skills/tool-design/SKILL.md +271 -0
  291. package/.agents/skills/tool-design/references/architectural_reduction.md +210 -0
  292. package/.agents/skills/tool-design/references/best_practices.md +176 -0
  293. package/.agents/skills/tool-design/scripts/description_generator.py +528 -0
  294. package/.agents/skills/typescript-advanced-types/SKILL.md +719 -0
  295. package/.agents/skills/typescript-expert/SKILL.md +428 -0
  296. package/.agents/skills/typescript-expert/references/tsconfig-strict.json +92 -0
  297. package/.agents/skills/typescript-expert/references/typescript-cheatsheet.md +383 -0
  298. package/.agents/skills/typescript-expert/references/utility-types.ts +335 -0
  299. package/.agents/skills/typescript-expert/scripts/ts_diagnostic.py +203 -0
  300. package/.agents/skills/typescript-react-reviewer/SKILL.md +200 -0
  301. package/.agents/skills/typescript-react-reviewer/references/antipatterns.md +510 -0
  302. package/.agents/skills/typescript-react-reviewer/references/checklist.md +267 -0
  303. package/.agents/skills/typescript-react-reviewer/references/react19-patterns.md +305 -0
  304. package/.agents/skills/typeset/SKILL.md +116 -0
  305. package/.agents/skills/workflow-creator/SKILL.md +337 -0
  306. package/.agents/skills/workflow-creator/references/agent-sessions.md +789 -0
  307. package/.agents/skills/workflow-creator/references/computation-and-validation.md +224 -0
  308. package/.agents/skills/workflow-creator/references/control-flow.md +450 -0
  309. package/.agents/skills/workflow-creator/references/discovery-and-verification.md +156 -0
  310. package/.agents/skills/workflow-creator/references/failure-modes.md +732 -0
  311. package/.agents/skills/workflow-creator/references/getting-started.md +289 -0
  312. package/.agents/skills/workflow-creator/references/session-config.md +355 -0
  313. package/.agents/skills/workflow-creator/references/state-and-data-flow.md +374 -0
  314. package/.agents/skills/workflow-creator/references/user-input.md +206 -0
  315. package/.agents/skills/workflow-creator/references/workflow-inputs.md +274 -0
  316. package/.agents/skills/xlsx/LICENSE.txt +30 -0
  317. package/.agents/skills/xlsx/SKILL.md +292 -0
  318. package/.agents/skills/xlsx/scripts/office/helpers/__init__.py +0 -0
  319. package/.agents/skills/xlsx/scripts/office/helpers/merge_runs.py +199 -0
  320. package/.agents/skills/xlsx/scripts/office/helpers/simplify_redlines.py +197 -0
  321. package/.agents/skills/xlsx/scripts/office/pack.py +159 -0
  322. package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
  323. package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
  324. package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
  325. package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
  326. package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
  327. package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
  328. package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
  329. package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
  330. package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
  331. package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
  332. package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
  333. package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
  334. package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
  335. package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
  336. package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
  337. package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
  338. package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
  339. package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
  340. package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
  341. package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
  342. package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
  343. package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
  344. package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
  345. package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
  346. package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
  347. package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
  348. package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
  349. package/.agents/skills/xlsx/scripts/office/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
  350. package/.agents/skills/xlsx/scripts/office/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
  351. package/.agents/skills/xlsx/scripts/office/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
  352. package/.agents/skills/xlsx/scripts/office/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
  353. package/.agents/skills/xlsx/scripts/office/schemas/mce/mc.xsd +75 -0
  354. package/.agents/skills/xlsx/scripts/office/schemas/microsoft/wml-2010.xsd +560 -0
  355. package/.agents/skills/xlsx/scripts/office/schemas/microsoft/wml-2012.xsd +67 -0
  356. package/.agents/skills/xlsx/scripts/office/schemas/microsoft/wml-2018.xsd +14 -0
  357. package/.agents/skills/xlsx/scripts/office/schemas/microsoft/wml-cex-2018.xsd +20 -0
  358. package/.agents/skills/xlsx/scripts/office/schemas/microsoft/wml-cid-2016.xsd +13 -0
  359. package/.agents/skills/xlsx/scripts/office/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
  360. package/.agents/skills/xlsx/scripts/office/schemas/microsoft/wml-symex-2015.xsd +8 -0
  361. package/.agents/skills/xlsx/scripts/office/soffice.py +183 -0
  362. package/.agents/skills/xlsx/scripts/office/unpack.py +132 -0
  363. package/.agents/skills/xlsx/scripts/office/validate.py +111 -0
  364. package/.agents/skills/xlsx/scripts/office/validators/__init__.py +15 -0
  365. package/.agents/skills/xlsx/scripts/office/validators/base.py +847 -0
  366. package/.agents/skills/xlsx/scripts/office/validators/docx.py +446 -0
  367. package/.agents/skills/xlsx/scripts/office/validators/pptx.py +275 -0
  368. package/.agents/skills/xlsx/scripts/office/validators/redlining.py +247 -0
  369. package/.agents/skills/xlsx/scripts/recalc.py +184 -0
  370. package/.claude/agents/reviewer.md +1 -0
  371. package/.github/agents/reviewer.md +1 -0
  372. package/.opencode/agents/reviewer.md +1 -0
  373. package/README.md +274 -169
  374. package/package.json +6 -7
  375. package/src/commands/cli/init/index.ts +2 -2
  376. package/src/commands/cli/init/scm.ts +7 -8
  377. package/src/commands/cli/workflow-command.test.ts +74 -0
  378. package/src/commands/cli/workflow.ts +7 -2
  379. package/src/scripts/bundle-configs.ts +128 -0
  380. package/src/sdk/components/compact-switcher.tsx +1 -1
  381. package/src/sdk/components/orchestrator-panel-store.ts +13 -0
  382. package/src/sdk/components/orchestrator-panel.tsx +10 -0
  383. package/src/sdk/components/statusline.tsx +13 -1
  384. package/src/sdk/providers/claude.ts +42 -0
  385. package/src/sdk/runtime/executor.ts +111 -32
  386. package/src/sdk/types.ts +7 -0
  387. package/src/sdk/workflows/builtin/ralph/claude/index.ts +132 -76
  388. package/src/sdk/workflows/builtin/ralph/copilot/index.ts +129 -71
  389. package/src/sdk/workflows/builtin/ralph/helpers/git.ts +184 -17
  390. package/src/sdk/workflows/builtin/ralph/helpers/prompts.ts +463 -79
  391. package/src/sdk/workflows/builtin/ralph/opencode/index.ts +124 -80
  392. package/src/services/system/auto-sync.ts +31 -51
  393. package/src/services/system/skills.ts +56 -60
  394. package/dist/lib/path-root-guard.d.ts +0 -4
  395. package/dist/lib/path-root-guard.d.ts.map +0 -1
  396. package/dist/sdk/components/color-utils.d.ts +0 -4
  397. package/dist/sdk/components/color-utils.d.ts.map +0 -1
  398. package/dist/sdk/components/compact-switcher.d.ts +0 -10
  399. package/dist/sdk/components/compact-switcher.d.ts.map +0 -1
  400. package/dist/sdk/components/connectors.d.ts +0 -15
  401. package/dist/sdk/components/connectors.d.ts.map +0 -1
  402. package/dist/sdk/components/connectors.test.d.ts +0 -2
  403. package/dist/sdk/components/connectors.test.d.ts.map +0 -1
  404. package/dist/sdk/components/edge.d.ts +0 -4
  405. package/dist/sdk/components/edge.d.ts.map +0 -1
  406. package/dist/sdk/components/error-boundary.d.ts +0 -23
  407. package/dist/sdk/components/error-boundary.d.ts.map +0 -1
  408. package/dist/sdk/components/graph-theme.d.ts +0 -17
  409. package/dist/sdk/components/graph-theme.d.ts.map +0 -1
  410. package/dist/sdk/components/header.d.ts +0 -3
  411. package/dist/sdk/components/header.d.ts.map +0 -1
  412. package/dist/sdk/components/hooks.d.ts +0 -15
  413. package/dist/sdk/components/hooks.d.ts.map +0 -1
  414. package/dist/sdk/components/layout.d.ts +0 -27
  415. package/dist/sdk/components/layout.d.ts.map +0 -1
  416. package/dist/sdk/components/layout.test.d.ts +0 -2
  417. package/dist/sdk/components/layout.test.d.ts.map +0 -1
  418. package/dist/sdk/components/node-card.d.ts +0 -10
  419. package/dist/sdk/components/node-card.d.ts.map +0 -1
  420. package/dist/sdk/components/orchestrator-panel-contexts.d.ts +0 -16
  421. package/dist/sdk/components/orchestrator-panel-contexts.d.ts.map +0 -1
  422. package/dist/sdk/components/orchestrator-panel-store.d.ts +0 -46
  423. package/dist/sdk/components/orchestrator-panel-store.d.ts.map +0 -1
  424. package/dist/sdk/components/orchestrator-panel-store.test.d.ts +0 -2
  425. package/dist/sdk/components/orchestrator-panel-store.test.d.ts.map +0 -1
  426. package/dist/sdk/components/orchestrator-panel-types.d.ts +0 -18
  427. package/dist/sdk/components/orchestrator-panel-types.d.ts.map +0 -1
  428. package/dist/sdk/components/orchestrator-panel.d.ts +0 -52
  429. package/dist/sdk/components/orchestrator-panel.d.ts.map +0 -1
  430. package/dist/sdk/components/session-graph-panel.d.ts +0 -7
  431. package/dist/sdk/components/session-graph-panel.d.ts.map +0 -1
  432. package/dist/sdk/components/status-helpers.d.ts +0 -6
  433. package/dist/sdk/components/status-helpers.d.ts.map +0 -1
  434. package/dist/sdk/components/statusline.d.ts +0 -7
  435. package/dist/sdk/components/statusline.d.ts.map +0 -1
  436. package/dist/sdk/components/workflow-picker-panel.d.ts +0 -123
  437. package/dist/sdk/components/workflow-picker-panel.d.ts.map +0 -1
  438. package/dist/sdk/define-workflow.d.ts +0 -78
  439. package/dist/sdk/define-workflow.d.ts.map +0 -1
  440. package/dist/sdk/define-workflow.test.d.ts +0 -2
  441. package/dist/sdk/define-workflow.test.d.ts.map +0 -1
  442. package/dist/sdk/errors.d.ts +0 -24
  443. package/dist/sdk/errors.d.ts.map +0 -1
  444. package/dist/sdk/errors.test.d.ts +0 -2
  445. package/dist/sdk/errors.test.d.ts.map +0 -1
  446. package/dist/sdk/index.d.ts +0 -13
  447. package/dist/sdk/index.d.ts.map +0 -1
  448. package/dist/sdk/providers/claude.d.ts +0 -170
  449. package/dist/sdk/providers/claude.d.ts.map +0 -1
  450. package/dist/sdk/providers/copilot.d.ts +0 -11
  451. package/dist/sdk/providers/copilot.d.ts.map +0 -1
  452. package/dist/sdk/providers/opencode.d.ts +0 -11
  453. package/dist/sdk/providers/opencode.d.ts.map +0 -1
  454. package/dist/sdk/runtime/discovery.d.ts +0 -86
  455. package/dist/sdk/runtime/discovery.d.ts.map +0 -1
  456. package/dist/sdk/runtime/executor-entry.d.ts +0 -11
  457. package/dist/sdk/runtime/executor-entry.d.ts.map +0 -1
  458. package/dist/sdk/runtime/executor.d.ts +0 -72
  459. package/dist/sdk/runtime/executor.d.ts.map +0 -1
  460. package/dist/sdk/runtime/executor.test.d.ts +0 -2
  461. package/dist/sdk/runtime/executor.test.d.ts.map +0 -1
  462. package/dist/sdk/runtime/graph-inference.d.ts +0 -35
  463. package/dist/sdk/runtime/graph-inference.d.ts.map +0 -1
  464. package/dist/sdk/runtime/loader.d.ts +0 -70
  465. package/dist/sdk/runtime/loader.d.ts.map +0 -1
  466. package/dist/sdk/runtime/panel.d.ts +0 -9
  467. package/dist/sdk/runtime/panel.d.ts.map +0 -1
  468. package/dist/sdk/runtime/theme.d.ts +0 -28
  469. package/dist/sdk/runtime/theme.d.ts.map +0 -1
  470. package/dist/sdk/runtime/tmux.d.ts +0 -297
  471. package/dist/sdk/runtime/tmux.d.ts.map +0 -1
  472. package/dist/sdk/types.d.ts +0 -295
  473. package/dist/sdk/types.d.ts.map +0 -1
  474. package/dist/sdk/workflows/builtin/deep-research-codebase/claude/index.d.ts +0 -62
  475. package/dist/sdk/workflows/builtin/deep-research-codebase/claude/index.d.ts.map +0 -1
  476. package/dist/sdk/workflows/builtin/deep-research-codebase/copilot/index.d.ts +0 -46
  477. package/dist/sdk/workflows/builtin/deep-research-codebase/copilot/index.d.ts.map +0 -1
  478. package/dist/sdk/workflows/builtin/deep-research-codebase/helpers/heuristic.d.ts +0 -26
  479. package/dist/sdk/workflows/builtin/deep-research-codebase/helpers/heuristic.d.ts.map +0 -1
  480. package/dist/sdk/workflows/builtin/deep-research-codebase/helpers/prompts.d.ts +0 -92
  481. package/dist/sdk/workflows/builtin/deep-research-codebase/helpers/prompts.d.ts.map +0 -1
  482. package/dist/sdk/workflows/builtin/deep-research-codebase/helpers/scout.d.ts +0 -57
  483. package/dist/sdk/workflows/builtin/deep-research-codebase/helpers/scout.d.ts.map +0 -1
  484. package/dist/sdk/workflows/builtin/deep-research-codebase/opencode/index.d.ts +0 -49
  485. package/dist/sdk/workflows/builtin/deep-research-codebase/opencode/index.d.ts.map +0 -1
  486. package/dist/sdk/workflows/builtin/ralph/claude/index.d.ts +0 -14
  487. package/dist/sdk/workflows/builtin/ralph/claude/index.d.ts.map +0 -1
  488. package/dist/sdk/workflows/builtin/ralph/copilot/index.d.ts +0 -14
  489. package/dist/sdk/workflows/builtin/ralph/copilot/index.d.ts.map +0 -1
  490. package/dist/sdk/workflows/builtin/ralph/helpers/git.d.ts +0 -17
  491. package/dist/sdk/workflows/builtin/ralph/helpers/git.d.ts.map +0 -1
  492. package/dist/sdk/workflows/builtin/ralph/helpers/prompts.d.ts +0 -119
  493. package/dist/sdk/workflows/builtin/ralph/helpers/prompts.d.ts.map +0 -1
  494. package/dist/sdk/workflows/builtin/ralph/helpers/review.d.ts +0 -20
  495. package/dist/sdk/workflows/builtin/ralph/helpers/review.d.ts.map +0 -1
  496. package/dist/sdk/workflows/builtin/ralph/opencode/index.d.ts +0 -14
  497. package/dist/sdk/workflows/builtin/ralph/opencode/index.d.ts.map +0 -1
  498. package/dist/sdk/workflows/index.d.ts +0 -24
  499. package/dist/sdk/workflows/index.d.ts.map +0 -1
  500. package/dist/services/config/definitions.d.ts +0 -85
  501. package/dist/services/config/definitions.d.ts.map +0 -1
  502. package/dist/services/system/copy.d.ts +0 -77
  503. package/dist/services/system/copy.d.ts.map +0 -1
  504. package/dist/services/system/detect.d.ts +0 -75
  505. package/dist/services/system/detect.d.ts.map +0 -1
  506. package/tsconfig.json +0 -33
@@ -0,0 +1,789 @@
1
+ # Agent Sessions
2
+
3
+ Each `ctx.stage()` call inside a workflow's `.run()` callback creates an isolated agent session. The runtime auto-initializes the provider client and session before invoking your callback — the callback receives `s` (a `SessionContext`) with `s.client` (the pre-created SDK client) and `s.session` (the pre-created session) ready to use. Auto-cleanup (disconnect, stop) is handled by the runtime after the callback completes. This is the programmatic equivalent of defining agent stages — you have full access to every SDK feature through `s.client` and `s.session`.
4
+
5
+ `ctx.stage()` takes four arguments: `ctx.stage(stageOpts, clientOpts, sessionOpts, callback)`.
6
+
7
+ ## Claude Agent SDK
8
+
9
+ Claude runs as a full interactive TUI in a tmux pane. The runtime auto-starts the Claude CLI (via `s.client`) and creates a session wrapper (`s.session`) before the callback runs. Pass CLI flags via `clientOpts` (2nd arg) and query defaults via `sessionOpts` (3rd arg).
10
+
11
+ ### Session lifecycle
12
+
13
+ ```ts
14
+ import { defineWorkflow } from "@bastani/atomic/workflows";
15
+
16
+ // ...
17
+ .run(async (ctx) => {
18
+ await ctx.stage(
19
+ { name: "implement", description: "Implement the feature" },
20
+ {}, // clientOpts: chatFlags and readyTimeoutMs go here
21
+ {}, // sessionOpts: query defaults (timeoutMs, pollIntervalMs, etc.) go here
22
+ async (s) => {
23
+ // s.client — Claude CLI wrapper (already started by runtime)
24
+ // s.session — session wrapper (ready to accept queries via s.session.query())
25
+
26
+ // Send queries — Claude maintains conversation context across calls
27
+ const result = await s.session.query((s.inputs.prompt ?? ""));
28
+ // result.output contains the captured response text
29
+
30
+ // Save transcript
31
+ s.save(s.sessionId);
32
+ },
33
+ );
34
+ })
35
+ ```
36
+
37
+ The runtime handles:
38
+ 1. Starting the Claude CLI in the tmux pane
39
+ 2. Creating a session wrapper bound to the pane (exposes `s.session.query()`)
40
+ 3. Auto-cleanup after the callback returns
41
+
42
+ Client options (2nd arg to `ctx.stage()`):
43
+ - `chatFlags` — CLI flags (default: `["--allow-dangerously-skip-permissions", "--dangerously-skip-permissions"]`)
44
+ - `readyTimeoutMs` — timeout waiting for TUI readiness (default: 30s)
45
+
46
+ Session options (3rd arg to `ctx.stage()`), applied as defaults to every `s.session.query()` call:
47
+ - `timeoutMs` — timeout waiting for Claude to finish responding (default: 300s)
48
+ - `pollIntervalMs` — polling interval (default: 2000ms)
49
+ - `submitPresses` — C-m presses per submit round (default: 1)
50
+ - `maxSubmitRounds` — max submit rounds (default: 6)
51
+ - `readyTimeoutMs` — timeout waiting for pane readiness before sending (default: 30s)
52
+
53
+ ### Basic usage with `s.session.query()`
54
+
55
+ ```ts
56
+ import { defineWorkflow } from "@bastani/atomic/workflows";
57
+
58
+ export default defineWorkflow<"claude">({ name: "implement" })
59
+ .run(async (ctx) => {
60
+ await ctx.stage(
61
+ { name: "implement", description: "Implement the feature" },
62
+ {},
63
+ {},
64
+ async (s) => {
65
+ const result = await s.session.query((s.inputs.prompt ?? ""));
66
+ // result.output contains the captured response text
67
+ s.save(s.sessionId);
68
+ },
69
+ );
70
+ })
71
+ .compile();
72
+ ```
73
+
74
+ `s.session.query(prompt)` sends text to the Claude pane, verifies delivery, retries if needed, and waits for output stabilization. Returns `{ output: string }`.
75
+
76
+ ### Multi-turn conversations
77
+
78
+ Claude maintains conversation context across calls within the same pane. Call `s.session.query()` multiple times in one stage for multi-turn conversations:
79
+
80
+ ```ts
81
+ .run(async (ctx) => {
82
+ await ctx.stage({ name: "implement" }, {}, {}, async (s) => {
83
+ // Turn 1: Plan
84
+ await s.session.query("Plan the implementation.");
85
+ // Turn 2: Execute (Claude remembers the plan)
86
+ await s.session.query("Now implement the plan.");
87
+ // Turn 3: Verify
88
+ await s.session.query("Run the tests.");
89
+ s.save(s.sessionId);
90
+ });
91
+ })
92
+ ```
93
+
94
+ ### Advanced: Claude Agent SDK `query()` API
95
+
96
+ For programmatic control beyond tmux automation, the Claude Agent SDK provides `query()`:
97
+
98
+ ```ts
99
+ import { query } from "@anthropic-ai/claude-agent-sdk";
100
+
101
+ .run(async (ctx) => {
102
+ await ctx.stage({ name: "implement" }, {}, {}, async (s) => {
103
+ const result = query({
104
+ prompt: (s.inputs.prompt ?? ""),
105
+ options: {
106
+ model: "claude-opus-4-6",
107
+ effort: "high",
108
+ maxTurns: 50,
109
+ maxBudgetUsd: 5.0,
110
+ permissionMode: "acceptEdits",
111
+ allowedTools: ["Read", "Write", "Edit", "Bash", "Grep", "Glob"],
112
+ disallowedTools: ["AskUserQuestion"],
113
+ systemPrompt: "You are a senior engineer...",
114
+ outputFormat: {
115
+ type: "json_schema",
116
+ schema: { type: "object", properties: { tasks: { type: "array", items: { type: "string" } } } },
117
+ },
118
+ agents: {
119
+ reviewer: { description: "Review code changes", prompt: "You are a code reviewer..." },
120
+ },
121
+ },
122
+ });
123
+ for await (const message of result) {
124
+ // Process streaming messages
125
+ }
126
+ });
127
+ })
128
+ ```
129
+
130
+ Key `query()` options:
131
+ - `model` — model ID (`"claude-opus-4-6"`, `"claude-sonnet-4-6"`) or alias (`"opus"`, `"sonnet"`, `"haiku"`)
132
+ - `effort` — reasoning effort (`"low"`, `"medium"`, `"high"`, `"max"` — `"max"` is Opus 4.6 only)
133
+ - `thinking` — thinking/reasoning config: `{ type: "adaptive" }` (default for supported models), `{ type: "enabled", budgetTokens: N }`, or `{ type: "disabled" }`
134
+ - `maxTurns` — maximum conversation turns
135
+ - `maxBudgetUsd` — spending cap in USD
136
+ - `permissionMode` — `"default"`, `"dontAsk"`, `"acceptEdits"`, `"bypassPermissions"`, `"plan"`
137
+ - `allowedTools` / `disallowedTools` — tool access control
138
+ - `tools` — base set of available built-in tools: `string[]` for specific tools, `[]` to disable all, or `{ type: "preset", preset: "claude_code" }` for defaults
139
+ - `systemPrompt` — custom system prompt (`string`) or preset with additions (`{ type: "preset", preset: "claude_code", append: "..." }`)
140
+ - `outputFormat` — structured output: `{ type: "json_schema", schema: { ... } }`
141
+ - `agents` — `Record<string, AgentDefinition>` — named subagents for orchestration
142
+ - `agent` — main thread agent name (must be defined in `agents` or settings)
143
+ - `resume` — session ID to resume a prior session
144
+ - `forkSession` — `boolean` — when `true` with `resume`, forks to a new session instead of continuing
145
+ - `mcpServers` — MCP server configurations
146
+ - `hooks` — `Partial<Record<HookEvent, HookCallbackMatcher[]>>` — event-driven callbacks (see `session-config.md`)
147
+ - `sandbox` — sandboxed command execution settings
148
+ - `betas` — enable beta features (e.g. `["context-1m-2025-08-07"]` for 1M context on Sonnet)
149
+
150
+ ### Subagents
151
+
152
+ Claude supports parallel subagents via the `agents` option (a `Record<string, AgentDefinition>` keyed by agent name):
153
+
154
+ ```ts
155
+ const agents = {
156
+ worker: {
157
+ description: "Implement a single task",
158
+ prompt: "You are a task implementer...",
159
+ tools: ["Read", "Write", "Edit", "Bash"],
160
+ },
161
+ reviewer: {
162
+ description: "Review code changes",
163
+ prompt: "You are a code reviewer...",
164
+ tools: ["Read", "Grep", "Glob"],
165
+ },
166
+ };
167
+
168
+ const result = query({
169
+ prompt: "Implement and review the feature",
170
+ options: { agents },
171
+ });
172
+ ```
173
+
174
+ ### Session continuity
175
+
176
+ Resume or fork prior sessions:
177
+
178
+ ```ts
179
+ // Resume a session (continues the same conversation)
180
+ const result = query({ prompt: "Continue...", options: { resume: sessionId } });
181
+
182
+ // Fork a session (creates a new branch from the session's history)
183
+ const result = query({ prompt: "Try a different approach", options: { resume: sessionId, forkSession: true } });
184
+ ```
185
+
186
+ ### Sub-agent delegation via `s.session.query()`
187
+
188
+ Invoke named sub-agents by prefixing the prompt with `@"agent-name (agent)"`. The agent must be defined in `.claude/agents/`:
189
+
190
+ ```ts
191
+ .run(async (ctx) => {
192
+ await ctx.stage({ name: "plan-and-implement" }, {}, {}, async (s) => {
193
+ // Delegate to the "planner" agent
194
+ await s.session.query(`@"planner (agent)" Create a plan for: ${(s.inputs.prompt ?? "")}`);
195
+
196
+ // Delegate to the "orchestrator" agent
197
+ await s.session.query(`@"orchestrator (agent)" Execute the plan above.`);
198
+
199
+ s.save(s.sessionId);
200
+ });
201
+ })
202
+ ```
203
+
204
+ ### Headless mode (background stages)
205
+
206
+ Claude headless stages use the Agent SDK's `query()` API directly in-process instead of automating a tmux pane. Set `headless: true` in the stage options:
207
+
208
+ ```ts
209
+ await ctx.stage(
210
+ { name: "background-analysis", headless: true },
211
+ {}, {},
212
+ async (s) => {
213
+ // s.session.query() works identically — the runtime uses
214
+ // HeadlessClaudeSessionWrapper which calls the Agent SDK directly
215
+ const result = await s.session.query("Analyze the codebase.");
216
+ s.save(s.sessionId);
217
+ return result.output;
218
+ },
219
+ );
220
+ ```
221
+
222
+ The callback interface is identical to interactive stages. Internally, the runtime uses `HeadlessClaudeClientWrapper` (no-op start/stop) and `HeadlessClaudeSessionWrapper` (calls `query()` from `@anthropic-ai/claude-agent-sdk` directly). No tmux pane is created, and the stage is invisible in the workflow graph.
223
+
224
+ ## Copilot SDK
225
+
226
+ Copilot uses a client-server architecture. The runtime auto-creates a `CopilotClient` (as `s.client`) and a `CopilotSession` (as `s.session`) before invoking your callback. Auto-cleanup (`session.disconnect()` and `client.stop()`) is handled by the runtime after the callback completes.
227
+
228
+ ### Basic usage
229
+
230
+ ```ts
231
+ import { defineWorkflow } from "@bastani/atomic/workflows";
232
+
233
+ export default defineWorkflow<"copilot">({ name: "implement" })
234
+ .run(async (ctx) => {
235
+ await ctx.stage(
236
+ { name: "implement" },
237
+ {}, // clientOpts: CopilotClientOptions (excluding cliUrl, which is auto-injected)
238
+ {}, // sessionOpts: CopilotSessionConfig (model, agent, tools, hooks, etc.)
239
+ async (s) => {
240
+ // s.client — CopilotClient (already started by runtime)
241
+ // s.session — CopilotSession (already created, foreground session set)
242
+
243
+ await s.session.send({ prompt: (s.inputs.prompt ?? "") });
244
+
245
+ s.save(await s.session.getMessages());
246
+ },
247
+ );
248
+ })
249
+ .compile();
250
+ ```
251
+
252
+ ### `send` vs `sendAndWait`: choosing the right method
253
+
254
+ **Default to `send`** for all Copilot workflow stages. `send` dispatches the
255
+ prompt and returns the `messageId` immediately — no timeout to guess, no
256
+ constants to tune, no risk of aborting a long-running agent mid-work.
257
+
258
+ ```ts
259
+ // Default pattern — clean, no timeout guessing
260
+ await s.session.send({ prompt });
261
+ ```
262
+
263
+ **Use `sendAndWait` only when the user explicitly requests timeout-based
264
+ waiting.** `sendAndWait` blocks until the session emits `session.idle` or the
265
+ timeout fires. If you must use it, ask the user for a reasonable timeout. If
266
+ they aren't sure, default to **5 minutes** (300 000 ms).
267
+
268
+ ```ts
269
+ // Only when the user explicitly wants timeout-gated waiting
270
+ const SEND_TIMEOUT_MS = 5 * 60 * 1000; // 5 minutes default; ask the user
271
+ await s.session.sendAndWait({ prompt }, SEND_TIMEOUT_MS);
272
+ ```
273
+
274
+ **Why not `sendAndWait` by default?** The 60-second default timeout is almost
275
+ never correct for real agent work — planners, reviewers, and orchestrators
276
+ routinely exceed it. Guessing large timeouts (30-60 min) adds messy constants
277
+ and still risks aborting work prematurely. `send` avoids the problem entirely.
278
+
279
+ ### Critical pitfall: session lifecycle controls what context is available
280
+
281
+ A workflow is not just a sequence of agent calls — it is an **information
282
+ flow problem**. The single most common failure mode in Copilot workflows is
283
+ assuming context carries across session boundaries when it doesn't.
284
+ Designing a workflow without thinking about information flow produces
285
+ sub-agents that hallucinate, repeat work, or drop requirements silently.
286
+
287
+ **Treat this section as load-bearing**, not decorative. If you skip it, your
288
+ workflow will ship broken in subtle, non-deterministic ways.
289
+
290
+ #### The three session lifecycle states
291
+
292
+ Every Copilot session is always in exactly one of these states, and the
293
+ state determines what context the model sees on its next turn:
294
+
295
+ | State | How you get there | Context available | Action needed |
296
+ |---|---|---|---|
297
+ | **Fresh** | `client.createSession(...)` | **None** — empty conversation | You MUST inject everything the agent needs in the first prompt |
298
+ | **Continued** | Same session, additional `send` calls | All prior turns in this session | Nothing — but watch total token usage |
299
+ | **Resumed** | `client.resumeSession(sessionId)` | All persisted turns from the prior session of the SAME agent | Nothing — full history is reattached |
300
+ | **Closed** | `session.disconnect()` or `client.stop()` | **Gone** from the live client; persisted on disk if the host enables it | Either resume by ID (same agent) or start fresh and re-inject context |
301
+
302
+ The failure mode: you close a session, create a new one, and assume the new
303
+ one "remembers" the previous conversation. It doesn't. `client` is just the
304
+ transport — each session is a fully independent conversation.
305
+
306
+ For normal workflow authoring, the key rule is simpler than the full lifecycle
307
+ table: **every new `ctx.stage()` call is fresh**. If you need full history,
308
+ prefer another turn inside the same stage callback. Resume/fork APIs are
309
+ provider-specific escape hatches, not the default stage-to-stage handoff path.
310
+
311
+ ```ts
312
+ // Buggy — the orchestrator session is fresh and knows NOTHING about
313
+ // what the planner just produced, because createSession() started a
314
+ // brand-new conversation.
315
+ await runAgent("planner", buildPlannerPrompt((ctx.inputs.prompt ?? "")));
316
+ await runAgent("orchestrator", buildOrchestratorPrompt());
317
+ // ↑ orchestrator only sees buildOrchestratorPrompt() — no planner output,
318
+ // no original user spec, no context.
319
+ ```
320
+
321
+ #### Three reliable ways to avoid losing context
322
+
323
+ Pick the one that fits the data you need to hand off. These are not
324
+ mutually exclusive — ralph uses (1) + (2) together as belt-and-braces.
325
+
326
+ **1. Explicit prompt handoff** — capture the prior session's last assistant
327
+ message and inject it (or a summary) into the next session's first prompt.
328
+ Simplest and most common fix:
329
+
330
+ ```ts
331
+ async function runAgent(agent: string, prompt: string): Promise<string> {
332
+ const session = await client.createSession({ agent, onPermissionRequest: approveAll });
333
+ await session.send({ prompt });
334
+ const messages = await session.getMessages();
335
+ await session.disconnect();
336
+ return getAssistantText(messages); // concatenate every top-level turn — see failure-modes.md §F1
337
+ }
338
+
339
+ // Correct — forward the planner's output into the orchestrator prompt
340
+ const plannerNotes = await runAgent("planner", buildPlannerPrompt((ctx.inputs.prompt ?? "")));
341
+ await runAgent(
342
+ "orchestrator",
343
+ buildOrchestratorPrompt((ctx.inputs.prompt ?? ""), { plannerNotes }),
344
+ );
345
+ ```
346
+
347
+ **2. External shared state** — write results to a medium both sessions can
348
+ read: the task list (`TaskCreate` / `TaskList`), files on disk, a git
349
+ working tree, or a database. The planner writes; the orchestrator reads.
350
+ Ralph uses `TaskCreate`/`TaskList` as its primary coordination medium.
351
+
352
+ **3. Keep the follow-up in the same stage callback** — if the next step needs
353
+ the full live conversation, don't cross a stage boundary. Send another turn to
354
+ the same session instead. This is the standard workflow-API way to preserve
355
+ history across related steps.
356
+
357
+ ```ts
358
+ // Same stage, multi-turn — full history stays attached
359
+ await s.session.send({ prompt: "Plan the implementation." });
360
+ await s.session.send({ prompt: "Follow up on the plan above." });
361
+ ```
362
+
363
+ If you deliberately drop down to provider-specific resume/fork APIs, keep them
364
+ within the same agent role. They are advanced escape hatches, not the normal
365
+ way stages communicate.
366
+
367
+ #### When context grows too large: compaction and clearing
368
+
369
+ Even within a single continued session, context can grow past the window.
370
+ Symptoms include lost-in-middle failures, repeated questions, and the model
371
+ "forgetting" earlier decisions. When that happens, you have two levers:
372
+
373
+ - **Compaction** — summarize the prior transcript into a shorter form and
374
+ feed it forward (either into a new session, or by starting a follow-up
375
+ session seeded with the summary). Most SDKs expose this as a built-in
376
+ command (Claude Code's `/compact` slash command, or programmatic helpers
377
+ in the OpenCode SDK). If the SDK you're using doesn't, roll your own with
378
+ a summarization call and start a fresh session with the summary in the
379
+ first prompt.
380
+ - **Clearing** — drop old turns entirely when they're no longer load-bearing
381
+ (e.g. one-shot tool outputs whose results were already captured to files).
382
+ Claude's `/clear`, per-SDK `clearHistory`-style APIs, or simply starting a
383
+ new session with only the essentials in prompt 1 all work.
384
+
385
+ Neither is free: compaction loses detail, clearing loses provenance. The
386
+ `context-compression` and `context-optimization` skills below cover the
387
+ trade-offs in depth.
388
+
389
+ #### Context engineering skills — consult these BEFORE writing code
390
+
391
+ Information flow is a design problem, not an implementation detail. Before
392
+ committing to a session layout, pull in the relevant skills:
393
+
394
+ | When you're deciding... | Consult |
395
+ |---|---|
396
+ | What context each session actually needs (anatomy + token budget) | `context-fundamentals` |
397
+ | How many sessions and how they hand off (orchestrator vs peers vs swarm) | `multi-agent-patterns` |
398
+ | How to compress large planner/reviewer output before re-injecting | `context-compression` |
399
+ | How to detect and prevent lost-in-middle, poisoning, and distraction | `context-degradation` |
400
+ | How to use files as coordination medium across sessions | `filesystem-context` |
401
+ | How to persist knowledge across whole workflow runs | `memory-systems` |
402
+ | Which turns to drop, which to cache, when to compact | `context-optimization` |
403
+
404
+ These aren't optional reading — they're the difference between a workflow
405
+ that works on day one and a workflow that silently degrades as inputs grow.
406
+ If you're about to write a multi-session workflow and you haven't consulted
407
+ at least `context-fundamentals` and `multi-agent-patterns`, **stop and read
408
+ them first.**
409
+
410
+ ### Multi-turn conversations
411
+
412
+ Send multiple prompts to the same session:
413
+
414
+ ```ts
415
+ .run(async (ctx) => {
416
+ await ctx.stage({ name: "implement" }, {}, {}, async (s) => {
417
+ // Turn 1
418
+ await s.session.send({ prompt: "Plan the implementation." });
419
+ // Turn 2
420
+ await s.session.send({ prompt: "Now implement the plan." });
421
+ // Turn 3
422
+ await s.session.send({ prompt: "Run the tests." });
423
+
424
+ s.save(await s.session.getMessages());
425
+ });
426
+ })
427
+ ```
428
+
429
+ ### Session configuration
430
+
431
+ Pass session config options as the 3rd arg to `ctx.stage()` (`sessionOpts`). These are forwarded to `client.createSession()`:
432
+
433
+ ```ts
434
+ await ctx.stage(
435
+ { name: "audit" },
436
+ {}, // clientOpts
437
+ {
438
+ model: "claude-sonnet-4.6",
439
+ reasoningEffort: "high",
440
+ systemMessage: "You are a security auditor...",
441
+ onUserInputRequest: (request) => { /* handle user input */ },
442
+ hooks: {
443
+ onPreToolUse: (event) => { /* before tool execution */ },
444
+ onPostToolUse: (event) => { /* after tool execution */ },
445
+ },
446
+ }, // sessionOpts
447
+ async (s) => {
448
+ await s.session.send({ prompt: (s.inputs.prompt ?? "") });
449
+ s.save(await s.session.getMessages());
450
+ },
451
+ );
452
+ ```
453
+
454
+ ### Custom tools
455
+
456
+ ```ts
457
+ import { defineTool } from "@github/copilot-sdk";
458
+
459
+ const myTool = defineTool({
460
+ name: "check-coverage",
461
+ description: "Check test coverage",
462
+ parameters: { type: "object", properties: { path: { type: "string" } } },
463
+ execute: async (params) => {
464
+ // Run coverage check
465
+ return { content: "Coverage: 85%" };
466
+ },
467
+ });
468
+
469
+ // Pass tools via sessionOpts (3rd arg to ctx.stage())
470
+ await ctx.stage(
471
+ { name: "implement" },
472
+ {},
473
+ { tools: [myTool] },
474
+ async (s) => {
475
+ await s.session.send({ prompt: (s.inputs.prompt ?? "") });
476
+ s.save(await s.session.getMessages());
477
+ },
478
+ );
479
+ ```
480
+
481
+ ### Extracting response text
482
+
483
+ Do **not** just grab `.at(-1).data.content` — a Copilot turn's final
484
+ `assistant.message` often has empty `content` (tool-calls-only) and
485
+ sub-agent messages can pollute the stream via `parentToolCallId`. Concatenate
486
+ every top-level turn's non-empty content instead. See
487
+ `references/failure-modes.md` §"Copilot: `getLastAssistantText` returns
488
+ empty string" for the full explanation and wrong-vs-right examples.
489
+
490
+ ```ts
491
+ import type { SessionEvent } from "@github/copilot-sdk";
492
+
493
+ /** Concatenate every top-level assistant turn's non-empty content.
494
+ * Canonical definition — also referenced in failure-modes.md §F1
495
+ * and computation-and-validation.md. */
496
+ function getAssistantText(messages: SessionEvent[]): string {
497
+ return messages
498
+ .filter(
499
+ (m): m is Extract<SessionEvent, { type: "assistant.message" }> =>
500
+ m.type === "assistant.message" && !m.data.parentToolCallId,
501
+ )
502
+ .map((m) => m.data.content)
503
+ .filter((c) => c.length > 0)
504
+ .join("\n\n");
505
+ }
506
+ ```
507
+
508
+ ### Streaming events
509
+
510
+ ```ts
511
+ // s.session is the CopilotSession — subscribe to events directly
512
+ s.session.on("assistant.message_delta", (event) => {
513
+ process.stdout.write(event.data.content);
514
+ });
515
+
516
+ s.session.on("assistant.reasoning_delta", (event) => {
517
+ // Access reasoning output
518
+ });
519
+ ```
520
+
521
+ ### Sub-agent delegation
522
+
523
+ Pass the `agent` parameter in `sessionOpts` (3rd arg to `ctx.stage()`) to bind the session to a named sub-agent:
524
+
525
+ ```ts
526
+ .run(async (ctx) => {
527
+ await ctx.stage(
528
+ { name: "plan" },
529
+ {},
530
+ { agent: "planner" }, // sessionOpts — binds the session to the "planner" agent
531
+ async (s) => {
532
+ await s.session.send({ prompt: (s.inputs.prompt ?? "") });
533
+ s.save(await s.session.getMessages());
534
+ },
535
+ );
536
+ })
537
+ ```
538
+
539
+ ### Headless mode (background stages)
540
+
541
+ Copilot headless stages let the SDK spawn its own CLI subprocess internally — no tmux pane is needed. Set `headless: true`:
542
+
543
+ ```ts
544
+ await ctx.stage(
545
+ { name: "background-task", headless: true },
546
+ {}, {},
547
+ async (s) => {
548
+ // s.session.send() works identically
549
+ await s.session.send({ prompt: "Analyze the codebase." });
550
+ s.save(await s.session.getMessages());
551
+ },
552
+ );
553
+ ```
554
+
555
+ The SDK creates a `CopilotClient` without a `cliUrl` — it spawns its own CLI process internally rather than connecting to a tmux-hosted server. The callback interface is identical.
556
+
557
+ ## OpenCode SDK
558
+
559
+ OpenCode uses a client-server model. The runtime auto-creates an `OpencodeClient` (as `s.client`) and an OpenCode session (as `s.session`) before invoking your callback. Use `s.client.session.prompt({ sessionID: s.session.id, ... })` to send prompts.
560
+
561
+ ### Basic usage
562
+
563
+ ```ts
564
+ import { defineWorkflow } from "@bastani/atomic/workflows";
565
+
566
+ export default defineWorkflow<"opencode">({ name: "implement" })
567
+ .run(async (ctx) => {
568
+ await ctx.stage(
569
+ { name: "implement" },
570
+ {}, // clientOpts: directory, experimental_workspaceID
571
+ { title: "implement" }, // sessionOpts: title, parentID, workspaceID
572
+ async (s) => {
573
+ // s.client — OpencodeClient (already connected)
574
+ // s.session — OpenCode Session (already created, TUI selected)
575
+
576
+ const result = await s.client.session.prompt({
577
+ sessionID: s.session.id,
578
+ parts: [{ type: "text", text: (s.inputs.prompt ?? "") }],
579
+ });
580
+
581
+ s.save(result.data!);
582
+ },
583
+ );
584
+ })
585
+ .compile();
586
+ ```
587
+
588
+ ### Critical pitfall: session lifecycle controls what context is available
589
+
590
+ OpenCode sessions have **exactly the same isolation semantics as Copilot
591
+ sessions**. Every call to `client.session.create(...)` returns a fresh,
592
+ empty conversation. Creating a new session for the next sub-agent wipes
593
+ everything the prior session knew — conversation history, tool-call
594
+ results, intermediate reasoning — unless you forward it explicitly.
595
+
596
+ The full explanation, the three lifecycle states (Fresh / Continued /
597
+ Resumed / Closed), the three valid ways to carry context across a session
598
+ boundary, compaction & clearing guidance, and the context engineering
599
+ skill-map live in the **Copilot** section above under
600
+ ["Critical pitfall: session lifecycle controls what context is
601
+ available"](#critical-pitfall-session-lifecycle-controls-what-context-is-available).
602
+ Every principle there applies to OpenCode without modification — just
603
+ substitute the OpenCode API equivalents:
604
+
605
+ | Concept | Copilot API | OpenCode API |
606
+ |---|---|---|
607
+ | Fresh session (auto-created) | `s.session` (runtime creates via `createSession`) | `s.session` (runtime creates via `session.create`) |
608
+ | Send a turn | `s.session.send({ prompt })` | `s.client.session.prompt({ sessionID: s.session.id, parts })` |
609
+ | Close / disconnect | Auto-handled by runtime | session lifecycle managed via server; no explicit disconnect in typical flow |
610
+ | Continue prior conversation | `s.client.resumeSession(sessionId)` (provider API; advanced) | Reuse the same `sessionID` with `s.client.session.prompt()` inside the same logical conversation. `ctx.stage()` itself still creates a fresh session every time |
611
+ | Extract final text | `getAssistantText(messages)` (see `failure-modes.md` §F1) | `extractResponseText(result.data!.parts)` |
612
+
613
+ **Multi-agent handoff example (applies the same pattern as Copilot):**
614
+
615
+ ```ts
616
+ // Buggy — orchestrator session is fresh; it has no idea what the planner
617
+ // produced because we created a brand-new session for it.
618
+ await runAgent("planner-1", "planner", buildPlannerPrompt((ctx.inputs.prompt ?? "")));
619
+ await runAgent("orchestrator-1", "orchestrator", buildOrchestratorPrompt());
620
+
621
+ // Correct — capture planner output and forward it into orchestrator prompt
622
+ const plannerNotes = await runAgent(
623
+ "planner-1",
624
+ "planner",
625
+ buildPlannerPrompt((ctx.inputs.prompt ?? "")),
626
+ );
627
+ await runAgent(
628
+ "orchestrator-1",
629
+ "orchestrator",
630
+ buildOrchestratorPrompt((ctx.inputs.prompt ?? ""), { plannerNotes }),
631
+ );
632
+ ```
633
+
634
+ When planner output is large enough to strain the orchestrator's context
635
+ window, compress before forwarding — consult `context-compression`. When a
636
+ single long-running OpenCode session starts showing lost-in-middle
637
+ symptoms, consult `context-optimization` for compaction/masking strategies
638
+ before reaching for "just start a new session", which loses all history.
639
+
640
+ **Read the Copilot section for the full write-up.** The pitfall applies
641
+ identically here; the only thing that changes is the method names.
642
+
643
+ ### Multi-turn conversations
644
+
645
+ Send multiple prompts to the same session using `s.client.session.prompt()` with `s.session.id`:
646
+
647
+ ```ts
648
+ .run(async (ctx) => {
649
+ await ctx.stage({ name: "multi-turn" }, {}, { title: "multi-turn" }, async (s) => {
650
+ // Turn 1
651
+ await s.client.session.prompt({
652
+ sessionID: s.session.id,
653
+ parts: [{ type: "text", text: "Plan the implementation." }],
654
+ });
655
+ // Turn 2
656
+ await s.client.session.prompt({
657
+ sessionID: s.session.id,
658
+ parts: [{ type: "text", text: "Now implement the plan." }],
659
+ });
660
+ // Turn 3
661
+ const result = await s.client.session.prompt({
662
+ sessionID: s.session.id,
663
+ parts: [{ type: "text", text: "Run the tests." }],
664
+ });
665
+
666
+ s.save(result.data!);
667
+ });
668
+ })
669
+ ```
670
+
671
+ ### Structured output
672
+
673
+ ```ts
674
+ // Inside a ctx.stage callback:
675
+ const result = await s.client.session.prompt({
676
+ sessionID: s.session.id,
677
+ parts: [{ type: "text", text: "List all API endpoints as JSON" }],
678
+ format: {
679
+ type: "json_schema",
680
+ schema: {
681
+ type: "object",
682
+ properties: {
683
+ endpoints: {
684
+ type: "array",
685
+ items: { type: "object", properties: { path: { type: "string" }, method: { type: "string" } } },
686
+ },
687
+ },
688
+ },
689
+ retryCount: 3,
690
+ },
691
+ });
692
+ ```
693
+
694
+ ### Context injection (no-reply)
695
+
696
+ Inject context into a session without triggering a response:
697
+
698
+ ```ts
699
+ // Inside a ctx.stage callback:
700
+ await s.client.session.prompt({
701
+ sessionID: s.session.id,
702
+ parts: [{ type: "text", text: "Here is the background context..." }],
703
+ noReply: true,
704
+ });
705
+ // Now send the actual prompt
706
+ const result = await s.client.session.prompt({
707
+ sessionID: s.session.id,
708
+ parts: [{ type: "text", text: "Based on the context, implement..." }],
709
+ });
710
+ ```
711
+
712
+ ### Extracting response text
713
+
714
+ ```ts
715
+ /** Filter for text parts only — non-text parts produce [object Object].
716
+ * Canonical definition — also referenced in failure-modes.md §F3
717
+ * and computation-and-validation.md. */
718
+ function extractResponseText(
719
+ parts: Array<{ type: string; [key: string]: unknown }>,
720
+ ): string {
721
+ return parts
722
+ .filter((p) => p.type === "text")
723
+ .map((p) => (p as { type: string; text: string }).text)
724
+ .join("\n");
725
+ }
726
+
727
+ // Usage inside a ctx.stage callback:
728
+ const result = await s.client.session.prompt({
729
+ sessionID: s.session.id,
730
+ parts: [{ type: "text", text: (s.inputs.prompt ?? "") }],
731
+ });
732
+ const text = extractResponseText(result.data!.parts);
733
+ ```
734
+
735
+ ### Event streaming
736
+
737
+ ```ts
738
+ // Inside a ctx.stage callback:
739
+ const unsubscribe = await s.client.event.subscribe((event) => {
740
+ if (event.type === "session.updated") {
741
+ console.log("Session updated:", event.data);
742
+ }
743
+ });
744
+ ```
745
+
746
+ ### Sub-agent delegation
747
+
748
+ Pass the `agent` parameter to `s.client.session.prompt()` to route a prompt to a named sub-agent:
749
+
750
+ ```ts
751
+ .run(async (ctx) => {
752
+ await ctx.stage(
753
+ { name: "plan" },
754
+ {},
755
+ { title: "plan" },
756
+ async (s) => {
757
+ // Route the prompt to the "planner" agent
758
+ const result = await s.client.session.prompt({
759
+ sessionID: s.session.id,
760
+ parts: [{ type: "text", text: (s.inputs.prompt ?? "") }],
761
+ agent: "planner",
762
+ });
763
+
764
+ s.save(result.data!);
765
+ },
766
+ );
767
+ })
768
+ ```
769
+
770
+ ### Headless mode (background stages)
771
+
772
+ OpenCode headless stages use `createOpencode()` from the SDK to start both server and client in-process. Set `headless: true`:
773
+
774
+ ```ts
775
+ await ctx.stage(
776
+ { name: "background-task", headless: true },
777
+ {}, { title: "background-task" },
778
+ async (s) => {
779
+ // s.client.session.prompt() works identically
780
+ const result = await s.client.session.prompt({
781
+ sessionID: s.session.id,
782
+ parts: [{ type: "text", text: "Analyze the codebase." }],
783
+ });
784
+ s.save(result.data!);
785
+ },
786
+ );
787
+ ```
788
+
789
+ Internally, the runtime uses `createOpencode({ port: 0 })` to start both the OpenCode server and client in-process. A cleanup callback closes the server when the stage completes. The callback interface is identical.