ci: add API reference docs generation workflow#1694
Conversation
Package TarballHow to installgh release download pr-1694-tarball --repo aws/agentcore-cli --pattern "*.tgz" --dir /tmp/pr-tarball
npm install -g /tmp/pr-tarball/aws-agentcore-0.22.0.tgz |
|
Claude Security Review: no high-confidence findings. (run) |
agentcore-cli-automation
left a comment
There was a problem hiding this comment.
Overall the pipeline is straightforward and the shared doc-model design is clean. However, I ran the scripts against the current CLI (mentally, using the source) and found three issues that will materially affect the generated docs. All three are fixable with small changes.
I've left inline comments on the specific lines.
| python-version: "3.12" | ||
|
|
||
| - name: Install the published CLI | ||
| run: npm install -g @aws/agentcore |
There was a problem hiding this comment.
Bug: this installs @latest, not the version being released.
The release-main-and-preview.yml workflow publishes preview releases with npm publish --tag preview (not latest). This publish-api-docs workflow triggers on release: [published], which fires for both GA and preview GitHub releases. So when a preview release triggers this workflow, npm install -g @aws/agentcore will pull down the previous GA (latest) version, and the docs will be generated for the wrong version — while the --version step below happily reports whatever was installed, giving false confidence.
Options:
- Install the exact tag from the release event, e.g.
npm install -g @aws/agentcore@${{ github.event.release.tag_name }}(strip a leadingvif your tags carry one). - Only run on GA releases:
if: github.event.release.prerelease == false(and drop preview docs entirely). - Look up the correct dist-tag from the event and install that.
Option 1 is the most robust.
| const m = line.match(/^ {2}([a-z][a-z0-9-]*)(?:\|[a-z0-9-]+)?\b/); | ||
| if (m) found.push(m[1]); | ||
| } | ||
| return found; |
There was a problem hiding this comment.
Bug: discoverCommands() will always return [] because top-level --help is intercepted.
src/cli/cli.ts attaches a custom program.on('option:help', ...) handler that renders an Ink/React TUI (renderHelp(program)) and then calls process.exit(0). That runs before Commander's default text-based help, so agentcore --help never emits the Commands: block this regex is looking for. Even with CI=1 / no TTY, Ink writes React output, not Commander's formatted text.
Net effect: discoverCommands() returns an empty list, so the "leftovers → Other" safety net at line 186 is a no-op — commands added to the CLI but not added to GROUPS here will be silently dropped, exactly what the comment says this code is trying to prevent.
Options:
- Invoke discovery via a channel that isn't intercepted — e.g.
agentcore help commandsor a small AST/program.commands-based dump exposed by the CLI itself. - Remove
discoverCommands()and instead hard-fail in CI if any command fromGROUPSproduces empty help output (see other comment) — that's a stricter contract and doesn't rely on top-level help at all. - Change the CLI's
option:helphandler to fall through to the default text help when stdout isn't a TTY, so scripted consumers work.
| { | ||
| id: 'evaluation', | ||
| title: 'Evaluation & Datasets', | ||
| commands: ['eval', 'evals', 'batch-evaluations', 'dataset'], |
There was a problem hiding this comment.
Bug: 'eval' and 'recommendations' are phantom commands and will render empty stubs.
Checked against src/cli/cli.ts:
- There is no
agentcore eval— the eval subtree is registered underprogram.command('evals')insrc/cli/commands/eval/command.tsx.evalsis already listed on the same line, soevalis a duplicate/typo. registerRecommendationsis defined insrc/cli/commands/recommendations/command.tsxbut is not imported or called fromsrc/cli/cli.ts.agentcore recommendationsdoesn't exist as a runnable command today.
Because help() in this script swallows execFileSync errors and returns '' (extract-cli-model.mjs:82–86), and entryForCommand falls back to a synthesized signature agentcore <cmd> [options] (line 127), both of these will produce entries in the generated .adoc with a fake signature and no description, parameters, or examples — silently broken output rather than a build failure.
Options:
- Remove
'eval'from theevaluationgroup and remove'recommendations'from theoptimizationgroup (and, separately, decide whetherregisterRecommendationsshould be wired up incli.ts). - Make
help()fail loudly when the command produces no output containingUsage:— this would have caught both today and will catch future drift automatically.
Ideally, do both — (2) alone would just turn the current silent breakage into a workflow failure at the next release, but (1) fixes it now.
610353f to
4f1acee
Compare
|
Claude Security Review: no high-confidence findings. (run) |
Coverage Report
|
Auto-generates the API reference as AsciiDoc on each release and uploads it as a build artifact for the docs team to publish.
4f1acee to
cc51892
Compare
|
Thanks for the careful review — addressed in the latest push: Version pin (workflow): Fixed. Now installs the exact release tag (
|
|
Claude Security Review: no high-confidence findings. (run) |
Adds a workflow that auto-generates the CLI command reference as AsciiDoc on each release (by scraping
agentcore <cmd> --help, grouped by category) and uploads it as a build artifact for the docs team to publish.Files: workflow + extractor (
scripts/extract-cli-model.mjs) + renderer (scripts/render_adoc.py). Runs onreleaseandworkflow_dispatch.