o: add log command, rename tail to chatstream

- Add 'o log [-n N]' to read last N lines from agent log (default 1000)
- Rename 'o tail' to 'o chatstream' for clarity
- Update TUI to show log history before streaming chat
This commit is contained in:
Levi Neely 2026-08-07 17:34:33 +02:00
parent 7100942984
commit 8397f1aa74
1 changed files with 33 additions and 6 deletions

View File

@ -381,20 +381,45 @@ cmd_prompt() {
done
}
cmd_tail() {
cmd_chatstream() {
local ctx s a
ctx=$(resolve_context "$@") || exit 1
s="${ctx%%|*}"
a="${ctx##*|}"
if [[ -z "$s" || -z "$a" ]]; then
echo "error: session and agent are required" >&2
echo " usage: o tail <session> <agent>" >&2
echo " usage: o chatstream <session> <agent>" >&2
echo " or: export session=<name> agent=<name>" >&2
exit 1
fi
exec ollie-9p read "session/$s/agent/$a/chat"
}
cmd_log() {
local lines=1000
local ctx s a
# Parse -n flag for line count
while [[ $# -gt 0 && "$1" == -* ]]; do
case "$1" in
-n) shift; lines="${1:-1000}"; shift ;;
-n*) lines="${1#-n}"; shift ;;
*) break ;;
esac
done
ctx=$(resolve_context "$@") || exit 1
s="${ctx%%|*}"
a="${ctx##*|}"
if [[ -z "$s" || -z "$a" ]]; then
echo "error: session and agent are required" >&2
echo " usage: o log [-n lines] [session] [agent]" >&2
echo " or: export session=<name> agent=<name>" >&2
exit 1
fi
ollie-9p read "session/$s/agent/$a/log" | tail -n "$lines"
}
cmd_env() {
# Accept optional positional args to set context
if [[ $# -ge 1 ]]; then
@ -481,10 +506,10 @@ cmd_tui() {
# └──────────────────────────────────┘
# State shown in tmux status-right.
# Pane 0: chat (top, 80%)
# Pane 0: chat (top, 80%) - show last 1000 lines of log, then tail chat
tmux -CC new-session -d -s "$tmux_session" -c "$HOME" \
-e "session=$s" -e "agent=$a"
tmux send-keys -t "$tmux_session" "clear; o tail | grep -v '\\[\\[\\[.*\\]\\]\\]'" Enter
tmux send-keys -t "$tmux_session" "o log -n 1000 | grep -v '\\[\\[\\[.*\\]\\]\\]'; o chatstream | grep -v '\\[\\[\\[.*\\]\\]\\]'" Enter
# Pane 1: prompt REPL (bottom, 20% height)
tmux split-window -t "$tmux_session" -v -l 20% \
@ -540,7 +565,8 @@ Commands:
kill Kill active session
prompt Interactive multi-line prompt REPL
tail Stream chat output
chatstream Stream chat output
log [-n N] Show last N lines of agent log (default 1000)
tui Launch tmux layout
tui exit Kill tmux TUI session
@ -584,7 +610,8 @@ case "$subcmd" in
stop) cmd_stop "$@" ;;
kill) cmd_kill "$@" ;;
prompt) cmd_prompt "$@" ;;
tail) cmd_tail "$@" ;;
chatstream) cmd_chatstream "$@" ;;
log) cmd_log "$@" ;;
tui) cmd_tui "$@" ;;
env) cmd_env "$@" ;;
help|-h|--help) cmd_help ;;