@exaudeus/workrail 3.27.0 → 3.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/dist/console/assets/{index-FtTaDku8.js → index-BZ6HkxGf.js} +1 -1
  2. package/dist/console/index.html +1 -1
  3. package/dist/manifest.json +3 -3
  4. package/docs/README.md +57 -0
  5. package/docs/adrs/001-hybrid-storage-backend.md +38 -0
  6. package/docs/adrs/002-four-layer-context-classification.md +38 -0
  7. package/docs/adrs/003-checkpoint-trigger-strategy.md +35 -0
  8. package/docs/adrs/004-opt-in-encryption-strategy.md +36 -0
  9. package/docs/adrs/005-agent-first-workflow-execution-tokens.md +105 -0
  10. package/docs/adrs/006-append-only-session-run-event-log.md +76 -0
  11. package/docs/adrs/007-resume-and-checkpoint-only-sessions.md +51 -0
  12. package/docs/adrs/008-blocked-nodes-architectural-upgrade.md +178 -0
  13. package/docs/adrs/009-bridge-mode-single-instance-mcp.md +195 -0
  14. package/docs/adrs/010-release-pipeline.md +89 -0
  15. package/docs/architecture/README.md +7 -0
  16. package/docs/architecture/refactor-audit.md +364 -0
  17. package/docs/authoring-v2.md +527 -0
  18. package/docs/authoring.md +873 -0
  19. package/docs/changelog-recent.md +201 -0
  20. package/docs/configuration.md +505 -0
  21. package/docs/ctc-mcp-proposal.md +518 -0
  22. package/docs/design/README.md +22 -0
  23. package/docs/design/agent-cascade-protocol.md +96 -0
  24. package/docs/design/autonomous-console-design-candidates.md +253 -0
  25. package/docs/design/autonomous-console-design-review.md +111 -0
  26. package/docs/design/autonomous-platform-mvp-discovery.md +525 -0
  27. package/docs/design/claude-code-source-deep-dive.md +713 -0
  28. package/docs/design/console-cyberpunk-ui-discovery.md +504 -0
  29. package/docs/design/console-execution-trace-candidates-final.md +160 -0
  30. package/docs/design/console-execution-trace-candidates.md +211 -0
  31. package/docs/design/console-execution-trace-design-candidates-v2.md +113 -0
  32. package/docs/design/console-execution-trace-design-review.md +74 -0
  33. package/docs/design/console-execution-trace-discovery.md +394 -0
  34. package/docs/design/console-execution-trace-final-review.md +77 -0
  35. package/docs/design/console-execution-trace-review.md +92 -0
  36. package/docs/design/console-performance-discovery.md +415 -0
  37. package/docs/design/console-ui-backlog.md +280 -0
  38. package/docs/design/daemon-architecture-discovery.md +853 -0
  39. package/docs/design/daemon-design-candidates.md +318 -0
  40. package/docs/design/daemon-design-review-findings.md +119 -0
  41. package/docs/design/daemon-engine-design-candidates.md +210 -0
  42. package/docs/design/daemon-engine-design-review.md +131 -0
  43. package/docs/design/daemon-execution-engine-discovery.md +280 -0
  44. package/docs/design/daemon-gap-analysis.md +554 -0
  45. package/docs/design/daemon-owns-console-plan.md +168 -0
  46. package/docs/design/daemon-owns-console-review.md +91 -0
  47. package/docs/design/daemon-owns-console.md +195 -0
  48. package/docs/design/data-model-erd.md +11 -0
  49. package/docs/design/design-candidates-consolidate-dev-staleness.md +98 -0
  50. package/docs/design/design-candidates-walk-cache-depth-limit.md +80 -0
  51. package/docs/design/design-review-consolidate-dev-staleness.md +54 -0
  52. package/docs/design/design-review-walk-cache-depth-limit.md +48 -0
  53. package/docs/design/implementation-plan-consolidate-dev-staleness.md +142 -0
  54. package/docs/design/implementation-plan-walk-cache-depth-limit.md +141 -0
  55. package/docs/design/layer3b-ghost-nodes-design-candidates.md +229 -0
  56. package/docs/design/layer3b-ghost-nodes-design-review.md +93 -0
  57. package/docs/design/layer3b-ghost-nodes-implementation-plan.md +219 -0
  58. package/docs/design/list-workflows-latency-fix-plan.md +128 -0
  59. package/docs/design/list-workflows-latency-fix-review.md +55 -0
  60. package/docs/design/list-workflows-latency-fix.md +109 -0
  61. package/docs/design/native-context-management-api.md +11 -0
  62. package/docs/design/performance-sweep-2026-04.md +96 -0
  63. package/docs/design/routines-guide.md +219 -0
  64. package/docs/design/sequence-diagrams.md +11 -0
  65. package/docs/design/subagent-design-principles.md +220 -0
  66. package/docs/design/temporal-patterns-design-candidates.md +312 -0
  67. package/docs/design/temporal-patterns-design-review-findings.md +163 -0
  68. package/docs/design/test-isolation-from-config-file.md +335 -0
  69. package/docs/design/v2-core-design-locks.md +2746 -0
  70. package/docs/design/v2-lock-registry.json +734 -0
  71. package/docs/design/workflow-authoring-v2.md +1044 -0
  72. package/docs/design/workflow-docs-spec.md +218 -0
  73. package/docs/design/workflow-extension-points.md +687 -0
  74. package/docs/design/workrail-auto-trigger-system.md +359 -0
  75. package/docs/design/workrail-config-file-discovery.md +513 -0
  76. package/docs/docker.md +110 -0
  77. package/docs/generated/v2-lock-closure-plan.md +26 -0
  78. package/docs/generated/v2-lock-coverage.json +797 -0
  79. package/docs/generated/v2-lock-coverage.md +177 -0
  80. package/docs/ideas/backlog.md +3927 -0
  81. package/docs/ideas/design-candidates-mcp-resilience.md +208 -0
  82. package/docs/ideas/design-review-findings-mcp-resilience.md +119 -0
  83. package/docs/ideas/implementation_plan.md +249 -0
  84. package/docs/ideas/third-party-workflow-setup-design-thinking.md +1948 -0
  85. package/docs/implementation/02-architecture.md +316 -0
  86. package/docs/implementation/04-testing-strategy.md +124 -0
  87. package/docs/implementation/09-simple-workflow-guide.md +835 -0
  88. package/docs/implementation/13-advanced-validation-guide.md +874 -0
  89. package/docs/implementation/README.md +21 -0
  90. package/docs/integrations/claude-code.md +300 -0
  91. package/docs/integrations/firebender.md +315 -0
  92. package/docs/migration/v0.1.0.md +147 -0
  93. package/docs/naming-conventions.md +45 -0
  94. package/docs/planning/README.md +104 -0
  95. package/docs/planning/github-ticketing-playbook.md +195 -0
  96. package/docs/plans/README.md +24 -0
  97. package/docs/plans/agent-managed-ticketing-design.md +605 -0
  98. package/docs/plans/agentic-orchestration-roadmap.md +112 -0
  99. package/docs/plans/assessment-gates-engine-handoff.md +536 -0
  100. package/docs/plans/content-coherence-and-references.md +151 -0
  101. package/docs/plans/library-extraction-plan.md +340 -0
  102. package/docs/plans/mr-review-workflow-redesign.md +1451 -0
  103. package/docs/plans/native-context-management-epic.md +11 -0
  104. package/docs/plans/perf-fixes-design-candidates.md +225 -0
  105. package/docs/plans/perf-fixes-design-review-findings.md +61 -0
  106. package/docs/plans/perf-fixes-new-issues-candidates.md +264 -0
  107. package/docs/plans/perf-fixes-new-issues-review.md +110 -0
  108. package/docs/plans/prompt-fragments.md +53 -0
  109. package/docs/plans/ui-ux-workflow-design-candidates.md +120 -0
  110. package/docs/plans/ui-ux-workflow-discovery.md +100 -0
  111. package/docs/plans/ui-ux-workflow-review.md +48 -0
  112. package/docs/plans/v2-followup-enhancements.md +587 -0
  113. package/docs/plans/workflow-categories-candidates.md +105 -0
  114. package/docs/plans/workflow-categories-discovery.md +110 -0
  115. package/docs/plans/workflow-categories-review.md +51 -0
  116. package/docs/plans/workflow-discovery-model-candidates.md +94 -0
  117. package/docs/plans/workflow-discovery-model-discovery.md +74 -0
  118. package/docs/plans/workflow-discovery-model-review.md +48 -0
  119. package/docs/plans/workflow-source-setup-phase-1.md +245 -0
  120. package/docs/plans/workflow-source-setup-phase-2.md +361 -0
  121. package/docs/plans/workflow-staleness-detection-candidates.md +104 -0
  122. package/docs/plans/workflow-staleness-detection-review.md +58 -0
  123. package/docs/plans/workflow-staleness-detection.md +80 -0
  124. package/docs/plans/workflow-v2-design.md +69 -0
  125. package/docs/plans/workflow-v2-roadmap.md +74 -0
  126. package/docs/plans/workflow-validation-design.md +98 -0
  127. package/docs/plans/workflow-validation-roadmap.md +108 -0
  128. package/docs/plans/workrail-platform-vision.md +420 -0
  129. package/docs/reference/agent-context-cleaner-snippet.md +94 -0
  130. package/docs/reference/agent-context-guidance.md +140 -0
  131. package/docs/reference/context-optimization.md +284 -0
  132. package/docs/reference/example-workflow-repository-template/.github/workflows/validate.yml +125 -0
  133. package/docs/reference/example-workflow-repository-template/README.md +268 -0
  134. package/docs/reference/example-workflow-repository-template/workflows/example-workflow.json +80 -0
  135. package/docs/reference/external-workflow-repositories.md +916 -0
  136. package/docs/reference/feature-flags-architecture.md +472 -0
  137. package/docs/reference/feature-flags.md +349 -0
  138. package/docs/reference/god-tier-workflow-validation.md +272 -0
  139. package/docs/reference/loop-optimization.md +209 -0
  140. package/docs/reference/loop-validation.md +176 -0
  141. package/docs/reference/loops.md +465 -0
  142. package/docs/reference/mcp-platform-constraints.md +59 -0
  143. package/docs/reference/recovery.md +88 -0
  144. package/docs/reference/releases.md +177 -0
  145. package/docs/reference/troubleshooting.md +105 -0
  146. package/docs/reference/workflow-execution-contract.md +998 -0
  147. package/docs/roadmap/README.md +22 -0
  148. package/docs/roadmap/legacy-planning-status.md +103 -0
  149. package/docs/roadmap/now-next-later.md +70 -0
  150. package/docs/roadmap/open-work-inventory.md +389 -0
  151. package/docs/tickets/README.md +39 -0
  152. package/docs/tickets/next-up.md +76 -0
  153. package/docs/workflow-management.md +317 -0
  154. package/docs/workflow-templates.md +423 -0
  155. package/docs/workflow-validation.md +184 -0
  156. package/docs/workflows.md +254 -0
  157. package/package.json +3 -1
  158. package/spec/authoring-spec.json +61 -16
  159. package/workflows/workflow-for-workflows.json +252 -93
  160. package/workflows/workflow-for-workflows.v2.json +188 -77
@@ -0,0 +1,835 @@
1
+ # Simple Workflow Creation Guide
2
+
3
+ > **A guide to creating simple, single-file workflows**
4
+
5
+ [![Status](https://img.shields.io/badge/status-specification-orange.svg)](https://github.com/EtienneBBeaulac/mcp)
6
+ [![Spec Version](https://img.shields.io/badge/spec-1.0.0-blue.svg)](specs/)
7
+ [![MCP Compatible](https://img.shields.io/badge/MCP-compatible-purple.svg)](https://modelcontextprotocol.org)
8
+
9
+ ## Table of Contents
10
+
11
+ 1. [Getting Started with Workflows](#getting-started-with-workflows)
12
+ 2. [Creating Your First Workflow](#creating-your-first-workflow)
13
+ 3. [Workflow Design Basics](#workflow-design-basics)
14
+ - [Function Reference Pattern (Advanced)](#function-reference-pattern-advanced)
15
+ 4. [Testing Your Workflow](#testing-your-workflow)
16
+ 5. [Common Mistakes to Avoid](#common-mistakes-to-avoid)
17
+ 6. [Examples](#examples)
18
+
19
+ ---
20
+
21
+ ## Getting Started with Workflows
22
+
23
+ ### What is a Workflow?
24
+
25
+ A workflow is a structured sequence of steps that guides an AI agent through a development task. Think of it as a recipe that helps the AI follow best practices and avoid common pitfalls.
26
+
27
+ ### How to Read the Existing Example
28
+
29
+ Let's look at the authentication workflow example:
30
+
31
+ ```json
32
+ {
33
+ "id": "simple-auth-implementation",
34
+ "name": "Simple Authentication Implementation",
35
+ "description": "Implement basic JWT authentication for a REST API with user login and token validation",
36
+ "preconditions": [
37
+ "User model exists in the database",
38
+ "JWT library is installed in the project",
39
+ "Environment variables for JWT_SECRET are configured"
40
+ ],
41
+ "clarificationPrompts": [
42
+ "What is the token expiration time you want to use?",
43
+ "Should the authentication support refresh tokens?",
44
+ "Do you need role-based access control?"
45
+ ],
46
+ "steps": [
47
+ {
48
+ "id": "analyze-current-auth",
49
+ "title": "Analyze current authentication setup",
50
+ "prompt": "Examine the existing authentication implementation if any. Look for: user model structure, existing auth middleware, login endpoints. Document what you find.",
51
+ "requireConfirmation": true
52
+ }
53
+ ],
54
+ "metaGuidance": [
55
+ "Always hash passwords using bcrypt or similar",
56
+ "Include proper error messages for debugging",
57
+ "Follow RESTful conventions for endpoints",
58
+ "Add rate limiting to prevent brute force attacks"
59
+ ]
60
+ }
61
+ ```
62
+
63
+ **Key Parts:**
64
+ - **`id`**: Unique identifier (use kebab-case)
65
+ - **`name`**: Human-friendly title
66
+ - **`description`**: What the workflow accomplishes
67
+ - **`preconditions`**: What must be true before starting
68
+ - **`clarificationPrompts`**: Questions to ask upfront
69
+ - **`steps`**: The actual workflow steps
70
+ - **`metaGuidance`**: Best practices that apply throughout
71
+
72
+ **Available in current release:**
73
+ - **`runCondition`**: Optional condition on steps for "choose your own adventure" workflows
74
+ - **`agentRole`**: Optional agent behavioral instructions (separate from user-facing prompts)
75
+
76
+ ---
77
+
78
+ ## Creating Your First Workflow
79
+
80
+ ### Step 1: Start with a Template
81
+
82
+ Copy the authentication example and modify it for your needs:
83
+
84
+ ```json
85
+ {
86
+ "id": "your-workflow-id",
87
+ "name": "Your Workflow Name",
88
+ "description": "What your workflow accomplishes",
89
+ "preconditions": [
90
+ "Prerequisite 1",
91
+ "Prerequisite 2"
92
+ ],
93
+ "clarificationPrompts": [
94
+ "Question 1?",
95
+ "Question 2?"
96
+ ],
97
+ "steps": [
98
+ {
99
+ "id": "step-1",
100
+ "title": "First Step",
101
+ "prompt": "What to do in this step",
102
+ "agentRole": "Optional: specific behavioral guidance for the AI agent",
103
+ "requireConfirmation": true
104
+ }
105
+ ],
106
+ "metaGuidance": [
107
+ "Best practice 1",
108
+ "Best practice 2"
109
+ ]
110
+ }
111
+ ```
112
+
113
+ ### Step 2: Define Your Steps
114
+
115
+ Each step should follow the **prep/implement/verify** pattern:
116
+
117
+ ```json
118
+ {
119
+ "id": "implement-feature",
120
+ "title": "Implement the feature",
121
+ "prompt": "**PREP**: First, understand the current state and requirements.\n\n**IMPLEMENT**: Make the necessary changes following the plan.\n\n**VERIFY**: Test your changes and ensure they work correctly.",
122
+ "requireConfirmation": true
123
+ }
124
+ ```
125
+
126
+ ### Step 3: Add Clarification Prompts
127
+
128
+ Ask questions that help clarify requirements:
129
+
130
+ ```json
131
+ "clarificationPrompts": [
132
+ "What is the main goal of this feature?",
133
+ "Are there any specific constraints or requirements?",
134
+ "Which files are most likely to be affected?"
135
+ ]
136
+ ```
137
+
138
+ ---
139
+
140
+ ## Workflow Design Basics
141
+
142
+ ### The prep/implement/verify Pattern
143
+
144
+ This pattern helps ensure quality by breaking each step into three phases:
145
+
146
+ 1. **PREP**: Understand the current state and requirements
147
+ 2. **IMPLEMENT**: Make focused, specific changes
148
+ 3. **VERIFY**: Test and validate the changes
149
+
150
+ **Example:**
151
+ ```json
152
+ {
153
+ "id": "add-user-validation",
154
+ "title": "Add user input validation",
155
+ "prompt": "**PREP**: Examine the current user input handling and identify validation gaps.\n\n**IMPLEMENT**: Add appropriate validation rules for user inputs.\n\n**VERIFY**: Test with various input scenarios to ensure validation works correctly.",
156
+ "requireConfirmation": true
157
+ }
158
+ ```
159
+
160
+ ### When to Use `requireConfirmation`
161
+
162
+ Use `requireConfirmation: true` when:
163
+ - The step makes significant changes
164
+ - User approval is needed before proceeding
165
+ - The step involves important decisions
166
+ - You want to pause for review
167
+
168
+ **Example:**
169
+ ```json
170
+ {
171
+ "id": "create-database-migration",
172
+ "title": "Create database migration",
173
+ "prompt": "Create a database migration for the new user fields.",
174
+ "requireConfirmation": true
175
+ }
176
+ ```
177
+
178
+ ### When to Use `askForFiles`
179
+
180
+ Use `askForFiles: true` when:
181
+ - The step needs to examine specific files
182
+ - File context is important for the step
183
+ - You want to ensure the agent has the right files
184
+
185
+ **Example:**
186
+ ```json
187
+ {
188
+ "id": "review-existing-code",
189
+ "title": "Review existing implementation",
190
+ "prompt": "Examine the current implementation and identify areas for improvement.",
191
+ "askForFiles": true
192
+ }
193
+ ```
194
+
195
+ ### When to Use `runCondition`
196
+
197
+ Use `runCondition` when:
198
+ - Different steps should execute based on task scope or complexity
199
+ - You want "choose your own adventure" style workflows
200
+ - Steps should be skipped based on user expertise or preferences
201
+ - Conditional logic is needed for different scenarios
202
+
203
+ **Example:**
204
+ ```json
205
+ {
206
+ "id": "advanced-optimization",
207
+ "title": "Advanced performance optimization",
208
+ "prompt": "Implement advanced caching and optimization strategies.",
209
+ "runCondition": {
210
+ "and": [
211
+ {"var": "taskScope", "equals": "large"},
212
+ {"var": "userExpertise", "equals": "expert"}
213
+ ]
214
+ }
215
+ }
216
+ ```
217
+
218
+ **Supported condition operators:**
219
+ - `equals`, `not_equals`: Value comparison
220
+ - `gt`, `gte`, `lt`, `lte`: Numeric comparison
221
+ - `and`, `or`, `not`: Logical operations
222
+
223
+ ### When to Use `agentRole`
224
+
225
+ Use `agentRole` when:
226
+ - You want to provide specific behavioral guidance to the AI agent
227
+ - The agent needs role-specific expertise (security expert, code reviewer, etc.)
228
+ - You want to separate agent instructions from user-facing content
229
+ - Different steps require different agent personas or expertise
230
+
231
+ **Example:**
232
+ ```json
233
+ {
234
+ "id": "security-review",
235
+ "title": "Security Code Review",
236
+ "prompt": "Please review the provided code for security issues.",
237
+ "agentRole": "You are a cybersecurity expert specializing in code security. Focus on identifying vulnerabilities like SQL injection, XSS, authentication bypasses, and data exposure. Provide specific remediation steps for any issues found.",
238
+ "askForFiles": true
239
+ }
240
+ ```
241
+
242
+ **Best Practices for agentRole:**
243
+ - Be specific about the agent's expertise and focus areas
244
+ - Include what the agent should look for or prioritize
245
+ - Mention the expected output format or approach
246
+ - Keep it separate from user-facing instructions in the prompt
247
+
248
+ ### Writing Good Prompts
249
+
250
+ **Good Prompt:**
251
+ ```json
252
+ {
253
+ "prompt": "**PREP**: Analyze the current authentication system and identify security gaps.\n\n**IMPLEMENT**: Add input validation and sanitization to prevent common attacks.\n\n**VERIFY**: Test with malicious inputs to ensure security measures work."
254
+ }
255
+ ```
256
+
257
+ **Bad Prompt:**
258
+ ```json
259
+ {
260
+ "prompt": "Fix the authentication system"
261
+ }
262
+ ```
263
+
264
+ **Why the first is better:**
265
+ - Clear structure with prep/implement/verify
266
+ - Specific instructions
267
+ - Includes validation criteria
268
+ - Follows the pattern consistently
269
+
270
+ ### Function Reference Pattern (Advanced)
271
+
272
+ For complex workflows with repeated instructions, you can use a **function reference pattern** to reduce duplication and improve maintainability. This creates a pseudo-DSL (Domain Specific Language) within your workflow.
273
+
274
+ #### How It Works
275
+
276
+ Define reusable "functions" in your `metaGuidance` section, then reference them throughout your workflow:
277
+
278
+ **Example Function Definitions:**
279
+ ```json
280
+ {
281
+ "metaGuidance": [
282
+ "fun updateDecisionLog() = 'Update Decision Log in CONTEXT.md: file paths/ranges, excerpts, why important, outcome impact. Limit 3-5 files/decision.'",
283
+ "fun useTools() = 'Use tools to verify - never guess. Expand file reads to imports/models/interfaces/classes/deps. Trace all dependencies.'",
284
+ "fun createFile(filename) = 'Use edit_file to create/update {filename}. NEVER output full content in chat - only summarize. If fails, request user help & log command.'",
285
+ "fun applyUserRules() = 'Apply & reference user-defined rules, patterns & preferences. Document alignment in Decision Log. Explain rule influence in decisions.'",
286
+ "fun matchPatterns() = 'Use codebase_search/grep to find similar patterns. Reference Decision Log patterns. Match target area unless user rules override.'",
287
+ "fun gitCommit(type, msg) = 'If git available: commit with {type}: {msg}. If unavailable: log in CONTEXT.md with timestamp.'",
288
+ "When you see function calls like updateDecisionLog() or createFile(spec.md), refer to the function definitions above for full instructions."
289
+ ]
290
+ }
291
+ ```
292
+
293
+ **Example Usage in Steps:**
294
+ ```json
295
+ {
296
+ "id": "create-specification",
297
+ "title": "Create Technical Specification",
298
+ "prompt": "Create a detailed technical specification from the analysis.\n\n**Requirements:**\n- Include existing patterns/conventions from analysis\n- System integration approach\n- applyUserRules() throughout\n- matchPatterns() from codebase\n\n**Actions:**\n- createFile(spec.md)\n- updateDecisionLog()\n- Sanity check complexity level"
299
+ }
300
+ ```
301
+
302
+ #### Benefits of Function References
303
+
304
+ 1. **Significant deduplication**: Each instruction appears only once
305
+ 2. **Improved consistency**: Same wording used everywhere
306
+ 3. **Better readability**: Prompts become more scannable
307
+ 4. **Easier maintenance**: Update function definition once, applies everywhere
308
+ 5. **Context savings**: Reduces file size by 15-20% while maintaining detail
309
+
310
+ #### Implementation Tips
311
+
312
+ - **Function Naming**: Use clear, descriptive names like `updateDecisionLog()` or `createFile(filename)`
313
+ - **Parameter Support**: Simple parameter substitution works: `createFile(spec.md)` becomes instructions for "spec.md"
314
+ - **Resumption Support**: Include function definitions in CONTEXT.md for workflow resumption
315
+ - **Documentation**: Always include the interpretation instruction in metaGuidance
316
+
317
+ #### When to Use This Pattern
318
+
319
+ **Good for:**
320
+ - Complex workflows with repeated instructions
321
+ - Workflows with >10 steps that share common patterns
322
+ - Team workflows where consistency is crucial
323
+ - Workflows that need detailed instructions but have character limits
324
+
325
+ **Avoid for:**
326
+ - Simple workflows with few steps
327
+ - One-off workflows that won't be maintained
328
+ - Workflows where explicit instructions are clearer
329
+
330
+ #### Character Limits and Validation
331
+
332
+ Remember that metaGuidance items have a 256-character limit in the schema. Keep function definitions concise:
333
+
334
+ ```json
335
+ // Good - under 256 characters
336
+ "fun updateDecisionLog() = 'Update Decision Log: file paths, why important, outcome impact. Limit 3-5 files.'"
337
+
338
+ // Too long - over 256 characters
339
+ "fun updateDecisionLog() = 'Update the Decision Log section in CONTEXT.md with detailed file paths and line ranges, excerpts showing why each file was important, and how they influenced the outcome and decision-making process throughout the workflow execution. Always limit to the top 3-5 most impactful files per decision for scannability and conciseness.'"
340
+ ```
341
+
342
+ ---
343
+
344
+ ## Testing Your Workflow
345
+
346
+ ### Step 1: Validate Against Schema
347
+
348
+ #### CLI Validation
349
+ Use the JSON schema to validate your workflow:
350
+
351
+ ```bash
352
+ # Example validation (when tools are available)
353
+ npm run validate-workflow your-workflow.json
354
+ ```
355
+
356
+ #### MCP Tool Validation
357
+ You can also validate workflow JSON directly through the MCP protocol:
358
+
359
+ ```bash
360
+ # Example: Validate workflow JSON via MCP tool
361
+ echo '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"workflow_validate_json","arguments":{"workflowJson":"{\"id\":\"my-workflow\",\"name\":\"My Workflow\",\"description\":\"A test workflow\",\"steps\":[{\"id\":\"step1\",\"title\":\"First Step\",\"prompt\":\"Do something\"}]}"}}}' | node dist/mcp-server.js
362
+ ```
363
+
364
+ **When to use `workflow_validate_json`:**
365
+ - Building workflow editors or management tools
366
+ - Integrating validation into automated workflows
367
+ - Providing real-time validation feedback
368
+ - Validating programmatically generated workflows
369
+
370
+ **Benefits:**
371
+ - Comprehensive JSON syntax validation
372
+ - Schema compliance checking
373
+ - Actionable error messages with suggestions
374
+ - No external dependencies required
375
+
376
+ ### Step 2: Basic Testing Checklist
377
+
378
+ - [ ] Does the workflow have a unique `id`?
379
+ - [ ] Is the `name` clear and descriptive?
380
+ - [ ] Does the `description` explain what it accomplishes?
381
+ - [ ] Are all required fields present?
382
+ - [ ] Do the steps follow the prep/implement/verify pattern?
383
+ - [ ] Are clarification prompts clear and relevant?
384
+ - [ ] Is metaGuidance helpful and specific?
385
+
386
+ ### Step 3: Advanced Step Output Validation
387
+
388
+ The workflow system includes a powerful **ValidationEngine** that can validate step outputs using three enhancement types:
389
+
390
+ #### JSON Schema Validation
391
+ Validate structured output against a JSON schema:
392
+
393
+ ```json
394
+ {
395
+ "id": "create-user-api",
396
+ "title": "Create user API endpoint",
397
+ "prompt": "**PREP**: Design the API endpoint structure.\n\n**IMPLEMENT**: Create the endpoint with proper validation.\n\n**VERIFY**: Test the endpoint with various inputs.",
398
+ "validationCriteria": [
399
+ {
400
+ "type": "schema",
401
+ "schema": {
402
+ "type": "object",
403
+ "properties": {
404
+ "endpoint": {"type": "string", "pattern": "^/api/users(/.*)?$"},
405
+ "method": {"type": "string", "enum": ["POST", "PUT", "PATCH"]},
406
+ "validation": {
407
+ "type": "object",
408
+ "properties": {
409
+ "required": {"type": "array", "items": {"type": "string"}},
410
+ "properties": {"type": "object"}
411
+ },
412
+ "required": ["required", "properties"]
413
+ }
414
+ },
415
+ "required": ["endpoint", "method", "validation"]
416
+ }
417
+ }
418
+ ]
419
+ }
420
+ ```
421
+
422
+ #### Context-Aware Validation
423
+ Apply validation rules conditionally based on context:
424
+
425
+ ```json
426
+ {
427
+ "id": "database-migration",
428
+ "title": "Create database migration",
429
+ "prompt": "**PREP**: Analyze the database changes needed.\n\n**IMPLEMENT**: Create migration files.\n\n**VERIFY**: Test migration in development environment.",
430
+ "validationCriteria": [
431
+ {
432
+ "type": "contains",
433
+ "value": "CREATE TABLE",
434
+ "condition": "context.migrationType === 'create'"
435
+ },
436
+ {
437
+ "type": "contains",
438
+ "value": "ALTER TABLE",
439
+ "condition": "context.migrationType === 'modify'"
440
+ },
441
+ {
442
+ "type": "regex",
443
+ "pattern": "rollback|down|revert",
444
+ "condition": "context.requiresRollback === true"
445
+ }
446
+ ]
447
+ }
448
+ ```
449
+
450
+ #### Logical Composition Validation
451
+ Combine multiple validation rules with logical operators:
452
+
453
+ ```json
454
+ {
455
+ "id": "security-implementation",
456
+ "title": "Implement security measures",
457
+ "prompt": "**PREP**: Identify security requirements.\n\n**IMPLEMENT**: Add authentication and authorization.\n\n**VERIFY**: Test security measures thoroughly.",
458
+ "validationCriteria": {
459
+ "and": [
460
+ {
461
+ "or": [
462
+ {"type": "contains", "value": "jwt"},
463
+ {"type": "contains", "value": "session"}
464
+ ]
465
+ },
466
+ {
467
+ "type": "regex",
468
+ "pattern": "\\b(authorize|permission|role)\\b"
469
+ },
470
+ {
471
+ "not": {
472
+ "type": "contains",
473
+ "value": "password"
474
+ }
475
+ }
476
+ ]
477
+ }
478
+ }
479
+ ```
480
+
481
+ ### Step 4: Common Validation Errors
482
+
483
+ **Missing Required Fields:**
484
+ ```json
485
+ // Missing required fields
486
+ {
487
+ "name": "My Workflow"
488
+ // Missing id, description, steps
489
+ }
490
+ ```
491
+
492
+ **Invalid Step Structure:**
493
+ ```json
494
+ // Invalid step
495
+ {
496
+ "id": "step-1",
497
+ "title": "My Step"
498
+ // Missing required 'prompt' field
499
+ }
500
+ ```
501
+
502
+ **Invalid ID Format:**
503
+ ```json
504
+ // Invalid ID (contains spaces)
505
+ {
506
+ "id": "my workflow",
507
+ // Should be: "my-workflow"
508
+ }
509
+ ```
510
+
511
+ **Invalid Validation Criteria:**
512
+ ```json
513
+ // Invalid schema format
514
+ {
515
+ "type": "schema",
516
+ "schema": "not a valid schema object"
517
+ }
518
+
519
+ // Invalid condition syntax
520
+ {
521
+ "type": "contains",
522
+ "value": "test",
523
+ "condition": "invalid javascript syntax"
524
+ }
525
+
526
+ // Missing logical operator
527
+ {
528
+ "validationCriteria": {
529
+ "invalidOperator": [
530
+ {"type": "contains", "value": "test"}
531
+ ]
532
+ }
533
+ }
534
+ ```
535
+
536
+ ---
537
+
538
+ ## Common Mistakes to Avoid
539
+
540
+ ### 1. **Vague Prompts**
541
+ ```json
542
+ // Too vague
543
+ {
544
+ "prompt": "Fix the bug"
545
+ }
546
+
547
+ // Specific and structured
548
+ {
549
+ "prompt": "**PREP**: Identify the root cause of the authentication bug.\n\n**IMPLEMENT**: Apply the fix with proper error handling.\n\n**VERIFY**: Test the fix with various scenarios."
550
+ }
551
+ ```
552
+
553
+ ### 2. **Missing Preconditions**
554
+ ```json
555
+ // No preconditions
556
+ {
557
+ "steps": [...]
558
+ }
559
+
560
+ // Clear preconditions
561
+ {
562
+ "preconditions": [
563
+ "Database is accessible",
564
+ "Required libraries are installed",
565
+ "Environment variables are configured"
566
+ ]
567
+ }
568
+ ```
569
+
570
+ ### 3. **Poor Step Organization**
571
+ ```json
572
+ // Steps not logically ordered
573
+ {
574
+ "steps": [
575
+ {"id": "test", "title": "Test the feature"},
576
+ {"id": "implement", "title": "Implement the feature"},
577
+ {"id": "plan", "title": "Plan the implementation"}
578
+ ]
579
+ }
580
+
581
+ // Logical order
582
+ {
583
+ "steps": [
584
+ {"id": "plan", "title": "Plan the implementation"},
585
+ {"id": "implement", "title": "Implement the feature"},
586
+ {"id": "test", "title": "Test the feature"}
587
+ ]
588
+ }
589
+ ```
590
+
591
+ ### 4. **Inconsistent Patterns**
592
+ ```json
593
+ // Inconsistent pattern usage
594
+ {
595
+ "steps": [
596
+ {"id": "step1", "prompt": "PREP: Analyze... IMPLEMENT: Code... VERIFY: Test..."},
597
+ {"id": "step2", "prompt": "Just do this thing"}
598
+ ]
599
+ }
600
+
601
+ // Consistent pattern usage
602
+ {
603
+ "steps": [
604
+ {"id": "step1", "prompt": "PREP: Analyze... IMPLEMENT: Code... VERIFY: Test..."},
605
+ {"id": "step2", "prompt": "PREP: Review... IMPLEMENT: Update... VERIFY: Validate..."}
606
+ ]
607
+ }
608
+ ```
609
+
610
+ ---
611
+
612
+ ## Examples
613
+
614
+ ### Example 1: Feature Implementation Workflow
615
+
616
+ ```json
617
+ {
618
+ "id": "feature-implementation",
619
+ "name": "Feature Implementation Workflow",
620
+ "description": "Implement a new feature following best practices",
621
+ "preconditions": [
622
+ "Feature requirements are clear",
623
+ "Codebase is accessible",
624
+ "Development environment is set up"
625
+ ],
626
+ "clarificationPrompts": [
627
+ "What is the main goal of this feature?",
628
+ "Are there any specific constraints or requirements?",
629
+ "Which parts of the codebase will be affected?"
630
+ ],
631
+ "steps": [
632
+ {
633
+ "id": "understand-requirements",
634
+ "title": "Understand requirements and scope",
635
+ "prompt": "**PREP**: Review the feature requirements and understand the scope.\n\n**IMPLEMENT**: Break down the requirements into specific tasks.\n\n**VERIFY**: Confirm understanding with stakeholders if needed.",
636
+ "requireConfirmation": true
637
+ },
638
+ {
639
+ "id": "plan-implementation",
640
+ "title": "Plan the implementation",
641
+ "prompt": "**PREP**: Analyze the codebase to understand the current architecture.\n\n**IMPLEMENT**: Create a detailed implementation plan with specific steps.\n\n**VERIFY**: Review the plan for completeness and feasibility.",
642
+ "requireConfirmation": true
643
+ },
644
+ {
645
+ "id": "implement-feature",
646
+ "title": "Implement the feature",
647
+ "prompt": "**PREP**: Set up the development environment and review the plan.\n\n**IMPLEMENT**: Write the code following the implementation plan.\n\n**VERIFY**: Test the implementation and ensure it meets requirements.",
648
+ "askForFiles": true,
649
+ "validationCriteria": [
650
+ {
651
+ "type": "contains",
652
+ "value": "function",
653
+ "condition": "context.language === 'javascript'"
654
+ },
655
+ {
656
+ "type": "contains",
657
+ "value": "def ",
658
+ "condition": "context.language === 'python'"
659
+ },
660
+ {
661
+ "type": "regex",
662
+ "pattern": "\\b(test|spec)\\b"
663
+ }
664
+ ]
665
+ },
666
+ {
667
+ "id": "test-and-validate",
668
+ "title": "Test and validate the feature",
669
+ "prompt": "**PREP**: Review the implementation and identify test scenarios.\n\n**IMPLEMENT**: Write comprehensive tests for the feature.\n\n**VERIFY**: Run tests and validate the feature works correctly.",
670
+ "requireConfirmation": true,
671
+ "validationCriteria": {
672
+ "and": [
673
+ {
674
+ "or": [
675
+ {"type": "contains", "value": "describe"},
676
+ {"type": "contains", "value": "test"}
677
+ ]
678
+ },
679
+ {
680
+ "type": "regex",
681
+ "pattern": "\\b(expect|assert|should)\\b"
682
+ },
683
+ {
684
+ "type": "length",
685
+ "min": 100,
686
+ "condition": "context.testCoverage === 'comprehensive'"
687
+ }
688
+ ]
689
+ }
690
+ }
691
+ ],
692
+ "metaGuidance": [
693
+ "Always follow the prep/implement/verify pattern",
694
+ "Write clear, readable code with good comments",
695
+ "Include proper error handling",
696
+ "Add tests for new functionality",
697
+ "Follow existing code conventions"
698
+ ]
699
+ }
700
+ ```
701
+
702
+ ### Example 2: Bug Fix Workflow
703
+
704
+ ```json
705
+ {
706
+ "id": "bug-fix-workflow",
707
+ "name": "Bug Fix Workflow",
708
+ "description": "Systematically identify and fix bugs",
709
+ "preconditions": [
710
+ "Bug report is clear and reproducible",
711
+ "Development environment is set up",
712
+ "Access to relevant code and logs"
713
+ ],
714
+ "clarificationPrompts": [
715
+ "What is the expected behavior?",
716
+ "What is the actual behavior?",
717
+ "Can you reproduce the bug consistently?",
718
+ "What steps lead to the bug?"
719
+ ],
720
+ "steps": [
721
+ {
722
+ "id": "reproduce-bug",
723
+ "title": "Reproduce the bug",
724
+ "prompt": "**PREP**: Understand the bug report and required environment.\n\n**IMPLEMENT**: Follow the steps to reproduce the bug.\n\n**VERIFY**: Confirm the bug occurs consistently.",
725
+ "requireConfirmation": true
726
+ },
727
+ {
728
+ "id": "identify-root-cause",
729
+ "title": "Identify the root cause",
730
+ "prompt": "**PREP**: Examine the code and logs related to the bug.\n\n**IMPLEMENT**: Trace through the code to find the root cause.\n\n**VERIFY**: Confirm the identified cause explains the bug behavior.",
731
+ "askForFiles": true
732
+ },
733
+ {
734
+ "id": "implement-fix",
735
+ "title": "Implement the fix",
736
+ "prompt": "**PREP**: Plan the fix based on the root cause analysis.\n\n**IMPLEMENT**: Apply the fix with minimal changes.\n\n**VERIFY**: Test that the fix resolves the bug without introducing new issues.",
737
+ "requireConfirmation": true,
738
+ "validationCriteria": [
739
+ {
740
+ "type": "contains",
741
+ "value": "fix",
742
+ "condition": "context.bugSeverity === 'high'"
743
+ },
744
+ {
745
+ "type": "regex",
746
+ "pattern": "\\b(error|exception|null|undefined)\\b"
747
+ },
748
+ {
749
+ "not": {
750
+ "type": "contains",
751
+ "value": "TODO"
752
+ }
753
+ }
754
+ ]
755
+ },
756
+ {
757
+ "id": "test-fix",
758
+ "title": "Test the fix",
759
+ "prompt": "**PREP**: Identify test scenarios including edge cases.\n\n**IMPLEMENT**: Run comprehensive tests on the fix.\n\n**VERIFY**: Confirm the bug is fixed and no regressions are introduced.",
760
+ "requireConfirmation": true
761
+ }
762
+ ],
763
+ "metaGuidance": [
764
+ "Always reproduce the bug before attempting to fix it",
765
+ "Make minimal changes to fix the issue",
766
+ "Test thoroughly to ensure no regressions",
767
+ "Document the fix and root cause",
768
+ "Consider adding tests to prevent future occurrences"
769
+ ]
770
+ }
771
+ ```
772
+
773
+ ---
774
+
775
+ ## Enhanced Example Workflows
776
+
777
+ The following example workflows in `spec/examples/` now demonstrate agentRole best practices:
778
+
779
+ ### 1. Simple Authentication Implementation (`valid-workflow.json`)
780
+
781
+ This example showcases how to use agentRole for different security-focused roles:
782
+
783
+ - **Security-focused systems analyst** for authentication assessment
784
+ - **Senior backend engineer** for secure middleware development
785
+ - **API development specialist** for authentication endpoints
786
+ - **Quality assurance engineer** for security testing
787
+
788
+ Each step demonstrates how agentRole provides specialized behavioral guidance while keeping user-facing prompts clear and focused.
789
+
790
+ ### 2. Adaptive Development Workflow (`conditional-workflow-example.json`)
791
+
792
+ This advanced example demonstrates agentRole usage with conditional logic:
793
+
794
+ - **Project setup specialist** for environment configuration
795
+ - **Senior business analyst** for complex requirement analysis (large/complex tasks only)
796
+ - **Efficient developer** for simple implementations
797
+ - **Patient mentor** for novice users
798
+ - **Senior software engineer** for expert implementations
799
+ - **Performance engineering specialist** for optimization (complex tasks only)
800
+
801
+ The agentRole fields automatically adapt based on:
802
+ - User expertise level (`novice`, `intermediate`, `expert`)
803
+ - Task scope (`small`, `medium`, `large`)
804
+ - Task complexity (0.1 to 1.0 scale)
805
+
806
+ ### AgentRole Best Practices Demonstrated
807
+
808
+ 1. **Role Specificity**: Each agentRole provides specific expertise and behavioral guidance
809
+ 2. **Separation of Concerns**: Agent instructions are separate from user-facing prompts
810
+ 3. **Conditional Adaptation**: Agent roles can change based on workflow conditions
811
+ 4. **Professional Personas**: Each role represents a realistic professional with specific expertise
812
+ 5. **Behavioral Guidance**: Roles guide approach, methodology, and focus areas
813
+
814
+ ## Next Steps
815
+
816
+ 1. **Practice**: Create a simple workflow for a task you're familiar with
817
+ 2. **Validate**: Use the schema to validate your workflow
818
+ 3. **Test**: Try using your workflow with an AI agent
819
+ 4. **Improve**: Refine your workflow based on feedback
820
+ 5. **Share**: Contribute your workflow to the community
821
+
822
+ ## References
823
+
824
+ - [Advanced Validation Guide](13-advanced-validation-guide.md) - Complete guide to ValidationEngine features
825
+ - [Architecture Guide](02-architecture.md) - Technical details of the ValidationEngine
826
+ - [Workflow Schema](../spec/workflow.schema.json)
827
+ - [Valid Example](../spec/examples/valid-workflow.json)
828
+ - [API Specification](../spec/mcp-api-v1.0.md)
829
+ - [Architecture Guide](02-architecture.md)
830
+
831
+ ---
832
+
833
+ **Last Updated**: 2024-01-15
834
+ **Documentation Version**: 0.0.1-alpha
835
+ **Maintained By**: Documentation Team