diff --git a/docs/workflows/developing.md b/docs/workflows/developing.md index e6c8da8f0b..ee87efbaeb 100644 --- a/docs/workflows/developing.md +++ b/docs/workflows/developing.md @@ -49,6 +49,14 @@ inputs: type: string default: "auto" prompt: "Integration to use (e.g. claude, copilot, gemini; 'auto' uses the project's initialized integration)" + spec_verdict: + type: string + enum: ["", approve, reject] + default: "" + plan_verdict: + type: string + enum: ["", approve, reject] + default: "" steps: - id: specify @@ -62,6 +70,7 @@ steps: message: "Review the generated spec before planning." options: [approve, reject] on_reject: abort + verdict_input: spec_verdict - id: plan command: speckit.plan @@ -74,6 +83,7 @@ steps: message: "Review the plan before generating tasks." options: [approve, reject] on_reject: abort + verdict_input: plan_verdict - id: tasks command: speckit.tasks @@ -116,6 +126,10 @@ Run it with: specify workflow run speckit -i spec="Build a kanban board with drag-and-drop task management" ``` +Without a terminal, the review gates pause. Resume them with +`--input spec_verdict=approve` and `--input plan_verdict=approve`, respectively. +Omitting a verdict preserves the pause (or the interactive prompt on a terminal). + ## Test locally ```bash diff --git a/tests/workflows/test_bundled_gate_verdict_inputs.py b/tests/workflows/test_bundled_gate_verdict_inputs.py new file mode 100644 index 0000000000..3081a55466 --- /dev/null +++ b/tests/workflows/test_bundled_gate_verdict_inputs.py @@ -0,0 +1,69 @@ +"""Bundled gates can be answered when a workflow has no terminal (#5389).""" + +import json +from pathlib import Path + +import pytest +import yaml +from typer.testing import CliRunner + +from specify_cli import app + + +ROOT = Path(__file__).resolve().parents[2] + + +@pytest.mark.parametrize( + ("workflow_id", "gate_id", "verdict_input"), + [ + ("speckit", "review-spec", "spec_verdict"), + ("speckit", "review-plan", "plan_verdict"), + ("bugfix", "review-assessment", "assessment_verdict"), + ], +) +def test_bundled_gate_resumes_without_tty( + tmp_path, monkeypatch, workflow_id, gate_id, verdict_input +): + source = yaml.safe_load( + (ROOT / "workflows" / workflow_id / "workflow.yml").read_text() + ) + gate = next(step for step in source["steps"] if step["id"] == gate_id) + assert gate["verdict_input"] == verdict_input + assert source["inputs"][verdict_input] == { + "type": "string", + "enum": ["", "approve", "reject"], + "default": "", + } + + # Keep the shipped gate and input schema, replacing agent commands with a + # local shell step so this exercises CLI run/resume without an agent. + source["steps"] = [gate, {"id": "after", "type": "shell", "run": "true"}] + source["inputs"] = {verdict_input: source["inputs"][verdict_input]} + source["workflow"]["id"] = f"gate-{gate_id}" + workflow = tmp_path / "workflow.yml" + workflow.write_text(yaml.safe_dump(source), encoding="utf-8") + monkeypatch.chdir(tmp_path) + runner = CliRunner() + + started = runner.invoke(app, ["workflow", "run", str(workflow), "--json"]) + assert started.exit_code == 0, started.output + run_id = json.loads(started.stdout)["run_id"] + assert json.loads(started.stdout)["status"] == "paused" + + empty = runner.invoke(app, ["workflow", "resume", run_id, "--json"]) + assert empty.exit_code == 0, empty.output + assert json.loads(empty.stdout)["status"] == "paused" + + explicit_empty = runner.invoke( + app, + ["workflow", "resume", run_id, "--json", "--input", f"{verdict_input}="], + ) + assert explicit_empty.exit_code == 0, explicit_empty.output + assert json.loads(explicit_empty.stdout)["status"] == "paused" + + approved = runner.invoke( + app, + ["workflow", "resume", run_id, "--json", "--input", f"{verdict_input}=approve"], + ) + assert approved.exit_code == 0, approved.output + assert json.loads(approved.stdout)["status"] == "completed" diff --git a/workflows/bugfix/workflow.yml b/workflows/bugfix/workflow.yml index a914eeafa9..c123f75fe0 100644 --- a/workflows/bugfix/workflow.yml +++ b/workflows/bugfix/workflow.yml @@ -23,6 +23,10 @@ inputs: type: string default: "auto" prompt: "Integration to use (e.g. claude, copilot, gemini; 'auto' uses the project's initialized integration)" + assessment_verdict: + type: string + enum: ["", approve, reject] + default: "" steps: - id: assess @@ -36,6 +40,7 @@ steps: message: "Review the assessment before any code change." options: [approve, reject] on_reject: abort + verdict_input: assessment_verdict - id: fix command: speckit.bug.fix diff --git a/workflows/speckit/workflow.yml b/workflows/speckit/workflow.yml index 571318af4d..1252101aa5 100644 --- a/workflows/speckit/workflow.yml +++ b/workflows/speckit/workflow.yml @@ -35,6 +35,14 @@ inputs: type: string default: "auto" prompt: "Integration to use (e.g. claude, copilot, gemini; 'auto' uses the project's initialized integration)" + spec_verdict: + type: string + enum: ["", approve, reject] + default: "" + plan_verdict: + type: string + enum: ["", approve, reject] + default: "" steps: - id: specify @@ -48,6 +56,7 @@ steps: message: "Review the generated spec before planning." options: [approve, reject] on_reject: abort + verdict_input: spec_verdict - id: plan command: speckit.plan @@ -60,6 +69,7 @@ steps: message: "Review the plan before generating tasks." options: [approve, reject] on_reject: abort + verdict_input: plan_verdict - id: tasks command: speckit.tasks