Add init workflow step to bootstrap projects like specify init#2838
Open
Copilot wants to merge 10 commits into
Open
Add init workflow step to bootstrap projects like specify init#2838Copilot wants to merge 10 commits into
init workflow step to bootstrap projects like specify init#2838Copilot wants to merge 10 commits into
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
1746289 to
fc8d6c3
Compare
mnriem
approved these changes
Jun 9, 2026
- Use `with os.scandir(...)` context manager so the iterator is always closed even when `any()` short-circuits, preventing file-descriptor leaks in long-running workflow runs. - Guard `os.chdir(prev_cwd)` in the `finally` block with a try/except so an `OSError` (e.g. directory deleted) doesn't bypass returning the captured `StepResult`. - Reject non-string `script` values in `validate()` with a clear error message, rather than silently passing them through to become `--script True` at runtime.
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
The --no-git and --branch-numbering flags were removed from `specify init` on main. Update InitStep to drop these unsupported config fields and fix tests accordingly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
02d67c1 to
5540606
Compare
…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>
Comment on lines
+110
to
+121
| targets_current_dir = here or not project or str(project) == "." | ||
| if targets_current_dir and not force: | ||
| base = context.project_root or os.getcwd() | ||
| try: | ||
| with os.scandir(base) as it: | ||
| not_empty = any( | ||
| entry for entry in it | ||
| if entry.name not in _ENGINE_OWNED_DIRS | ||
| ) | ||
| except OSError: | ||
| not_empty = False | ||
| if not_empty: |
Comment on lines
+48
to
+52
| Supported config fields (all optional): | ||
|
|
||
| ``project`` | ||
| Project name or path to create. Use ``"."`` for the current | ||
| directory. Ignored when ``here`` is truthy. |
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>
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