u/complete: add model/backend flags and env var support; fix winid=0

- Add -model and -backend flags; read OLLIE_COMPLETE_MODEL /
  OLLIE_COMPLETE_BACKEND as defaults; error if neither is set
- Guard against winid=0 (acme column tag / +Errors window)
- Document OLLIE_COMPLETE_MODEL and OLLIE_COMPLETE_BACKEND in
  README.md and doc/env.sample

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Levi Neely 2026-05-03 13:43:30 +02:00
parent 2c8e59e7f5
commit cddda76a3f
3 changed files with 38 additions and 3 deletions

View File

@ -55,6 +55,8 @@ OLLIE_MODEL=qwen/qwen3-235b-a22b
OLLIE_TOOLS_PATH=~/.config/ollie/tools # directory for tool scripts ({tool} steps)
OLLIE_MEMORY_PATH=~/.config/ollie/memory # directory for memory files (ollie/m)
OLLIE_ELEVATE_SOCKET=${XDG_RUNTIME_DIR}/ollie/elevate.sock # socket path for x/elevate adapter (default: $XDG_RUNTIME_DIR/ollie/elevate.sock)
OLLIE_COMPLETE_BACKEND=ollama # backend for u/complete (required)
OLLIE_COMPLETE_MODEL=qwen3:latest # model for u/complete (required)
```
Shell environment variables take precedence over the env file.

View File

@ -39,3 +39,7 @@
# kiro / codewhisperer (bearer token or sqlite:// path)
#OLLIE_KIRO_TOKEN=
# u/complete: backend and model for acme code completion (required by u/complete)
#OLLIE_COMPLETE_BACKEND=ollama
#OLLIE_COMPLETE_MODEL=qwen3:latest

View File

@ -11,7 +11,36 @@ BFG="${0%/*}/../s/bfg"
cmd=${0##*/}
die() { printf '%s: %s\n' "$cmd" "$*" >&2; exit 1; }
[ -z "${winid:-}" ] && die "must be run from an acme window (\$winid not set)"
usage() {
cat <<EOF
usage: $cmd [-model MODEL] [-backend BACKEND]
Flags:
-model MODEL model to use (default: \$OLLIE_COMPLETE_MODEL)
-backend BACKEND backend to use (default: \$OLLIE_COMPLETE_BACKEND)
-help show this help
EOF
exit 0
}
model=${OLLIE_COMPLETE_MODEL:-}
backend=${OLLIE_COMPLETE_BACKEND:-}
while [ $# -gt 0 ]; do
case $1 in
-model) model=$2; shift ;;
-backend) backend=$2; shift ;;
-help) usage ;;
-*) die "unknown flag: $1" ;;
*) break ;;
esac
shift
done
[ -z "$model" ] && die "model required: set OLLIE_COMPLETE_MODEL or pass -model"
[ -z "$backend" ] && die "backend required: set OLLIE_COMPLETE_BACKEND or pass -backend"
[ -z "${winid:-}" ] || [ "$winid" = "0" ] && die "must be run from an acme window"
# Get filename for language context (last field of ctl line 1)
filename=$(9p read acme/$winid/ctl | awk 'NR==1{print $NF}')
@ -33,8 +62,8 @@ suffix=$(9p read acme/$winid/data)
prefix="${prefix: -$PREFIX_MAX}"
suffix="${suffix:0:$SUFFIX_MAX}"
# Query model; -agent copilot strips tools and uses a minimal prompt
result=$("$BFG" -agent copilot \
# Query model
result=$("$BFG" -agent copilot -model "$model" -backend "$backend" \
"Complete the code at the cursor in ${filename}. Output ONLY the text to insert — no explanation, no markdown, no preamble.
<prefix>