✨ Allow send custom binary to the agents (#12770)

This commit is contained in:
Alonso Torres 2026-11-03 09:31:59 +01:00 committed by GitHub
parent 93d36d04d8
commit 2f57d380db
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 43 additions and 13 deletions

View File

@ -85,6 +85,10 @@ target instance is running and its MCP config has been generated:
# 'main', 'ws1' and similar spellings are rejected.
./manage.sh start-coding-agent claude --ws 1
./manage.sh start-coding-agent opencode --ws 2
# Run a different executable (e.g. a wrapper script) with the same MCP
# wiring. --ws and --bin may come in any order.
./manage.sh start-coding-agent claude --bin claude-alt
```
Equivalents by hand (run from inside the workspace directory):

View File

@ -209,15 +209,18 @@ below):
The files are committed templates + an `envsubst` pass; see
[`.devenv/README.md`](../../../.devenv/README.md) for the full layout.
`./manage.sh start-coding-agent <client> [--ws N] [...passthrough]`
`./manage.sh start-coding-agent <client> [--ws N] [--bin EXE] [...passthrough]`
launches the chosen client against one workspace, `cd`'ing into the right
directory and refusing to launch if the instance is not running:
directory and refusing to launch if the instance is not running. `--bin`
runs another executable in place of the client's default one (for example a
wrapper script), with the same MCP wiring:
```bash
./manage.sh start-coding-agent claude # ws0
./manage.sh start-coding-agent opencode --ws 1 # ws1
./manage.sh start-coding-agent vscode # opens VS Code on ws0
./manage.sh start-coding-agent codex --ws 2 # ws2
./manage.sh start-coding-agent claude --bin claude-alt
```
A given AI client session drives **exactly one workspace**, so running N

View File

@ -1085,6 +1085,11 @@ function attach-devenv {
# no flag → ws0 (the live repo at $PWD).
# --ws N → wsN's workspace clone at ${PENPOT_WORKSPACES_DIR}/wsN
# (N is an integer; non-integer values are rejected).
# --bin EXE → run EXE instead of the client's default executable (e.g. a
# wrapper such as 'claude-alt'); the client still picks
# how the MCP config is wired in.
# --ws and --bin may come in any order; everything after them is passed
# through to the client.
# Before launching, the function cd's into the resolved workspace and refuses
# to start unless the target instance's 'main' container is up — the Penpot
# and Serena MCP servers only exist while the devenv is running.
@ -1099,14 +1104,14 @@ function attach-devenv {
# committed templates). Nothing is written to .codex/config.toml,
# so the developer's own Codex config is left untouched.
#
# Usage: ./manage.sh start-coding-agent <claude|opencode|vscode|codex> [--ws N] [...passthrough]
# Usage: ./manage.sh start-coding-agent <claude|opencode|vscode|codex> [--ws N] [--bin EXE] [...passthrough]
function start-coding-agent {
local client="${1:-}"
[[ $# -gt 0 ]] && shift
case "$client" in
""|-h|--help)
echo "Usage: $0 start-coding-agent <claude|opencode|vscode|codex> [--ws N] [...passthrough]" >&2
echo "Usage: $0 start-coding-agent <claude|opencode|vscode|codex> [--ws N] [--bin EXE] [...passthrough]" >&2
return 1
;;
claude|opencode|vscode|codex)
@ -1118,10 +1123,26 @@ function start-coding-agent {
esac
local instance="ws0"
if [[ $# -gt 0 && "$1" == "--ws" ]]; then
instance="$(parse-ws-integer "$2")" || return 1
shift 2
fi
local bin_override=""
while [[ $# -gt 0 ]]; do
case "$1" in
--ws)
instance="$(parse-ws-integer "$2")" || return 1
shift 2
;;
--bin)
if [[ -z "${2:-}" ]]; then
echo "start-coding-agent: --bin requires an executable name or path." >&2
return 1
fi
bin_override="$2"
shift 2
;;
*)
break
;;
esac
done
# --ws is the default-elided flag: only emit it in suggestion strings for
# ws1+; ws0 is the default target so 'run-devenv --agentic' is the right hint.
@ -1162,6 +1183,7 @@ function start-coding-agent {
vscode) bin="code"; cfg_rel=".vscode/mcp.json" ;;
codex) bin="codex"; cfg_rel=".devenv/templates/codex.toml" ;;
esac
[[ -n "$bin_override" ]] && bin="$bin_override"
if ! command -v "$bin" >/dev/null 2>&1; then
echo "start-coding-agent: '$bin' is not on PATH." >&2
@ -1179,13 +1201,13 @@ function start-coding-agent {
cd "$workspace" || return 1
case "$client" in
claude)
exec claude --mcp-config "$cfg_rel" "$@"
exec "$bin" --mcp-config "$cfg_rel" "$@"
;;
opencode)
OPENCODE_CONFIG="$cfg_rel" exec opencode "$@"
OPENCODE_CONFIG="$cfg_rel" exec "$bin" "$@"
;;
vscode)
exec code "$workspace" "$@"
exec "$bin" "$workspace" "$@"
;;
codex)
# Build our servers as `-c mcp_servers.<name>....` overrides from the
@ -1207,7 +1229,7 @@ function start-coding-agent {
echo " .devenv/{shared,templates}/codex.toml." >&2
return 1
fi
exec codex "${codex_args[@]}" "$@"
exec "$bin" "${codex_args[@]}" "$@"
;;
esac
}
@ -1547,7 +1569,8 @@ function usage {
echo " config wired in. cd's into the workspace, refuses to launch if the"
echo " instance is not running, and forwards extra args to the client."
echo " client: claude | opencode | vscode | codex"
echo " Options: --ws N (default: 0). See agentic-devenv.md and"
echo " Options: --ws N (default: 0), --bin EXE (run EXE instead of"
echo " the client's default executable). See agentic-devenv.md and"
echo " .devenv/README.md for per-client setup and override paths."
echo ""
echo "- build-bundle Build all bundles (frontend, backend, exporter, storybook and mcp)."