Skip to content

feat: add worktree provisioning#14

Merged
AlecRust merged 2 commits into
AlecRust:mainfrom
asainz:add-worktree-provisioning
May 8, 2026
Merged

feat: add worktree provisioning#14
AlecRust merged 2 commits into
AlecRust:mainfrom
asainz:add-worktree-provisioning

Conversation

@asainz
Copy link
Copy Markdown
Collaborator

@asainz asainz commented May 7, 2026

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.

# 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.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 new command 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 thread src/provision/runner.ts
Comment on lines +114 to +117
} catch (error) {
if (!isMissingPathError(error)) {
const reason = getErrorMessage(error);
copies.push({ ...item, source, destination, status: "failed", reason });
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@AlecRust AlecRust merged commit 317564f into AlecRust:main May 8, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants