feat(worktree): Add worktree commands, per-worktree trunks, and worktree-aware filtering#1188
Open
ed-irl wants to merge 1 commit into
Open
feat(worktree): Add worktree commands, per-worktree trunks, and worktree-aware filtering#1188ed-irl wants to merge 1 commit into
ed-irl wants to merge 1 commit into
Conversation
Collaborator
Author
This was referenced Jun 2, 2026
This was referenced Jun 12, 2026
640febe to
f59037a
Compare
Owner
|
extracted just the scriptrun functionality into #1276 |
abhinav
added a commit
that referenced
this pull request
Jun 14, 2026
Introduces a small, single-responsibility package for executing user-configured shell scripts and capturing their output. Scripts may be either plain shell snippets (passed to 'sh -c') or self-contained executables starting with a shebang line (written to a temp file and executed directly). stdout and stderr are captured independently and returned alongside the exit code. The package does not interpret script output; that's the caller's responsibility. This keeps scriptrun reusable across different output protocols (commit messages, conflict resolutions, etc). A non-zero exit is reported in the RunResult rather than as an error, so callers can distinguish 'script ran and disagreed' from 'script could not be run at all.' Part of #1243 This intentionally narrows PR #1188 to only the core scriptrun functionality described in issue #1243: the generic script runner. --------- Co-authored-by: Edmund Kohlwey <ed@irl.llc>
f59037a to
70afff3
Compare
70afff3 to
0460c55
Compare
Adds the script-execution foundation and the cross-feature protocol
surface that the message generator and both auto-resolvers will use.
Runner (existing): executes a user-configured script either via
'sh -c' or by writing a shebang script to a temp file and exec'ing it.
stdout, stderr, and the exit code are returned without interpretation
so each feature can plug its own handler on top.
Shared protocol (new in this commit):
- ResolveResponse: the JSON document scripts emit on stdout (the
union of {title, body, assumptions, questions, unresolved_files}
fields). ParseResponse with ErrEmptyOutput / InvalidOutputError
for diagnostics.
- QAPair: per-question persistent-resolution-file record.
- Operation enum and EnvFor(operation, branch, base) returning the
shared GS_OPERATION / GS_BRANCH / GS_BASE env that every script
receives. Feature-specific env layers on top.
Per-repo scratch directory (new in this commit):
- internal/spice/spicedir owns <repo-root>/.spice/.
- Path / EnsureDir for the directory; ResolutionPath /
EnsureResolutionsDir for per-feature resolution files at
.spice/resolutions/<feature>.json. Does not modify .gitignore --
that's a project policy decision left to the user.
Configurable iteration cap (new in this commit):
- spice.scriptResolve.maxIterations (int, default 10) bounds the
questions Q&A loop across all features.
- Config.ScriptResolveMaxIterations() reads it with default+warning
fallback for invalid values.
Unit tests cover EnvFor, ParseResponse (empty/invalid/valid),
spicedir path + EnsureDir, and ScriptResolveMaxIterations parsing.
Together these are the surfaces that ed-irl/restack-auto-resolve,
ed-irl/integration-auto-resolve, and ed-irl/ai-message-gen will
consume in their respective fixups to collapse the existing
per-feature divergences. See doc/src/guide/scripts.md on
ed-irl/scripts-protocol-guide for the user-facing protocol contract.
0460c55 to
253532c
Compare
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.
Adds 'gs worktree create' and 'gs worktree list'. 'worktree create' gives each new worktree its own local trunk branch that tracks the same remote ref as the canonical trunk, so 'repo sync' and restacks in different worktrees never contend on a single shared trunk checkout. Use -b to also stack a tracked branch on the worktree trunk, or --no-trunk for the legacy detached-HEAD behavior.
The state store gains a per-worktree trunk registry (worktree-trunks key), persisted additively so older binaries and pre-feature repos are unaffected. IsTrunk, TrunkFor, and WorktreeTrunks let trunk-equivalents act as graph roots: traversals stop at them, branches may stack on them, and they cannot themselves be tracked or deleted.
BranchGraph treats all trunk-equivalents as roots and adds StacksInWorktree to collect full stacks touching a given worktree. The sync handler pulls the canonical remote ref into the worktree's local trunk. 'log short' and 'repo restack' gain -w/--worktree to scope to the current worktree's stacks.
Part of #1243