Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/cli.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,24 @@ registerUsage(program)
registerAnalytics(program)
registerPing(program)

// 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)
Loading