From 30621d2ed9c92192936393a4f0eb6d6461be6b90 Mon Sep 17 00:00:00 2001 From: Levi Neely Date: Mon, 3 Aug 2026 09:56:34 +0200 Subject: [PATCH] scripts: add 'o kill', slash commands in prompt REPL o kill: kills the active session. Prompt REPL now supports slash commands: /stop, /compact, /kill, /clear, /model X, /backend X, /cwd X, /help Slash commands are handled locally without sending to the agent. --- data/scripts/o | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/data/scripts/o b/data/scripts/o index 8ef0792..b20cce7 100755 --- a/data/scripts/o +++ b/data/scripts/o @@ -167,7 +167,8 @@ cmd_prompt() { s=$(require_session) a=$(require_agent "$s") echo "[$s/$a]" - echo "Enter prompts (blank line sends, Ctrl+D exits):" + echo "Enter prompts (blank line sends, Ctrl+D exits)." + echo "Slash commands: /stop /compact /kill /clear /model /backend /cwd /help" echo "" local buf="" @@ -185,6 +186,30 @@ cmd_prompt() { printf "\n" break fi + # Slash commands (only when buffer is empty — first line) + if [[ -z "$buf" && "$line" == /* ]]; then + local cmd="${line#/}" + case "$cmd" in + stop) echo "stop" | ollie-9p write "$path/ctl"; echo "[stopped]" ;; + compact) echo "compact" | ollie-9p write "$path/ctl"; echo "[compacted]" ;; + kill) echo "kill" | ollie-9p write "session/$s/ctl"; echo "[session killed]"; break ;; + clear) echo "clear" | ollie-9p write "$path/ctl"; echo "[cleared]" ;; + model*) echo "$cmd" | ollie-9p write "$path/ctl"; echo "[${cmd}]" ;; + backend*) echo "$cmd" | ollie-9p write "$path/ctl"; echo "[${cmd}]" ;; + cwd*) echo "$cmd" | ollie-9p write "$path/ctl"; echo "[${cmd}]" ;; + help) + echo " /stop — interrupt running agent" + echo " /compact — compact context" + echo " /kill — kill the session" + echo " /clear — clear history" + echo " /model X — switch model" + echo " /backend X — switch backend" + echo " /cwd X — change working directory" + ;; + *) echo "unknown command: /$cmd (try /help)" ;; + esac + continue + fi if [[ -z "$line" && -n "$buf" ]]; then # Blank line sends accumulated buffer printf '%s\n' "$buf" | ollie-9p write "$path/prompt" @@ -225,6 +250,12 @@ cmd_stop() { echo "stop" | ollie-9p write "$path/ctl" } +cmd_kill() { + local s + s=$(require_session) + echo "kill" | ollie-9p write "session/$s/ctl" +} + cmd_tui() { local s a s=$(require_session) @@ -270,7 +301,8 @@ commands: read Read a file from the active agent's namespace ls [path] List namespace entries (defaults to agent dir) ctl Send control command (stop, compact, kill, ...) - stop Interrupt the running agent (shorthand for 'o ctl stop') + stop Interrupt the running agent + kill Kill the active session prompt Interactive multi-line prompt REPL tail Stream chat output tui Launch tmux layout (chat + prompt + state + shell) @@ -299,6 +331,7 @@ case "$subcmd" in ls) cmd_ls "$@" ;; ctl) cmd_ctl "$@" ;; stop) cmd_stop "$@" ;; + kill) cmd_kill "$@" ;; prompt) cmd_prompt "$@" ;; tail) cmd_tail "$@" ;; tui) cmd_tui "$@" ;;