worktree

package
v0.17.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package worktree implements Epic 12's launch-time isolation (S-3/R-3): Create prepares an isolated git worktree + branch for a session and Remove tears it down. Session ids are validated against path traversal (ADR-004) before anything ever touches git or disk.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(repoDir, id, name string) (string, error)

Create makes an isolated git worktree for session id. When name has usable letters or numbers, its preferred directory is <name-slug> and its branch is swarm/<name-slug>-<id>. If that friendly directory is occupied by another same-named session, this session falls back to <name-slug>-<id>. An unnamed session retains the established id-only form. id is validated before anything touches git or disk, so a rejected id never creates so much as the .swarm directory.

func Remove

func Remove(repoDir, id string) error

Remove tears down session id's worktree under repoDir: `git worktree remove --force` followed by `git worktree prune` (R-3). Removing an unknown session errors.

func RemoveAt

func RemoveAt(repoDir, dir string) error

RemoveAt tears down the exact worktree path persisted in Meta.AgentCwd. It accepts only a direct child of <repoDir>/.swarm/worktrees, so corrupt or malicious metadata cannot make teardown remove an arbitrary path. Remove is retained for sessions created by older versions, whose id was their path.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL