-
Notifications
You must be signed in to change notification settings - Fork 332
Description
Problem
The auto-rewrite hook (rtk-rewrite.sh generated by rtk init -g) rewrites all docker compose commands to rtk docker compose, but RTK only supports a subset of subcommands: ps, logs, build.
Any other subcommand (config, up, down, exec, restart, etc.) or global docker compose flags (-f, --project-name) fail immediately:
$ docker compose -f docker-compose.base.yaml -f docker-compose.local.yaml config --services
# Hook rewrites to:
$ rtk docker compose -f docker-compose.base.yaml -f docker-compose.local.yaml config --services
error: unexpected argument '-f' found
Usage: rtk docker compose [OPTIONS] <COMMAND>
The agent then has to detect the failure and retry with /usr/local/bin/docker compose, wasting tokens on the error + retry.
Root cause
In the hook script, the docker compose match is unconditional:
if echo "$MATCH_CMD" | grep -qE '^docker[[:space:]]+compose([[:space:]]|$)'; then
REWRITTEN="${ENV_PREFIX}$(echo "$CMD_BODY" | sed 's/^docker /rtk docker /')"It should only match the subcommands RTK actually implements (ps, logs, build).
Suggested fix
Restrict the hook pattern to supported subcommands only:
if echo "$MATCH_CMD" | grep -qE '^docker[[:space:]]+compose[[:space:]]+(ps|logs|build)([[:space:]]|$)'; thenThis is a one-line change in the hook template. Relates to #276 (which requests adding more subcommands — until they're added, the hook shouldn't rewrite them).
On v0.22.2. Happy to submit a PR if that helps.