docs: Generate CLI reference docs for kagent and kmcp - #470
Open
yashrajshuklaaa wants to merge 1 commit into
Open
docs: Generate CLI reference docs for kagent and kmcp#470yashrajshuklaaa wants to merge 1 commit into
yashrajshuklaaa wants to merge 1 commit into
Conversation
Signed-off-by: Yashraj Shukla <shuklayashraj68@gmail.com>
Contributor
Author
|
cc @kristin-kronstain-brown PTAL |
Contributor
Author
|
All checks are green except " |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.