Skip to content

Add test coverage: scripts/sync-prompts.py #46

Description

@overcut-ai

Overview

scripts/sync-prompts.py is the CLI that replaces each workflow step's instruction with the contents of its matching Markdown prompt. It loads workflow.json, reads every non-README .md file in a playbook directory, and rewrites the workflow in place before printing warnings for mismatches.

Why This Matters

Because the script rewrites every playbook’s workflow.json, a regression (missing prompt detection, incorrect matching, or malformed writes) could silently corrupt multiple workflows at once. Without automated tests, these issues would only be caught after damaging the JSON.

Files Needing Tests

  • scripts/sync-prompts.py (~102 lines)

Suggested Test Cases

  • Happy path: create a temp playbook with matching workflow.json and prompt files; assert instructions are updated and CLI output lists the synced steps.
  • Prompt mismatch warning: include an extra .md without a workflow step and assert it is reported under "Warning: .md files with no matching step" while the workflow remains valid JSON.
  • Missing prompt detection: include a workflow step whose instruction already exists but has no corresponding .md and assert the script reports it under "Warning: steps with instructions but no matching .md file".
  • Edge case: run against a directory that lacks prompt .md files (only README) and assert it exits non-zero after printing "No prompt .md files found".
  • Error case: run against a directory lacking workflow.json and assert it exits non-zero with "Error: not found" without creating files.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions