feat: improve --help output for AI agents and humans#1080
feat: improve --help output for AI agents and humans#1080patrikbraborec wants to merge 5 commits intomasterfrom
Conversation
Extends the command framework with examples, docsUrl, interactive, and group metadata, reworks the main help menu with category groups, and adds EXAMPLES + LEARN MORE sections modeled after gh. Also fixes misleading namespace descriptions, clarifies the 'actor' entrypoint's relationship to 'apify actor', supports 'help' as a positional arg equivalent to --help, and normalizes sentence punctuation across all descriptions. Refs #1060 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Per-command EXAMPLES and the main help menu now prefix example descriptions with "# " (shell-comment style), matching the `gh` CLI convention. Each example becomes a self-contained copy-paste block, which prevents AI agents from mistaking description prose for part of the command. Also updates the main-help `apify create` example to its interactive form (dropping the stray `my-actor` positional) with a comment explaining the flow, so users don't copy an invocation that looks incomplete. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@TC-MO I added you as optional review, if you want to check the help commands. |
|
Thank you will check in the afternoon |
l2ysho
left a comment
There was a problem hiding this comment.
thx @patrikbraborec, i found one possible problem, pls take a look
The previous help-rewrite logic scanned every positional past index 0 for the literal word "help", which hijacked commands whose own args happened to be "help" (e.g. `actor set-value key1 help` or `actor set-value help value1` would show help instead of writing to the key-value store). Only treat a positional as a help trigger when it is an actual subcommand slot: position 1 when the base command has subcommands, and position 2 only when position 1 is a real subcommand and that subcommand takes no positional args of its own. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Implements the findings from the staff review of the help output rework: prefix bare 'actor' example commands with the current entrypoint so they stay copy-pasteable when viewed under 'apify actor', render the interactive note on namespace commands, drop the now-unused mapGroupBy helper, add unit tests for the help renderers, and note the no-op path of the help-positional rewrite under the actor entrypoint. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
vladfrangu
left a comment
There was a problem hiding this comment.
Can we get some before and after screenshots please 🙏
|
|
||
| static override examples = [ | ||
| { | ||
| description: 'Log in interactively (opens a browser to complete the flow).', |
There was a problem hiding this comment.
Technically you pick an option and then fill it in depending on the option you picked
| command: 'apify login --token apify_api_xxxxx', | ||
| }, | ||
| { | ||
| description: 'Log in by manually pasting a token instead of opening a browser.', |
There was a problem hiding this comment.
This will prompt the token, better to remove this example
|
|
||
| static override interactive = true; | ||
|
|
||
| static override interactiveNote = 'Prompts for confirmation before deleting.'; |
There was a problem hiding this comment.
Lets add the same warning of "it cant be skipped" (even tho technically it can with echo "y" | apify datasets rm xxx
|
|
||
| static override interactive = true; | ||
|
|
||
| static override interactiveNote = 'Prompts for confirmation before deleting.'; |
|
|
||
| static override interactive = true; | ||
|
|
||
| static override interactiveNote = 'Prompts for confirmation before deleting.'; |
| static override interactiveNote = | ||
| 'Prompts for an Actor name and template if not provided. To run non-interactively, pass the name as a positional argument and --template.'; |
There was a problem hiding this comment.
Maybe we need a non-interactive example too?
| /** | ||
| * A "polyfill" for Map.groupBy | ||
| */ | ||
| export function mapGroupBy<K, T>(items: Iterable<T>, keySelector: (item: T, index: number) => K): Map<K, T[]> { |
There was a problem hiding this comment.
Unless it throws errors, dont remove this, as we might want it in the future
Summary
--helpoutput across all CLI commands with structured metadata (descriptions, examples, flags, environment variables) that is useful for both human users and AI agentsinteractiveNote,docsUrl,examples, andaiNotestatic properties to commands for richer help text_BaseCommandRenderer,CommandHelp,CommandWithSubcommands) to support the new structured output format#comments (matches theghCLI convention) in both per-command EXAMPLES and the main help menu, so each example is a self-contained copy-paste blockapify createexample to its interactive form with a#-commented description, instead of the misleadingapify create my-actorinvocationTest plan
yarn lintpassesyarn formatpasses (only untracked.claude/settings.local.jsonfails, not part of the project)yarn buildsucceedsapify <cmd> --helprenders example descriptions as#commentsapify helpmain menu shows the commentedapify createexampleCloses #1060
🤖 Generated with Claude Code