workspace

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package workspace manages a bones workspace: the .bones/ directory, its on-disk config, and the associated leaf daemon process. Workspaces created before the rename used .agent-infra/; both Init and Join silently migrate that legacy name to .bones/ on first touch.

Two entry points:

Init creates a fresh workspace and starts a leaf daemon.
Join locates an existing workspace (walking up from cwd) and verifies
its leaf is reachable.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAlreadyInitialized = errors.New("workspace already initialized")
	ErrNoWorkspace        = errors.New("no bones workspace found")
	ErrLeafUnreachable    = errors.New("leaf daemon not reachable")
	ErrLeafStartTimeout   = errors.New("leaf daemon failed to start within timeout")
	ErrLegacyLayout       = errors.New("workspace uses pre-ADR-0041 layout")
)

Functions

func ExitCode

func ExitCode(err error) int

ExitCode maps errors returned by Init and Join to conventional process exit codes: 0 on success, 2-6 for known sentinels, 1 for anything else. Callers that want a different convention can inspect errors directly.

func FindRoot added in v0.4.0

func FindRoot(start string) (string, error)

FindRoot is the unauthenticated workspace lookup: walks up from start until it finds a directory containing the .bones marker dir, returns that directory, or ErrNoWorkspace if the filesystem root is reached.

Unlike Join, FindRoot does not load config.json or contact the leaf daemon — useful for commands that only need the workspace path (e.g. bones apply, which materializes from the hub fossil and never talks to the leaf).

func ReadName added in v0.6.0

func ReadName(root string) (string, error)

ReadName returns the workspace_name override or "" if not set.

func WriteName added in v0.6.0

func WriteName(root, name string) error

WriteName persists the workspace_name override at <root>/.bones/workspace_name.

Types

type Info

type Info struct {
	AgentID      string
	NATSURL      string
	LeafHTTPURL  string
	WorkspaceDir string
}

Info describes a live workspace. Returned by both Init and Join.

func Init

func Init(ctx context.Context, cwd string) (Info, error)

Init scaffolds a fresh workspace at cwd: ensures .bones/ exists, writes agent.id (idempotent — reused if already present), and transparently migrates a pre-ADR-0041 layout if found. Does NOT start the hub — hub.Start runs lazily on first verb that needs it via workspace.Join.

Returns ErrLegacyLayout if a pre-ADR-0041 hub is still running and must be torn down via `bones down` before migration can proceed.

Init is idempotent: re-invocation against an existing workspace succeeds with the existing agent.id.

func Join

func Join(ctx context.Context, cwd string) (Info, error)

Join locates the nearest .bones/ walking up from cwd, ensures the hub is running (auto-starting via hub.Start when not healthy), and returns a populated Info. A pre-rename .agent-infra/ marker rooted at cwd is silently migrated to .bones/ before walkUp; a pre-ADR-0041 .orchestrator/ layout is migrated transparently when no legacy hub is running, or surfaced as ErrLegacyLayout when one is.

On the first call after computer restart, Join prints one stderr line ("bones: starting hub for workspace ...") and continues once the hub is up.

Jump to

Keyboard shortcuts

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