feat(spawn): add Treehouse worktree setup hook - #47
michael-sb wants to merge 12 commits into
Conversation
Treehouse v1.8.0 adds post_create/pre_destroy hooks that fire at worktree lifecycle points. Use post_create to run per-project setup scripts (data/<project>-setup.sh) right before treehouse get hands the worktree over, which is earlier and simpler than waiting inside fm-spawn. Add bin/fm-treehouse-post-create.sh, a single global hook script wired in ~/.config/treehouse/config.toml. It locates firstmate's data/ from its own location and runs data/<project>-setup.sh if it exists (project name = worktree directory basename, matching the data/projects.md convention). Output is logged to state/treehouse-setup-<project>.log. A failing setup script is non-fatal: treehouse continues on hook failure by design, and the hook exits with the setup script's code so the failure surfaces in treehouse's own logs. The mechanism is general - any project can get a data/<name>-setup.sh and the hook picks it up automatically, no per-project hardcoding. Secondmates have no project worktree, so the hook is irrelevant to them.
|
Sorry - my firstmate got a bit carried away - he can be quite proactive :D |
Scout plan (huddle-app second mate, 2026-08-29)Proposed Options / Plan / Blocking / Lead decisions for this ticket, from the Current state
Options
The body ruling leaves no live placement alternative: the in-app menu remains available in the browser and Hammerspoon host, while the ruled direct intent, queue information, and Accept remain outside it. Recommended PlanModules: Restructure Seams: The replay-derived queue supplies a count/status summary outside the menu and an ordered read-only list inside it; neither surface switches Huddles. Accept stays a direct button and retains server authority. Menu commands call existing Huddle app actions. Every setting uses one model and persistence path; hiding keycaps leaves shortcut handlers enabled. Theme selection changes role-token resolution only. Validation criteria: Intent remains one faint secondary-text line at top left; the menu button rests at top right with no border or background; queue information remains visible at bottom left for zero and several waiting Huddles; Accept stays inside the bottom Blocking?
Lead decisionsNone. The 2026-08-29 ruling fixes placement, direct information, menu contents, keycap optionality, and token use. #44/#51 own the remaining settings persistence decision. |
Intent
Add per-project worktree setup via treehouse post_create hook. A single global hook script (bin/fm-treehouse-post-create.sh) is wired in ~/.config/treehouse/config.toml and fires when treehouse provisions or resets a worktree. It locates firstmate's data/ from its own location and runs data/-setup.sh if it exists. Non-fatal on failure, logs to state/treehouse-setup-.log. Replaces earlier fm-spawn-based approach with treehouse-native lifecycle hook.
What Changed
post_createhook script that runs optional per-project setup scripts from firstmate data and records non-fatal setup output under state logs.Risk Assessment
✅ Low: Captain, the change is bounded to Treehouse hook wiring/spawn context plus focused tests, and I did not find substantiated merge-blocking or follow-up issues.
Testing
Inspected the targeted diff, ran the focused hook/bootstrap/spawn shell tests, captured reviewer-visible CLI evidence for hook wiring and setup execution/logging, and confirmed the worktree remained clean.
Evidence: treehouse-post-create-e2e-transcript
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 1 issue found → auto-fixed ✅
bin/fm-bootstrap.sh:130-treehouse_hook_command_usableaccepts an executable hook path anywhere in the shell command, so a post_create entry likeecho /abs/bin/fm-treehouse-post-create.shis treated as configured even though Treehouse would never execute the hook. Bootstrap would then stay silent while per-project setup never runs; restrict the match to the executable command word, allowing only known-safe prefixes such as environment assignments.🔧 Fix: Captain, tighten treehouse hook detection
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
git status --short --branchgit diff --stat 2a2fe0566e63b883ec53dc3e34dc14306689f989..539e5297f842a684de95513470b186397e030a5agit diff --name-only 2a2fe0566e63b883ec53dc3e34dc14306689f989..539e5297f842a684de95513470b186397e030a5atests/fm-treehouse-post-create.test.shtests/fm-bootstrap.test.shtests/fm-spawn-treehouse-env.test.shCreated an isolated firstmate home and git worktree under/var/folders/t0/dws_m6l52lj97dkt9f4hd_sh0000gn/T/no-mistakes-evidence/01KVSZTTNA0BR1Y3D5XK12THFM/treehouse-post-create-e2e, ranbin/fm-bootstrap.sh install treehouse-post-create-hookwith localFM_HOME/XDG_CONFIG_HOME, then invokedbin/fm-treehouse-post-create.shfrom the matching worktree and verified the setup marker plusstate/treehouse-setup-app.log.git status --short✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.