refactor: complete tmux-to-herdr migration review and enhance workspace reuse logic

This commit is contained in:
Antigravity
2026-07-20 09:21:25 +09:00
parent efadc231fb
commit d7fa9af410
2 changed files with 37 additions and 12 deletions
+37 -7
View File
@@ -221,17 +221,47 @@ print('\t'.join(env_flags) + '\n' + ' '.join(binary_tokens))
# fresh workspace inside whatever session is active (default or # fresh workspace inside whatever session is active (default or
# isolated) and place the agent there. No cross-session label lookup # isolated) and place the agent there. No cross-session label lookup
# needed since `--session` already scopes everything. # needed since `--session` already scopes everything.
ws_id=$(_real_herdr workspace create --cwd "${ws:-.}" --no-focus 2>/dev/null | python3 -c " # Resolve ws_id and split direction:
import sys, json # - 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: try:
d = json.loads(sys.stdin.read()) target_label = os.path.basename(os.path.abspath(os.environ.get('WS_CWD', '.')))
print(d.get('result', {}).get('workspace', {}).get('workspace_id', '')) 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: except Exception:
pass 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) kill-session)
sess="" sess=""
@@ -1231,7 +1261,7 @@ isolation_env_prefix() {
local agent="$1" root="$2" local agent="$1" root="$2"
case "$agent" in case "$agent" in
claude) printf 'CLAUDE_CONFIG_DIR=%q ' "$root" ;; 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 esac
} }
-5
View File
@@ -1,5 +0,0 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages: {}
sdks:
dart: ">=3.0.0 <4.0.0"