Skip to content

Conversation

@BYK
Copy link
Member

@BYK BYK commented Dec 13, 2025

Summary

Add self-documenting CLI commands so each command provides its own help metadata. The main help output is generated dynamically from all registered commands, preventing missing documentation.

Changes

  • Add CommandMeta type for command metadata (name, short, usage, long, examples)
  • Each command file (run, tail, mcp, server) exports its own meta object
  • COMMANDS array in cli.ts pairs metadata with handlers
  • help.ts generates help dynamically from the COMMANDS registry
  • Support spotlight help <cmd> and spotlight <cmd> --help for detailed help

Behavior

Invocation Result
spotlight --help Main help (all commands with short descriptions)
spotlight help Main help
spotlight help run Detailed help for run command
spotlight run --help Detailed help for run command

Benefits

  1. Prevention: Adding a new command requires exporting meta, making help text a natural part of development
  2. Colocation: Help text lives with the command logic it describes
  3. Consistency: All commands follow the same pattern
  4. Per-command help: Users can get detailed help for specific commands

- Add CommandMeta type for command metadata (name, short, usage, long, examples)
- Each command file (run, tail, mcp, server) exports its own metadata
- COMMANDS array in cli.ts pairs metadata with handlers
- help.ts generates help dynamically from COMMANDS registry
- Support 'spotlight help <cmd>' and 'spotlight <cmd> --help' for detailed help

This prevents missing documentation by ensuring help text is colocated
with command implementations.
@vercel
Copy link

vercel bot commented Dec 13, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Review Updated (UTC)
spotlightjs Skipped Skipped Dec 13, 2025 2:10am

@BYK BYK deployed to Preview December 13, 2025 01:54 — with GitHub Actions Active
- Add Command type combining meta and handler
- Each command exports default { meta, handler } object
- Simplify COMMANDS array to just [run, tail, mcp, server]
- Change changeset to minor (new feature)

Addresses PR review feedback.
@BYK BYK deployed to Preview December 13, 2025 02:04 — with GitHub Actions Active
Copy link
Member Author

@BYK BYK left a comment

Choose a reason for hiding this comment

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

Addressed both comments:

  1. ✅ Changed changeset from patch to minor

  2. ✅ Refactored to use standardized {meta, handler} export pattern:

    • Added Command type that combines meta and handler
    • Each command file now exports default { meta, handler } satisfies Command
    • COMMANDS array simplified to [run, tail, mcp, server]
    • CLI_CMD_MAP built from this cleaner registry

Previously 'spotlight help run' would incorrectly trigger the special
run command handling, setting cmdArgs to [] instead of ['run'].

Now we check that 'run' is the first positional before applying the
special handling, so 'spotlight help run' works correctly.
@BYK BYK force-pushed the byk/feat/self-documenting-cli-commands branch from bcd8fe7 to bf31248 Compare December 13, 2025 02:10
@BYK BYK deployed to Preview December 13, 2025 02:10 — with GitHub Actions Active
@BYK BYK marked this pull request as ready for review December 13, 2025 02:11
@BYK BYK requested review from betegon December 13, 2025 02:11
console.error(`Unknown command: ${targetCmd}`);
console.error(`Run 'spotlight help' to see available commands.`);
process.exit(1);
}
Copy link

Choose a reason for hiding this comment

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

Bug: Help command shows error for valid "help" subcommand

When a user runs spotlight help help, the CLI prints "Unknown command: help" and exits with error code 1, even though "help" is listed as a valid command in the main help output (line 42). This happens because showCommandHelp searches only the COMMANDS array which contains [run, tail, mcp, server] but not the help command itself. The "help" command is hardcoded in the help text but excluded from the dynamic command registry, creating an inconsistency where users can't get detailed help about the help command.

Additional Locations (1)

Fix in Cursor Fix in Web

@BYK BYK merged commit 91f2ddb into main Dec 14, 2025
20 checks passed
@BYK BYK deleted the byk/feat/self-documenting-cli-commands branch December 14, 2025 14:26
BYK pushed a commit that referenced this pull request Dec 23, 2025
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and publish to npm
yourself or [setup this action to publish
automatically](https://github.com/changesets/action#with-publishing). If
you're not ready to do a release yet, that's fine, whenever you add more
changesets to main, this PR will be updated.


# Releases
## @spotlightjs/[email protected]

### Minor Changes

- Add support for continuous profiling (Profiling V2)
([#1202](#1202))

- Add self-documenting CLI commands with per-command help support
([#1206](#1206))

Each CLI command now provides its own metadata (short description,
usage, detailed help, and examples). The main help output is generated
dynamically from this metadata, and users can get detailed help for
specific commands via `spotlight help <command>` or `spotlight <command>
--help`.

### Patch Changes

- Remove dead code
([#1214](#1214))

- Fix profile visualization issues in trace views:
([#1203](#1203))

- Update frame colors to use vibrant, high-contrast colors for better
visibility
    -   Add custom nanovis palette for Spotlight's dark theme
    -   Fix sunburst center text showing bytes instead of sample counts
    -   Fix treemap visibility with proper color contrast

- added support for AI SDK v2 in AI Mode
([#1216](#1216))

- updated the empty pages of traces and envelopes
([#1213](#1213))

- open external links in default browser
([#1212](#1212))

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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