From 5fbc9119099b5bb9a1293423bae0769ad4aa7532 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 10 Jan 2026 23:33:00 +0000 Subject: [PATCH] Improve validation tool robustness and fix documentation link Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com> --- .../tools/validate_workflows.py | 23 +++++++++++++------ docs/WORKFLOW_VALIDATION.md | 2 +- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/backend/autometabuilder/tools/validate_workflows.py b/backend/autometabuilder/tools/validate_workflows.py index 770d64e..b4852b8 100755 --- a/backend/autometabuilder/tools/validate_workflows.py +++ b/backend/autometabuilder/tools/validate_workflows.py @@ -5,11 +5,14 @@ import sys from pathlib import Path from typing import List, Tuple -# Add the backend directory to the path to import the schema module -backend_dir = Path(__file__).parent.parent.parent -sys.path.insert(0, str(backend_dir)) - -from autometabuilder.workflow.n8n_schema import N8NWorkflow +# Import the schema module - try direct import first (when installed via poetry) +# If that fails, add parent directory to path (for direct script execution) +try: + from autometabuilder.workflow.n8n_schema import N8NWorkflow +except ImportError: + backend_dir = Path(__file__).resolve().parent.parent.parent + sys.path.insert(0, str(backend_dir)) + from autometabuilder.workflow.n8n_schema import N8NWorkflow def find_workflow_files(base_path: Path) -> List[Path]: @@ -75,8 +78,14 @@ def validate_workflow_file(workflow_path: Path) -> Tuple[bool, str]: def main(): """Main function to validate all workflow files.""" - # Find the backend directory - script_dir = Path(__file__).parent.parent.parent / "autometabuilder" + # Find the autometabuilder directory by looking for the packages subdirectory + # This works whether run as a script or via poetry command + script_dir = Path(__file__).resolve().parent.parent + + # Verify we found the right directory + if not (script_dir / "packages").exists(): + print("Error: Could not locate autometabuilder/packages directory") + return 1 # Find all workflow files workflow_files = find_workflow_files(script_dir) diff --git a/docs/WORKFLOW_VALIDATION.md b/docs/WORKFLOW_VALIDATION.md index 4073d23..cd81dd0 100644 --- a/docs/WORKFLOW_VALIDATION.md +++ b/docs/WORKFLOW_VALIDATION.md @@ -4,7 +4,7 @@ This repository includes a validation tool for workflow JSON files based on the ## Schema Definition -The workflow JSON schema is defined in [ROADMAP.md](ROADMAP.md) (lines 84-430). It defines the structure for N8N-style workflows with the following key requirements: +The workflow JSON schema is defined in [ROADMAP.md](../ROADMAP.md) (lines 84-430). It defines the structure for N8N-style workflows with the following key requirements: - **Required fields**: `name`, `nodes`, `connections` - **Nodes**: Must contain at least 1 node with `id`, `name`, `type`, `typeVersion`, and `position`