docs: Generate CLI reference docs for kagent and kmcp - #470
docs: Generate CLI reference docs for kagent and kmcp#470yashrajshuklaaa wants to merge 1 commit into
Conversation
Signed-off-by: Yashraj Shukla <shuklayashraj68@gmail.com>
|
cc @kristin-kronstain-brown PTAL |
|
All checks are green except " |
|
@yashrajshuklaaa Looking good!
Three blocking items, then a decision I would like your view on. Biggest things to look at1. The The link checker only scans 2. Five pages ship a truncated meta description. The script already parses the correct string as All five are non-root commands, so While you are in that function: the frontmatter is emitted as unquoted YAML built from 3. Ten pages lose their worked examples, because those commands have no Cobra
Should fixGenerating docs is not side-effect free. Your reasoning about In CI the practical impact is nil, since the runner's home is thrown away. Two reasons to fix it anyway:
Pointing Worth correcting the claim in the PR description either way, since it is the sentence a reviewer leans on when deciding this is safe to run unattended. ANSI color silently destroys parsing, and nothing catches it. This one is kmcp-only. kagent uses the stock Cobra template and emits no escapes at all, but kmcp's Every header comparison in
That second assertion is the general guard, and it also covers the next item.
Wire
The generator overwrites Two suggestionsFix the kmcp template typos upstream and delete two parser special-cases. You worked around On "one approach for both": the uniformity argument is real and I am not asking you to change course. But it is worth naming that for kmcp the native path would sidestep every workaround in this script at once — Related: the output is already not fully uniform. kmcp's custom template uses Two things for us, not you
On the Thank you for the time you are spending on this! |
kristin-kronstain-brown
left a comment
There was a problem hiding this comment.
Left a comment.
Closes #262.
What this does
Adds automated CLI reference doc generation for both
kagentandkmcp, replacing kagent's hand written CLI pages and kmcp's flat manual pages. Wired into the existingupdate-ref-docs.yamlworkflow, same as the API and Helm docs.Why this approach
kagentandkmcpare not built the same way internally.kmcpexports its Cobra root command from a public package, so it could be documented natively usingcobra/doc.kagent's root command sits insidepackage mainand usesinternal/packages, so it cannot be imported from an external repo at all, this is a Go language restriction, not something fixable from the website side.Since native generation is not available for both CLIs equally, this PR uses one approach for both: build the real binary in CI, then walk
<binary> <path> --helprecursively to reconstruct the full command tree. This is the same category of approach used inagentgateway/website'sgenerate-agctl-ref.py, linked as prior art in the issue, though that script parses source statically while this one reads the actual compiled binary's output.Calling
--helprecursively is safe, Cobra intercepts it before anyPreRun/RunEhooks run, so no side effects like docker-compose or cluster calls get triggered during generation.What is new
scripts/generate-cli-docs.py: the generator script. Produces one Hugo page per command, matching the existingkagent-<command>.mdnaming style, with frontmatter, flags, subcommand links, and examples.scripts/audit-cli-docs.py: a small check script that verifies frontmatter, code fences, and section formatting before the generated pages get committed..github/workflows/update-ref-docs.yaml: build each CLI binary, smoke test it with--help, then generate docs into the right content folders.Content changes
docs-site/content/kagent/resources/cli/: fully regenerated, as agreed in the issue. Nested subcommands now get their own pages instead of being folded into one parent page, so future subcommands get documented automatically.docs-site/content/kmcp/reference/: the 9 existing manual CLI pages moved into a newcli/subfolder and are now generated, matching kagent's structure.kagent-help.mdandkmcp-help.mdremoved, Cobra's built in help command has no real content of its own.completionis kept, since it documents actual shell specific subcommands that are genuinely useful.Drift this caught
Regenerating from real
--helpoutput showed the old manual docs had gone stale in a few places:kagent deploystill documented--api-key/--api-key-secret, which do not exist anymore (--env-filereplaced them)kagent invokestill documented--url-override, replaced by--tokengemini-2.0-flash, actual default is nowgemini-2.5-flashKnown trade-off
The old
kagent-mcp.mdhad hand written links to kmcp's dedicated reference pages.--helptext cannot express that kind of cross-repo relationship, so those specific links are not present in the generated version. Happy to add them back manually if maintainers would like that.Testing done
--helptext of both CLIs, not just a sample fixture. This caught and fixed a few real issues:Available Commands::with double colon,GlobalFlags:with no space), now handledinitcommand prints a duplicatedExamples:section, only the first one is kept now.mdfilenames, which do not resolve under Hugo's URL scheme, fixed to use correct relative paths--configflag default was leaking the machine's actual home directory into the docs, now shown as the generic$HOMEplaceholderscripts/audit-cli-docs.pyruns clean across all 61 generated pageshugo server, including clicking through nested subcommand linksFollow ups (not blocking this PR)
cobra/docgeneration like kmcp, without changing the page layout.kagent-mcp.mdcross-links mentioned above, if maintainers want them restored.