feat(daemon): add MULTICA_POST_CHECKOUT_HOOK for repo checkout extensibility#3309
Open
medi1-3 wants to merge 1 commit into
Open
feat(daemon): add MULTICA_POST_CHECKOUT_HOOK for repo checkout extensibility#3309medi1-3 wants to merge 1 commit into
medi1-3 wants to merge 1 commit into
Conversation
After repocache.CreateWorktree completes (either fresh worktree or update
of an existing one), invoke the executable at MULTICA_POST_CHECKOUT_HOOK
if the env var is set and points to an executable file.
The hook is invoked with the worktree as CWD and these env vars set so it
can act without re-deriving them from CWD or git state:
MULTICA_WORKTREE_PATH absolute path to the worktree
MULTICA_REPO_URL URL passed to `multica repo checkout`
MULTICA_REPO_NAME basename of the worktree path
MULTICA_BRANCH actual branch name on the worktree
Behavior:
- Unset/empty MULTICA_POST_CHECKOUT_HOOK is a no-op (default).
- Missing path, directory, or non-executable file is logged at WARN
and skipped — never aborts the checkout.
- Hook exit non-zero is logged at WARN with stdout+stderr; checkout
still succeeds.
- 30s timeout caps hook runtime so a hung hook can't stall task spawn.
Use cases: materializing per-repo .env files from an external secret
store, dropping skill files into the worktree, running language-specific
project bootstrap (`pnpm install`, `python -m venv`, etc.) before the
agent starts.
Tests cover: unset (no-op), happy path (env vars + CWD reach the hook),
non-executable file (skipped), missing path (skipped), non-zero exit
(non-fatal).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
@medi1-3 is attempting to deploy a commit to the IndexLabs Team on Vercel. A member of the Team first needs to authorize it. |
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.
Summary
Adds an opt-in
MULTICA_POST_CHECKOUT_HOOKenvironment variable. When set to an executable path, the daemon runs that script after every successful worktree create or update inrepocache.CreateWorktree. The hook receives the worktree as CWD and the following env vars:MULTICA_WORKTREE_PATH,MULTICA_REPO_URL,MULTICA_REPO_NAME,MULTICA_BRANCH.Why
Self-hosted deployments often need to materialize per-repo state into the worktree immediately after checkout — typical examples:
.envfrom an external secret store (Infisical, Vault, Doppler) so dotenv-based tooling (pnpm dev,pytest,python-dotenv) just works once the agentcds in.pnpm install,python -m venv .venv,poetry install, etc.Today, agents must remember to run such steps manually after
multica repo checkout. A daemon-level hook makes the bootstrap step transparent and reliable.Design
context.WithTimeoutso a hung hook cannot stall task spawning.os.Getenv, matching thegitEnvpattern already used in this file.Behavior matrix
Test plan
cache_test.go.go test ./internal/daemon/repocache/— passesgo test ./internal/daemon/...— passes (no regression in sibling packages).envfile — pending (will report in a comment).Compatibility
Fully backwards compatible. The env var defaults to unset, in which case behavior is identical to today's.