# Claude Code runtime adapter for muxr.
#
# A runtime adapter is pure config: it tells muxr how to drive ONE coding CLI
# (launch, resume, fork, switch model, exit, find the session id). muxr core
# has no per-runtime code -- adding a runtime is writing one of these blocks.
#
# As of muxr 3.1 this file IS the built-in Claude default: the binary embeds it
# (`include_str!`) and parses it into the adapter table at load. There is no
# compiled-in Claude struct -- Claude is "just an adapter that happens to be in
# the box." Paste this block into your muxr config to customize, or `include`
# this file (see extensions/README.md).

[tools.claude]
bin = "claude"

# Initial launch. `{name}` -> the tmux session name (<repo>/<campaign>).
args = ["--name", "{name}"]

# Resume a prior conversation by id. `{session_id}` comes from discovery below.
resume_args = ["--resume", "{session_id}"]

# Fallback when no session id is known yet (continue the most recent).
continue_args = ["--continue"]

# Fork: branch a NEW conversation id off an existing one.
fork_args = ["--fork-session"]

# Set the model at launch. `{model}` -> the requested model.
model_args = ["--model", "{model}"]

# Slash commands sent into the live pane (not launch flags).
rename_command       = "/rename {name}"
model_switch_command = "/model {model}"
exit_command         = "/exit"          # used by recycle + `muxr upgrade`

# How the appended system prompt (HARNESS rules) is delivered.
#   "file"   -> --append-system-prompt-file <path>   (Claude)
#   "string" -> --append-system-prompt <contents>
prompt_mode = "file"

# Claude accepts extra working roots via --add-dir.
supports_add_dirs = true

# How muxr recovers the conversation id for `muxr save`: walk the session's
# process tree, and for each pid read a per-pid JSON file, pulling `id_key`.
[tools.claude.session_discovery]
type = "file"
pattern = "~/.claude/sessions/{pid}.json"
id_key = "sessionId"

# Readiness probe: muxr reads this file (written by the operator's Claude Code
# hooks -- Stop writes idle, PreToolUse/UserPromptSubmit write busy) to decide
# whether it's safe to upgrade a session in-place. `since` enforces a quiet
# period: even after the state flips to "idle", muxr waits until the last
# transition is at least `min_idle` seconds old before relaunching.
[tools.claude.readiness]
type = "file"
pattern = "~/.config/muxr/readiness/{session_id}.json"
state_key = "state"
idle_value = "idle"
since_key = "since"
