Documentation
¶
Overview ¶
Package shellstate owns validation and persistence of Sidecar shell display names. It is deliberately independent of both the TUI and CLI transports.
Index ¶
Constants ¶
const ( NameEnv = "SIDECAR_SHELL_NAME" SessionEnv = "SIDECAR_SHELL" )
NameEnv carries the current display name into the shell's environment, and SessionEnv the tmux session that owns it. An agent that can read its own shell name can tell a default ("Shell 9") from a real one, which is what makes the rename instruction actionable rather than a rule to remember.
const MaxNameBytes = 50
const NamingInstruction = "This terminal is a Sidecar project shell. Learn its display name from $" + NameEnv +
" as a cue (it may be empty on older shells, or lag after a rename in this process), or run " +
"`sidecar shell name` for the authoritative name from Sidecar's manifest. \"Shell 3\" is the unset default; " +
"a previous task's name is equally stale. Keep the name aligned with your current task: at the start of work " +
"and whenever context changes materially, if the name does not describe what you are doing now, run " +
"`sidecar shell rename \"short context\"`. Update at meaningful boundaries, not every sub-step. Prefer the " +
"outcome (\"shell rename implementation\") over the model or a transient action (\"Codex running tests\"). " +
"These commands act only on the current Sidecar shell; never edit shells.json or rename tmux sessions directly."
NamingInstruction is the canonical guidance for keeping a shell's display name useful. It lives here, next to the rules it describes, so every delivery channel — AGENTS.md, a harness system-prompt append, help text — quotes one source instead of drifting copies.
The trigger is "name does not describe current work," not only the generated "Shell N" default — a leftover previous-task name is equally stale.
Variables ¶
This section is empty.
Functions ¶
func IsValidation ¶
func NormalizeName ¶
Types ¶
type Definition ¶
type Definition struct {
TmuxName string `json:"tmuxName"`
DisplayName string `json:"displayName"`
// Namespace is the resolved tmux socket path. Empty identifies a legacy
// entry that a headless rename must never claim as a side effect.
Namespace string `json:"namespace,omitempty"`
CreatedAt time.Time `json:"createdAt"`
AgentType string `json:"agentType,omitempty"`
SkipPerms bool `json:"skipPerms,omitempty"`
// WorkDir is the parent worktree path this shell was created in. Empty on
// pre-td-4819be manifests; callers infer or treat empty as current workDir.
WorkDir string `json:"workDir,omitempty"`
}
Definition contains all information needed to recreate a shell session.
type LookupResult ¶ added in v0.97.0
func LookupCurrent ¶ added in v0.97.0
func LookupCurrent(stateDir string, id Identity) (LookupResult, error)
LookupCurrent returns the display name of the current Sidecar project shell from the registered manifest. It does not create state or depend on process environment cues, so it works for shells created before SIDECAR_SHELL_NAME injection existed.
type RenameRequest ¶
type RenameResult ¶
type RenameResult struct {
Shell string `json:"shell"`
OldName string `json:"oldName"`
Name string `json:"name"`
Changed bool `json:"changed"`
}
func RenameAtPath ¶
func RenameAtPath(path string, req RenameRequest) (RenameResult, error)
RenameAtPath performs a locked read-before-write mutation of one manifest.
func RenameCurrent ¶
func RenameCurrent(stateDir string, req RenameRequest) (RenameResult, error)
RenameCurrent searches registered project manifests without creating state.