home

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package home resolves the Codex home a router serves ($CODEX_HOME, else ~/.codex) into a stable identity: a short ID hashed from the canonical path and a display name. Sessions are keyed by (home ID, thread ID), so two homes never share state even when their thread IDs collide.

Index

Constants

View Source
const LabelSep = " · "

LabelSep separates the parts of a label.

Variables

This section is empty.

Functions

func Disambiguate

func Disambiguate(labels, ids []string) []string

Disambiguate returns labels with " · <4-hex>" appended to each label that more than one entry shares. ids[i] belongs to labels[i]. The suffix is hashed from the id, so it works for any id format, including UUIDv7 thread ids whose leading hex is a timestamp. Two colliding ids can still share a suffix (1 in 65536); the labels stay display only.

func Given

func Given(getenv func(string) string) (string, error)

Given returns the home path as the user set it, $CODEX_HOME else $HOME/.codex, cleaned with its symlinks kept. Name comes from it, so a process handed this path resolves the same home under the same Name.

func Label

func Label(homeName, cwd string) string

Label is the display label "home · repo · branch", or "home · dir" when cwd is not in a readable repo. It is not an identity (M1).

func RepoBranch

func RepoBranch(cwd string) (repo, branch string, ok bool)

RepoBranch finds the git repo containing cwd by reading .git files, never by running git. A linked worktree reports its main repo's name. Detached HEAD gives the short commit sha. ok is false when cwd is in no repo or the repo's metadata cannot be read.

Types

type Home

type Home struct {
	ID   string `json:"id"`
	Path string `json:"path"` // canonical: symlinks resolved when the dir exists
	Name string `json:"name"`
}

Home is one Codex home. ID is the first 12 hex of sha256(Path).

func Resolve

func Resolve(getenv func(string) string) (Home, error)

Resolve returns the home from $CODEX_HOME, else $HOME/.codex. A relative CODEX_HOME is an error: its meaning would depend on the caller's cwd, so two shells could give one home two IDs. The dir need not exist yet; then the cleaned path is used as is.

Jump to

Keyboard shortcuts

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