This commit is contained in:
Levi Neely 2026-05-27 08:54:41 +02:00
parent 992050d462
commit 6557d80788
2 changed files with 53 additions and 1 deletions

4
mkfile
View File

@ -6,6 +6,8 @@ all:V:
go build -o $TARG .
cp scripts/Kmpl $BIN/Kmpl
chmod +x $BIN/Kmpl
cp scripts/Oi $BIN/Oi
chmod +x $BIN/Oi
clean:V:
rm -f $TARG $BIN/Kmpl
rm -f $TARG $BIN/Kmpl $BIN/Oi

50
scripts/Oi Normal file
View File

@ -0,0 +1,50 @@
#!/usr/bin/env bash
# Oi: single-click Navigator trigger for acme.
# Spawns or reuses a persistent Navigator session scoped to cwd,
# sends current file context, and opens the chat window.
set -euo pipefail
cmd=${0##*/}
die() { printf '%s: %s\n' "$cmd" "$*" >&2; exit 1; }
OLLIE=${OLLIE:-$HOME/mnt/ollie}
try() { "$@" 2>/dev/null || { ollie-remount && "$@"; }; }
# Derive deterministic session name from cwd
cwd=$(pwd)
hash=$(printf '%s' "$cwd" | cksum | awk '{print $1}')
NAV_NAME="nav-${hash}"
NAV_PATH="$OLLIE/s/$NAV_NAME"
# Spawn session if it doesn't exist
if ! [ -d "$NAV_PATH" ] 2>/dev/null; then
printf 'name=%s\ncwd=%s\nagent=partner\n' "$NAV_NAME" "$cwd" | try tee "$OLLIE/s/new" >/dev/null
sleep 0.5
fi
# Gather context from acme window (if running inside one)
context=""
if [ -n "${winid:-}" ] && [ "$winid" != "0" ]; then
filename=$(9p read acme/$winid/tag | awk '{print $1; exit}')
# Read selection (dot)
sel=$(9p read acme/$winid/rdsel 2>/dev/null || true)
# Git diff for this file (unstaged changes)
diff=$(cd "$cwd" && git diff -- "$filename" 2>/dev/null | head -100 || true)
context="File: $filename"
[ -n "$sel" ] && context="$context\n\nSelection:\n$sel"
[ -n "$diff" ] && context="$context\n\nRecent changes (git diff):\n$diff"
else
# No acme window context; just send cwd info
diff=$(cd "$cwd" && git diff --stat HEAD 2>/dev/null | head -30 || true)
context="Working directory: $cwd"
[ -n "$diff" ] && context="$context\n\nRecent changes:\n$diff"
fi
# Send prompt to Navigator
printf '%b' "$context\n\nReview this and share your observations." | try tee "$NAV_PATH/prompt" >/dev/null
# Print session ID so ollie-acme can open it
printf '%s\n' "$NAV_NAME"