workspace

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package workspace provides workspace detection and management.

Index

Constants

View Source
const (
	// PrimaryMarker is the main config file that identifies a workspace.
	// The town.json file lives in mayor/ along with other mayor config.
	PrimaryMarker = "mayor/town.json"

	// SecondaryMarker is an alternative indicator at the town level.
	// Note: This can match rig-level mayors too, so we continue searching
	// upward after finding this to look for primary markers.
	SecondaryMarker = "mayor"
)

Markers used to detect a Gas Town workspace.

Variables

View Source
var ErrNotFound = errors.New("not in a Gas Town workspace")

ErrNotFound indicates no workspace was found.

Functions

func Find

func Find(startDir string) (string, error)

Find locates the town root by walking up from the given directory. It prefers mayor/town.json over mayor/ directory as workspace marker. When in a worktree path (polecats/ or crew/), continues to outermost workspace. Does not resolve symlinks to stay consistent with os.Getwd().

func FindFromCwd

func FindFromCwd() (string, error)

FindFromCwd locates the town root from the current working directory.

func FindFromCwdOrError

func FindFromCwdOrError() (string, error)

FindFromCwdOrError is like FindFromCwd but returns an error if not found.

func FindOrError

func FindOrError(startDir string) (string, error)

FindOrError is like Find but returns a user-friendly error if not found.

func GetTownName

func GetTownName(townRoot string) (string, error)

GetTownName loads the town name from the workspace's town.json config. This is used for generating unique tmux session names that avoid collisions when running multiple Gas Town instances.

func GetTownNameFromCwd

func GetTownNameFromCwd() (string, error)

GetTownNameFromCwd locates the town root from the current working directory and returns the town name from its configuration.

func IsWorkspace

func IsWorkspace(dir string) (bool, error)

IsWorkspace checks if the given directory is a Gas Town workspace root. A directory is a workspace if it has a primary marker (mayor/town.json) or a secondary marker (mayor/ directory).

func MustGetTownName

func MustGetTownName(townRoot string) string

MustGetTownName returns the town name or panics if it cannot be loaded. Use sparingly - prefer GetTownName with proper error handling.

Types

This section is empty.

Jump to

Keyboard shortcuts

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