spec-kit icon indicating copy to clipboard operation
spec-kit copied to clipboard

feat(workflows): expose workflow source directory to steps

Open rhuss opened this issue 4 months ago • 0 comments

Description

Expose the resolved source directory of a workflow definition to steps, enabling workflows to reference sibling files (extension manifests, adapter scripts, etc.) without requiring the user to pass the path redundantly.

What this adds:

  • {{ context.workflow_dir }} template expression, available in all step types
  • SPECKIT_WORKFLOW_DIR environment variable, set automatically for shell steps
  • Persistence of workflow_dir in state.json so resumed workflows restore the original source directory (not the run-directory copy path)

Value semantics:

  • File-loaded workflows: parent directory of the source YAML file
  • Installed-by-ID workflows: the installation directory (.specify/workflows/<id>/)
  • String-loaded workflows: empty (no source path available)
  • On resume: original source directory preserved from first execution

Closes #3467 Refs #3445

Testing

  • [x] Tested locally with uv run specify --help
  • [x] Ran existing tests with uv sync && uv run pytest
  • [x] Tested with a sample project (if applicable)

10 new tests covering:

  • Expression resolution, defaults, and string interpolation for {{ context.workflow_dir }}
  • StepContext field storage
  • from_yaml vs from_string loading behavior
  • SPECKIT_WORKFLOW_DIR env var presence/absence in shell steps
  • Resume preserves original workflow_dir
  • State persistence round-trip
  • Cross-platform (YAML single-quoted scalars, forward-slash paths for Windows)

All 416 tests pass (including 10 new), verified on macOS locally and CI (ubuntu + windows matrix).

AI Disclosure

  • [x] I did use AI assistance (describe below)

Implementation, tests, and bot review triage performed with Claude Code (Opus 4.6). All changes reviewed and approved by the author.

rhuss avatar Jul 11 '26 06:07 rhuss