Skip to content

feat: Add worktree commands with per-worktree trunks#1249

Open
ed-irl wants to merge 2 commits into
ed-irl/restack-options-paramfrom
ed-irl/scripts-protocol-guide
Open

feat: Add worktree commands with per-worktree trunks#1249
ed-irl wants to merge 2 commits into
ed-irl/restack-options-paramfrom
ed-irl/scripts-protocol-guide

Conversation

@ed-irl

@ed-irl ed-irl commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

Add gs worktree create and gs worktree list, backed by a per-worktree trunk registry, plus worktree-aware filtering for log and repo restack.

Per-worktree trunks:

  • state: New worktree-trunks store key (additive/optional, so older
    repos and binaries are unaffected) registering local branches that
    are trunk-equivalents — each tracks the same remote ref as the
    canonical trunk. Store gains IsTrunk, TrunkFor, WorktreeTrunks, and
    Register/UnregisterWorktreeTrunk; branch transactions now treat any
    registered trunk as a graph root.
  • spice: BranchGraph tracks the full set of trunk-equivalents so
    Downstack, Bottom, and Stack traversals stop at any trunk. Adds
    StacksInWorktree to enumerate stacks touching a given worktree.

Commands:

  • worktree create <path>: by default creates a local trunk branch
    (named after the directory, or --trunk) tracking the remote trunk,
    so sync and restack in different worktrees never contend on one
    shared checkout. --no-trunk keeps detached-HEAD behavior; -b stacks
    a tracked branch on the worktree trunk.
  • worktree list: shows each worktree, its branch, and stack.

Worktree-aware filtering:

  • log short -w and repo restack -w scope to stacks with a branch
    checked out in the current worktree; -w implies --all for log.
  • sync resolves the trunk to pull into via TrunkFor(worktree root),
    fast-forwarding the local trunk from the canonical remote ref.

Includes unit tests, test scripts, regenerated docs/help, and a
changelog entry.

@ed-irl

ed-irl commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator Author

This change is part of the following stack:

Change managed by git-spice.

@ed-irl ed-irl force-pushed the ed-irl/scripts-protocol-guide branch 2 times, most recently from f59037a to 70afff3 Compare June 15, 2026 09:52
@ed-irl ed-irl changed the title docs: Add shared protocol guide for script integrations feat: Add worktree commands with per-worktree trunks Jun 19, 2026
@ed-irl ed-irl force-pushed the ed-irl/scripts-protocol-guide branch from 70afff3 to 0460c55 Compare June 19, 2026 01:01
ed-irl added 2 commits June 23, 2026 11:38
Introduces restack.Options{AutoResolve} and threads an opts *Options
parameter through the high-level restack entry points (RestackBranch,
RestackStack, RestackDownstack) and the merge/sync RestackHandler
interfaces, with all current callers passing nil.

This is foundational plumbing for the restack auto-resolve feature.
Landing it on a branch below the consuming stacks lets every branch
inherit the 3-arg signature, rather than the signature change living
on a branch parallel to its callers.
Adds doc/src/guide/scripts.md as the single source of truth for the
shared protocol that ties together three soon-to-be-aligned features:

  - spice.message.generator (commit message generation)
  - spice.restack.resolver  (restack auto-resolve)
  - spice.integration.resolver (integration-rebuild auto-resolve)

Documents:

  - Invocation shape (shebang vs sh -c, working dir, args forwarding).
  - Shared env contract: GS_OPERATION, GS_BRANCH, GS_BASE, plus the
    table of all GS_OPERATION values across the three features. Lists
    message-feature-specific extras (GS_MESSAGE_*, GS_TITLE, GS_BODY).
  - JSON output schema (the union of fields across all three features).
  - Assumptions logging, the questions Q&A loop, and termination rules.
  - .spice/resolutions/<feature>.json layout for persistent Q&A.
  - spice.scriptResolve.maxIterations cap.
  - Worked examples and error-handling expectations.

This commit is a prerequisite for the implementation work landing on
ed-irl/scriptrun and the three feature branches above it. Registering
the page in doc/mkdocs.yml's User Guide section.
@ed-irl ed-irl changed the base branch from main to ed-irl/restack-options-param June 24, 2026 01:31
@ed-irl ed-irl force-pushed the ed-irl/scripts-protocol-guide branch from 0460c55 to 253532c Compare June 24, 2026 01:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant