From ccf2d0387f3d7bbf2c1e9bc41aff3896b11bb0b7 Mon Sep 17 00:00:00 2001 From: hbrooks Date: Thu, 16 Jul 2026 10:38:23 -0400 Subject: [PATCH 1/2] feat(cli): bare `agent` opens a connected session 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. --- src/cli.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/cli.tsx b/src/cli.tsx index d91cc45..598058c 100644 --- a/src/cli.tsx +++ b/src/cli.tsx @@ -43,4 +43,12 @@ registerUsage(program) registerAnalytics(program) registerPing(program) +// Bare `agent` (no args at all) drops into a fresh connected session, as a +// shorthand for `agent session start --connect`. Everything else parses +// untouched — `agent --help`/`--version` still print the full top-level help, +// and every subcommand dispatches normally. +if (process.argv.length === 2) { + process.argv.push('session', 'start', '--connect') +} + await program.parseAsync(process.argv) From cc1a1a39139b1578341e7b3a1a17bd023667fd41 Mon Sep 17 00:00:00 2001 From: hbrooks Date: Thu, 16 Jul 2026 10:40:56 -0400 Subject: [PATCH 2/2] feat(cli): forward prompt + flags to connect for non-subcommand args 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. --- src/cli.tsx | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/cli.tsx b/src/cli.tsx index 598058c..99c460b 100644 --- a/src/cli.tsx +++ b/src/cli.tsx @@ -43,12 +43,24 @@ registerUsage(program) registerAnalytics(program) registerPing(program) -// Bare `agent` (no args at all) drops into a fresh connected session, as a -// shorthand for `agent session start --connect`. Everything else parses -// untouched — `agent --help`/`--version` still print the full top-level help, -// and every subcommand dispatches normally. -if (process.argv.length === 2) { - process.argv.push('session', 'start', '--connect') +// Any invocation that isn't a known subcommand or a top-level help/version +// request is shorthand for `agent session start --connect ...`. So a bare +// `agent`, and `agent "fix the tests" --model ...`, both forward the prompt +// and every trailing flag through to a fresh connected session. `agent --help`, +// `agent --version`, `agent help`, and every subcommand dispatch unchanged. +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') } await program.parseAsync(process.argv)