Skip to content
This repository was archived by the owner on Feb 25, 2026. It is now read-only.

feat: add kilo help --all command and auto-generated CLI reference docs#571

Closed
maphew wants to merge 6 commits intoKilo-Org:devfrom
maphew:feat/help-all-command
Closed

feat: add kilo help --all command and auto-generated CLI reference docs#571
maphew wants to merge 6 commits intoKilo-Org:devfrom
maphew:feat/help-all-command

Conversation

@maphew
Copy link
Contributor

@maphew maphew commented Feb 21, 2026

Summary

  • Add kilo help --all command that outputs full CLI reference in markdown or plain text format (#560)
  • Add generateCommandTable() function that produces a markdown command table from the command barrel
  • Auto-generate two docs artifacts via script/generate.ts: a Markdoc partial for the command table and a full CLI Command Reference page
  • Replace the hand-written (stale) command table in cli.md with the generated partial
  • Add CLI Command Reference nav entry in the docs site

Closes Kilo-Org/kilocode#6294, closes Kilo-Org/kilocode#6291

Credit

The quick-reference table format was inspired by @Githubguy132010's contribution in Kilo-Org/kilocode#6294 — thanks for the idea!

Changes

kilo help command

  • src/kilocode/help.ts — Core generateHelp() + new generateCommandTable() functions
  • src/kilocode/help-command.tsHelpCommand yargs CommandModule
  • src/cli/commands.ts — Barrel file exporting all CommandModule objects
  • src/index.ts — Replaced 19 individual .command() calls with barrel import + loop

Auto-generated docs

  • script/generate-cli-docs.ts — Generation script (runs with --conditions=browser)
  • src/kilocode/generate-cli-docs.ts — Entrypoint that writes both generated files
  • script/generate.ts — Added CLI docs generation step before format
  • packages/kilo-docs/markdoc/partials/cli-commands-table.md — Generated command table partial
  • packages/kilo-docs/pages/code-with-ai/platforms/cli-reference.md — Generated full reference page

Docs site updates

  • packages/kilo-docs/pages/code-with-ai/platforms/cli.md — Replaced hand-written table with {% partial %}
  • packages/kilo-docs/lib/nav/code-with-ai.ts — Added "Command Reference" subLink under CLI

Usage

kilo help --all                    # Full CLI reference in Markdown
kilo help auth                     # Scoped to auth command + subcommands
kilo help --all --format text      # Plain text format
kilo help --all > REFERENCE.md     # Pipeable to file

Testing

  • 15 tests in test/kilocode/help.test.ts (no mocks) — markdown/text output, subcommands, filtering, ANSI stripping, table generation, edge cases
  • Typecheck clean (bun turbo typecheck)
  • Docs build succeeds with new cli-reference page

…or text

Add a 'kilo help' command that outputs the full CLI reference as Markdown
or plain text, with support for scoping to a single command.

- Extract command registrations into src/cli/commands.ts barrel
- Implement generateHelp() in src/kilocode/help.ts using yargs internals
- Add HelpCommand with --all, --format, and [command] positional
- 8 tests covering markdown/text output, scoping, ANSI stripping, errors
@kilo-code-bot
Copy link
Contributor

kilo-code-bot bot commented Feb 21, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

All previously flagged issues (empty catch block, missing await, unused options.all, local path leak, missing AttachStub in tests) have been addressed in subsequent commits (faecb4a, 81b1904). The implementation is clean and well-tested.

Highlights

  • generateHelp() and generateCommandTable() are well-separated concerns with clear responsibilities
  • Tests use real command definitions (no mocks), exercising actual behavior
  • ANSI stripping and process.cwd() sanitization prevent path leaks in generated docs
  • The yargs internals usage is documented with a graceful fallback in the catch block
  • The commands barrel (commands.ts) cleanly separates command registration from CLI setup
Files Reviewed (10 files)
  • packages/opencode/src/kilocode/help.ts — Core help generation logic
  • packages/opencode/src/kilocode/help-command.tskilo help command definition
  • packages/opencode/src/kilocode/generate-cli-docs.ts — Doc generation script
  • packages/opencode/src/cli/commands.ts — Commands barrel
  • packages/opencode/src/index.ts — CLI entry point (barrel integration)
  • packages/opencode/test/kilocode/help.test.ts — Tests
  • packages/kilo-docs/lib/nav/code-with-ai.ts — Nav config update
  • packages/kilo-docs/markdoc/partials/cli-commands-table.md — Generated table
  • packages/kilo-docs/pages/code-with-ai/platforms/cli-reference.md — Generated reference
  • script/generate-cli-docs.ts — Root generation script wrapper
  • script/generate.ts — Generation pipeline integration
  • specs/cli-docs-generation.md — Spec document
  • specs/help-all-command.md — Spec document

@maphew
Copy link
Contributor Author

maphew commented Feb 21, 2026

Note on duplicate PR

There's also #570 targeting this issue. Both are valid approaches — here's a quick comparison for reviewers:

#570 uses a static registry — a hand-written data structure (~250 lines) describing every command, option, and subcommand. The output is nicely formatted with Markdown tables for options and a version banner. The downside is that the registry must be manually updated whenever commands change, and nothing enforces that. A few descriptions have already drifted from the actual command definitions (e.g. debug scrap and debug skill).

This PR (#571) uses dynamic introspection — it walks the real CommandModule objects at runtime via yargs internals to generate help text. This means it automatically picks up any command added to or changed in the barrel, so it can't drift out of sync. The tradeoff is the output is less polished (code-fenced yargs help text rather than structured tables), and it relies on yargs internal APIs (documented in code, with graceful fallback if they change).

#570 (static) #571 (dynamic)
Accuracy over time Requires manual sync Always matches reality
Output polish Structured tables Code-fenced help text
Maintenance cost Update registry per command change None
Fragility None (static data) Yargs internals (with fallback)
Commands barrel Not extracted Extracted for reuse
File location src/cli/cmd/ (upstream path) src/kilocode/ (lower merge conflict risk)
Testability Monkey-patches stdout Pure function, no patching

Either approach works — the core question is whether the team prefers polished static output that needs maintenance, or auto-generated output that stays correct on its own.

}): Promise<string> {
const format = options.format ?? "md"

const all = options.commands ?? (await loadCommands())
Copy link
Contributor

Choose a reason for hiding this comment

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

[WARNING]: options.all is accepted but never read

The all boolean in the function signature (line 159) is never checked. When no command is specified, generateHelp always returns help for every command regardless of options.all. This means generateHelp({ all: false }) still dumps the full reference.

Either use the flag to gate the behavior (e.g., return early or show a usage hint when all is falsy and no command is set), or remove it from the signature to avoid confusing future callers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 81b1904options.all now gates the filtering via an IIFE. When neither all nor command is set, relevant is empty and the function returns an empty string.

Add generateCommandTable() to help.ts and a generation script that
produces two artifacts: a Markdoc partial for the command table and
a full CLI reference page. Both are generated by script/generate.ts
and auto-committed by the generate.yml workflow on push to dev.

Replace hand-written command table in cli.md with the generated
partial and add a nav entry for the new CLI Command Reference page.

Closes #572
@maphew maphew changed the title feat: add kilo help --all command for full CLI reference feat: add kilo help --all command and auto-generated CLI reference docs Feb 21, 2026
…add AttachStub

- Add missing await on .rejects.toThrow() assertion (false-positive risk)
- Gate generateHelp on options.all so callers get empty output when
  neither all nor command is set
- Sanitize process.cwd() paths in generated CLI reference (was leaking
  developer's local path into published docs)
- Add AttachCommand stub to test commands array for full coverage
@markijbema
Copy link
Contributor

Hi! Thank you for taking the time to contribute to this project—we really appreciate it. 🙏

We are currently working on re-platforming the core of our VS Code and JetBrains extensions to be based on our new Kilo CLI, with a complete rebuild based on OpenCode as our new foundation, and the moment has come to promote this repository to become the main repository. To do that, we moved the code from this repository to the kilocode repository.

This unfortunately means we cannot merge this branch here anymore. Please add https://github.com/Kilo-Org/kilocode.git as a remote, and push your branch there and create a new PR in https://github.com/Kilo-Org/kilocode . We unfortunately cannot do this for you as then the PR would not be in your name anymore. If you need any help, feel free to ask on our Discord in #kilo-dev-contributors

Sorry for the inconvenience and thank you for contributing to Kilo!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Auto-generate CLI reference docs from help.ts [FEATURE]: add kilo help --all to dump full CLI reference as markdown

2 participants