Skip to content

feat(worktree): add setup script support for post-creation automation#432

Open
Clarity-89 wants to merge 14 commits intoasheshgoplani:mainfrom
Clarity-89:feature/worktree-setup-script-core
Open

feat(worktree): add setup script support for post-creation automation#432
Clarity-89 wants to merge 14 commits intoasheshgoplani:mainfrom
Clarity-89:feature/worktree-setup-script-core

Conversation

@Clarity-89
Copy link
Copy Markdown
Contributor

Summary

  • Add convention-based .agent-deck/worktree-setup.sh that runs automatically after worktree creation
  • Allows repos to copy gitignored config files (.env, .mcp.json, etc.) into new worktrees
  • CLI paths stream script stdout/stderr in real-time for progress feedback
  • TUI paths buffer output and log warnings on failure
  • Setup script failure is non-fatal — worktree is still created with a warning

How it works

  1. After CreateWorktree succeeds, checks for .agent-deck/worktree-setup.sh in the source repo
  2. If found, runs it via sh -e with AGENT_DECK_REPO_ROOT and AGENT_DECK_WORKTREE_PATH env vars
  3. 60-second timeout prevents hanging scripts from blocking session creation

Example .agent-deck/worktree-setup.sh:

#!/bin/sh
for f in .env .env.local .mcp.json; do
    [ -f "$AGENT_DECK_REPO_ROOT/$f" ] && cp "$AGENT_DECK_REPO_ROOT/$f" "$AGENT_DECK_WORKTREE_PATH/$f"
done

Test plan

  • 8 unit tests covering find, run (success/failure/timeout), and the combined wrapper
  • Manual: create worktree session in repo with setup script — verify files copied
  • Manual: create worktree session in repo without setup script — no change in behavior
  • Manual: make setup script fail — verify worktree still created with warning

asheshgoplani and others added 14 commits March 18, 2026 18:28
…hgoplani#366)

Check existing terminal-features before appending to avoid duplicates
that balloon the list to 260+ entries over multiple session starts.

Committed by Ashesh Goplani
When the name field is left empty, a random adjective-noun name (e.g.,
"golden-eagle") is shown as a dimmed placeholder and used on submit.
The worktree branch placeholder also reflects the generated name.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Branch shows as dimmed placeholder (not filled input) when using
  generated name; only fills when user types a custom name
- Align Validate() and GetValuesWithWorktree() branch derivation logic
- Add tests for generated name fallback, branch placeholder behavior,
  and worktree branch derivation

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…nal-features-spam

Fix asheshgoplani#366: prevent terminal-features spam by checking before appending
Feat: auto-generate session names as placeholders when name field is empty
…-happy

Feat: add happy wrapper support for Claude and Codex (opt-in via use_happy config)
…ranch

Feat: worktree branch reuse (local+remote) and fzf branch picker via Ctrl+F
…key input

The extended-keys option was set server-wide (`set -sq`), which caused
tmux to activate xterm modifyOtherKeys mode on the outer terminal
(iTerm2, etc.). This persisted even after the tmux option was turned off,
causing Ctrl+R and other modified keys to be sent as escape sequences
that Bubble Tea cannot parse — breaking the recent sessions picker and
other Ctrl-key shortcuts in the dashboard.

Two fixes:
- tmux.go: changed `set -sq extended-keys on` to per-session
  `set-option -t <session> -q extended-keys on` at both call sites
- keyboard_compat.go: also disable xterm modifyOtherKeys (ESC[>4;0m)
  on TUI startup alongside the existing Kitty protocol disable, as a
  defense-in-depth measure

Fixes regression introduced in b427418 (asheshgoplani#342).
Add support for a convention-based setup script at
.agent-deck/worktree-setup.sh that runs automatically after worktree
creation. This allows repos to copy gitignored config files (.env,
.mcp.json, etc.) into new worktrees without manual intervention.

- FindWorktreeSetupScript discovers the script in the source repo
- RunWorktreeSetupScript executes it with AGENT_DECK_REPO_ROOT and
  AGENT_DECK_WORKTREE_PATH env vars, sh -e, 60s timeout
- CreateWorktreeWithSetup wraps CreateWorktree with setup script
  execution (non-fatal on failure)
- All 4 worktree creation call sites updated (CLI + TUI)
- CLI paths stream stdout/stderr in real-time for progress feedback
- TUI paths buffer output and log on failure
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.

5 participants