Skip to content

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

Open
maphew wants to merge 13 commits intoKilo-Org:mainfrom
maphew:feat/help-all-command
Open

feat: add kilo help --all command and auto-generated CLI reference docs#6116
maphew wants to merge 13 commits intoKilo-Org:mainfrom
maphew:feat/help-all-command

Conversation

@maphew
Copy link
Copy Markdown
Contributor

@maphew maphew commented Feb 22, 2026

Note: Re-created from Kilo-Org/kilo#571 per @markijbema's request, since the repo has moved to kilocode.

Closes #6114

Summary

  • Add kilo help --all command that outputs full CLI reference in markdown or plain text format
  • 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

Credit

The quick-reference table format was inspired by @Githubguy132010's contribution in #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
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 Kilo-Org#572
…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
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Feb 22, 2026

⚠️ No Changeset found

Latest commit: 246ced8

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot bot commented Feb 22, 2026

Code Review Summary

Status: 10 Issues Found | Recommendation: Address before merge

Fix these issues in Kilo Cloud

Overview

Severity Count
CRITICAL 1
WARNING 4
SUGGESTION 5
Issue Details (click to expand)

CRITICAL

File Line Issue
packages/opencode/src/index.ts 142 The automatic one-time JSON→SQLite database migration runs inside yargs middleware, which executes for every CLI command including kilo help. This means a user running kilo help --all could trigger a potentially minutes-long migration. Consider gating the migration to only run for commands that actually need the database.

WARNING

File Line Issue
packages/opencode/src/cli/commands.ts 45 kilo db command is included in the commands barrel but was previously not registered in the CLI. Verify this is intentional — if DbCommand was deliberately excluded before, re-adding it via the barrel could expose unfinished functionality.
packages/opencode/src/kilocode/help.ts N/A generateHelp with --all filters to commands where c.describe is truthy (line 169). In yargs, hidden commands have describe: false. This means hidden/internal commands are silently excluded from kilo help --all output, contradicting the spec which says hidden commands should appear with an [internal] callout.
packages/opencode/src/kilocode/help.ts N/A Log.Default.warn() in getSubcommands (line 76) writes to the log file. In a CLI tool where stdout is the primary output channel, this is fine. But if the log is configured to print to stderr (via --print-logs), the warning will be visible to users when yargs internals change. Consider whether this should be a debug-level log instead.
packages/opencode/src/kilocode/generate-cli-docs.ts N/A path.resolve(import.meta.dir, "../../../..") (line 4) computes the monorepo root by counting parent directories. This is fragile — if the file is moved to a different depth, the path breaks silently. Consider using a more robust root-finding approach (e.g., walking up to find package.json with workspaces).

SUGGESTION

File Line Issue
packages/opencode/src/kilocode/help.ts N/A The variable name all in the IIFE at line 167 (relevant) is fine, but the parameter name all in generateHelp options could be confused with the local cmds variable. Consider renaming to showAll for clarity.
packages/opencode/src/kilocode/help-command.ts N/A kilo help with no args outputs a usage hint to stdout. Consider whether this should also show the standard --help output (command list) for discoverability, or at minimum mention kilo --help as an alternative.
packages/opencode/src/index.ts 10 Filesystem import — this is actually still used at line 107 (Filesystem.exists(marker)), so the import is NOT dead.
packages/opencode/src/index.ts N/A Unrelated change — switched from individual .command() calls to a for loop over the commands barrel. This is a good refactor but changes the registration order, which could affect yargs command matching priority. Verify the TUI default command ($0) still takes precedence correctly.
packages/opencode/src/kilocode/generate-cli-docs.ts N/A Uses string concatenation for file paths (root + "packages/...") instead of path.join(). While functional, path.join() is more robust across platforms.
Other Observations (not in diff)
  • The generated cli-reference.md and cli-commands-table.md are auto-generated files. Their content correctness depends on the generateHelp and generateCommandTable functions working correctly at generation time.
  • The spec files (specs/cli-docs-generation.md, specs/help-all-command.md) are well-written and provide good context for the implementation. They are documentation-only and don't affect runtime behavior.
  • Test coverage in help.test.ts is solid — tests use real command definitions (no mocks), cover markdown/text formats, subcommand extraction, edge cases, and the command table generator.
Files Reviewed (14 files)
  • packages/kilo-docs/lib/nav/code-with-ai.ts - 0 new issues
  • packages/kilo-docs/markdoc/partials/cli-commands-table.md - 0 new issues (auto-generated)
  • packages/kilo-docs/pages/code-with-ai/platforms/cli-reference.md - 0 new issues (auto-generated)
  • packages/kilo-docs/pages/code-with-ai/platforms/cli.md - 0 new issues
  • packages/opencode/src/cli/commands.ts - 1 existing issue
  • packages/opencode/src/index.ts - 2 existing issues
  • packages/opencode/src/kilocode/generate-cli-docs.ts - 2 existing issues
  • packages/opencode/src/kilocode/help-command.ts - 1 existing issue
  • packages/opencode/src/kilocode/help.ts - 3 existing issues
  • packages/opencode/test/kilocode/help.test.ts - 0 new issues
  • script/generate-cli-docs.ts - 0 new issues
  • script/generate.ts - 0 new issues
  • specs/cli-docs-generation.md - 0 new issues (spec doc)
  • specs/help-all-command.md - 0 new issues (spec doc)

maphew and others added 4 commits February 28, 2026 11:35
- Restore JSON→SQLite migration code accidentally removed from middleware
- Replace console.warn with Log.Default.warn in help.ts
- Fix Windows path: use path.resolve(import.meta.dir) instead of new URL().pathname
- Revert unrelated process.stderr.write→console.error change
- Require --all flag explicitly; kilo help with no args shows usage hint

Amp-Thread-ID: https://ampcode.com/threads/T-019ca5c0-c077-76ab-9e52-4a2a7e8ed1a7
Co-authored-by: Amp <amp@ampcode.com>
@maphew
Copy link
Copy Markdown
Contributor Author

maphew commented Feb 28, 2026

Bot Review Scorecard — All Issues Addressed

# Severity Issue Status
1 CRITICAL Migration code removed from \index.ts\ ✅ Restored (commit 5a29c23)
2 WARNING \console.warn\ in \help.ts\ visible to users ✅ Changed to \Log.Default.warn\
3 WARNING Windows path in \generate-cli-docs.ts\ ✅ Fixed with \path.resolve(import.meta.dir)\
4 WARNING \kilo db\ dropped from CLI registration 🚫 Not a real issue — \DbCommand\ was always in the barrel
5 WARNING \generateHelp\ includes commands without \describe\ 🚫 Not a real issue — line 168 already filters && c.describe\
6 SUGGESTION Confusing variable name \�ll\ 🚫 Already named \
elevant\ in current code
7 SUGGESTION Unnecessary \kilocode_change\ marker in \generate-cli-docs.ts\ 🚫 No such marker exists in the file
8 SUGGESTION \kilo help\ with no args dumps full reference ✅ Now shows usage hint, requires --all\ explicitly
9 SUGGESTION Dead \Filesystem\ import ✅ No longer dead — used by restored migration code
10 SUGGESTION Unrelated \console.error\ change ✅ Reverted to original \process.stderr.write\
11 OTHER Empty \openapi.json\ artifact ✅ Removed (commit 1e8de62)
12 OTHER \DbCommand\ missing from test fixture ✅ Added (commit 1e8de62)
13 OTHER Generated docs stale (missing \kilo db) ✅ Regenerated (commit 7a72a65)

CI status: typecheck ✅ · unit (linux/windows) ✅ · docs build ✅ · link-checker ✅ · e2e ❌ flaky (unrelated \projects-switch.spec.ts)

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: add kilo help --all command and auto-generated CLI reference docs

1 participant