Skip to content

feat(cli): bare agent opens a connected session#46

Merged
hbrooks merged 2 commits into
mainfrom
feat/bare-agent-connect
Jul 16, 2026
Merged

feat(cli): bare agent opens a connected session#46
hbrooks merged 2 commits into
mainfrom
feat/bare-agent-connect

Conversation

@hbrooks

@hbrooks hbrooks commented Jul 16, 2026

Copy link
Copy Markdown
Member

What

Any agent invocation that isn't a known subcommand or a top-level --help/--version is now shorthand for agent session start --connect ..., forwarding the prompt and every trailing flag into a fresh connected session:

  • agent → opens a connected session
  • agent "fix the tests"agent session start --connect "fix the tests"
  • agent "fix the tests" --model claude-opus-4-8 → prompt + all flags forwarded
  • agent --model claude-opus-4-8 "fix" → leading flags forwarded too

How

src/cli.tsx inspects the first arg before parsing. If it's a known subcommand (or an alias), or a top-level -h/--help/-V/--version/help, it dispatches unchanged. Otherwise it splices session start --connect in front of the args:

const topLevelCommands = new Set([
  'help',
  ...program.commands.flatMap((c) => [c.name(), ...c.aliases()]),
])
const first = process.argv[2]
const isTopLevel =
  first === '-h' || first === '--help' ||
  first === '-V' || first === '--version' ||
  (first !== undefined && topLevelCommands.has(first))
if (!isTopLevel) {
  process.argv.splice(2, 0, 'session', 'start', '--connect')
}

Verification

bun run typecheck passes, and each dispatch path resolves correctly (checked via --help so nothing spends money):

Invocation Resolves to
agent --help top-level help
agent "fix the tests" --help session start (prompt + flags forwarded)
agent --model x "fix" --help session start (leading flag forwarded)
agent session list --help subcommand untouched
agent --version version string

Caveats

  • The prompt must be quoted. agent lets fix the tests (unquoted) becomes four positionals and start takes one [prompt], so Commander errors with "too many arguments". Quoted works.
  • Subcommand typos now forward to connect as a prompt rather than erroring with "unknown command".
  • Bare/prompt invocations start a new session (spin up a sandbox) by default — inherent to making start --connect the default.

hbrooks added 2 commits July 16, 2026 10:38
Rewrite a bare `agent` invocation (no args) to `agent session start
--connect`, so the default entry point drops straight into a fresh
connected session. Gated strictly on argv having no operands, so
`agent --help`/`--version` still print the full top-level help and every
subcommand dispatches unchanged.
Broaden the bare-invocation shorthand into a catch-all: any first arg
that isn't a known subcommand or a top-level help/version request is
treated as `agent session start --connect ...`, so `agent "fix the
tests" --model ...` forwards the prompt and every trailing flag through
to a fresh connected session. Top-level help/version and every
subcommand still dispatch unchanged.
@hbrooks
hbrooks merged commit 6317cfb into main Jul 16, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant