Documentation
¶
Index ¶
- func BuildCommand(uuid, mode string, resume bool, overlayPath, envExports string) string
- func FindClaudeChild(panePID string) string
- func IsClaudeAlive(pid string) (bool, error)
- func OverlayPathIfExists(overlayPath string) string
- func ReadEffortLevel(path string) string
- func SessionExists(uuid string) bool
- func SettingsJSONPath() (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildCommand ¶
BuildCommand builds the claude CLI command string. If resume is true, tries --resume first, falls back to --session-id if the session no longer exists. Claude is the pane process — when it exits, the tmux session dies.
If envExports is non-empty, it is prepended verbatim as a shell prelude — e.g. "export CLAUDE_CODE_NO_FLICKER='1' CTM_STATUSLINE_DUMP='/tmp/...'". The caller is responsible for loading ~/.config/ctm/claude-env.json (via config.ClaudeEnvExports) and producing this string. This lets ctm set real shell env vars that claude reads during early startup, which is too early for the overlay's `env` block to take effect.
If overlayPath is non-empty, it is passed via --settings to layer ctm-only claude customizations (statusline, theme, etc.) on top of the user's global settings without modifying ~/.claude/settings.json. The overlay check is a TOCTOU-safe shell guard — `[ -r path ]` re-evaluates at exec time and falls back gracefully if the file vanished.
NOTE: The || fallback fires on ANY non-zero exit from `claude --resume`, not just "session not found". A crash, auth error, or Ctrl-C will also trigger a fresh session with the same UUID. This is intentional — it's better to recover into a usable state than to leave the user stranded.
func FindClaudeChild ¶
FindClaudeChild finds a claude process among children of the given PID by walking /proc/*/status. Pure Go — no pgrep dependency.
For each PID directory under /proc, it reads /proc/<pid>/status and checks the PPid and Name fields. Returns the first PID whose PPid == panePID and Name == "claude", or empty string if none found.
func IsClaudeAlive ¶
IsClaudeAlive checks if a PID exists and is not a zombie.
func OverlayPathIfExists ¶
OverlayPathIfExists returns overlayPath if the file exists and is readable, otherwise returns empty string. Used to gate the --settings flag.
func ReadEffortLevel ¶
ReadEffortLevel returns the current effort level stored under the "effortLevel" key in path (typically ~/.claude/settings.json). Values in the wild: "min" / "low" / "medium" / "high" / "xhigh" / "max".
Returns "" when the file is missing, unreadable, unparseable, the key is absent, or the value is not a string — intentionally silent so callers (the statusline renderer) can display nothing on missing data without a noisy error path.
func SessionExists ¶
SessionExists checks if a Claude session UUID has data in ~/.claude/. It checks ~/.claude/projects/ and ~/.claude/conversations/, returning false (not an error) if neither directory exists.
func SettingsJSONPath ¶
SettingsJSONPath returns the canonical path to Claude Code's user-level settings file (~/.claude/settings.json). Unlike ~/.claude.json (which stores per-user runtime state), this file holds the documented user-overridable configuration.
ctm reads this file (e.g., for the "effortLevel" key consumed by the statusline renderer) but never writes to it. UI-shaping defaults (tui, viewMode) live in claude-overlay.json — see buildSampleOverlay in cmd/overlay.go — so ctm stays additive, not invasive, on the user's per-user Claude Code config.
Types ¶
This section is empty.