fix(lib): strip leading agent binary path unconditionally before herdr agent start

This commit is contained in:
2026-08-14 10:52:43 +09:00
parent 50d12a1bf3
commit 6699159c76
+6 -3
View File
@@ -286,22 +286,25 @@ print('\t'.join(env_flags) + '\n' + ' '.join(binary_tokens))
if echo "$name" | grep -qi "agy"; then kind="agy"
elif echo "$name" | grep -qi "claude"; then kind="claude"
elif echo "$name" | grep -qi "hermes"; then kind="hermes"
elif echo "$name" | grep -qi "cline"; then kind="cline"
elif echo "${final_cmd:-}" | grep -qi "agy"; then kind="agy"
elif echo "${final_cmd:-}" | grep -qi "claude"; then kind="claude"
elif echo "${final_cmd:-}" | grep -qi "hermes"; then kind="hermes"
elif echo "${final_cmd:-}" | grep -qi "cline"; then kind="cline"
fi
;;
esac
# Strip duplicate agent binary name/path from final_cmd if present, preventing Go flag.Parse() positional argument interruption
# Strip duplicate agent binary name/path from final_cmd if present, preventing positional argument misinterpretation
final_cmd=$(python3 -c "
import sys, shlex
cmd = sys.argv[1]
kind = sys.argv[2]
try:
tokens = shlex.split(cmd)
if tokens and (tokens[0] == kind or tokens[0].endswith('/' + kind)):
if len(tokens) > 1 and not tokens[1].startswith('-'):
if tokens:
first = tokens[0]
if first in ('claude', 'agy', 'hermes', 'cline') or any(first.endswith('/' + a) for a in ('claude', 'agy', 'hermes', 'cline')) or (kind and (first == kind or first.endswith('/' + kind))):
tokens = tokens[1:]
print(' '.join(shlex.quote(t) for t in tokens))
except Exception: