fix(agents): correct copilot flag order and mastracode prompt mode

Merged
KI
6mo ago
+4-2

Summary

Audited all 9 supported terminal CLI agents (packages/shared/src/builtin-terminal-agents.ts), upgraded each to latest, and fixed two registry bugs that caused prompts to fail or be silently dropped.

copilot — flag order

promptCommand was copilot -i --allow-tool=write, which rendered to copilot -i --allow-tool=write "PROMPT". commander.js consumes the next token as -i's value, so it absorbed --allow-tool=write and then errored on the prompt:

error: too many arguments. Expected 0 arguments but got 1.

Reordered to copilot --allow-tool=write -i so the prompt heredoc lands directly after -i as its <prompt> value.

mastracode — prompt silently dropped

command: "mastracode" with the default argv transport rendered mastracode "PROMPT". Mastracode's cli.js only runs parseArgs on the headless path (gated by --prompt/-p); the TUI path (tuiMain) constructs MastraTUI without any initialMessage, so the positional arg never reached the agent.

Added promptCommand: "mastracode --prompt" so prompts go through the headless path that actually executes. Upstream has no "interactive + auto-execute prompt" flag (unlike copilot's -i or gemini's -i, --prompt-interactive), so prompt-mode now exits after completion. The no-prompt command: "mastracode" still opens the TUI.

Other agents verified

Rendered the live shell command from buildPromptCommandString for every agent and smoke-tested the prompt path. claude / amp / codex / gemini / opencode / pi / cursor-agent were already correct — claude and mastracode returned actual model output during the test.

Upgrades performed locally

AgentBefore → After
amp0.0.1775751886 → 0.0.1777480150 (amp update)
gemini0.34.0 → 0.38.2 (brew upgrade gemini-cli)
mastracode0.14.0 → 0.16.0 (bun add -g mastracode@latest) — desktop dep also bumped from 0.15.0-alpha.3 → 0.16.0
opencode1.2.21 → 1.14.29 (brew upgrade opencode)
copilot0.0.412 → 1.0.39 (brew upgrade copilot-cli) — major version bump, -i/-p interface unchanged

claude (2.1.123), codex (0.125.0), and pi (0.60.0) were already at latest.

Note: legacy migration string

packages/shared/src/agent-permissions-migration.ts still carries the same copilot -i --allow-all ordering, but its docstring says it intentionally restores pre-#3546 strings to backfill legacy users — leaving it alone deliberately. Open question whether to fix the migration string too, or accept that backfilled users get the broken ordering until they reset to defaults.

Test plan

  • bun test packages/shared — 613 pass
  • bun test apps/desktop/src/main/lib/agent-setup — 54 pass
  • Rendered each agent's prompt command via buildPromptCommandString; all 9 land the prompt in the right slot
  • copilot: copilot --allow-tool=write -i "PROMPT" parses cleanly (no more too many arguments)
  • mastracode: mastracode --prompt "PROMPT" returns model output and exits 0
  • Smoke test in a real Superset terminal pane that starting each agent with a task prompt drops you in interactively (or in mastracode's case, runs the prompt and exits)

Summary by cubic

Fixes prompt handling for copilot and mastracode so prompts parse, run, and return to an interactive session. Also corrects the legacy copilot migration and reverts the desktop mastracode bump to keep workspace versions aligned.

  • Bug Fixes

    • copilot (registry): Reordered to copilot --allow-tool=write -i so the prompt is consumed by -i instead of erroring.
    • copilot (legacy migration): Reordered to copilot --allow-all -i; keeps the --yolo suffix.
    • mastracode: Added promptCommand: "mastracode --prompt" and promptCommandSuffix: "; mastracode" to run the prompt headlessly, then relaunch the TUI on the same thread. Starting without a prompt still opens the TUI.
  • Dependencies

    • Reverted the apps/desktop mastracode bump; workspace remains on 0.15.0-alpha.3.

Summary by CodeRabbit

  • New Features

    • Added a prompt-command capability for the mastracode terminal agent to improve interactive prompts.
  • Chores

    • Updated mastracode to v0.16.0 to pick up latest improvements.
    • Adjusted the Copilot terminal agent’s prompt command ordering for more consistent and predictable behavior, including the legacy override.