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
This commit is contained in:
parent
d621e7322a
commit
6c26f15840
|
|
@ -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] <path>" >&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 <session>/<agent> 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
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue