diff --git a/data/scripts/o b/data/scripts/o index 6d48ccb..75b0d9b 100755 --- a/data/scripts/o +++ b/data/scripts/o @@ -5,8 +5,11 @@ # o Root level # o Session level # o / Agent level +# o : Agent level (colon separator) # -# The slash in session/agent disambiguates context level. +# The slash or colon in session/agent disambiguates context level. +# Use colon when session or agent names contain slashes. +# Names with spaces can be quoted: o "my session:my agent" prompt # # Subcommands: # read Read a file (-l to loop) @@ -476,8 +479,11 @@ Context is determined by the first argument: o Root level o Session level o / Agent level + o : Agent level (colon separator) -The slash in / disambiguates context level. +The slash or colon in session/agent disambiguates context level. +Use colon when session or agent names contain slashes. +Names with spaces can be quoted: o "my session:my agent" prompt Paths starting with / are root-relative (ignore context): o myproj ls /bypass List root bypass/ even in session context @@ -497,7 +503,7 @@ Commands (availability depends on context): deny [id] Deny pending bypass request read/write Access session files - Agent level (o / ...): + Agent level (o / or : ...): new [cwd] Create session (if needed) and agent ls List agent files ctl Agent control (stop, compact, model, etc.) @@ -519,6 +525,8 @@ Commands (availability depends on context): Examples: o ls # list root (sessions, models) o myproj/coding new # create session+agent (cwd=$PWD) + o myproj:coding new # same, using colon separator + o "my proj:coding" new # session name with space o myproj/coding new ~/src # create with specific cwd o myproj ls # list session contents o myproj/coding prompt # interactive prompt @@ -560,23 +568,40 @@ dispatch_cmd() { } # Parse context from first argument +# Supports: +# session/agent (slash separator) +# session:agent (colon separator) +# "session name/agent" (quoted with spaces) +# session\ name/agent (escaped spaces) parse_context() { local arg="$1" - if [[ "$arg" == */* ]]; then - # session/agent format + + # Check for colon or slash separator + # Colon takes precedence if both present (allows session with / in name) + if [[ "$arg" == *:* ]]; then + CTX_SESSION="${arg%%:*}" + CTX_AGENT="${arg#*:}" + elif [[ "$arg" == */* ]]; then CTX_SESSION="${arg%%/*}" CTX_AGENT="${arg#*/}" - PREFIX="session/$CTX_SESSION/agent/$CTX_AGENT" else # session only CTX_SESSION="$arg" + CTX_AGENT="" + fi + + # Build prefix + if [[ -n "$CTX_AGENT" ]]; then + PREFIX="session/$CTX_SESSION/agent/$CTX_AGENT" + else PREFIX="session/$CTX_SESSION" fi } -# Re-split arguments: handles quoted invocations (e.g., acme passes -# the entire command as a single-quoted string). -set -- $* +# Note: We do NOT re-split arguments here. The previous `set -- $*` was +# removed because it breaks quoted arguments with spaces. If callers pass +# a single quoted string, they should use eval or proper quoting. +# For acme integration, the calling script should handle argument parsing. # Main dispatch if [[ $# -lt 1 ]]; then