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.
This commit is contained in:
Levi Neely 2026-08-03 09:56:34 +02:00
parent ae556a2a3a
commit 30621d2ed9
1 changed files with 35 additions and 2 deletions

View File

@ -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 <file> Read a file from the active agent's namespace
ls [path] List namespace entries (defaults to agent dir)
ctl <cmd> 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 "$@" ;;