Skip to content

feat: generate CLI reference docs on release - #1033

Open
u9g wants to merge 9 commits into
mainfrom
jason/generate-docs
Open

u9g wants to merge 9 commits into
mainfrom
jason/generate-docs

Conversation

@u9g

@u9g u9g commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

docs.livekit.io's CLI reference is hand-written, so every flag or subcommand change in lk has to be re-documented separately and drifts almost immediately. This makes the CLI's own help text the source of truth for that reference.

  • lk generate-docs <command path> (hidden) prints a command's usage line, its subcommands, and its options as markdown, in the format the docs.livekit.io CLI reference already uses:

    ```shell
    lk agent deploy [options] [working-dir]
    ```
    
    Options for `deploy`:
    
    - `--deployment NAME` (alias `-d`): NAME of the deployment. Defaults to production.
    

    It reads the same flag data --help prints: the first backticked word in a flag's usage is its value placeholder, defaults come from the flag's value, and hidden commands, hidden flags, and the --help flag are left out. The heading, description, and examples around it stay hand-written on the docs page.

  • Help text aligned with the docs: the CLI reference's current descriptions for the agent, simulate, debugger, private-link, cloud auth, project, and docs commands are ported into their help text, and every value flag gets a placeholder (--region REGION rather than --region string). Switching the docs to generated output then changes little on the page, and --help gets the docs' wording. cloud auth --revoke gets the usage text it was missing.

  • What --help knows but the docs dropped: generate-docs now marks required flags ("Required."), names the environment variable a flag reads (LIVEKIT_AGENT_DEPLOYMENT on agent dev, LK_SESSION_PORT on the debugger), and says simulate text and audio take the simulate options.

  • Help text fixed after comparing it with the current docs.livekit.io pages: rollback --version is required (it never defaulted to the previous version); deploy --region and create --deployment were never read, so they're hidden (still accepted); update-secrets --overwrite replaces every secret; deploy --image/--image-tar ignore --deployment; versions --attribute(s) filter; project list --json includes API secrets; init says when --lang, --install, --skills, and --region prompt or fall back; each debugger --json says what it prints; --samples accepts 1 or 3; export takes any finished run; private-link create --endpoint takes an Azure Private Link Service alias.

  • notify-docs.yaml runs when a release is published (prereleases are skipped). It dispatches livekit-cli-released with the tag to livekit/internal-actions, which forwards it to livekit/web. That workflow downloads the release's lk, regenerates the reference with lk generate-docs, and opens a docs PR. It uses the existing org secret SYNC_DISPATCH_TOKEN, the same relay agent-skills uses, so no credential that writes to livekit/web lives in this public repo.

To change wording on docs.livekit.io, edit the command's help text here; the next published release updates the docs.

Related:

How to verify

make build
./bin/lk generate-docs agent deploy
./bin/lk generate-docs agent simulate
./bin/lk agent deploy --help
./bin/lk generate-docs nope   # unknown command: lk nope, exit 1
./bin/lk --help | grep -c generate-docs   # 0, hidden
go test ./cmd/lk

@u9g

u9g commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor Author

lk generate-docs printing agent deploy and agent simulate in the docs.livekit.io CLI reference format, the same help text in lk agent deploy --help with placeholders, the update banner staying on stderr when captured to a file, an unknown command failing, and the command staying hidden from lk --help.

generate-docs.mp4

u9g added 3 commits October 12, 2026 16:24
Prints a command's usage line, subcommands, and options as markdown in
the format docs.livekit.io's CLI reference uses (e.g.
`lk generate-docs agent deploy`). docs.livekit.io regenerates its CLI
reference from this on every release.
Ports the CLI reference's descriptions for the agent, simulate, debugger,
private-link, cloud auth, project, and docs commands into their flag and
subcommand help, and gives every value flag a placeholder, so the
generated reference reads like the current hand-written one.
@u9g
u9g force-pushed the jason/generate-docs branch from 48c59b8 to 3c9fe72 Compare October 12, 2026 20:32
u9g added 4 commits October 15, 2026 10:40
#1040)

* fix: describe --deployment for agent delete and promote

agent delete deletes the whole agent when --deployment is unset, and agent
promote rejects an unset --deployment, so the shared flag's "Defaults to
production" was wrong for both. They now have their own flag, and promote
requires it.

* feat: list command aliases in generate-docs output

Each alias gets its own usage line and joins the options label, the way the
docs.livekit.io CLI reference wrote them by hand (lk agent logs / lk agent tail).

* feat: add generate-docs --list

Prints every command under a path that the reference documents: commands that
are run, and groups with their own options. docs.livekit.io generates a partial
for each, so a new command can't go missing from the reference.
… options

The docs reference lost three things --help shows: which flags are
required (lk agent promote --deployment, lk agent rollback --version),
the environment variable a flag reads (LIVEKIT_AGENT_DEPLOYMENT on
lk agent dev), and that lk agent simulate text and audio take the
options on lk agent simulate.
…reate

Neither flag is read: lk agent create always deploys to production, and
lk agent deploy keeps the region the agent was created in. Both still
parse, hidden, so existing scripts keep working.
Comparing the generated reference with the hand-written docs.livekit.io
pages found help text that was wrong or dropped what the pages said:

- agent rollback --version is required; it never defaulted to the
  previous version.
- agent update-secrets --overwrite replaces every secret, not only the
  keys given.
- agent deploy --image and --image-tar ignore --deployment.
- agent versions --attribute and --attributes filter versions instead of
  recording attributes.
- project list --json includes each project's API key and secret.
- agent init: when --lang, --install, --skills, and --region prompt or
  fall back, that --region is used only with --deploy, and that --deploy
  implies --install.
- --log-level accepts CRITICAL for Python and FATAL for Node.js.
- Each debugger subcommand's --json says what it prints (NDJSON for
  events), and debugger logs has no --json.
- simulate --samples accepts 1 or 3, --pass-rate needs more than one
  sample, and export takes any finished run.
- private-link create --endpoint accepts an Azure Private Link Service
  alias.
@u9g

u9g commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

lk generate-docs marking rollback --version and promote --deployment Required (and the CLI enforcing it), simulate text pointing at the simulate options it takes, dev --deployment listing LIVEKIT_AGENT_DEPLOYMENT, deploy no longer listing the no-op --region and noting --image ignores --deployment, project list --json warning it includes the API secret, and debugger events --json saying it prints NDJSON.

generate-docs-fixes.mp4

- `lk generate-docs` with no command path panicked; it now errors and
  points to --list. --list no longer prints a blank line for the root.
- Required and Default markers come only from the flag definition. The
  generator no longer skips them when the usage text happens to contain
  "Required" or "Default", private-link drops its hand-written
  "Required.", and --help now marks required flags with "(required)".
- The generator prints duration defaults as 30m, not 30m0s, and honors
  HideDefault. The debugger's DefaultText derives from its constants.
- `project add` shows its arguments as optional, since the CLI asks for
  any that are missing.
- `debugger stop --metrics` says it requires --chat-history.
- Help text says "non-interactive mode" instead of "with --yes or
  without a terminal".
- notify-docs fires on `released`, so promoting a prerelease to a full
  release also regenerates the docs. Prereleases still don't trigger it.
- Add generate_docs_test.go, including a pass over the real command tree.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kath0la

kath0la commented Oct 16, 2026

Copy link
Copy Markdown

I made some small changes: some rephrasing, reusing default values, and adding a test. I changed the github action to released from published because it got flagged as not getting triggered by a prerelease getting promoted to a release.

Comment thread cmd/lk/agent_private_link.go Outdated
&cli.StringFlag{
Name: "name",
Usage: "Private link name",
Usage: "`NAME` for the private link. Required.",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sometimes "required" is in the usage text and sometimes it's not (for example, endpoint). It would be preferable to not include it in the text consistently and just use the Required field to document it.

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.

3 participants