feat(@scripts/session-tools): ✨ add permission mode support
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
fa5e1b640d
commit
2c9a36ed3a
2 changed files with 15 additions and 4 deletions
|
|
@ -68,7 +68,12 @@ case "$cmd" in
|
|||
# prompts "Choose [1/2]" for spawn mode and blocks forever. Default to
|
||||
# worktree (isolated session per spawn — safe for concurrent agents);
|
||||
# override per-instance with CLAUDE_RC_SPAWN=same-dir|session.
|
||||
exec claude rc --name "$name" --spawn "${CLAUDE_RC_SPAWN:-worktree}"
|
||||
# --permission-mode sets the mode for spawned sessions; bypassPermissions
|
||||
# so phone/web sessions run without permission prompts (override with
|
||||
# CLAUDE_RC_PERM=default|acceptEdits|plan|...).
|
||||
exec claude rc --name "$name" \
|
||||
--spawn "${CLAUDE_RC_SPAWN:-worktree}" \
|
||||
--permission-mode "${CLAUDE_RC_PERM:-bypassPermissions}"
|
||||
;;
|
||||
list|ls)
|
||||
printf '%-16s %-10s %s\n' NAME STATE DIR
|
||||
|
|
|
|||
10
bin/crc
10
bin/crc
|
|
@ -24,6 +24,9 @@
|
|||
#
|
||||
# Options:
|
||||
# --spawn <m> worktree | same-dir | session (default: worktree)
|
||||
# --perm <m> permission mode for spawned sessions:
|
||||
# bypassPermissions | default | acceptEdits | plan | dontAsk | auto
|
||||
# (default: bypassPermissions)
|
||||
#
|
||||
# Env: CRC_HOST default host when none given (default: apricot.lan)
|
||||
set -eu
|
||||
|
|
@ -31,12 +34,13 @@ set -eu
|
|||
host=${CRC_HOST:-apricot.lan}
|
||||
action=launch # launch | stop | status | log
|
||||
spawn=worktree
|
||||
perm=bypassPermissions
|
||||
have_host=0
|
||||
dir_set=0
|
||||
dir=''
|
||||
rc_args=''
|
||||
|
||||
usage() { sed -n '2,29p' "$0" | sed 's/^# \{0,1\}//'; }
|
||||
usage() { sed -n '2,31p' "$0" | sed 's/^# \{0,1\}//'; }
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
|
|
@ -45,6 +49,7 @@ while [ $# -gt 0 ]; do
|
|||
--status) action=status; shift ;;
|
||||
--log) action=log; shift ;;
|
||||
--spawn) [ $# -ge 2 ] || { echo "crc: --spawn needs a value" >&2; exit 2; }; spawn=$2; shift 2 ;;
|
||||
--perm|--permission-mode) [ $# -ge 2 ] || { echo "crc: $1 needs a value" >&2; exit 2; }; perm=$2; shift 2 ;;
|
||||
--) shift; rc_args=$*; break ;;
|
||||
-*) echo "crc: unknown option: $1" >&2; exit 2 ;;
|
||||
*)
|
||||
|
|
@ -91,6 +96,7 @@ NAME=$(printf %q "$name")
|
|||
REL=$(printf %q "$rel")
|
||||
ABS=$(printf %q "$abs")
|
||||
SPAWN=$(printf %q "$spawn")
|
||||
PERM=$(printf %q "$perm")
|
||||
ACTION=$(printf %q "$action")
|
||||
RC_ARGS=$(printf %q "$rc_args")
|
||||
|
||||
|
|
@ -129,7 +135,7 @@ case "\$ACTION" in
|
|||
else
|
||||
cd "\$DIR" 2>/dev/null || { echo "crc: directory not found: \$DIR" >&2; exit 1; }
|
||||
: > "\$LOG"
|
||||
nohup claude rc --name "\$NAME" --spawn "\$SPAWN" \$RC_ARGS </dev/null >>"\$LOG" 2>&1 &
|
||||
nohup claude rc --name "\$NAME" --spawn "\$SPAWN" --permission-mode "\$PERM" \$RC_ARGS </dev/null >>"\$LOG" 2>&1 &
|
||||
echo \$! > "\$PIDF"
|
||||
i=0; while [ \$i -lt 20 ] && [ -z "\$(envid)" ] && alive; do sleep 1; i=\$((i+1)); done
|
||||
fi
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue