worktreeTool

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package worktreeTool implements EnterWorktree and ExitWorktree tools.

EnterWorktree creates a new git worktree and switches the session's working directory into it. ExitWorktree removes or keeps the worktree and restores the original working directory.

Port of src/tools/EnterWorktreeTool/ and src/tools/ExitWorktreeTool/.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsInsideWorktree

func IsInsideWorktree(cwd string) bool

IsInsideWorktree returns true if cwd is a git worktree (not the main checkout).

Types

type CwdSetter

type CwdSetter func(newCwd string) error

CwdSetter is called when the worktree tool needs to change the session cwd. Returns an error if the change was rejected.

type EnterWorktree

type EnterWorktree struct {
	// GetCwd returns the current working directory.
	GetCwd func() string
	// SetCwd changes the session's working directory.
	SetCwd CwdSetter
}

EnterWorktree creates a git worktree and switches into it.

func (*EnterWorktree) Description

func (t *EnterWorktree) Description() string

func (*EnterWorktree) Execute

func (t *EnterWorktree) Execute(ctx context.Context, raw json.RawMessage) (tool.Result, error)

func (*EnterWorktree) InputSchema

func (t *EnterWorktree) InputSchema() json.RawMessage

func (*EnterWorktree) IsConcurrencySafe

func (t *EnterWorktree) IsConcurrencySafe(_ json.RawMessage) bool

func (*EnterWorktree) IsReadOnly

func (t *EnterWorktree) IsReadOnly(_ json.RawMessage) bool

func (*EnterWorktree) Name

func (t *EnterWorktree) Name() string

type ExitWorktree

type ExitWorktree struct {
	// GetCwd returns the current working directory.
	GetCwd func() string
	// SetCwd changes the session's working directory.
	SetCwd CwdSetter
	// OriginalCwd is the directory to return to on exit.
	OriginalCwd string
}

ExitWorktree exits the current worktree and returns to the original directory.

func (*ExitWorktree) Description

func (t *ExitWorktree) Description() string

func (*ExitWorktree) Execute

func (t *ExitWorktree) Execute(ctx context.Context, raw json.RawMessage) (tool.Result, error)

func (*ExitWorktree) InputSchema

func (t *ExitWorktree) InputSchema() json.RawMessage

func (*ExitWorktree) IsConcurrencySafe

func (t *ExitWorktree) IsConcurrencySafe(_ json.RawMessage) bool

func (*ExitWorktree) IsReadOnly

func (t *ExitWorktree) IsReadOnly(_ json.RawMessage) bool

func (*ExitWorktree) Name

func (t *ExitWorktree) Name() string

Jump to

Keyboard shortcuts

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