Documentation
¶
Index ¶
Constants ¶
const ( DefaultLogMaxSizeMB = 50 DefaultLogMaxAgeDays = 30 DefaultLogMaxFiles = 10 )
Default values for log rotation knobs. Exposed as constants so callers can reference them in tests and docs without hardcoding.
const DefaultHookTimeoutSec = 5
DefaultHookTimeoutSec mirrors internal/hooks.DefaultTimeout. Kept in sync manually so this package doesn't depend on internal/hooks (which would create a cycle via cmd).
const SchemaVersion = 1
SchemaVersion is the current on-disk schema version of config.json. Bump this and append a Step to the Plan returned by MigrationPlan() whenever the shape of Config changes in a non-additive way.
Variables ¶
This section is empty.
Functions ¶
func ClaudeOverlayPath ¶
func ClaudeOverlayPath() string
ClaudeOverlayPath returns the path to the optional claude settings overlay. When this file exists, ctm passes --settings <path> to every claude invocation, layering it on top of the user's existing claude settings without modifying ~/.claude/settings.json.
func EnvFilePath ¶
func EnvFilePath() string
EnvFilePath returns the path to the optional ctm-managed env file. When this file exists, ctm sources it in the shell before spawning claude. Use this for env vars that must exist as real shell environment (e.g. CLAUDE_CODE_NO_FLICKER) rather than inside claude's settings.json env key, which is evaluated too late in claude's startup.
func MigrationPlan ¶
MigrationPlan returns the migrate.Plan for config.json. Steps is empty at v1 because the initial migration only stamps the version — no content changes are required to turn an unversioned config.json into v1.
Callers run the returned Plan before Load so the typed unmarshal sees a file already at the current SchemaVersion.
func TmuxConfPath ¶
func TmuxConfPath() string
TmuxConfPath returns the path to the tmux config file.
Types ¶
type Config ¶
type Config struct {
// SchemaVersion is stamped onto config.json by the migrate runner on
// startup. Exposed so Load/write round-trip preserves it; callers
// should not set it explicitly — Default() and write() handle it.
SchemaVersion int `json:"schema_version"`
RequiredEnv []string `json:"required_env"`
RequiredInPath []string `json:"required_in_path"`
ScrollbackLines int `json:"scrollback_lines"`
HealthCheckTimeoutSec int `json:"health_check_timeout_seconds"`
GitCheckpointBeforeYolo bool `json:"git_checkpoint_before_yolo"`
DefaultMode string `json:"default_mode"`
// Log rotation knobs for ~/.config/ctm/logs/<session>.jsonl.
// A zero value means "use the built-in default" (50 MiB / 30 d / 10
// files). To effectively disable a cap, set it to a very large number
// rather than 0. LogPolicy() resolves zeros to defaults.
LogMaxSizeMB int `json:"log_max_size_mb"`
LogMaxAgeDays int `json:"log_max_age_days"`
LogMaxFiles int `json:"log_max_files"`
// Hooks maps lifecycle event names (on_attach, on_new, on_yolo,
// on_safe, on_kill) to shell commands run when the event fires.
// Nil / empty means no hooks. Commands run with CTM_EVENT +
// CTM_SESSION_{NAME,UUID,MODE,WORKDIR} in the env and are bounded
// by HookTimeoutSec seconds. See internal/hooks for the full
// contract.
Hooks map[string]string `json:"hooks"`
// HookTimeoutSec is the per-hook wall-clock ceiling. Zero → default
// (5 s). Set a very large number to effectively disable the cap.
HookTimeoutSec int `json:"hook_timeout_seconds"`
}
Config holds user preferences for ctm.
func Load ¶
Load reads Config from path. If the file does not exist it creates it with defaults and returns those defaults.
The decoder is strict: unknown top-level keys are rejected. On the first load that encounters an unknown key (typo, dropped experimental field, etc.), ctm copies the original bytes to a sibling ".bak.unknowns.<unix-nano>", strips the unknown keys, rewrites the file, and emits a WARN-level slog line naming each dropped key. See internal/jsonstrict for the full contract. This self-heals once, then strictness catches future typos immediately.
func (Config) HookTimeout ¶
HookTimeout returns the per-hook wall-clock ceiling. A zero HookTimeoutSec resolves to DefaultHookTimeoutSec so old configs (and users who never set it) still get a sensible default.