Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions docs/workflows/developing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
69 changes: 69 additions & 0 deletions tests/workflows/test_bundled_gate_verdict_inputs.py
Original file line number Diff line number Diff line change
@@ -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"
5 changes: 5 additions & 0 deletions workflows/bugfix/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
10 changes: 10 additions & 0 deletions workflows/speckit/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: ""
Comment on lines +38 to +41
plan_verdict:
type: string
enum: ["", approve, reject]
default: ""

steps:
- id: specify
Expand All @@ -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
Expand All @@ -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
Expand Down