Skip to content

feat(worktree): add opencode-worktree helper script with branch name sanitization#118

Merged
dzianisv merged 2 commits intomainfrom
fix/opencode-worktree-sanitize-branch-name
Feb 15, 2026
Merged

feat(worktree): add opencode-worktree helper script with branch name sanitization#118
dzianisv merged 2 commits intomainfrom
fix/opencode-worktree-sanitize-branch-name

Conversation

@dzianisv
Copy link
Owner

@dzianisv dzianisv commented Feb 15, 2026

Summary

  • Add opencode-worktree helper script that creates git worktrees as sibling directories, symlinks shared files (.env*, node_modules), and launches OpenCode
  • Sanitize user-provided branch names to comply with git-check-ref-format rules (fixes fatal: '../vibe.205' is not a valid branch name)
  • Auto-cleanup on exit: when OpenCode exits, automatically remove the worktree directory and branch if there are no uncommitted, stashed, or unpushed changes; otherwise keep it and print manual removal instructions
  • Add install.sh integration and package.json scripts (worktree, install:opencode-worktree)

engineer added 2 commits February 15, 2026 13:28
…sanitization

Add opencode-worktree.ts — creates a git worktree as a sibling directory,
symlinks .env and node_modules, and launches opencode in it.

Includes sanitizeBranch() to handle arguments like '../vibe.205' that
contain characters invalid per git-check-ref-format(1): strips leading
dots/slashes, collapses '..', removes invalid characters.

Also adds install:opencode-worktree npm script and integrates the helper
into install.sh.
After opencode exits, check for uncommitted changes, stashed changes,
and unpushed commits. If the worktree is clean, automatically remove
the worktree directory and delete the branch. Otherwise, keep it and
print manual removal instructions.
@dzianisv dzianisv merged commit b31d4ba into main Feb 15, 2026
1 check 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.

1 participant