feat(scaffold): declarative .guardex.json worktree provisioning (workmux W2)#642
Merged
NagyVikt merged 1 commit intoJun 8, 2026
Conversation
…mux W2) A fresh agent worktree is a clean checkout — gitignored files (.env, node_modules, .venv) are missing, so agents start broken. gitguardex only auto-provisioned the hardcoded apps/* monorepo shape; any other layout got nothing. Port workmux's declarative provisioning so any repo can describe its own. - New .guardex.json `provision` block: files.copy / files.symlink (globs) + postCreate hooks. Parsed with the existing jsonc-parser (comments allowed) — no new dependency. - src/scaffold/provision-config.js: loader + minimal dependency-free glob (literal + single-segment *, e.g. apps/*/.env) + copy/symlink/postCreate appliers. Best-effort: missing config, no-match, or a failing hook never throws fatally (protects gx branch start). - Wired into prepareAgentWorktree (auto-invoked on worktree creation), ahead of the apps/* convenience which stays the zero-config default. The apps-gate early-return was removed so non-monorepo repos are provisioned too. Security: copy/symlink are fenced two ways — pattern strings reject absolute/.. paths, and each resolved source/destination is realpath-checked to stay inside repoRoot/worktreePath, so an in-repo symlink (link -> /etc) cannot escape on read or write. postCreate runs repo-owner config (same trust as package.json scripts), logs each command, is non-fatal, and is disabled with GUARDEX_PROVISION_HOOKS=0. Tests: test/provision-config.test.js (9 cases incl. escape-fence regression). Independent review: 1 HIGH (symlink escape) fixed + covered; full-suite failing set byte-identical to base (zero new failures).
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.
Automated by gx branch finish (PR flow).