feat(workflows): add JSON output for workflow run resume and status by doquanghuy · Pull Request #2814 · github/spec-kit (original) (raw)

@doquanghuy @claude

Adds an opt-in --json flag to workflow run, workflow resume, and workflow status that emits a single machine-readable object (run_id, workflow_id, status, current step; status also reports per-step states and a runs list) for automation and external orchestrators.

JSON is written via a small _emit_workflow_json helper using plain stdout, so Rich markup, highlighting, and line-wrapping can never alter the emitted object. Default human-readable output and exit codes are unchanged when --json is omitted. Reference docs updated.

Closes github#2811.

Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

@doquanghuy

…json

Conflicts:

docs/reference/workflows.md

src/specify_cli/init.py

tests/test_workflows.py

@doquanghuy @claude

Suppressing the banner and the step-start callback was not enough to guarantee a single parseable JSON object on stdout: individual steps still write there while the engine runs. The gate step prints its prompt, and the prompt step runs a CLI subprocess that inherits the process's stdout file descriptor — either can corrupt the JSON stream for interactive runs or integration-backed workflows.

Wrap engine.execute()/engine.resume() in a file-descriptor-level redirect (dup2) when --json is set, so both Python-level writes and inherited-fd subprocess output go to stderr while stdout carries only the emitted JSON. Step progress stays visible on stderr. status does not run the engine, so it is unaffected.

Tests cover both pollution channels (a Python print and a real subprocess) via fd-level capture, and the inactive no-op path. Docs note the stdout/stderr split.

Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

@doquanghuy @claude

The redirect helper's docstring and its test comment wrote print\s, which renders as "print\s" rather than "prints". Replace with plain "prints".

Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

@doquanghuy

…json

Conflicts:

docs/reference/workflows.md

kanfil added a commit to tikalk/agentic-sdlc-spec-kit that referenced this pull request

Jun 4, 2026

@kanfil

Merge upstream github/spec-kit (3 commits):

Fork adjustments:

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})