From 6c26f15840e9bc1d322ffabca7f77260fc99deb3 Mon Sep 17 00:00:00 2001 From: Levi Neely Date: Mon, 10 Aug 2026 13:47:10 +0200 Subject: [PATCH] o: support root-relative paths with leading / Paths starting with / are treated as root-relative, ignoring the current context prefix. This allows accessing root-level files/directories even when in a session or agent context. Example: o myproj/coding ls /bypass # list root bypass/ dir --- data/scripts/o | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/data/scripts/o b/data/scripts/o index 18fd33a..d8f2f33 100755 --- a/data/scripts/o +++ b/data/scripts/o @@ -45,6 +45,20 @@ is_command() { return 1 } +# ── Path resolution helper ────────────────────────────────────── +# Resolves a path: if it starts with /, treat as root-level (strip /) +# Otherwise, prepend PREFIX. +resolve_path() { + local p="$1" + if [[ "$p" == /* ]]; then + # Absolute path - strip leading / and use as root-relative + echo "${p#/}" + else + # Relative path - prepend PREFIX + echo "${PREFIX}${PREFIX:+/}$p" + fi +} + # ── Subcommands ───────────────────────────────────────────────── cmd_read() { @@ -59,7 +73,8 @@ cmd_read() { echo "usage: o read [-l] " >&2 exit 1 fi - local path="${PREFIX}${PREFIX:+/}$1" + local path + path=$(resolve_path "$1") if $loop; then while true; do ollie-9p read "$path" || break @@ -75,7 +90,8 @@ cmd_write() { exit 1 fi local file="$1"; shift - local path="${PREFIX}${PREFIX:+/}$file" + local path + path=$(resolve_path "$file") if [[ $# -gt 0 ]]; then printf '%s\n' "$*" | ollie-9p write "$path" else @@ -86,7 +102,7 @@ cmd_write() { cmd_ls() { local path="${PREFIX}" if [[ $# -ge 1 ]]; then - path="${PREFIX}${PREFIX:+/}$1" + path=$(resolve_path "$1") fi ollie-9p ls "$path" } @@ -329,6 +345,9 @@ Context is determined by the first argument: The slash in / disambiguates context level. +Paths starting with / are root-relative (ignore context): + o myproj ls /bypass List root bypass/ even in session context + Commands (availability depends on context): Root level: @@ -363,7 +382,7 @@ Examples: o myproj new coding # create agent 'coding' o myproj/coding prompt # interactive prompt o myproj/coding read chat # read chat stream - o myproj/coding tui # launch tmux TUI + o myproj/coding ls /bypass # list root bypass/ from agent context o generate "explain monads" # one-shot, no session EOF }