Skip to content

simulate: list, view and export subcommands - #968

Merged
u9g merged 5 commits into
mainfrom
jason/simulate-subcommands
Sep 11, 2026
Merged

u9g merged 5 commits into
mainfrom
jason/simulate-subcommands

Conversation

@u9g

@u9g u9g commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Requested in Slack: lk agent simulate --view can reopen a past run, but there was no way to list runs to find an ID.

Rather than add --list next to --view and --export, this makes the run operations subcommands. Each of those flags took an ID and replaced the whole run action, and audio inherited them, so lk agent simulate audio --view ID parsed and did something meaningless. A flag that swaps the action is a subcommand; this matches the noun/verb shape of the rest of lk (lk agent list, lk room list, lk egress list) and the git stash / git stash list / git stash show precedent of a verb whose bare form does the main thing.

lk agent simulate                     prints the subcommand list, runs nothing (was: text run)
lk agent simulate text [entrypoint]   run, text mode (new; was bare simulate)
lk agent simulate audio [entrypoint]  run, audio pipeline (unchanged)
lk agent simulate list                newest runs for the project (new)
lk agent simulate view <run-id>       was --view
lk agent simulate export <run-id>     was --export

Commit 1 turns --view/--export into view/export with a positional run ID and updates the exit hints to print the new forms. The old flags are removed, not aliased: the hint is reprinted after every run, so only stale scrollback breaks.

Commit 2 adds list: one ListSimulationRuns call for the project's first page (server returns newest first, 20 per page, no jobs), rendered like lk agent list with --json for the raw response.

Commit 3 adds --limit to list, the same next_page_token loop as lk egress list: unset keeps the single-page default, --limit N walks pages until N runs are collected. --json prints the collected runs inside the List response so the field formatting is unchanged. No filters yet.

Commit 4 adds text: simulate audio names its mode, so simulate text should exist too.

Commit 5 makes bare simulate a help command. With list/view/export under it, a verb that also runs on its own is the odd one out, and lk agent simulate typed alone now shows the options instead of starting a run. The project is not resolved on the help path. Docs that say lk agent simulate for a text run need to say lk agent simulate text.

The run flags on simulate stay persistent, so list/view/export still parse --scenarios etc. and ignore them. Making them local would break lk agent simulate --scenarios f audio: urfave/cli v3 resolves a flag by the first command in the lineage that declares it and re-runs PreParse on the child's flags, so a shared or duplicated flag loses the value parsed on the parent.

Tested against my dev project: list, list --limit 3, list --json, view <id> (CI and TUI paths), export <id>. Paging tested against a staging project with 184 runs: --limit 45 returned 45 unique runs across three pages, newest first with no seam; --limit 1000 drained all 184.

u9g added 2 commits September 8, 2026 14:12
--view ID and --export ID each replaced the whole run action from inside
a flag, and audio inherited both. A flag that takes an ID and swaps the
action is a subcommand, so they become `lk agent simulate view <run-id>`
and `lk agent simulate export <run-id>`, matching the noun/verb shape of
the rest of lk. The exit hints print the new forms.
`lk agent simulate list` prints the API's first page (newest first) with
ID, created time, status, mode and agent name, or the raw response with
--json, so a run ID can be found without the dashboard.
@u9g
u9g force-pushed the jason/simulate-subcommands branch from 6b361bf to 88f2a00 Compare September 8, 2026 18:13
`lk agent simulate list` fetched only the API's first page (20 runs).
--limit walks next_page_token until that many runs are collected, the
same loop as `lk egress list`; unset keeps the single-page default.
--json now prints the collected runs wrapped in the List response so the
field formatting is unchanged.
@u9g

u9g commented Sep 11, 2026

Copy link
Copy Markdown
Contributor Author

Demo of the subcommands against my dev project: bare lk agent simulate printing help and running nothing, text --help, list, list --limit 3, list --json, export, view in CI mode and in the TUI, and audio --view failing to parse.

simulate-subcommands.mp4

u9g added 2 commits September 11, 2026 12:56
`lk agent simulate text` runs the same text simulation as bare
`lk agent simulate`, so the mode can be spelled out the same way as
`simulate audio`. Bare `simulate` is unchanged.
`lk agent simulate` with no subcommand shows the subcommand list and
does nothing else; a run needs `text` or `audio`. The project is not
resolved for the help path.

@theomonnom theomonnom left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@u9g
u9g merged commit dbd3886 into main Sep 11, 2026
25 checks passed
@u9g
u9g deleted the jason/simulate-subcommands branch September 11, 2026 20:02
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.

2 participants