feat: add worktree provisioning#14
Merged
Merged
Conversation
# Current problem New Git worktrees do not include ignored local files like environment files, so builds and tooling can fail until users manually copy project-specific state. # Proposed solution Add a provision config section that runs after worktree creation, supports safe file copies and optional shell steps, wires provisioning into the new command, and documents the lifecycle separately from bootstrap.
There was a problem hiding this comment.
Pull request overview
This PR introduces a new “provision” lifecycle that runs immediately after creating a Git worktree, allowing users to copy local ignored files (e.g., .env) into the new worktree and optionally run shell steps there. It extends the config schema to support provisioning, wires provisioning into wkb new, and updates tests/docs accordingly.
Changes:
- Add a provisioning runner that performs safe in-root file copies and executes post-create shell steps with injected WORKBOX_* env vars.
- Extend config parsing/merging/validation to support a
[provision]section (including duplicate step-name validation). - Integrate provisioning into the
newcommand and document provision vs. bootstrap behavior.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/provision/runner.ts | Implements provisioning logic (copy + steps) with root-escape protection. |
| src/provision/runner.test.ts | Adds unit tests for copy/step behavior and path safety checks. |
| src/core/path.ts | Treats ENOTDIR like ENOENT during root-path validation to support non-existent paths. |
| src/core/config.ts | Adds Zod schemas + merge logic for new [provision] config section. |
| src/core/config.test.ts | Adds config tests for provision defaults, merging, and validation errors. |
| src/commands/new.ts | Runs provisioning after worktree creation and returns provision results in output data. |
| src/commands/commands.test.ts | Adds new command coverage for successful and failing provisioning. |
| src/commands/rm.test.ts | Updates test configs to include the new required provision config field. |
| README.md | Documents provisioning configuration and its relationship to bootstrap. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+114
to
+117
| } catch (error) { | ||
| if (!isMissingPathError(error)) { | ||
| const reason = getErrorMessage(error); | ||
| copies.push({ ...item, source, destination, status: "failed", reason }); |
Collaborator
Author
There was a problem hiding this comment.
Fixed in ac0591e — added required to ProvisionCopyResult and covered the exposed field in the runner test.
# Current problem Provision copy results spread the configured copy entry into result objects, so the runtime JSON shape includes the required flag while the declared result type omitted it. # Proposed solution Add required to the provision copy result type and cover the exposed field in the provision runner test.
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.
Current problem
New Git worktrees do not include ignored local files like environment files, so builds and tooling can fail until users manually copy project-specific state.
Proposed solution
Add a provision config section that runs after worktree creation, supports safe file copies and optional shell steps, wires provisioning into the new command, and documents the lifecycle separately from bootstrap.