spec-kit
spec-kit copied to clipboard
feat(workflows): expose workflow source directory to steps
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 typesSPECKIT_WORKFLOW_DIRenvironment variable, set automatically for shell steps- Persistence of
workflow_dirinstate.jsonso 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_yamlvsfrom_stringloading behaviorSPECKIT_WORKFLOW_DIRenv 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.