cdshell

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package cdshell owns the __TREEPAD_CD__ shell-bridge protocol.

The tp shell wrapper sets TREEPAD_CD_FD=3 and redirects fd 3 into its $(...) capture, letting tp's stdout go to the real terminal. When the env var is absent (stale wrapper, direct binary invocation, tests) EmitCD falls back to writing the "__TREEPAD_CD__\t<path>\n" sentinel to d.Out.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base

func Base(ctx context.Context, d Deps, in BaseInput) error

Base emits a cd sentinel for the main worktree.

func CD

func CD(ctx context.Context, d Deps, in CDInput) error

CD emits a cd sentinel for the given branch's worktree path.

func EmitCD

func EmitCD(d Deps, path string)

EmitCD writes the __TREEPAD_CD__ sentinel for the path. In the fallback path (no fd-3 sentinel), it also writes a human-readable line.

func MaybeWarnStaleWrapper

func MaybeWarnStaleWrapper(d Deps, hasAgentCommand bool)

MaybeWarnStaleWrapper prints a one-line stderr hint when an agent_command is configured but the new shell wrapper has not been installed.

Types

type BaseInput

type BaseInput struct {
	// Cwd overrides os.Getwd for testing.
	Cwd string
}

BaseInput parameterises a tp base invocation.

type CDInput

type CDInput struct {
	Branch string
}

CDInput parameterises a tp cd invocation.

type Deps

type Deps struct {
	Out        io.Writer
	Log        Logger
	IsTerminal func(w io.Writer) bool
	// CDSentinel, when non-nil, returns the writer EmitCD uses instead of
	// the fd-3 probe. Tests set this to a bytes.Buffer.
	CDSentinel func() io.Writer
	Runner     worktree.CommandRunner
}

Deps are the external dependencies cdshell needs.

type Logger

type Logger interface {
	Warn(format string, args ...any)
}

Logger is the logging interface cdshell requires from its caller.

Jump to

Keyboard shortcuts

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