feat(spawn): add Treehouse worktree setup hook - #47
Closed
michael-sb wants to merge 12 commits into
Closed
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.
Author
|
Sorry - my firstmate got a bit carried away - he can be quite proactive :D |
This was referenced Aug 7, 2026
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.
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.