@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.
- package/.agents/skills/adapt/SKILL.md +199 -0
- package/.agents/skills/advanced-evaluation/SKILL.md +402 -0
- package/.agents/skills/advanced-evaluation/references/bias-mitigation.md +288 -0
- package/.agents/skills/advanced-evaluation/references/evaluation-pipeline.md +43 -0
- package/.agents/skills/advanced-evaluation/references/implementation-patterns.md +315 -0
- package/.agents/skills/advanced-evaluation/references/metrics-guide.md +331 -0
- package/.agents/skills/advanced-evaluation/scripts/evaluation_example.py +392 -0
- package/.agents/skills/animate/SKILL.md +175 -0
- package/.agents/skills/arrange/SKILL.md +124 -0
- package/.agents/skills/audit/SKILL.md +148 -0
- package/.agents/skills/bdi-mental-states/SKILL.md +311 -0
- package/.agents/skills/bdi-mental-states/references/bdi-ontology-core.md +207 -0
- package/.agents/skills/bdi-mental-states/references/framework-integration.md +582 -0
- package/.agents/skills/bdi-mental-states/references/rdf-examples.md +315 -0
- package/.agents/skills/bdi-mental-states/references/sparql-competency.md +420 -0
- package/.agents/skills/bolder/SKILL.md +117 -0
- package/.agents/skills/bun/SKILL.md +199 -0
- package/.agents/skills/clarify/SKILL.md +183 -0
- package/.agents/skills/colorize/SKILL.md +143 -0
- package/.agents/skills/context-compression/SKILL.md +272 -0
- package/.agents/skills/context-compression/references/evaluation-framework.md +213 -0
- package/.agents/skills/context-compression/scripts/compression_evaluator.py +862 -0
- package/.agents/skills/context-compression/tests/test_compression_evaluator.py +56 -0
- package/.agents/skills/context-degradation/SKILL.md +206 -0
- package/.agents/skills/context-degradation/references/patterns.md +314 -0
- package/.agents/skills/context-degradation/scripts/degradation_detector.py +614 -0
- package/.agents/skills/context-fundamentals/SKILL.md +201 -0
- package/.agents/skills/context-fundamentals/references/context-components.md +283 -0
- package/.agents/skills/context-fundamentals/scripts/context_manager.py +533 -0
- package/.agents/skills/context-optimization/SKILL.md +195 -0
- package/.agents/skills/context-optimization/references/optimization_techniques.md +272 -0
- package/.agents/skills/context-optimization/scripts/compaction.py +562 -0
- package/.agents/skills/create-spec/SKILL.md +244 -0
- package/.agents/skills/critique/SKILL.md +225 -0
- package/.agents/skills/critique/reference/cognitive-load.md +106 -0
- package/.agents/skills/critique/reference/heuristics-scoring.md +234 -0
- package/.agents/skills/critique/reference/personas.md +178 -0
- package/.agents/skills/delight/SKILL.md +304 -0
- package/.agents/skills/distill/SKILL.md +122 -0
- package/.agents/skills/docx/LICENSE.txt +30 -0
- package/.agents/skills/docx/SKILL.md +590 -0
- package/.agents/skills/docx/scripts/__init__.py +1 -0
- package/.agents/skills/docx/scripts/accept_changes.py +135 -0
- package/.agents/skills/docx/scripts/comment.py +318 -0
- package/.agents/skills/docx/scripts/office/helpers/__init__.py +0 -0
- package/.agents/skills/docx/scripts/office/helpers/merge_runs.py +199 -0
- package/.agents/skills/docx/scripts/office/helpers/simplify_redlines.py +197 -0
- package/.agents/skills/docx/scripts/office/pack.py +159 -0
- package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
- package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
- package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
- package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
- package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
- package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
- package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
- package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
- package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
- package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
- package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
- package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
- package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
- package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
- package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
- package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
- package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
- package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
- package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
- package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
- package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
- package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
- package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
- package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
- package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
- package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
- package/.agents/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
- package/.agents/skills/docx/scripts/office/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
- package/.agents/skills/docx/scripts/office/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
- package/.agents/skills/docx/scripts/office/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
- package/.agents/skills/docx/scripts/office/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
- package/.agents/skills/docx/scripts/office/schemas/mce/mc.xsd +75 -0
- package/.agents/skills/docx/scripts/office/schemas/microsoft/wml-2010.xsd +560 -0
- package/.agents/skills/docx/scripts/office/schemas/microsoft/wml-2012.xsd +67 -0
- package/.agents/skills/docx/scripts/office/schemas/microsoft/wml-2018.xsd +14 -0
- package/.agents/skills/docx/scripts/office/schemas/microsoft/wml-cex-2018.xsd +20 -0
- package/.agents/skills/docx/scripts/office/schemas/microsoft/wml-cid-2016.xsd +13 -0
- package/.agents/skills/docx/scripts/office/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
- package/.agents/skills/docx/scripts/office/schemas/microsoft/wml-symex-2015.xsd +8 -0
- package/.agents/skills/docx/scripts/office/soffice.py +183 -0
- package/.agents/skills/docx/scripts/office/unpack.py +132 -0
- package/.agents/skills/docx/scripts/office/validate.py +111 -0
- package/.agents/skills/docx/scripts/office/validators/__init__.py +15 -0
- package/.agents/skills/docx/scripts/office/validators/base.py +847 -0
- package/.agents/skills/docx/scripts/office/validators/docx.py +446 -0
- package/.agents/skills/docx/scripts/office/validators/pptx.py +275 -0
- package/.agents/skills/docx/scripts/office/validators/redlining.py +247 -0
- package/.agents/skills/docx/scripts/templates/comments.xml +3 -0
- package/.agents/skills/docx/scripts/templates/commentsExtended.xml +3 -0
- package/.agents/skills/docx/scripts/templates/commentsExtensible.xml +3 -0
- package/.agents/skills/docx/scripts/templates/commentsIds.xml +3 -0
- package/.agents/skills/docx/scripts/templates/people.xml +3 -0
- package/.agents/skills/evaluation/SKILL.md +251 -0
- package/.agents/skills/evaluation/references/metrics.md +339 -0
- package/.agents/skills/evaluation/scripts/evaluator.py +627 -0
- package/.agents/skills/explain-code/SKILL.md +230 -0
- package/.agents/skills/extract/SKILL.md +91 -0
- package/.agents/skills/filesystem-context/SKILL.md +287 -0
- package/.agents/skills/filesystem-context/references/implementation-patterns.md +549 -0
- package/.agents/skills/filesystem-context/scripts/filesystem_context.py +425 -0
- package/.agents/skills/find-skills/SKILL.md +142 -0
- package/.agents/skills/frontend-design/SKILL.md +147 -0
- package/.agents/skills/frontend-design/reference/color-and-contrast.md +132 -0
- package/.agents/skills/frontend-design/reference/interaction-design.md +195 -0
- package/.agents/skills/frontend-design/reference/motion-design.md +99 -0
- package/.agents/skills/frontend-design/reference/responsive-design.md +114 -0
- package/.agents/skills/frontend-design/reference/spatial-design.md +100 -0
- package/.agents/skills/frontend-design/reference/typography.md +133 -0
- package/.agents/skills/frontend-design/reference/ux-writing.md +107 -0
- package/.agents/skills/gh-commit/SKILL.md +243 -0
- package/.agents/skills/gh-create-pr/SKILL.md +93 -0
- package/.agents/skills/harden/SKILL.md +354 -0
- package/.agents/skills/hosted-agents/SKILL.md +260 -0
- package/.agents/skills/hosted-agents/references/infrastructure-patterns.md +700 -0
- package/.agents/skills/hosted-agents/scripts/sandbox_manager.py +590 -0
- package/.agents/skills/impeccable/SKILL.md +365 -0
- package/.agents/skills/impeccable/reference/color-and-contrast.md +105 -0
- package/.agents/skills/impeccable/reference/craft.md +70 -0
- package/.agents/skills/impeccable/reference/extract.md +70 -0
- package/.agents/skills/impeccable/reference/interaction-design.md +195 -0
- package/.agents/skills/impeccable/reference/motion-design.md +99 -0
- package/.agents/skills/impeccable/reference/responsive-design.md +114 -0
- package/.agents/skills/impeccable/reference/spatial-design.md +100 -0
- package/.agents/skills/impeccable/reference/typography.md +142 -0
- package/.agents/skills/impeccable/reference/ux-writing.md +107 -0
- package/.agents/skills/impeccable/scripts/cleanup-deprecated.mjs +214 -0
- package/.agents/skills/init/SKILL.md +138 -0
- package/.agents/skills/layout/SKILL.md +125 -0
- package/.agents/skills/liteparse/SKILL.md +222 -0
- package/.agents/skills/memory-systems/SKILL.md +219 -0
- package/.agents/skills/memory-systems/references/implementation.md +551 -0
- package/.agents/skills/memory-systems/scripts/memory_store.py +616 -0
- package/.agents/skills/multi-agent-patterns/SKILL.md +257 -0
- package/.agents/skills/multi-agent-patterns/references/frameworks.md +433 -0
- package/.agents/skills/multi-agent-patterns/scripts/coordination.py +613 -0
- package/.agents/skills/normalize/SKILL.md +70 -0
- package/.agents/skills/onboard/SKILL.md +245 -0
- package/.agents/skills/opentui/SKILL.md +201 -0
- package/.agents/skills/opentui/references/animation/REFERENCE.md +431 -0
- package/.agents/skills/opentui/references/components/REFERENCE.md +144 -0
- package/.agents/skills/opentui/references/components/code-diff.md +672 -0
- package/.agents/skills/opentui/references/components/containers.md +417 -0
- package/.agents/skills/opentui/references/components/inputs.md +531 -0
- package/.agents/skills/opentui/references/components/text-display.md +386 -0
- package/.agents/skills/opentui/references/core/REFERENCE.md +145 -0
- package/.agents/skills/opentui/references/core/api.md +543 -0
- package/.agents/skills/opentui/references/core/configuration.md +168 -0
- package/.agents/skills/opentui/references/core/gotchas.md +393 -0
- package/.agents/skills/opentui/references/core/patterns.md +449 -0
- package/.agents/skills/opentui/references/keyboard/REFERENCE.md +617 -0
- package/.agents/skills/opentui/references/layout/REFERENCE.md +337 -0
- package/.agents/skills/opentui/references/layout/patterns.md +444 -0
- package/.agents/skills/opentui/references/react/REFERENCE.md +174 -0
- package/.agents/skills/opentui/references/react/api.md +436 -0
- package/.agents/skills/opentui/references/react/configuration.md +302 -0
- package/.agents/skills/opentui/references/react/gotchas.md +443 -0
- package/.agents/skills/opentui/references/react/patterns.md +501 -0
- package/.agents/skills/opentui/references/solid/REFERENCE.md +201 -0
- package/.agents/skills/opentui/references/solid/api.md +564 -0
- package/.agents/skills/opentui/references/solid/configuration.md +316 -0
- package/.agents/skills/opentui/references/solid/gotchas.md +427 -0
- package/.agents/skills/opentui/references/solid/patterns.md +560 -0
- package/.agents/skills/opentui/references/testing/REFERENCE.md +614 -0
- package/.agents/skills/optimize/SKILL.md +266 -0
- package/.agents/skills/overdrive/SKILL.md +142 -0
- package/.agents/skills/pdf/LICENSE.txt +30 -0
- package/.agents/skills/pdf/SKILL.md +314 -0
- package/.agents/skills/pdf/forms.md +294 -0
- package/.agents/skills/pdf/reference.md +612 -0
- package/.agents/skills/pdf/scripts/check_bounding_boxes.py +65 -0
- package/.agents/skills/pdf/scripts/check_fillable_fields.py +11 -0
- package/.agents/skills/pdf/scripts/convert_pdf_to_images.py +33 -0
- package/.agents/skills/pdf/scripts/create_validation_image.py +37 -0
- package/.agents/skills/pdf/scripts/extract_form_field_info.py +122 -0
- package/.agents/skills/pdf/scripts/extract_form_structure.py +115 -0
- package/.agents/skills/pdf/scripts/fill_fillable_fields.py +98 -0
- package/.agents/skills/pdf/scripts/fill_pdf_form_with_annotations.py +107 -0
- package/.agents/skills/playwright-cli/SKILL.md +344 -0
- package/.agents/skills/playwright-cli/references/element-attributes.md +23 -0
- package/.agents/skills/playwright-cli/references/playwright-tests.md +39 -0
- package/.agents/skills/playwright-cli/references/request-mocking.md +87 -0
- package/.agents/skills/playwright-cli/references/running-code.md +231 -0
- package/.agents/skills/playwright-cli/references/session-management.md +169 -0
- package/.agents/skills/playwright-cli/references/storage-state.md +275 -0
- package/.agents/skills/playwright-cli/references/test-generation.md +88 -0
- package/.agents/skills/playwright-cli/references/tracing.md +139 -0
- package/.agents/skills/playwright-cli/references/video-recording.md +143 -0
- package/.agents/skills/polish/SKILL.md +224 -0
- package/.agents/skills/pptx/LICENSE.txt +30 -0
- package/.agents/skills/pptx/SKILL.md +232 -0
- package/.agents/skills/pptx/editing.md +205 -0
- package/.agents/skills/pptx/pptxgenjs.md +420 -0
- package/.agents/skills/pptx/scripts/__init__.py +0 -0
- package/.agents/skills/pptx/scripts/add_slide.py +195 -0
- package/.agents/skills/pptx/scripts/clean.py +286 -0
- package/.agents/skills/pptx/scripts/office/helpers/__init__.py +0 -0
- package/.agents/skills/pptx/scripts/office/helpers/merge_runs.py +199 -0
- package/.agents/skills/pptx/scripts/office/helpers/simplify_redlines.py +197 -0
- package/.agents/skills/pptx/scripts/office/pack.py +159 -0
- package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
- package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
- package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
- package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
- package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
- package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
- package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
- package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
- package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
- package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
- package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
- package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
- package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
- package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
- package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
- package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
- package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
- package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
- package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
- package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
- package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
- package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
- package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
- package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
- package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
- package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
- package/.agents/skills/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
- package/.agents/skills/pptx/scripts/office/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
- package/.agents/skills/pptx/scripts/office/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
- package/.agents/skills/pptx/scripts/office/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
- package/.agents/skills/pptx/scripts/office/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
- package/.agents/skills/pptx/scripts/office/schemas/mce/mc.xsd +75 -0
- package/.agents/skills/pptx/scripts/office/schemas/microsoft/wml-2010.xsd +560 -0
- package/.agents/skills/pptx/scripts/office/schemas/microsoft/wml-2012.xsd +67 -0
- package/.agents/skills/pptx/scripts/office/schemas/microsoft/wml-2018.xsd +14 -0
- package/.agents/skills/pptx/scripts/office/schemas/microsoft/wml-cex-2018.xsd +20 -0
- package/.agents/skills/pptx/scripts/office/schemas/microsoft/wml-cid-2016.xsd +13 -0
- package/.agents/skills/pptx/scripts/office/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
- package/.agents/skills/pptx/scripts/office/schemas/microsoft/wml-symex-2015.xsd +8 -0
- package/.agents/skills/pptx/scripts/office/soffice.py +183 -0
- package/.agents/skills/pptx/scripts/office/unpack.py +132 -0
- package/.agents/skills/pptx/scripts/office/validate.py +111 -0
- package/.agents/skills/pptx/scripts/office/validators/__init__.py +15 -0
- package/.agents/skills/pptx/scripts/office/validators/base.py +847 -0
- package/.agents/skills/pptx/scripts/office/validators/docx.py +446 -0
- package/.agents/skills/pptx/scripts/office/validators/pptx.py +275 -0
- package/.agents/skills/pptx/scripts/office/validators/redlining.py +247 -0
- package/.agents/skills/pptx/scripts/thumbnail.py +289 -0
- package/.agents/skills/project-development/SKILL.md +291 -0
- package/.agents/skills/project-development/references/case-studies.md +388 -0
- package/.agents/skills/project-development/references/pipeline-patterns.md +610 -0
- package/.agents/skills/project-development/scripts/pipeline_template.py +796 -0
- package/.agents/skills/prompt-engineer/SKILL.md +263 -0
- package/.agents/skills/prompt-engineer/references/advanced_patterns.md +271 -0
- package/.agents/skills/prompt-engineer/references/core_prompting.md +137 -0
- package/.agents/skills/prompt-engineer/references/quality_improvement.md +193 -0
- package/.agents/skills/quieter/SKILL.md +103 -0
- package/.agents/skills/research-codebase/SKILL.md +227 -0
- package/.agents/skills/shape/SKILL.md +96 -0
- package/.agents/skills/skill-creator/LICENSE.txt +202 -0
- package/.agents/skills/skill-creator/SKILL.md +485 -0
- package/.agents/skills/skill-creator/agents/analyzer.md +274 -0
- package/.agents/skills/skill-creator/agents/comparator.md +202 -0
- package/.agents/skills/skill-creator/agents/grader.md +223 -0
- package/.agents/skills/skill-creator/assets/eval_review.html +146 -0
- package/.agents/skills/skill-creator/eval-viewer/generate_review.py +471 -0
- package/.agents/skills/skill-creator/eval-viewer/viewer.html +1325 -0
- package/.agents/skills/skill-creator/references/schemas.md +430 -0
- package/.agents/skills/skill-creator/scripts/__init__.py +0 -0
- package/.agents/skills/skill-creator/scripts/aggregate_benchmark.py +401 -0
- package/.agents/skills/skill-creator/scripts/generate_report.py +326 -0
- package/.agents/skills/skill-creator/scripts/improve_description.py +247 -0
- package/.agents/skills/skill-creator/scripts/package_skill.py +136 -0
- package/.agents/skills/skill-creator/scripts/quick_validate.py +103 -0
- package/.agents/skills/skill-creator/scripts/run_eval.py +310 -0
- package/.agents/skills/skill-creator/scripts/run_loop.py +328 -0
- package/.agents/skills/skill-creator/scripts/utils.py +47 -0
- package/.agents/skills/sl-commit/SKILL.md +51 -0
- package/.agents/skills/sl-submit-diff/SKILL.md +55 -0
- package/.agents/skills/teach-impeccable/SKILL.md +71 -0
- package/.agents/skills/test-driven-development/SKILL.md +371 -0
- package/.agents/skills/test-driven-development/testing-anti-patterns.md +299 -0
- package/.agents/skills/tool-design/SKILL.md +271 -0
- package/.agents/skills/tool-design/references/architectural_reduction.md +210 -0
- package/.agents/skills/tool-design/references/best_practices.md +176 -0
- package/.agents/skills/tool-design/scripts/description_generator.py +528 -0
- package/.agents/skills/typescript-advanced-types/SKILL.md +719 -0
- package/.agents/skills/typescript-expert/SKILL.md +428 -0
- package/.agents/skills/typescript-expert/references/tsconfig-strict.json +92 -0
- package/.agents/skills/typescript-expert/references/typescript-cheatsheet.md +383 -0
- package/.agents/skills/typescript-expert/references/utility-types.ts +335 -0
- package/.agents/skills/typescript-expert/scripts/ts_diagnostic.py +203 -0
- package/.agents/skills/typescript-react-reviewer/SKILL.md +200 -0
- package/.agents/skills/typescript-react-reviewer/references/antipatterns.md +510 -0
- package/.agents/skills/typescript-react-reviewer/references/checklist.md +267 -0
- package/.agents/skills/typescript-react-reviewer/references/react19-patterns.md +305 -0
- package/.agents/skills/typeset/SKILL.md +116 -0
- package/.agents/skills/workflow-creator/SKILL.md +337 -0
- package/.agents/skills/workflow-creator/references/agent-sessions.md +789 -0
- package/.agents/skills/workflow-creator/references/computation-and-validation.md +224 -0
- package/.agents/skills/workflow-creator/references/control-flow.md +450 -0
- package/.agents/skills/workflow-creator/references/discovery-and-verification.md +156 -0
- package/.agents/skills/workflow-creator/references/failure-modes.md +732 -0
- package/.agents/skills/workflow-creator/references/getting-started.md +289 -0
- package/.agents/skills/workflow-creator/references/session-config.md +355 -0
- package/.agents/skills/workflow-creator/references/state-and-data-flow.md +374 -0
- package/.agents/skills/workflow-creator/references/user-input.md +206 -0
- package/.agents/skills/workflow-creator/references/workflow-inputs.md +274 -0
- package/.agents/skills/xlsx/LICENSE.txt +30 -0
- package/.agents/skills/xlsx/SKILL.md +292 -0
- package/.agents/skills/xlsx/scripts/office/helpers/__init__.py +0 -0
- package/.agents/skills/xlsx/scripts/office/helpers/merge_runs.py +199 -0
- package/.agents/skills/xlsx/scripts/office/helpers/simplify_redlines.py +197 -0
- package/.agents/skills/xlsx/scripts/office/pack.py +159 -0
- package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
- package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
- package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
- package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
- package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
- package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
- package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
- package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
- package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
- package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
- package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
- package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
- package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
- package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
- package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
- package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
- package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
- package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
- package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
- package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
- package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
- package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
- package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
- package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
- package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
- package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
- package/.agents/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
- package/.agents/skills/xlsx/scripts/office/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
- package/.agents/skills/xlsx/scripts/office/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
- package/.agents/skills/xlsx/scripts/office/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
- package/.agents/skills/xlsx/scripts/office/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
- package/.agents/skills/xlsx/scripts/office/schemas/mce/mc.xsd +75 -0
- package/.agents/skills/xlsx/scripts/office/schemas/microsoft/wml-2010.xsd +560 -0
- package/.agents/skills/xlsx/scripts/office/schemas/microsoft/wml-2012.xsd +67 -0
- package/.agents/skills/xlsx/scripts/office/schemas/microsoft/wml-2018.xsd +14 -0
- package/.agents/skills/xlsx/scripts/office/schemas/microsoft/wml-cex-2018.xsd +20 -0
- package/.agents/skills/xlsx/scripts/office/schemas/microsoft/wml-cid-2016.xsd +13 -0
- package/.agents/skills/xlsx/scripts/office/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
- package/.agents/skills/xlsx/scripts/office/schemas/microsoft/wml-symex-2015.xsd +8 -0
- package/.agents/skills/xlsx/scripts/office/soffice.py +183 -0
- package/.agents/skills/xlsx/scripts/office/unpack.py +132 -0
- package/.agents/skills/xlsx/scripts/office/validate.py +111 -0
- package/.agents/skills/xlsx/scripts/office/validators/__init__.py +15 -0
- package/.agents/skills/xlsx/scripts/office/validators/base.py +847 -0
- package/.agents/skills/xlsx/scripts/office/validators/docx.py +446 -0
- package/.agents/skills/xlsx/scripts/office/validators/pptx.py +275 -0
- package/.agents/skills/xlsx/scripts/office/validators/redlining.py +247 -0
- package/.agents/skills/xlsx/scripts/recalc.py +184 -0
- package/.claude/agents/reviewer.md +1 -0
- package/.github/agents/reviewer.md +1 -0
- package/.opencode/agents/reviewer.md +1 -0
- package/README.md +274 -169
- package/package.json +6 -7
- package/src/commands/cli/init/index.ts +2 -2
- package/src/commands/cli/init/scm.ts +7 -8
- package/src/commands/cli/workflow-command.test.ts +74 -0
- package/src/commands/cli/workflow.ts +7 -2
- package/src/scripts/bundle-configs.ts +128 -0
- package/src/sdk/components/compact-switcher.tsx +1 -1
- package/src/sdk/components/orchestrator-panel-store.ts +13 -0
- package/src/sdk/components/orchestrator-panel.tsx +10 -0
- package/src/sdk/components/statusline.tsx +13 -1
- package/src/sdk/providers/claude.ts +42 -0
- package/src/sdk/runtime/executor.ts +111 -32
- package/src/sdk/types.ts +7 -0
- package/src/sdk/workflows/builtin/ralph/claude/index.ts +132 -76
- package/src/sdk/workflows/builtin/ralph/copilot/index.ts +129 -71
- package/src/sdk/workflows/builtin/ralph/helpers/git.ts +184 -17
- package/src/sdk/workflows/builtin/ralph/helpers/prompts.ts +463 -79
- package/src/sdk/workflows/builtin/ralph/opencode/index.ts +124 -80
- package/src/services/system/auto-sync.ts +31 -51
- package/src/services/system/skills.ts +56 -60
- package/dist/lib/path-root-guard.d.ts +0 -4
- package/dist/lib/path-root-guard.d.ts.map +0 -1
- package/dist/sdk/components/color-utils.d.ts +0 -4
- package/dist/sdk/components/color-utils.d.ts.map +0 -1
- package/dist/sdk/components/compact-switcher.d.ts +0 -10
- package/dist/sdk/components/compact-switcher.d.ts.map +0 -1
- package/dist/sdk/components/connectors.d.ts +0 -15
- package/dist/sdk/components/connectors.d.ts.map +0 -1
- package/dist/sdk/components/connectors.test.d.ts +0 -2
- package/dist/sdk/components/connectors.test.d.ts.map +0 -1
- package/dist/sdk/components/edge.d.ts +0 -4
- package/dist/sdk/components/edge.d.ts.map +0 -1
- package/dist/sdk/components/error-boundary.d.ts +0 -23
- package/dist/sdk/components/error-boundary.d.ts.map +0 -1
- package/dist/sdk/components/graph-theme.d.ts +0 -17
- package/dist/sdk/components/graph-theme.d.ts.map +0 -1
- package/dist/sdk/components/header.d.ts +0 -3
- package/dist/sdk/components/header.d.ts.map +0 -1
- package/dist/sdk/components/hooks.d.ts +0 -15
- package/dist/sdk/components/hooks.d.ts.map +0 -1
- package/dist/sdk/components/layout.d.ts +0 -27
- package/dist/sdk/components/layout.d.ts.map +0 -1
- package/dist/sdk/components/layout.test.d.ts +0 -2
- package/dist/sdk/components/layout.test.d.ts.map +0 -1
- package/dist/sdk/components/node-card.d.ts +0 -10
- package/dist/sdk/components/node-card.d.ts.map +0 -1
- package/dist/sdk/components/orchestrator-panel-contexts.d.ts +0 -16
- package/dist/sdk/components/orchestrator-panel-contexts.d.ts.map +0 -1
- package/dist/sdk/components/orchestrator-panel-store.d.ts +0 -46
- package/dist/sdk/components/orchestrator-panel-store.d.ts.map +0 -1
- package/dist/sdk/components/orchestrator-panel-store.test.d.ts +0 -2
- package/dist/sdk/components/orchestrator-panel-store.test.d.ts.map +0 -1
- package/dist/sdk/components/orchestrator-panel-types.d.ts +0 -18
- package/dist/sdk/components/orchestrator-panel-types.d.ts.map +0 -1
- package/dist/sdk/components/orchestrator-panel.d.ts +0 -52
- package/dist/sdk/components/orchestrator-panel.d.ts.map +0 -1
- package/dist/sdk/components/session-graph-panel.d.ts +0 -7
- package/dist/sdk/components/session-graph-panel.d.ts.map +0 -1
- package/dist/sdk/components/status-helpers.d.ts +0 -6
- package/dist/sdk/components/status-helpers.d.ts.map +0 -1
- package/dist/sdk/components/statusline.d.ts +0 -7
- package/dist/sdk/components/statusline.d.ts.map +0 -1
- package/dist/sdk/components/workflow-picker-panel.d.ts +0 -123
- package/dist/sdk/components/workflow-picker-panel.d.ts.map +0 -1
- package/dist/sdk/define-workflow.d.ts +0 -78
- package/dist/sdk/define-workflow.d.ts.map +0 -1
- package/dist/sdk/define-workflow.test.d.ts +0 -2
- package/dist/sdk/define-workflow.test.d.ts.map +0 -1
- package/dist/sdk/errors.d.ts +0 -24
- package/dist/sdk/errors.d.ts.map +0 -1
- package/dist/sdk/errors.test.d.ts +0 -2
- package/dist/sdk/errors.test.d.ts.map +0 -1
- package/dist/sdk/index.d.ts +0 -13
- package/dist/sdk/index.d.ts.map +0 -1
- package/dist/sdk/providers/claude.d.ts +0 -170
- package/dist/sdk/providers/claude.d.ts.map +0 -1
- package/dist/sdk/providers/copilot.d.ts +0 -11
- package/dist/sdk/providers/copilot.d.ts.map +0 -1
- package/dist/sdk/providers/opencode.d.ts +0 -11
- package/dist/sdk/providers/opencode.d.ts.map +0 -1
- package/dist/sdk/runtime/discovery.d.ts +0 -86
- package/dist/sdk/runtime/discovery.d.ts.map +0 -1
- package/dist/sdk/runtime/executor-entry.d.ts +0 -11
- package/dist/sdk/runtime/executor-entry.d.ts.map +0 -1
- package/dist/sdk/runtime/executor.d.ts +0 -72
- package/dist/sdk/runtime/executor.d.ts.map +0 -1
- package/dist/sdk/runtime/executor.test.d.ts +0 -2
- package/dist/sdk/runtime/executor.test.d.ts.map +0 -1
- package/dist/sdk/runtime/graph-inference.d.ts +0 -35
- package/dist/sdk/runtime/graph-inference.d.ts.map +0 -1
- package/dist/sdk/runtime/loader.d.ts +0 -70
- package/dist/sdk/runtime/loader.d.ts.map +0 -1
- package/dist/sdk/runtime/panel.d.ts +0 -9
- package/dist/sdk/runtime/panel.d.ts.map +0 -1
- package/dist/sdk/runtime/theme.d.ts +0 -28
- package/dist/sdk/runtime/theme.d.ts.map +0 -1
- package/dist/sdk/runtime/tmux.d.ts +0 -297
- package/dist/sdk/runtime/tmux.d.ts.map +0 -1
- package/dist/sdk/types.d.ts +0 -295
- package/dist/sdk/types.d.ts.map +0 -1
- package/dist/sdk/workflows/builtin/deep-research-codebase/claude/index.d.ts +0 -62
- package/dist/sdk/workflows/builtin/deep-research-codebase/claude/index.d.ts.map +0 -1
- package/dist/sdk/workflows/builtin/deep-research-codebase/copilot/index.d.ts +0 -46
- package/dist/sdk/workflows/builtin/deep-research-codebase/copilot/index.d.ts.map +0 -1
- package/dist/sdk/workflows/builtin/deep-research-codebase/helpers/heuristic.d.ts +0 -26
- package/dist/sdk/workflows/builtin/deep-research-codebase/helpers/heuristic.d.ts.map +0 -1
- package/dist/sdk/workflows/builtin/deep-research-codebase/helpers/prompts.d.ts +0 -92
- package/dist/sdk/workflows/builtin/deep-research-codebase/helpers/prompts.d.ts.map +0 -1
- package/dist/sdk/workflows/builtin/deep-research-codebase/helpers/scout.d.ts +0 -57
- package/dist/sdk/workflows/builtin/deep-research-codebase/helpers/scout.d.ts.map +0 -1
- package/dist/sdk/workflows/builtin/deep-research-codebase/opencode/index.d.ts +0 -49
- package/dist/sdk/workflows/builtin/deep-research-codebase/opencode/index.d.ts.map +0 -1
- package/dist/sdk/workflows/builtin/ralph/claude/index.d.ts +0 -14
- package/dist/sdk/workflows/builtin/ralph/claude/index.d.ts.map +0 -1
- package/dist/sdk/workflows/builtin/ralph/copilot/index.d.ts +0 -14
- package/dist/sdk/workflows/builtin/ralph/copilot/index.d.ts.map +0 -1
- package/dist/sdk/workflows/builtin/ralph/helpers/git.d.ts +0 -17
- package/dist/sdk/workflows/builtin/ralph/helpers/git.d.ts.map +0 -1
- package/dist/sdk/workflows/builtin/ralph/helpers/prompts.d.ts +0 -119
- package/dist/sdk/workflows/builtin/ralph/helpers/prompts.d.ts.map +0 -1
- package/dist/sdk/workflows/builtin/ralph/helpers/review.d.ts +0 -20
- package/dist/sdk/workflows/builtin/ralph/helpers/review.d.ts.map +0 -1
- package/dist/sdk/workflows/builtin/ralph/opencode/index.d.ts +0 -14
- package/dist/sdk/workflows/builtin/ralph/opencode/index.d.ts.map +0 -1
- package/dist/sdk/workflows/index.d.ts +0 -24
- package/dist/sdk/workflows/index.d.ts.map +0 -1
- package/dist/services/config/definitions.d.ts +0 -85
- package/dist/services/config/definitions.d.ts.map +0 -1
- package/dist/services/system/copy.d.ts +0 -77
- package/dist/services/system/copy.d.ts.map +0 -1
- package/dist/services/system/detect.d.ts +0 -75
- package/dist/services/system/detect.d.ts.map +0 -1
- 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.
|