moflo 4.9.20 → 4.9.22

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 (240) hide show
  1. package/.claude/agents/analysis/analyze-code-quality.md +0 -121
  2. package/.claude/agents/analysis/code-analyzer.md +5 -26
  3. package/.claude/agents/architecture/system-design/arch-system-design.md +0 -119
  4. package/.claude/agents/base-template-generator.md +0 -1
  5. package/.claude/agents/core/coder.md +0 -22
  6. package/.claude/agents/core/planner.md +0 -16
  7. package/.claude/agents/core/researcher.md +0 -16
  8. package/.claude/agents/core/reviewer.md +0 -17
  9. package/.claude/agents/core/tester.md +0 -19
  10. package/.claude/agents/custom/test-long-runner.md +0 -2
  11. package/.claude/agents/development/dev-backend-api.md +0 -167
  12. package/.claude/agents/development/dev-database.md +43 -0
  13. package/.claude/agents/development/dev-frontend.md +42 -0
  14. package/.claude/agents/devops/ci-cd/ops-cicd-github.md +0 -112
  15. package/.claude/agents/documentation/api-docs/docs-api-openapi.md +0 -111
  16. package/.claude/agents/security/security-auditor.md +45 -0
  17. package/.claude/guidance/shipped/moflo-agent-rules.md +172 -0
  18. package/.claude/guidance/shipped/moflo-claude-swarm-cohesion.md +73 -265
  19. package/.claude/guidance/shipped/moflo-cli-reference.md +6 -6
  20. package/.claude/guidance/shipped/moflo-core-guidance.md +66 -184
  21. package/.claude/guidance/shipped/moflo-cross-platform.md +1 -1
  22. package/.claude/guidance/shipped/moflo-error-handling.md +3 -3
  23. package/.claude/guidance/shipped/moflo-guidance-rules.md +17 -7
  24. package/.claude/guidance/shipped/moflo-memory-strategy.md +76 -182
  25. package/.claude/guidance/shipped/moflo-memorydb-maintenance.md +6 -8
  26. package/.claude/guidance/shipped/moflo-settings-injection.md +7 -9
  27. package/.claude/guidance/shipped/moflo-source-hygiene.md +5 -5
  28. package/.claude/guidance/shipped/moflo-spell-connectors.md +3 -4
  29. package/.claude/guidance/shipped/moflo-spell-custom-steps.md +3 -4
  30. package/.claude/guidance/shipped/moflo-spell-engine.md +40 -162
  31. package/.claude/guidance/shipped/moflo-spell-runner.md +134 -0
  32. package/.claude/guidance/shipped/moflo-spell-sandboxing.md +10 -57
  33. package/.claude/guidance/shipped/moflo-spell-troubleshooting.md +149 -0
  34. package/.claude/guidance/shipped/moflo-subagents.md +43 -114
  35. package/.claude/guidance/shipped/moflo-task-icons.md +4 -4
  36. package/.claude/guidance/shipped/moflo-user-facing-language.md +3 -3
  37. package/.claude/guidance/shipped/moflo-verbose-command-filtering.md +3 -3
  38. package/.claude/guidance/shipped/moflo-yaml-reference.md +4 -5
  39. package/.claude/helpers/gate.cjs +192 -15
  40. package/.claude/helpers/prompt-hook.mjs +4 -38
  41. package/.claude/helpers/simplify-classify.cjs +32 -11
  42. package/.claude/helpers/subagent-bootstrap.json +1 -1
  43. package/.claude/helpers/subagent-start.cjs +1 -1
  44. package/.claude/skills/connector-builder/SKILL.md +42 -429
  45. package/.claude/skills/connector-builder/templates/connector.md +189 -0
  46. package/.claude/skills/connector-builder/templates/step-command.md +176 -0
  47. package/.claude/skills/eldar/SKILL.md +7 -7
  48. package/.claude/skills/fl/SKILL.md +3 -3
  49. package/.claude/skills/fl/execution-modes.md +39 -16
  50. package/.claude/skills/fl/phases.md +3 -3
  51. package/.claude/skills/{simplify → flo-simplify}/SKILL.md +11 -11
  52. package/.claude/skills/guidance/SKILL.md +17 -9
  53. package/.claude/skills/memory-patterns/SKILL.md +1 -1
  54. package/.claude/skills/publish/SKILL.md +121 -36
  55. package/.claude/skills/reset-epic/SKILL.md +2 -2
  56. package/.claude/skills/spell-builder/SKILL.md +39 -226
  57. package/.claude/skills/spell-builder/architecture.md +1 -1
  58. package/.claude/skills/spell-builder/permissions.md +107 -0
  59. package/.claude/skills/spell-builder/preflight.md +101 -0
  60. package/.claude/skills/spell-schedule/SKILL.md +2 -3
  61. package/bin/gate.cjs +192 -15
  62. package/bin/lib/retired-files.mjs +146 -0
  63. package/bin/prompt-hook.mjs +4 -38
  64. package/bin/session-start-launcher.mjs +120 -1
  65. package/bin/setup-project.mjs +63 -69
  66. package/bin/simplify-classify.cjs +32 -11
  67. package/dist/src/cli/appliance/rvfa-builder.js +1 -1
  68. package/dist/src/cli/commands/agent.js +3 -9
  69. package/dist/src/cli/commands/doctor-checks-deep.js +4 -0
  70. package/dist/src/cli/commands/hooks.js +1 -3
  71. package/dist/src/cli/commands/index.js +2 -0
  72. package/dist/src/cli/commands/retire.js +111 -0
  73. package/dist/src/cli/hooks/reasoningbank/index.js +7 -7
  74. package/dist/src/cli/init/claudemd-generator.js +30 -33
  75. package/dist/src/cli/init/executor.js +53 -69
  76. package/dist/src/cli/init/helpers-generator.js +165 -52
  77. package/dist/src/cli/init/moflo-init.js +41 -114
  78. package/dist/src/cli/init/settings-generator.js +44 -14
  79. package/dist/src/cli/mcp-tools/agent-tools.js +9 -27
  80. package/dist/src/cli/mcp-tools/hooks-tools.js +23 -21
  81. package/dist/src/cli/memory/controllers/semantic-router.js +18 -12
  82. package/dist/src/cli/memory/sona-optimizer.js +6 -6
  83. package/dist/src/cli/neural/domain/services/learning-service.js +3 -3
  84. package/dist/src/cli/services/agent-router.js +2 -5
  85. package/dist/src/cli/services/hook-block-hash.js +11 -2
  86. package/dist/src/cli/services/hook-wiring.js +86 -3
  87. package/dist/src/cli/services/subagent-bootstrap.js +1 -1
  88. package/dist/src/cli/shared/events/example-usage.js +6 -6
  89. package/dist/src/cli/shared/hooks/task-hooks.js +8 -8
  90. package/dist/src/cli/version.js +1 -1
  91. package/package.json +3 -2
  92. package/retired-files.json +1989 -0
  93. package/scripts/post-install-bootstrap.mjs +19 -0
  94. package/src/cli/data/model-registry.json +2 -2
  95. package/.claude/agents/consensus/byzantine-coordinator.md +0 -63
  96. package/.claude/agents/consensus/crdt-synchronizer.md +0 -997
  97. package/.claude/agents/consensus/gossip-coordinator.md +0 -63
  98. package/.claude/agents/consensus/performance-benchmarker.md +0 -851
  99. package/.claude/agents/consensus/quorum-manager.md +0 -823
  100. package/.claude/agents/consensus/raft-manager.md +0 -63
  101. package/.claude/agents/consensus/security-manager.md +0 -622
  102. package/.claude/agents/data/ml/data-ml-model.md +0 -193
  103. package/.claude/agents/github/code-review-swarm.md +0 -538
  104. package/.claude/agents/github/github-modes.md +0 -172
  105. package/.claude/agents/github/issue-tracker.md +0 -311
  106. package/.claude/agents/github/multi-repo-swarm.md +0 -551
  107. package/.claude/agents/github/pr-manager.md +0 -183
  108. package/.claude/agents/github/project-board-sync.md +0 -508
  109. package/.claude/agents/github/release-manager.md +0 -360
  110. package/.claude/agents/github/release-swarm.md +0 -580
  111. package/.claude/agents/github/repo-architect.md +0 -391
  112. package/.claude/agents/github/swarm-issue.md +0 -566
  113. package/.claude/agents/github/swarm-pr.md +0 -414
  114. package/.claude/agents/github/sync-coordinator.md +0 -426
  115. package/.claude/agents/github/workflow-automation.md +0 -606
  116. package/.claude/agents/goal/code-goal-planner.md +0 -440
  117. package/.claude/agents/goal/goal-planner.md +0 -168
  118. package/.claude/agents/hive-mind/collective-intelligence-coordinator.md +0 -127
  119. package/.claude/agents/hive-mind/queen-coordinator.md +0 -198
  120. package/.claude/agents/hive-mind/scout-explorer.md +0 -233
  121. package/.claude/agents/hive-mind/swarm-memory-manager.md +0 -184
  122. package/.claude/agents/hive-mind/worker-specialist.md +0 -208
  123. package/.claude/agents/neural/safla-neural.md +0 -73
  124. package/.claude/agents/optimization/benchmark-suite.md +0 -665
  125. package/.claude/agents/optimization/load-balancer.md +0 -431
  126. package/.claude/agents/optimization/performance-monitor.md +0 -672
  127. package/.claude/agents/optimization/resource-allocator.md +0 -674
  128. package/.claude/agents/optimization/topology-optimizer.md +0 -808
  129. package/.claude/agents/reasoning/goal-planner.md +0 -67
  130. package/.claude/agents/sona/sona-learning-optimizer.md +0 -74
  131. package/.claude/agents/sparc/architecture.md +0 -472
  132. package/.claude/agents/sparc/pseudocode.md +0 -318
  133. package/.claude/agents/sparc/refinement.md +0 -525
  134. package/.claude/agents/sparc/specification.md +0 -276
  135. package/.claude/agents/specialized/mobile/spec-mobile-react-native.md +0 -225
  136. package/.claude/agents/swarm/adaptive-coordinator.md +0 -391
  137. package/.claude/agents/swarm/hierarchical-coordinator.md +0 -321
  138. package/.claude/agents/swarm/mesh-coordinator.md +0 -383
  139. package/.claude/agents/testing/production-validator.md +0 -395
  140. package/.claude/agents/testing/tdd-london-swarm.md +0 -244
  141. package/.claude/agents/v3/adr-architect.md +0 -184
  142. package/.claude/agents/v3/aidefence-guardian.md +0 -277
  143. package/.claude/agents/v3/claims-authorizer.md +0 -208
  144. package/.claude/agents/v3/collective-intelligence-coordinator.md +0 -988
  145. package/.claude/agents/v3/ddd-domain-expert.md +0 -220
  146. package/.claude/agents/v3/injection-analyst.md +0 -232
  147. package/.claude/agents/v3/memory-specialist.md +0 -987
  148. package/.claude/agents/v3/performance-engineer.md +0 -1225
  149. package/.claude/agents/v3/pii-detector.md +0 -146
  150. package/.claude/agents/v3/reasoningbank-learner.md +0 -213
  151. package/.claude/agents/v3/security-architect-aidefence.md +0 -405
  152. package/.claude/agents/v3/security-architect.md +0 -865
  153. package/.claude/agents/v3/security-auditor.md +0 -771
  154. package/.claude/agents/v3/sparc-orchestrator.md +0 -182
  155. package/.claude/agents/v3/swarm-memory-manager.md +0 -142
  156. package/.claude/agents/v3/v3-integration-architect.md +0 -205
  157. package/.claude/commands/claude-flow-help.md +0 -103
  158. package/.claude/commands/claude-flow-memory.md +0 -107
  159. package/.claude/commands/claude-flow-swarm.md +0 -205
  160. package/.claude/commands/github/README.md +0 -11
  161. package/.claude/commands/github/code-review-swarm.md +0 -514
  162. package/.claude/commands/github/code-review.md +0 -25
  163. package/.claude/commands/github/github-modes.md +0 -146
  164. package/.claude/commands/github/github-swarm.md +0 -113
  165. package/.claude/commands/github/issue-tracker.md +0 -284
  166. package/.claude/commands/github/issue-triage.md +0 -25
  167. package/.claude/commands/github/multi-repo-swarm.md +0 -519
  168. package/.claude/commands/github/pr-enhance.md +0 -26
  169. package/.claude/commands/github/pr-manager.md +0 -164
  170. package/.claude/commands/github/project-board-sync.md +0 -471
  171. package/.claude/commands/github/release-manager.md +0 -332
  172. package/.claude/commands/github/release-swarm.md +0 -544
  173. package/.claude/commands/github/repo-analyze.md +0 -25
  174. package/.claude/commands/github/repo-architect.md +0 -361
  175. package/.claude/commands/github/swarm-issue.md +0 -482
  176. package/.claude/commands/github/swarm-pr.md +0 -285
  177. package/.claude/commands/github/sync-coordinator.md +0 -294
  178. package/.claude/commands/github/workflow-automation.md +0 -442
  179. package/.claude/commands/hooks/README.md +0 -11
  180. package/.claude/commands/hooks/overview.md +0 -58
  181. package/.claude/commands/hooks/post-edit.md +0 -117
  182. package/.claude/commands/hooks/post-task.md +0 -112
  183. package/.claude/commands/hooks/pre-edit.md +0 -113
  184. package/.claude/commands/hooks/pre-task.md +0 -111
  185. package/.claude/commands/hooks/session-end.md +0 -118
  186. package/.claude/commands/hooks/setup.md +0 -103
  187. package/.claude/commands/simplify.md +0 -101
  188. package/.claude/commands/sparc/analyzer.md +0 -42
  189. package/.claude/commands/sparc/architect.md +0 -43
  190. package/.claude/commands/sparc/ask.md +0 -86
  191. package/.claude/commands/sparc/batch-executor.md +0 -44
  192. package/.claude/commands/sparc/code.md +0 -78
  193. package/.claude/commands/sparc/coder.md +0 -44
  194. package/.claude/commands/sparc/debug.md +0 -72
  195. package/.claude/commands/sparc/debugger.md +0 -44
  196. package/.claude/commands/sparc/designer.md +0 -43
  197. package/.claude/commands/sparc/devops.md +0 -98
  198. package/.claude/commands/sparc/docs-writer.md +0 -69
  199. package/.claude/commands/sparc/documenter.md +0 -44
  200. package/.claude/commands/sparc/innovator.md +0 -44
  201. package/.claude/commands/sparc/integration.md +0 -72
  202. package/.claude/commands/sparc/mcp.md +0 -106
  203. package/.claude/commands/sparc/memory-manager.md +0 -44
  204. package/.claude/commands/sparc/optimizer.md +0 -44
  205. package/.claude/commands/sparc/orchestrator.md +0 -116
  206. package/.claude/commands/sparc/post-deployment-monitoring-mode.md +0 -72
  207. package/.claude/commands/sparc/refinement-optimization-mode.md +0 -72
  208. package/.claude/commands/sparc/researcher.md +0 -44
  209. package/.claude/commands/sparc/reviewer.md +0 -44
  210. package/.claude/commands/sparc/security-review.md +0 -69
  211. package/.claude/commands/sparc/sparc-modes.md +0 -139
  212. package/.claude/commands/sparc/sparc.md +0 -99
  213. package/.claude/commands/sparc/spec-pseudocode.md +0 -69
  214. package/.claude/commands/sparc/spell-manager.md +0 -44
  215. package/.claude/commands/sparc/supabase-admin.md +0 -337
  216. package/.claude/commands/sparc/swarm-coordinator.md +0 -44
  217. package/.claude/commands/sparc/tdd.md +0 -44
  218. package/.claude/commands/sparc/tester.md +0 -44
  219. package/.claude/commands/sparc/tutorial.md +0 -68
  220. package/.claude/commands/sparc.md +0 -151
  221. package/.claude/guidance/shipped/moflo-session-start.md +0 -154
  222. package/.claude/guidance/shipped/moflo-spell-engine-architecture.md +0 -145
  223. package/.claude/skills/browser/SKILL.md +0 -204
  224. package/.claude/skills/github-code-review/SKILL.md +0 -1140
  225. package/.claude/skills/github-multi-repo/SKILL.md +0 -866
  226. package/.claude/skills/github-project-management/SKILL.md +0 -1272
  227. package/.claude/skills/github-release-management/SKILL.md +0 -1074
  228. package/.claude/skills/github-workflow-automation/SKILL.md +0 -1060
  229. package/.claude/skills/hive-mind-advanced/SKILL.md +0 -712
  230. package/.claude/skills/hooks-automation/SKILL.md +0 -1193
  231. package/.claude/skills/pair-programming/SKILL.md +0 -1202
  232. package/.claude/skills/performance-analysis/SKILL.md +0 -563
  233. package/.claude/skills/skill-builder/SKILL.md +0 -910
  234. package/.claude/skills/sparc-methodology/SKILL.md +0 -904
  235. package/.claude/skills/stream-chain/SKILL.md +0 -563
  236. package/.claude/skills/swarm-advanced/SKILL.md +0 -811
  237. package/.claude/skills/swarm-orchestration/SKILL.md +0 -179
  238. package/.claude/skills/verification-quality/SKILL.md +0 -649
  239. package/.claude/skills/worker-benchmarks/skill.md +0 -135
  240. package/.claude/skills/worker-integration/skill.md +0 -154
@@ -1,38 +1,21 @@
1
- # Spell Engine — Running, Creating, and Customizing Spells
1
+ # Spell Engine — Definition Format & Step Types
2
2
 
3
- **Purpose:** How to run spells via MCP tools, create new spell definitions, register custom step commands, and understand the shipped vs user override layering system. Reference when a user asks to run, create, or modify spells.
3
+ **Purpose:** How to define a spell (YAML/JSON schema, arguments, steps, variable interpolation) and a reference for the nine built-in step command types. For execution mechanics (running, dry-run, error codes, pause/resume, layering, credentials), see `.claude/guidance/moflo-spell-runner.md`.
4
4
 
5
5
  ---
6
6
 
7
7
  ## Claude's Role During Spell Execution
8
8
 
9
- **Claude MUST treat the spell definition as a strict contract — execute only what it specifies, using only the capabilities it declares.** This applies equally whether the spell is run manually, via MCP, or on a schedule by the daemon.
9
+ **Treat the spell definition as a strict contract — execute only what it specifies, using only the capabilities it declares.** This applies whether the spell runs manually, via MCP, or on a schedule.
10
10
 
11
11
  | Constraint | Detail |
12
12
  |-----------|--------|
13
13
  | Step config is the complete instruction | Do not add commands, flags, arguments, or actions beyond what `config` contains |
14
14
  | Capability restrictions are absolute | If a step restricts `fs:read` to `["./src/"]`, do not read files outside `./src/` even if helpful |
15
15
  | `CAPABILITY_DENIED` means stop | Do not attempt workarounds — report the denial and halt the step |
16
- | No improvisation between steps | Do not perform actions outside of step boundaries, even if "obvious" (e.g., do not auto-fix a failing step's output before passing it to the next step unless the spell defines a step for that) |
16
+ | No improvisation between steps | Do not perform actions outside step boundaries, even if "obvious" |
17
17
 
18
- See `.claude/guidance/shipped/moflo-spell-sandboxing.md` for the full Execution Constraint Principle and capability type reference.
19
-
20
- ---
21
-
22
- ## Running a Spell via MCP Tools
23
-
24
- **Use `mcp__moflo__spell_cast` to execute a spell from a YAML/JSON file.** The bridge layer handles parsing, validation, and runner lifecycle automatically.
25
-
26
- | MCP Tool | Purpose |
27
- |----------|---------|
28
- | `mcp__moflo__spell_cast` | Run spell from file content (YAML/JSON) |
29
- | `mcp__moflo__spell_execute` | Execute a spell definition object directly |
30
- | `mcp__moflo__spell_cancel` | Cancel a running spell by ID |
31
- | `mcp__moflo__spell_status` | Check if a spell is currently running |
32
- | `mcp__moflo__spell_suspend` | Pause a running spell for later resumption |
33
- | `mcp__moflo__spell_resume` | Resume a previously paused spell |
34
-
35
- **Dry-run mode validates without executing.** Pass `dryRun: true` to check definition validity, argument resolution, and step config schemas before committing to execution.
18
+ See `.claude/guidance/moflo-spell-sandboxing.md` for the full Execution Constraint Principle and capability type reference.
36
19
 
37
20
  ---
38
21
 
@@ -102,7 +85,7 @@ steps:
102
85
  |---------|-------------|
103
86
  | `{args.environment}` | Spell argument value |
104
87
  | `{check-branch.stdout}` | Output field from step `check-branch` |
105
- | `{credentials.API_KEY}` | Credential value (redacted in logs) |
88
+ | `{credentials.API_KEY}` | Credential value (redacted in logs — see `moflo-spell-runner.md`) |
106
89
 
107
90
  Interpolation works in all string values within step `config`. Nested object values and arrays are interpolated recursively.
108
91
 
@@ -122,7 +105,7 @@ steps:
122
105
 
123
106
  ## Step Command Types
124
107
 
125
- **Nine built-in step types are registered automatically.** Each implements `execute()`, `validate()`, `describeOutputs()`, and optional `rollback()`. Additional step types can be added via pluggable step discovery see `moflo-spell-custom-steps.md` for the JS/TS, YAML, and npm-package extension paths.
108
+ **Nine built-in step types are registered automatically.** Each implements `execute()`, `validate()`, `describeOutputs()`, and optional `rollback()`. To add new step types via JS/TS files, YAML composite steps, or `moflo-step-*` npm packages, see `.claude/guidance/moflo-spell-custom-steps.md`.
126
109
 
127
110
  ### bash — Run a Shell Command
128
111
 
@@ -130,8 +113,8 @@ steps:
130
113
  - id: build
131
114
  type: bash
132
115
  config:
133
- command: "npm run build" # Required. Shell command to execute.
134
- timeout: 30000 # Optional. Timeout in ms (default: 30000).
116
+ command: "npm run build" # Required.
117
+ timeout: 30000 # Optional. Default 30000.
135
118
  failOnError: true # Optional. Fail step on non-zero exit (default: true).
136
119
  ```
137
120
 
@@ -145,9 +128,9 @@ steps:
145
128
  - id: research
146
129
  type: agent
147
130
  config:
148
- agentType: "researcher" # Required. Agent type (researcher, coder, tester, etc.).
149
- prompt: "Find all API endpoints in {args.directory}" # Required. Task prompt.
150
- background: false # Optional. Run in background (default: false).
131
+ agentType: "researcher" # Required. researcher, coder, tester, etc.
132
+ prompt: "Find all API endpoints in {args.directory}" # Required.
133
+ background: false # Optional. Default false.
151
134
  ```
152
135
 
153
136
  **Outputs:** `result` (string), `agentType` (string), `prompt` (string).
@@ -160,14 +143,14 @@ steps:
160
143
  - id: check-env
161
144
  type: condition
162
145
  config:
163
- if: "{args.environment} === 'production'" # Required. Expression to evaluate.
146
+ if: "{args.environment} === 'production'" # Required.
164
147
  then: "deploy-prod" # Optional. Step ID to jump to if true.
165
148
  else: "deploy-staging" # Optional. Step ID to jump to if false.
166
149
  ```
167
150
 
168
151
  **Outputs:** `result` (boolean), `branch` (string: "then" or "else"), `nextStep` (string).
169
152
 
170
- The runner uses `nextStep` to jump to the target step ID. Jumps can go forward or backward. A max-iteration guard (`steps.length * 10`) prevents infinite loops.
153
+ The runner uses `nextStep` to jump to the target step ID. Jumps may go forward or backward. A max-iteration guard (`steps.length * 10`) prevents infinite loops.
171
154
 
172
155
  ---
173
156
 
@@ -177,10 +160,10 @@ The runner uses `nextStep` to jump to the target step ID. Jumps can go forward o
177
160
  - id: process-files
178
161
  type: loop
179
162
  config:
180
- over: ["{args.files}"] # Required. Array to iterate (or variable reference).
181
- maxIterations: 100 # Optional. Safety limit (default: 100).
182
- itemVar: "file" # Optional. Current item variable name (default: "item").
183
- indexVar: "idx" # Optional. Current index variable name (default: "index").
163
+ over: ["{args.files}"] # Required. Array or variable reference.
164
+ maxIterations: 100 # Optional. Default 100.
165
+ itemVar: "file" # Optional. Default "item".
166
+ indexVar: "idx" # Optional. Default "index".
184
167
  steps: # Nested steps run for each item.
185
168
  - id: process-one
186
169
  type: bash
@@ -190,7 +173,7 @@ The runner uses `nextStep` to jump to the target step ID. Jumps can go forward o
190
173
 
191
174
  **Outputs:** `totalItems` (number), `iterations` (number), `truncated` (boolean), `items` (array).
192
175
 
193
- Nested `steps` are defined on the step definition (not inside `config`). The runner executes all nested steps per iteration, injecting `itemVar` and `indexVar` into the variable context. Previous values are saved and restored after the loop completes.
176
+ Nested `steps` go on the step definition (not inside `config`). The runner injects `itemVar` and `indexVar` per iteration; previous values are saved and restored after the loop.
194
177
 
195
178
  ---
196
179
 
@@ -200,11 +183,11 @@ Nested `steps` are defined on the step definition (not inside `config`). The run
200
183
  - id: load-config
201
184
  type: memory
202
185
  config:
203
- action: "read" # Required. One of: read, write, search.
204
- namespace: "workflow-state" # Required. Memory namespace.
205
- key: "last-deploy" # Required for read/write. Memory key.
206
- value: "{deploy.stdout}" # Required for write. Value to store.
207
- query: "deploy status" # Required for search. Semantic query.
186
+ action: "read" # Required. read | write | search.
187
+ namespace: "workflow-state" # Required.
188
+ key: "last-deploy" # Required for read/write.
189
+ value: "{deploy.stdout}" # Required for write.
190
+ query: "deploy status" # Required for search.
208
191
  ```
209
192
 
210
193
  **Outputs:** `value` (object), `found` (boolean), `written` (boolean), `results` (array), `count` (number).
@@ -217,10 +200,10 @@ Nested `steps` are defined on the step definition (not inside `config`). The run
217
200
  - id: confirm
218
201
  type: prompt
219
202
  config:
220
- message: "Deploy to {args.environment}?" # Required. Question text.
221
- options: ["yes", "no"] # Optional. Multiple choice options.
222
- default: "no" # Optional. Default if no input.
223
- outputVar: "user_choice" # Optional. Variable to store response.
203
+ message: "Deploy to {args.environment}?" # Required.
204
+ options: ["yes", "no"] # Optional. Multiple choice.
205
+ default: "no" # Optional.
206
+ outputVar: "user_choice" # Optional.
224
207
  ```
225
208
 
226
209
  **Outputs:** `response` (string), `message` (string), `outputVar` (string).
@@ -233,7 +216,7 @@ Nested `steps` are defined on the step definition (not inside `config`). The run
233
216
  - id: cooldown
234
217
  type: wait
235
218
  config:
236
- duration: 5000 # Required. Wait duration in milliseconds.
219
+ duration: 5000 # Required. Milliseconds.
237
220
  ```
238
221
 
239
222
  **Outputs:** `waited` (number — actual wait time in ms).
@@ -264,103 +247,21 @@ Requires `playwright` as a peer dependency. The command checks for Playwright av
264
247
  - id: create-issue
265
248
  type: github
266
249
  config:
267
- action: "create-issue" # Required. create-issue, create-pr, add-label, comment, etc.
250
+ action: "create-issue" # Required.
268
251
  title: "Bug: {args.title}" # Required for create-issue/create-pr.
269
- body: "Details here" # Optional. Issue/PR body.
252
+ body: "Details here" # Optional.
270
253
  repo: "owner/repo" # Optional. Defaults to current repo.
271
254
  ```
272
255
 
273
256
  **Outputs:** `url` (string), `number` (number), `action` (string).
274
257
 
275
- Supports 8 actions: `create-issue`, `create-pr`, `add-label`, `remove-label`, `comment`, `close-issue`, `close-pr`, `merge-pr`. Requires `gh` CLI installed and authenticated.
276
-
277
- ---
278
-
279
- ## Custom Step Commands
280
-
281
- **To register custom step types, see `moflo-spell-custom-steps.md`.** That doc covers the three extension paths (JS/TS step files, YAML composite steps, `moflo-step-*` npm packages), priority ordering, and how to configure `createRunner()` for discovery.
282
-
283
- ---
284
-
285
- ## Shipped vs User Definition Layering
286
-
287
- **Shipped definitions are bundled defaults. User definitions override shipped ones by name match.**
288
-
289
- | Tier | Source | Priority |
290
- |------|--------|----------|
291
- | Shipped | Bundled in moflo package source (`workflows/shipped/`) | Lower |
292
- | User | Project-local path (configurable via `moflo.yaml`) | Higher — overrides shipped by name |
293
-
294
- ### How Layering Works
295
-
296
- 1. `loadSpellDefinitions()` loads shipped definitions first
297
- 2. Then loads user definitions from configured directories
298
- 3. If a user definition has the same `name` as a shipped one, the user version wins
299
- 4. New names in user directories are additive (they extend, not replace, the set)
300
-
301
- ### Loading Definitions Programmatically
302
-
303
- ```typescript
304
- import { loadSpellDefinitions, loadSpellByName } from 'moflo/dist/src/cli/spells/index.js';
305
-
306
- const { spells, errors } = loadSpellDefinitions({
307
- shippedDir: 'node_modules/moflo/workflows/shipped',
308
- userDirs: ['.claude/workflows', 'workflows/'],
309
- });
310
- const result = loadSpellByName('deploy-staging', { /* same options */ });
311
- ```
312
-
313
- ---
314
-
315
- ## Error Handling and Rollback
316
-
317
- **The runner collects errors without throwing.** `SpellResult` always returns — check `result.success` and `result.errors`.
318
-
319
- | Error Code | Meaning |
320
- |------------|---------|
321
- | `DEFINITION_VALIDATION_FAILED` | Invalid YAML/JSON or schema violation |
322
- | `ARGUMENT_VALIDATION_FAILED` | Missing required argument or type mismatch |
323
- | `UNKNOWN_STEP_TYPE` | No step command registered for this type |
324
- | `STEP_VALIDATION_FAILED` | Step config fails command's schema validation |
325
- | `STEP_EXECUTION_FAILED` | Step threw during execution |
326
- | `STEP_TIMEOUT` | Step exceeded its timeout |
327
- | `STEP_CANCELLED` | Spell cancelled via AbortSignal |
328
- | `CONDITION_TARGET_NOT_FOUND` | Condition branch references nonexistent step ID |
329
- | `PAUSED_STATE_NOT_FOUND` | No paused state for spell ID on resume |
330
- | `PAUSED_STATE_EXPIRED` | Paused state exceeded stale timeout |
331
- | `ROLLBACK_FAILED` | Rollback of completed steps failed |
332
- | `SPELL_CANCELLED` | Entire spell was cancelled |
333
-
334
- ### continueOnError
335
-
336
- **Set `continueOnError: true` on a step to keep running after failure.** The failed step is recorded in results but execution continues. Without this flag, a step failure triggers rollback of completed steps and terminates the spell.
337
-
338
- ---
339
-
340
- ## Pause and Resume
341
-
342
- **Pause serializes spell state to memory. Resume reconstructs and continues from where it left off.**
343
-
344
- ```typescript
345
- import { buildPausedState, persistPausedState, resumeSpell } from 'moflo/dist/src/cli/spells/index.js';
346
-
347
- // Pause after step 2 of 5
348
- const state = buildPausedState(spellId, definition, 2, variables, completedResults, args);
349
- await persistPausedState(state, memory);
350
-
351
- // Later: resume from step 3
352
- const result = await resumeSpell(spellId, { memory, variables: { override: 'value' } });
353
- ```
354
-
355
- **Stale timeout is 24 hours by default.** Paused state older than this is rejected on resume and cleaned up. Use `cleanupStalePaused(memory)` to sweep expired entries.
356
-
357
- **Variable overrides on resume** allow injecting or modifying context between pause and resume (e.g., user edits a value in between).
258
+ Supported actions: `create-issue`, `create-pr`, `add-label`, `remove-label`, `comment`, `close-issue`, `close-pr`, `merge-pr`. Requires `gh` CLI installed and authenticated.
358
259
 
359
260
  ---
360
261
 
361
262
  ## Creating New Spell Definitions
362
263
 
363
- **To create a spell for a user, write a `.yaml` file in their project's spell directory** (typically `.claude/workflows/` or a path configured in `moflo.yaml`).
264
+ To create a spell, write a `.yaml` file in the project's spell directory (typically `.claude/workflows/`, or the path configured in `moflo.yaml`).
364
265
 
365
266
  1. Start with `name` and `steps`
366
267
  2. Add `arguments` for any user-provided values
@@ -378,38 +279,15 @@ const result = await resumeSpell(spellId, { memory, variables: { override: 'valu
378
279
  | Loop `over` resolves to an array | Loop command validates at execution |
379
280
  | No circular condition jumps | Max-iteration guard catches these |
380
281
 
381
- ---
382
-
383
- ## Dry-Run Validation
384
-
385
- **Always dry-run before executing a new or modified spell.** Dry-run validates the definition, resolves arguments, and checks step configs without executing anything.
386
-
387
- ```typescript
388
- import { runSpellFromContent } from 'moflo/dist/src/cli/spells/index.js';
389
-
390
- const result = await runSpellFromContent(yamlContent, 'my-spell.yaml', { dryRun: true });
391
- if (!result.success) {
392
- console.error('Validation errors:', result.errors);
393
- }
394
- ```
395
-
396
- Via MCP: pass `dryRun: true` to `mcp__moflo__spell_cast`.
397
-
398
- ---
399
-
400
- ## Credential Handling
401
-
402
- **Credentials are accessed via `{credentials.KEY}` in interpolation.** The credential accessor is injected into the runner at creation time — spells never store credentials directly.
403
-
404
- Credential values listed in `RunnerOptions.credentialValues` are automatically redacted from step output to prevent accidental exposure in logs or results.
282
+ **Always dry-run before executing a new or modified spell** (see `.claude/guidance/moflo-spell-runner.md` § Dry-Run Validation).
405
283
 
406
284
  ---
407
285
 
408
286
  ## See Also
409
287
 
410
- - `.claude/guidance/shipped/moflo-spell-custom-steps.md` — Pluggable step commands: JS/TS, YAML, and `moflo-step-*` npm packages
411
- - `.claude/guidance/shipped/moflo-spell-connectors.md` — Connectors: resource adapters, registry, step-vs-connector decision
412
- - `.claude/guidance/shipped/moflo-spell-sandboxing.md` — Capability-based security for steps
413
- - `.claude/guidance/shipped/moflo-spell-engine-architecture.md` — Architecture decisions for Epic #100
414
- - `.claude/guidance/shipped/moflo-core-guidance.md` — CLI, hooks, swarm, memory reference
415
- - `.claude/guidance/shipped/moflo-subagents.md` — Subagents protocol
288
+ - `.claude/guidance/moflo-spell-runner.md` — Running spells, MCP tools, dry-run, error codes, pause/resume, credentials, definition layering
289
+ - `.claude/guidance/moflo-spell-sandboxing.md` — Capability-based security for steps; required reading before authoring
290
+ - `.claude/guidance/moflo-spell-custom-steps.md` — Pluggable step commands: JS/TS files, YAML composites, `moflo-step-*` packages
291
+ - `.claude/guidance/moflo-spell-connectors.md` — Connectors: resource adapters, registry, step-vs-connector decision
292
+ - `.claude/guidance/moflo-spell-troubleshooting.md` — Common failure modes (sandbox/network, permission gaps, environment)
293
+ - `.claude/guidance/moflo-core-guidance.md` — CLI, hooks, swarm, memory reference
@@ -0,0 +1,134 @@
1
+ # Spell Runner — Execution, Layering, Errors, and Recovery
2
+
3
+ **Purpose:** How spells are run, validated, paused, resumed, and how errors and credentials are handled. For the YAML schema, step types, and authoring rules, see `.claude/guidance/moflo-spell-engine.md`.
4
+
5
+ ---
6
+
7
+ ## Running a Spell via MCP Tools
8
+
9
+ **Use `mcp__moflo__spell_cast` to execute a spell from a YAML/JSON file.** The bridge layer handles parsing, validation, and runner lifecycle automatically.
10
+
11
+ | MCP Tool | Purpose |
12
+ |----------|---------|
13
+ | `mcp__moflo__spell_cast` | Run spell from file content (YAML/JSON) |
14
+ | `mcp__moflo__spell_execute` | Execute a spell definition object directly |
15
+ | `mcp__moflo__spell_cancel` | Cancel a running spell by ID |
16
+ | `mcp__moflo__spell_status` | Check whether a spell is currently running |
17
+ | `mcp__moflo__spell_suspend` | Pause a running spell for later resumption |
18
+ | `mcp__moflo__spell_resume` | Resume a previously paused spell |
19
+
20
+ **Dry-run mode validates without executing.** Pass `dryRun: true` to check definition validity, argument resolution, and step config schemas before committing to execution.
21
+
22
+ ---
23
+
24
+ ## Dry-Run Validation
25
+
26
+ **Always dry-run before executing a new or modified spell.** Dry-run validates the definition, resolves arguments, and checks step configs — nothing executes.
27
+
28
+ ```typescript
29
+ import { runSpellFromContent } from 'moflo/dist/src/cli/spells/index.js';
30
+
31
+ const result = await runSpellFromContent(yamlContent, 'my-spell.yaml', { dryRun: true });
32
+ if (!result.success) {
33
+ console.error('Validation errors:', result.errors);
34
+ }
35
+ ```
36
+
37
+ Via MCP: pass `dryRun: true` to `mcp__moflo__spell_cast`.
38
+
39
+ Dry runs also show the per-step permission report — see `.claude/guidance/moflo-spell-sandboxing.md` § Permission Levels.
40
+
41
+ ---
42
+
43
+ ## Shipped vs User Definition Layering
44
+
45
+ **Shipped definitions are bundled defaults. User definitions override shipped ones by name match.**
46
+
47
+ | Tier | Source | Priority |
48
+ |------|--------|----------|
49
+ | Shipped | Bundled in moflo package source (`workflows/shipped/`) | Lower |
50
+ | User | Project-local path (configurable via `moflo.yaml`) | Higher — overrides shipped by name |
51
+
52
+ ### How Layering Works
53
+
54
+ 1. `loadSpellDefinitions()` loads shipped definitions first
55
+ 2. Then loads user definitions from configured directories
56
+ 3. If a user definition has the same `name` as a shipped one, the user version wins
57
+ 4. New names in user directories are additive (they extend, not replace, the set)
58
+
59
+ ### Loading Definitions Programmatically
60
+
61
+ ```typescript
62
+ import { loadSpellDefinitions, loadSpellByName } from 'moflo/dist/src/cli/spells/index.js';
63
+
64
+ const { spells, errors } = loadSpellDefinitions({
65
+ shippedDir: 'node_modules/moflo/workflows/shipped',
66
+ userDirs: ['.claude/workflows', 'workflows/'],
67
+ });
68
+ const result = loadSpellByName('deploy-staging', { /* same options */ });
69
+ ```
70
+
71
+ ---
72
+
73
+ ## Error Handling and Rollback
74
+
75
+ **The runner collects errors without throwing.** `SpellResult` always returns — check `result.success` and `result.errors`.
76
+
77
+ | Error Code | Meaning |
78
+ |------------|---------|
79
+ | `DEFINITION_VALIDATION_FAILED` | Invalid YAML/JSON or schema violation |
80
+ | `ARGUMENT_VALIDATION_FAILED` | Missing required argument or type mismatch |
81
+ | `UNKNOWN_STEP_TYPE` | No step command registered for this type |
82
+ | `STEP_VALIDATION_FAILED` | Step config fails the command's schema validation |
83
+ | `STEP_EXECUTION_FAILED` | Step threw during execution |
84
+ | `STEP_TIMEOUT` | Step exceeded its timeout |
85
+ | `STEP_CANCELLED` | Spell cancelled via AbortSignal |
86
+ | `CONDITION_TARGET_NOT_FOUND` | Condition branch references a nonexistent step ID |
87
+ | `PAUSED_STATE_NOT_FOUND` | No paused state for spell ID on resume |
88
+ | `PAUSED_STATE_EXPIRED` | Paused state exceeded the stale timeout |
89
+ | `ROLLBACK_FAILED` | Rollback of completed steps failed |
90
+ | `SPELL_CANCELLED` | Entire spell was cancelled |
91
+
92
+ ### continueOnError
93
+
94
+ **Set `continueOnError: true` on a step to keep running after failure.** The failed step is recorded in results but execution continues. Without this flag, a step failure triggers rollback of completed steps and terminates the spell.
95
+
96
+ ---
97
+
98
+ ## Pause and Resume
99
+
100
+ **Pause serializes spell state to memory. Resume reconstructs and continues from where it left off.**
101
+
102
+ ```typescript
103
+ import { buildPausedState, persistPausedState, resumeSpell } from 'moflo/dist/src/cli/spells/index.js';
104
+
105
+ // Pause after step 2 of 5
106
+ const state = buildPausedState(spellId, definition, 2, variables, completedResults, args);
107
+ await persistPausedState(state, memory);
108
+
109
+ // Later: resume from step 3
110
+ const result = await resumeSpell(spellId, { memory, variables: { override: 'value' } });
111
+ ```
112
+
113
+ **Stale timeout is 24 hours by default.** Paused state older than this is rejected on resume and cleaned up. Use `cleanupStalePaused(memory)` to sweep expired entries.
114
+
115
+ **Variable overrides on resume** allow injecting or modifying context between pause and resume (e.g., user edits a value in between).
116
+
117
+ ---
118
+
119
+ ## Credential Handling
120
+
121
+ **Credentials are accessed via `{credentials.KEY}` in interpolation.** The credential accessor is injected into the runner at creation time — spells never store credentials directly.
122
+
123
+ Credential values listed in `RunnerOptions.credentialValues` are automatically redacted from step output to prevent accidental exposure in logs or results. The `credentials` capability gates access — see `.claude/guidance/moflo-spell-sandboxing.md`.
124
+
125
+ ---
126
+
127
+ ## See Also
128
+
129
+ - `.claude/guidance/moflo-spell-engine.md` — Definition format, step types, variable interpolation
130
+ - `.claude/guidance/moflo-spell-sandboxing.md` — Capability-based security and permission levels
131
+ - `.claude/guidance/moflo-spell-troubleshooting.md` — Common failure modes when running spells
132
+ - `.claude/guidance/moflo-spell-custom-steps.md` — Pluggable step commands
133
+ - `.claude/guidance/moflo-spell-connectors.md` — Resource connectors and the registry
134
+ - `.claude/guidance/moflo-core-guidance.md` — CLI, hooks, swarm, memory reference
@@ -135,14 +135,14 @@ Each method calls `enforceScope()` internally. If the resource is outside the st
135
135
  | `bash` | `checkShell()` | **Enforced** |
136
136
  | `browser` | `checkBrowserEvaluate()`, `checkNet()` | **Enforced** |
137
137
  | `memory` | `checkMemory()` | **Enforced** |
138
- | `agent` | `checkAgent()` | **Enforced** (#258) |
139
- | `github` | `checkShell()` | **Enforced** (#258) |
140
- | Connectors | `checkNet()` via `GatedConnectorAccessor` | **Enforced** (#265) |
141
- | Credentials | `checkCredentials()` | **Enforced** (#268) |
138
+ | `agent` | `checkAgent()` | **Enforced** |
139
+ | `github` | `checkShell()` | **Enforced** |
140
+ | Connectors | `checkNet()` via `GatedConnectorAccessor` | **Enforced** |
141
+ | Credentials | `checkCredentials()` | **Enforced** |
142
142
  | Control flow (`condition`, `loop`, `parallel`, `composite`) | N/A | No I/O — child steps individually checked |
143
143
  | `wait`, `prompt` | N/A | No dangerous capabilities |
144
144
 
145
- **Gateway is non-optional** (#266): `WorkflowContext.gateway` is required. A `DenyAllGateway` is the default — any code path that reaches a gateway check without going through `step-executor` (which installs a properly-scoped gateway) will fail loudly rather than silently skipping enforcement.
145
+ **Gateway is non-optional**: `WorkflowContext.gateway` is required. A `DenyAllGateway` is the default — any code path that reaches a gateway check without going through `step-executor` (which installs a properly-scoped gateway) will fail loudly rather than silently skipping enforcement.
146
146
 
147
147
  ---
148
148
 
@@ -250,60 +250,13 @@ Before shipping any new or edited spell step, walk through every item. Silently-
250
250
 
251
251
  When reviewing a spell PR, scan every bash step for a missing `permissionLevel` and ask: *does this step touch the network, or does it depend on network state from earlier?* If yes, `elevated` (or an explicit `net` grant) is required.
252
252
 
253
- ## Troubleshooting
254
-
255
- ### Symptom: bash step fails with DNS / SSH resolution errors inside a spell
256
-
257
- Typical error messages from inside a bash step:
258
-
259
- - `ssh: Could not resolve hostname github.com: Temporary failure in name resolution`
260
- - `fatal: Could not read from remote repository.`
261
- - `curl: (6) Could not resolve host ...`
262
- - `getaddrinfo ENOTFOUND ...`
263
- - Any other DNS/connection failure, even though the **same command works in your normal shell**.
264
-
265
- **Tell-tale clue:** the error mentions `Temporary failure in name resolution` (a glibc-specific wording). That means the step is running inside a Linux sandbox (`bwrap` on Linux / WSL), **not** your outer shell — Git Bash or PowerShell won't produce that exact message.
266
-
267
- **Root cause:** `src/cli/spells/core/bwrap-sandbox.ts` isolates the network by default:
268
-
269
- ```ts
270
- if (!hasNet && !needsToolHomeAccess(options.permissionLevel)) {
271
- args.push('--unshare-net'); // ← no network, no DNS
272
- }
273
- ```
274
-
275
- A bash step gets network access only when **one** of these is true:
276
-
277
- 1. The step declares a `net` capability, **or**
278
- 2. The step's `permissionLevel` is `elevated` or `autonomous`.
279
-
280
- If neither applies, bwrap runs the command in a namespace with `--unshare-net`, and DNS silently fails. There is no log line announcing the network was taken away — you just see the command's own DNS error.
281
-
282
- **Fix:** for any bash step that does `git pull`/`git push`/`git fetch`, `gh` API calls, `curl`, `npm install`, or any other outbound network:
283
-
284
- ```yaml
285
- - id: create-branch
286
- type: bash
287
- permissionLevel: elevated # ← grants network in bwrap
288
- config:
289
- command: "git pull origin main && ..."
290
- ```
291
-
292
- Or declare the `net` capability explicitly if the step doesn't need the full `elevated` profile (note: `bash-command.ts` must include `net` in its declared capabilities for the engine to accept the grant — otherwise you'll see `Capability violation: step type "bash" does not declare capability "net"`).
293
-
294
- **Quick diagnosis checklist** when a spell's bash step can't reach the network:
295
-
296
- 1. Does the same command work in your outer shell? If yes, it's sandbox-related, not config.
297
- 2. Is the error wording glibc-style (`Temporary failure in name resolution`)? → bwrap is involved.
298
- 3. Open the spell YAML — does the failing step have `permissionLevel: elevated`? If not, add it and retry.
299
- 4. If you use `set -e` in a multi-command bash step, **do it**. Without it, a trailing `... || true` (common for stash-pop cleanups) will mask the real network failure and you'll see a confusing error several steps later (e.g. "pathspec did not match" when a branch that was never pulled/created is later checked out).
300
-
301
253
  ## See Also
302
254
 
303
- - `.claude/guidance/shipped/moflo-spell-engine.md` — Spell engine usage and YAML format
304
- - `.claude/guidance/shipped/moflo-spell-connectors.md` — Optional resource adapters (not the enforcement layer)
305
- - `.claude/guidance/shipped/moflo-spell-engine-architecture.md` — Engine architecture and messaging
306
- - `.claude/guidance/shipped/moflo-core-guidance.md` — Full CLI/MCP reference
255
+ - `.claude/guidance/moflo-spell-engine.md` — Spell definition format and step types
256
+ - `.claude/guidance/moflo-spell-runner.md` — Running spells, dry-run, error codes, pause/resume
257
+ - `.claude/guidance/moflo-spell-troubleshooting.md` — Sandbox/network failure modes (DNS errors, `--unshare-net`, `set -e` traps)
258
+ - `.claude/guidance/moflo-spell-connectors.md` — Optional resource adapters (not the enforcement layer)
259
+ - `.claude/guidance/moflo-core-guidance.md` — Full CLI/MCP reference
307
260
  - `src/cli/spells/core/permission-resolver.ts` — Capability → permission level derivation
308
261
  - `src/cli/spells/core/permission-disclosure.ts` — Risk classification and reporting
309
262
  - `src/cli/spells/core/permission-acceptance.ts` — Acceptance storage and gate