Add init workflow step to bootstrap projects like specify init#2838
Merged
Conversation
Copilot
AI
changed the title
[WIP] Add InitStep for bootstrapping project workflow
Add Jun 3, 2026
init workflow step to bootstrap projects like specify init
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new workflow step type (type: init) so workflows can bootstrap (or merge into) a Spec Kit project by invoking the bundled specify init logic in-process, enabling end-to-end “scaffold → run steps” workflows without requiring a manual pre-step.
Changes:
- Introduces
InitStep(src/specify_cli/workflows/steps/init/) that buildsspecify initargv from step config, runs it viaCliRunner, and capturesexit_code/stdout/stderr. - Registers the new step type in the workflow step registry and engine’s valid-step-type fallback, and updates architecture/README docs.
- Adds tests covering argv building, workflow-default integration fallback, directory creation via
project, invalid integration failure, and validation.
Show a summary per file
| File | Description |
|---|---|
| workflows/README.md | Documents the new init step type and provides a YAML example. |
| workflows/ARCHITECTURE.md | Updates step-type counts/table and module tree to include init. |
| tests/test_workflows.py | Adds test coverage for the new InitStep. |
| src/specify_cli/workflows/steps/init/init.py | Implements InitStep execution, expression resolution, and validation. |
| src/specify_cli/workflows/engine.py | Adds init to the engine’s valid step-type fallback set. |
| src/specify_cli/workflows/init.py | Registers InitStep in the built-in STEP_REGISTRY. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 6/6 changed files
- Comments generated: 3
…ne-owned dirs - Apply DEFAULT_INIT_INTEGRATION fallback when neither step config nor workflow context provides an integration, so output.integration always reflects the actual integration used. - Add integration_options config field to support --integration-options passthrough (required for generic integration and --skills mode). - Exclude .specify/ from the non-empty directory fast-fail check so that here: true works when the engine has already created its run-state directory before steps execute. - Note: mix_stderr=False is not needed — Click 8.2+ captures stderr separately by default and the existing try/except handles access. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
When the workflow engine creates .specify/workflows/runs/ before steps execute, the directory is technically non-empty. Previously, specify init would prompt for confirmation (hanging in unattended mode) unless the user explicitly set force: true. Now the step detects that only engine-owned directories (.specify/) are present and implicitly adds --force so init proceeds without user interaction. Also fixes the test to exercise the implicit-force path rather than passing force: True explicitly (which bypassed the check entirely). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…rror, include all resolved fields in output - Derive VALID_SCRIPT_TYPES from SCRIPT_TYPE_CHOICES in _agent_config so the valid set cannot drift from the specify init CLI. - Fail fast with a clear error when os.scandir() raises OSError (e.g. permission denied) instead of silently treating the directory as empty. - Include preset, force, and ignore_agent_tools in all output dicts (both fast-fail and normal paths) for consistent interpolation and debugging downstream. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…rding - When Click does not expose result.stderr (older versions where stderr is mixed into stdout), use stdout as stderr on non-zero exit so workflows can consistently read steps.<id>.output.stderr for errors. - Update README inline comment for force: wording to say 'when target directory already exists' rather than 'non-empty directory', matching the actual specify init behavior for the project: form. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Move argv flag-building (--integration, --script, --preset, --ignore-agent-tools) before the non-empty-dir and OSError early returns so output['argv'] always reflects the complete command. - --force is appended after the check since it may be set implicitly. - Replace list comprehension with any() generator expression to short-circuit without allocating a full list of DirEntry objects. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
A file or symlink named .specify should not be excluded from the non-empty check. Use entry.is_dir(follow_symlinks=False) to ensure only an actual directory is considered engine-owned content. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ack order - Only set implicit --force when engine-owned directories (.specify/) are actually present. A completely empty directory no longer gets --force added unnecessarily. - Fix integration resolution precedence: resolve step config expression first, then fall back to workflow default (also resolved), then to DEFAULT_INIT_INTEGRATION. Previously, a step expression resolving to falsy would bypass the workflow default entirely. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Workflows had no way to scaffold a project; users had to run
specify initmanually before any workflow could drive the spec-driven process. This adds aninitstep type so a workflow can bootstrap (or merge into) a project itself.Changes
InitStep(type: init) insrc/specify_cli/workflows/steps/init/— runs the bundledspecify initcommand in-process againstcontext.project_root, capturingexit_code/stdout/stderrand returningFAILEDon non-zero exit.project,here,integration,integration_options,script,force,ignore_agent_tools,preset; string fields resolve{{ }}expressions.DEFAULT_INIT_INTEGRATION(copilot); defaults to--ignore-agent-toolssince workflows run unattended..specify/) exist,--forceis implicitly added so init proceeds unattended.validate()rejectsscriptvalues other thansh/ps.STEP_REGISTRYand the engine's valid-step-types fallback.workflows/ARCHITECTURE.mdandworkflows/README.mdupdated (step table, module tree, new "Init Steps" section).Example