Auto-inject --head for in-box gh pr create#15
Conversation
`agentbox-ctl git pr create` (and `gh pr create`) forward args verbatim to the relay, which ran `gh pr create` in the host repo without --head. The host repo isn't on the box's branch and `agentbox/*` branches deliberately get no upstream tracking, so gh aborted with "you must first push the current branch to a remote, or use the --head flag". Default --head to the box branch at the relay (the single host-side executor for the in-box path), for `create` when the caller didn't pass --head. Mirrors the host CLI's existing injectPrCreateHead, now shared from @agentbox/relay so both surfaces use one rule. Covers docker (registered worktree branch) and cloud (probed sandbox HEAD).
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 53dd191. Configure here.
| ): string[] { | ||
| if (op !== 'create') return args; | ||
| if (!branch || branch === 'HEAD') return args; | ||
| if (args.some((a) => a === '--head' || a.startsWith('--head='))) return args; |
There was a problem hiding this comment.
Missing -H short-flag detection causes double injection
Medium Severity
The new injectPrCreateHead helper checks for --head and --head= but not -H, which is gh pr create's documented short form for --head. If a caller passes -H feat/x, the function won't detect it and will prepend an additional --head <box-branch>, resulting in conflicting head-branch arguments. The same incomplete check is duplicated in the cloud-path guard in host-actions.ts.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 53dd191. Configure here.
…ized pruneCloud The orphan-sandbox prune was daytona-only. Generalize pruneDaytona into a provider-agnostic pruneCloud over a CLOUD_PRUNE_PROVIDERS list so vercel and hetzner (both previously unwired despite working backend.list()) enumerate cloud sandboxes and offer to delete the ones missing from state.json. Closes backlog #15.


Summary
agentbox-ctl git pr create(andgh pr create) from inside a box forward args verbatim to the relay, which rangh pr createin the host repo without--head. The host repo isn't checked out on the box's branch, andagentbox/*branches deliberately get no upstream tracking, soghaborted with "you must first push the current branch to a remote, or use the --head flag". It only worked when--headwas passed manually.--headto the box's branch at the relay (the single host-side executor for the in-box path), forcreateonly when the caller didn't already pass--head.injectPrCreateHead(op, branch, args)added to@agentbox/relay; the host CLI's existingagentbox git pr createinjection now delegates to it, so both surfaces use one rule.worktree.branch) and cloud (probed sandbox HEAD).agentbox/*upstream-tracking skip on push.Test plan
pnpm build,pnpm typecheck,pnpm lintcleanpnpm test(relay 90 -> 95: newgh.test.ts+ no-double-inject case; full suite 335 passing)server.test.tsassertsgh pr createemits--head agentbox/box-oneand never double-injects when the caller supplies--headagentbox-ctl git pushthenagentbox-ctl git pr create --base main --title t --body b(no--head) succeeds and the PR head is the box branchNote: this very PR was opened with an explicit
--headbecause the running host relay predates the fix.Note
Low Risk
Scoped to
gh pr createargv shaping after existing auth/prompt gates; no changes to push upstream tracking or token binding.Overview
Fixes in-box
gh pr createwhen the relay runsghin the host repo without--head: GitHub CLI would infer head from the host checkout (wrong branch or missing upstream) and fail unless--headwas passed manually.A shared
injectPrCreateHeadin@agentbox/relayprepends--head <box branch>forcreateonly, when the caller did not already pass--headand a real branch name exists (not empty / detachedHEAD). The host CLI’sagentbox git pr createpath now delegates to the same helper instead of duplicating logic.The relay applies injection on both execution paths: docker uses the registered worktree branch; cloud probes sandbox
git rev-parse --abbrev-ref HEADbefore injecting. Injection runs after host-initiated token validation so params hashing is unchanged.New unit tests cover the helper and relay behavior (including no double-inject when
--headis supplied).Reviewed by Cursor Bugbot for commit 53dd191. Configure here.