feat(autominator): implement research-driven node and workflow building

This commit is contained in:
mrsaifullah52 2025-11-22 12:23:51 +05:00
parent 82b4f1dcb4
commit 36ce3c42d2
1 changed files with 121 additions and 41 deletions

View File

@ -7,24 +7,74 @@
<workflow> <workflow>
<step n="0" goal="Contextual Analysis (Smart Elicitation)"> <step n="0" goal="Load Config and Check Prerequisites">
<critical>Before asking any questions, analyze what the user has already told you</critical> <critical>Load configuration and check for requirements file before proceeding</critical>
<action>Review the user's initial request and conversation history</action> <action>Resolve variables from config_source: workflows_folder, requirements_folder, output_folder, user_name, communication_language</action>
<action>Extract any mentioned: workflow type, trigger, integrations, complexity, requirements</action> <action>Create {{workflows_folder}} directory if it does not exist</action>
<action>Create {{requirements_folder}} directory if it does not exist</action>
<check if="ALL requirements are clear from context"> <action>Search for requirements files in {{requirements_folder}}</action>
<action>Summarize your understanding</action> <action>List all files matching pattern: req-*.md</action>
<action>Skip directly to Step 2 (Research n8n Documentation)</action>
<check if="no requirements files found">
<output>⚠️ No Requirements File Found
Before creating a workflow, you need to gather requirements.
**Options:**
1. Run `*gather-requirements` to create a requirements file
2. Provide requirements manually in this session
Would you like to:
a) Run gather-requirements workflow now
b) Continue without requirements file (manual elicitation)
Enter your choice (a/b):</output>
<action>WAIT for user input</action>
<check if="user chooses 'a'">
<action>Invoke workflow: {project-root}/{bmad_folder}/autominator/workflows/gather-requirements/workflow.yaml</action>
<action>After gather-requirements completes, reload this step to find the new requirements file</action>
</check> </check>
<check if="SOME requirements are clear"> <check if="user chooses 'b'">
<action>Note what you already know</action> <action>Set {{requirements_file}} = empty</action>
<action>Only ask about missing information in Step 1</action> <action>Proceed to Step 1 for manual elicitation</action>
</check>
</check> </check>
<check if="requirements are unclear or minimal"> <check if="one requirements file found">
<action>Proceed with full elicitation in Step 1</action> <action>Set {{requirements_file}} to the found file path</action>
<action>Load and parse requirements file COMPLETELY</action>
<action>Extract requirements: workflow_name, problem_description, trigger_type, data_requirements, desired_outcome, integrations, conditional_logic, criticality</action>
<action>Extract research findings: use_case_research, node_research, parameter_structures, workflow_pattern_research</action>
<action>Display loaded requirements summary to user</action>
<action>Skip to Step 4 (Plan Workflow Structure) - research already done</action>
</check>
<check if="multiple requirements files found">
<output>📋 Multiple Requirements Files Found:
[Display numbered list of files with workflow names]
Which requirements file would you like to use?
Enter the number (1-N) or 'new' to create a new one:</output>
<action>WAIT for user input</action>
<check if="user enters number">
<action>Set {{requirements_file}} to selected file path</action>
<action>Load and parse requirements file COMPLETELY</action>
<action>Extract requirements: workflow_name, problem_description, trigger_type, data_requirements, desired_outcome, integrations, conditional_logic, criticality</action>
<action>Extract research findings: use_case_research, node_research, parameter_structures, workflow_pattern_research</action>
<action>Display loaded requirements summary to user</action>
<action>Skip to Step 4 (Plan Workflow Structure) - research already done</action>
</check>
<check if="user enters 'new'">
<action>Invoke workflow: {project-root}/{bmad_folder}/autominator/workflows/gather-requirements/workflow.yaml</action>
<action>After gather-requirements completes, reload this step to find the new requirements file</action>
</check>
</check> </check>
</step> </step>
@ -242,47 +292,65 @@
</step> </step>
<step n="6" goal="Build Workflow JSON"> <step n="6" goal="Build Workflow JSON">
<critical>Follow guidelines from {{helpers}} for proper node creation</critical> <critical>Use EXACT node types and parameter structures from {{node_research}} and {{parameter_structures}}</critical>
<critical>Follow modern n8n format from {{helpers}}</critical>
<action>Initialize workflow structure:</action> <action>Initialize workflow structure with modern n8n format:</action>
<substep> <substep>
{ {
"name": "{{workflow_name}}", "name": "{{workflow_name}}",
"nodes": [], "nodes": [],
"pinData": {},
"connections": {}, "connections": {},
"active": false, "active": false,
"settings": { "settings": {
"executionOrder": "v1" "executionOrder": "v1"
}, },
"versionId": "[generate UUID]",
"meta": {
"templateCredsSetupCompleted": true,
"instanceId": "[generate UUID]"
},
"id": "[generate short ID]",
"tags": [] "tags": []
} }
</substep> </substep>
<action>Build nodes ONE at a time following these rules:</action> <action>Build nodes ONE at a time following these rules:</action>
<substep>For Each Node: <substep>For Each Node (Use EXACT structures from research):
1. Generate unique node ID 1. Generate UUID for node ID (format: "f8b7ff4f-6375-4c79-9b2c-9814bfdd0c92")
2. Set node name (unique, descriptive) 2. Set node name (unique, descriptive)
3. Set node type (e.g., n8n-nodes-base.webhook) 3. Use EXACT node type from {{node_research}}:
4. Set typeVersion (usually 1) - MUST be format: "n8n-nodes-base.nodeName"
5. Calculate position: - NEVER use: "@n8n/n8n-nodes-*" format
- First node (trigger): [250, 300] - Example: "n8n-nodes-base.gmail" NOT "@n8n/n8n-nodes-gmail.gmail"
4. Use EXACT typeVersion from {{node_research}}:
- MUST be INTEGER (2, 3, 4)
- NEVER use float (2.1, 3.4)
5. Calculate position as INTEGER array:
- Format: [x, y] where x and y are integers
- First node (trigger): [240, 300]
- Subsequent nodes: add 220 to x for each step - Subsequent nodes: add 220 to x for each step
- Branches: adjust y by ±100 - Branches: adjust y by ±100
6. Configure parameters based on node type 6. Use EXACT parameter structure from {{parameter_structures}}:
7. Add credentials if needed - For Set node (v3+): use assignments.assignments structure
8. Set error handling options if required: - For Gmail node (v2+): use "message" parameter (NOT "text")
- continueOnFail: true/false - For IF node (v2+): use conditions.conditions structure (NO "name" field in conditions)
- retryOnFail: true/false - For Slack channel: use __rl flag with mode and cachedResultName
- maxTries: number - Copy structure EXACTLY from research, don't modify
- waitBetweenTries: milliseconds 7. Add webhookId (UUID) if node type is webhook
8. Add credentials if needed
9. Field order: parameters, id, name, type, typeVersion, position, webhookId, credentials
10. Store node name in list for validation
</substep> </substep>
<substep>For Each Connection: <substep>For Each Connection (CRITICAL FORMAT):
1. Identify source node name 1. Identify source node name (must match node "name" field exactly)
2. Identify target node name 2. Identify target node name (must match node "name" field exactly)
3. Create connection entry in connections object: 3. Create connection entry with CORRECT format:
"Source Node Name": [ "Source Node Name": {
"main": [
[ [
{ {
"node": "Target Node Name", "node": "Target Node Name",
@ -291,10 +359,13 @@
} }
] ]
] ]
4. For IF nodes: }
4. CRITICAL: The "main" wrapper object is REQUIRED
5. NEVER use format: "Source": [[{...}]] (missing "main" wrapper)
6. For IF nodes:
- index 0 = true branch - index 0 = true branch
- index 1 = false branch - index 1 = false branch
5. Validate all referenced nodes exist 7. Validate all referenced nodes exist in node names list
</substep> </substep>
<substep>Node Building Order: <substep>Node Building Order:
@ -320,6 +391,15 @@
<action>- Ensure proper spacing and alignment</action> <action>- Ensure proper spacing and alignment</action>
<action>- Validate all required parameters are set</action> <action>- Validate all required parameters are set</action>
<action>Resolve final save path:</action>
<check if="{{save_location}} was provided by user">
<action>Use {{save_location}} as-is</action>
</check>
<check if="{{save_location}} is empty or default">
<action>Use {{workflows_folder}}/{{workflow_name}}.json</action>
<action>Ensure {{workflows_folder}} directory exists</action>
<action>Store resolved path in {{save_location}}</action>
</check>
<action>Save workflow to {{save_location}}</action> <action>Save workflow to {{save_location}}</action>
</step> </step>