From d7fa9af4106dabf2d30424243caa09bb2fcaf123 Mon Sep 17 00:00:00 2001 From: Antigravity Date: Mon, 20 Jul 2026 09:21:25 +0900 Subject: [PATCH] refactor: complete tmux-to-herdr migration review and enhance workspace reuse logic --- .agents/skills/lib.sh | 44 ++++++++++++++++++++++++++++++++++++------- pubspec.lock | 5 ----- 2 files changed, 37 insertions(+), 12 deletions(-) delete mode 100644 pubspec.lock diff --git a/.agents/skills/lib.sh b/.agents/skills/lib.sh index 42826b3..097a805 100644 --- a/.agents/skills/lib.sh +++ b/.agents/skills/lib.sh @@ -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 } diff --git a/pubspec.lock b/pubspec.lock deleted file mode 100644 index 573410f..0000000 --- a/pubspec.lock +++ /dev/null @@ -1,5 +0,0 @@ -# Generated by pub -# See https://dart.dev/tools/pub/glossary#lockfile -packages: {} -sdks: - dart: ">=3.0.0 <4.0.0"