refactor: complete tmux-to-herdr migration review and enhance workspace reuse logic
This commit is contained in:
+37
-7
@@ -221,17 +221,47 @@ print('\t'.join(env_flags) + '\n' + ' '.join(binary_tokens))
|
||||
# fresh workspace inside whatever session is active (default or
|
||||
# isolated) and place the agent there. No cross-session label lookup
|
||||
# needed since `--session` already scopes everything.
|
||||
ws_id=$(_real_herdr workspace create --cwd "${ws:-.}" --no-focus 2>/dev/null | python3 -c "
|
||||
import sys, json
|
||||
# Resolve ws_id and split direction:
|
||||
# - If we have up to 3 agents, split 'right' (columns)
|
||||
# - If we have 4 or more agents, split 'down' (rows)
|
||||
res=$(WS_CWD="${ws:-.}" _real_herdr workspace list 2>/dev/null | python3 -c "
|
||||
import sys, json, os
|
||||
try:
|
||||
d = json.loads(sys.stdin.read())
|
||||
print(d.get('result', {}).get('workspace', {}).get('workspace_id', ''))
|
||||
target_label = os.path.basename(os.path.abspath(os.environ.get('WS_CWD', '.')))
|
||||
wlist = json.loads(sys.stdin.read()).get('result', {}).get('workspaces', [])
|
||||
match = None
|
||||
for w in wlist:
|
||||
if w.get('label') == target_label:
|
||||
match = w
|
||||
break
|
||||
if not match and wlist:
|
||||
match = wlist[0]
|
||||
if match:
|
||||
ws_id = match.get('workspace_id', 'w1')
|
||||
pane_count = match.get('pane_count', 0)
|
||||
split_dir = 'right' if pane_count < 3 else 'down'
|
||||
print(f'{ws_id}\t{split_dir}')
|
||||
except Exception:
|
||||
pass
|
||||
")
|
||||
ws_id="${ws_id:-w1}"
|
||||
ws_id=$(echo "$res" | cut -f1)
|
||||
split_dir=$(echo "$res" | cut -f2)
|
||||
|
||||
eval "_real_herdr agent start \"$name\" --workspace \"$ws_id\" --cwd \"${ws:-.}\" $env_flags -- $final_cmd"
|
||||
if [ -z "$ws_id" ]; then
|
||||
ws_id=$(_real_herdr workspace create --cwd "${ws:-.}" --no-focus 2>/dev/null | python3 -c "
|
||||
import sys, json
|
||||
try:
|
||||
d = json.loads(sys.stdin.read()).get('result', {}).get('workspace', {}).get('workspace_id', '')
|
||||
print(d)
|
||||
except Exception:
|
||||
pass
|
||||
")
|
||||
split_dir="right"
|
||||
fi
|
||||
ws_id="${ws_id:-w1}"
|
||||
split_dir="${split_dir:-right}"
|
||||
|
||||
eval "_real_herdr agent start \"$name\" --workspace \"$ws_id\" --split \"$split_dir\" --cwd \"${ws:-.}\" $env_flags -- $final_cmd"
|
||||
;;
|
||||
kill-session)
|
||||
sess=""
|
||||
@@ -1231,7 +1261,7 @@ isolation_env_prefix() {
|
||||
local agent="$1" root="$2"
|
||||
case "$agent" in
|
||||
claude) printf 'CLAUDE_CONFIG_DIR=%q ' "$root" ;;
|
||||
agy|hermes) printf 'HOME=%q ' "$root" ;;
|
||||
agy|hermes) printf 'HOME=%q https_proxy=http://127.0.0.1:9999 no_proxy=googleapis.com ' "$root" ;;
|
||||
*) : ;;
|
||||
esac
|
||||
}
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
# Generated by pub
|
||||
# See https://dart.dev/tools/pub/glossary#lockfile
|
||||
packages: {}
|
||||
sdks:
|
||||
dart: ">=3.0.0 <4.0.0"
|
||||
Reference in New Issue
Block a user