feat(a2ui): add a2ui cli prompt generation#2691
Conversation
🦋 Changeset detectedLatest commit: 843f798 The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds a public a2ui-cli that delegates catalog extraction and prompt generation, introduces ChangesA2UI CLI and Catalog Functions
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
packages/genui/a2ui-cli/bin/cli.js (1)
121-124: 💤 Low valueConsider simplifying the conditional object spreads.
The double ternary with conditional spreads is harder to read than necessary. Since
buildA2UISystemPromptlikely acceptsundefinedvalues or has defaults, consider simplifying:♻️ Simplified approach
const systemPrompt = buildA2UISystemPrompt({ - ...(catalog ? { catalog } : {}), - ...(options.appendix ? { appendix: options.appendix } : {}), + catalog, + appendix: options.appendix, });If the function doesn't accept
undefined, the current approach is fine.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/genui/a2ui-cli/bin/cli.js` around lines 121 - 124, The object construction for systemPrompt is overly verbose; simplify the call to buildA2UISystemPrompt by passing catalog and appendix directly (use catalog and appendix: options.appendix) instead of conditional spreads, i.e., remove the ...(catalog ? { catalog } : {}) and ...(options.appendix ? { appendix: options.appendix } : {}) patterns and pass those properties directly to buildA2UISystemPrompt (unless buildA2UISystemPrompt explicitly rejects undefined—if so, keep the guards).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/genui/a2ui-cli/bin/cli.js`:
- Around line 112-120: When options.catalogDir is used, validate the result of
readA2UICatalogFromDirectory to ensure the returned catalog contains components
or functions and fail with a clear error if it's empty; specifically after
calling readA2UICatalogFromDirectory (the value assigned to catalog) check
properties like catalog.components and catalog.functions (or equivalent arrays)
for length > 0 and, if both are empty or missing, log an explicit error and
terminate (throw or process.exit with a message) instead of proceeding to use
BASIC_CATALOG or generating a prompt with an empty catalog.
In `@packages/genui/a2ui-prompt/src/index.ts`:
- Around line 47-50: The code is blindly casting readJsonObject(catalogJsonPath)
to Record<string, JsonSchema> and may silently drop extra components; change the
logic around componentManifests and readJsonObject to validate the parsed JSON
is an object with exactly one top-level key: call
readJsonObject(catalogJsonPath), assert it is a non-null object, compute
Object.keys(...) and if keys.length !== 1 throw or return a clear error
mentioning catalogJsonPath, otherwise extract that single entry (or keep the
single-entry object) and push the validated JsonSchema into componentManifests;
reference functions/vars: readJsonObject, catalogJsonPath, componentManifests.
---
Nitpick comments:
In `@packages/genui/a2ui-cli/bin/cli.js`:
- Around line 121-124: The object construction for systemPrompt is overly
verbose; simplify the call to buildA2UISystemPrompt by passing catalog and
appendix directly (use catalog and appendix: options.appendix) instead of
conditional spreads, i.e., remove the ...(catalog ? { catalog } : {}) and
...(options.appendix ? { appendix: options.appendix } : {}) patterns and pass
those properties directly to buildA2UISystemPrompt (unless buildA2UISystemPrompt
explicitly rejects undefined—if so, keep the guards).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 20e6d028-ff1c-4cd9-89b8-a22601c2c366
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (21)
packages/genui/a2ui-catalog-extractor/README.mdpackages/genui/a2ui-catalog-extractor/package.jsonpackages/genui/a2ui-catalog-extractor/readme.zh_cn.mdpackages/genui/a2ui-catalog-extractor/src/cli.tspackages/genui/a2ui-cli/AGENTS.mdpackages/genui/a2ui-cli/README.mdpackages/genui/a2ui-cli/bin/cli.jspackages/genui/a2ui-cli/package.jsonpackages/genui/a2ui-prompt/AGENTS.mdpackages/genui/a2ui-prompt/README.mdpackages/genui/a2ui-prompt/package.jsonpackages/genui/a2ui-prompt/rslib.config.tspackages/genui/a2ui-prompt/src/index.tspackages/genui/a2ui-prompt/tsconfig.build.jsonpackages/genui/a2ui-prompt/tsconfig.jsonpackages/genui/a2ui-prompt/turbo.jsonpackages/genui/a2ui/package.jsonpackages/genui/a2ui/tsconfig.build.jsonpackages/genui/server/agent/a2ui-catalog.tspackages/genui/server/agent/a2ui-prompt.tspackages/genui/tsconfig.json
36cb75d to
613de8f
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/genui/a2ui-prompt/src/index.ts (1)
77-80: 💤 Low valueConsider logging or throwing for malformed function definitions.
The code silently skips function values that aren't records, which could hide malformed function definition files. Consider at least logging a warning or throwing an error with the file path to help developers debug invalid function schemas.
📋 Optional enhancement
for (const [name, value] of Object.entries(functionRecord)) { if (!isRecord(value)) { + console.warn( + `[a2ui-prompt] Skipping non-object function entry "${name}" in ${entry.name}`, + ); continue; }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/genui/a2ui-prompt/src/index.ts` around lines 77 - 80, The loop over Object.entries(functionRecord) currently skips non-record values silently; update the block in index.ts (the loop using functionRecord and the isRecord check) to surface malformed function definitions by logging a warning (including the name/key and file path or source identifier) or throwing a descriptive error; ensure the message references the offending key (name) and the loader/context so developers can locate the invalid schema, and keep the existing continue/skip behavior behind a flag or only use logging if you don't want to break runtime.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/genui/a2ui-prompt/src/index.ts`:
- Around line 77-80: The loop over Object.entries(functionRecord) currently
skips non-record values silently; update the block in index.ts (the loop using
functionRecord and the isRecord check) to surface malformed function definitions
by logging a warning (including the name/key and file path or source identifier)
or throwing a descriptive error; ensure the message references the offending key
(name) and the loader/context so developers can locate the invalid schema, and
keep the existing continue/skip behavior behind a flag or only use logging if
you don't want to break runtime.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 3200786f-e5b3-43a7-97be-993065b2aef0
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (21)
packages/genui/a2ui-catalog-extractor/README.mdpackages/genui/a2ui-catalog-extractor/package.jsonpackages/genui/a2ui-catalog-extractor/readme.zh_cn.mdpackages/genui/a2ui-catalog-extractor/src/cli.tspackages/genui/a2ui-cli/AGENTS.mdpackages/genui/a2ui-cli/README.mdpackages/genui/a2ui-cli/bin/cli.jspackages/genui/a2ui-cli/package.jsonpackages/genui/a2ui-prompt/AGENTS.mdpackages/genui/a2ui-prompt/README.mdpackages/genui/a2ui-prompt/package.jsonpackages/genui/a2ui-prompt/rslib.config.tspackages/genui/a2ui-prompt/src/index.tspackages/genui/a2ui-prompt/tsconfig.build.jsonpackages/genui/a2ui-prompt/tsconfig.jsonpackages/genui/a2ui-prompt/turbo.jsonpackages/genui/a2ui/package.jsonpackages/genui/a2ui/tsconfig.build.jsonpackages/genui/server/agent/a2ui-catalog.tspackages/genui/server/agent/a2ui-prompt.tspackages/genui/tsconfig.json
✅ Files skipped from review due to trivial changes (4)
- packages/genui/a2ui-prompt/tsconfig.json
- packages/genui/a2ui-prompt/README.md
- packages/genui/a2ui-catalog-extractor/README.md
- packages/genui/a2ui-catalog-extractor/readme.zh_cn.md
Merging this PR will improve performance by 5.14%
Performance Changes
Tip Curious why this is faster? Comment Comparing Footnotes
|
React External#1724 Bundle Size — 698.01KiB (0%).843f798(current) vs 11ef105 main#1718(baseline) Bundle metrics
|
| Current #1724 |
Baseline #1718 |
|
|---|---|---|
0B |
0B |
|
0B |
0B |
|
0% |
0% |
|
0 |
0 |
|
3 |
3 |
|
17 |
17 |
|
5 |
5 |
|
8.59% |
8.59% |
|
0 |
0 |
|
0 |
0 |
Bundle analysis report Branch Sherry-hue:feat/a2ui-cli-prompt Project dashboard
Generated by RelativeCI Documentation Report issue
Web Explorer#10183 Bundle Size — 903.53KiB (0%).843f798(current) vs 11ef105 main#10177(baseline) Bundle metrics
Bundle size by type
|
| Current #10183 |
Baseline #10177 |
|
|---|---|---|
499.15KiB |
499.15KiB |
|
402.16KiB |
402.16KiB |
|
2.22KiB |
2.22KiB |
Bundle analysis report Branch Sherry-hue:feat/a2ui-cli-prompt Project dashboard
Generated by RelativeCI Documentation Report issue
React Example with Element Template#876 Bundle Size — 201.67KiB (0%).843f798(current) vs 11ef105 main#870(baseline) Bundle metrics
|
| Current #876 |
Baseline #870 |
|
|---|---|---|
0B |
0B |
|
0B |
0B |
|
0% |
27.9% |
|
0 |
0 |
|
4 |
4 |
|
99 |
99 |
|
30 |
30 |
|
39.25% |
39.25% |
|
2 |
2 |
|
0 |
0 |
Bundle size by type no changes
| Current #876 |
Baseline #870 |
|
|---|---|---|
145.76KiB |
145.76KiB |
|
55.91KiB |
55.91KiB |
Bundle analysis report Branch Sherry-hue:feat/a2ui-cli-prompt Project dashboard
Generated by RelativeCI Documentation Report issue
React Example#8607 Bundle Size — 237.81KiB (0%).843f798(current) vs 11ef105 main#8601(baseline) Bundle metrics
|
| Current #8607 |
Baseline #8601 |
|
|---|---|---|
0B |
0B |
|
0B |
0B |
|
0% |
0% |
|
0 |
0 |
|
4 |
4 |
|
200 |
200 |
|
80 |
80 |
|
44.68% |
44.68% |
|
2 |
2 |
|
0 |
0 |
Bundle size by type no changes
| Current #8607 |
Baseline #8601 |
|
|---|---|---|
145.76KiB |
145.76KiB |
|
92.05KiB |
92.05KiB |
Bundle analysis report Branch Sherry-hue:feat/a2ui-cli-prompt Project dashboard
Generated by RelativeCI Documentation Report issue
React MTF Example#1741 Bundle Size — 208.75KiB (0%).843f798(current) vs 11ef105 main#1735(baseline) Bundle metrics
|
| Current #1741 |
Baseline #1735 |
|
|---|---|---|
0B |
0B |
|
0B |
0B |
|
0% |
0% |
|
0 |
0 |
|
3 |
3 |
|
195 |
195 |
|
77 |
77 |
|
44.17% |
44.17% |
|
2 |
2 |
|
0 |
0 |
Bundle size by type no changes
| Current #1741 |
Baseline #1735 |
|
|---|---|---|
111.23KiB |
111.23KiB |
|
97.52KiB |
97.52KiB |
Bundle analysis report Branch Sherry-hue:feat/a2ui-cli-prompt Project dashboard
Generated by RelativeCI Documentation Report issue
8bf4706 to
1cd15a5
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/genui/a2ui-cli/README.md`:
- Around line 67-82: Remove monorepo-specific maintainer instructions from the
"Local Development" section of packages/genui/a2ui-cli/README.md: delete the
repo-internal example commands (the `node packages/genui/a2ui-cli/bin/cli.js
generate prompt --out /tmp/a2ui-system-prompt.txt` usage and the `pnpm -C
packages/genui/a2ui-prompt build` rebuild steps) and replace with a concise,
user-facing instruction for installing or running the published CLI (e.g., how
to install the package globally or use npx), ensuring no workspace paths or
maintainer-only build steps remain.
In `@packages/genui/a2ui-prompt/turbo.json`:
- Around line 11-20: Turbo build.inputs for packages/genui/a2ui-prompt is
missing the upstream server agent sources, which can cause stale dist/** after
changes; update the inputs array in turbo.json (the "inputs" entry in
packages/genui/a2ui-prompt/turbo.json) to include the server agent sources that
this package imports (add the matching path pattern for the upstream files such
as ../../server/agent/** or ../server/agent/** depending on repo layout) so
changes to the server agent (imported in src/index.ts and referenced by
tsconfig.json/tsconfig.build.json) will invalidate the cache and rebuild the
package.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 011be767-3aaf-4aea-8fc3-6af734a9e0f4
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (22)
biome.jsoncpackages/genui/a2ui-catalog-extractor/README.mdpackages/genui/a2ui-catalog-extractor/package.jsonpackages/genui/a2ui-catalog-extractor/readme.zh_cn.mdpackages/genui/a2ui-catalog-extractor/src/cli.tspackages/genui/a2ui-cli/AGENTS.mdpackages/genui/a2ui-cli/README.mdpackages/genui/a2ui-cli/bin/cli.jspackages/genui/a2ui-cli/package.jsonpackages/genui/a2ui-prompt/AGENTS.mdpackages/genui/a2ui-prompt/README.mdpackages/genui/a2ui-prompt/package.jsonpackages/genui/a2ui-prompt/rslib.config.tspackages/genui/a2ui-prompt/src/index.tspackages/genui/a2ui-prompt/tsconfig.build.jsonpackages/genui/a2ui-prompt/tsconfig.jsonpackages/genui/a2ui-prompt/turbo.jsonpackages/genui/a2ui/package.jsonpackages/genui/a2ui/tsconfig.build.jsonpackages/genui/server/agent/a2ui-catalog.tspackages/genui/server/agent/a2ui-prompt.tspackages/genui/tsconfig.json
✅ Files skipped from review due to trivial changes (6)
- packages/genui/a2ui-prompt/package.json
- packages/genui/a2ui/tsconfig.build.json
- packages/genui/a2ui-prompt/AGENTS.md
- packages/genui/tsconfig.json
- packages/genui/a2ui-catalog-extractor/readme.zh_cn.md
- packages/genui/a2ui-prompt/README.md
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/genui/a2ui-prompt/src/index.ts`:
- Around line 34-38: The code only checks existence with fs.existsSync before
calling fs.readdirSync, which causes an unhelpful ENOTDIR when a file path is
passed; update the checks for catalogDir (and the other directory checked around
lines 67-73) to verify the path is a directory by using
fs.statSync(path).isDirectory() (or fs.lstatSync) and throw a clear Error like
`[a2ui-prompt] Catalog directory is not a directory: ${path}` (or analogous
message for the other dir) if the check fails; also catch stat errors and
rethrow a descriptive A2UI error so readdirSync is only called on confirmed
directories.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 42a84134-ea41-4ac9-9b17-796d4ae55b64
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (22)
biome.jsoncpackages/genui/a2ui-catalog-extractor/README.mdpackages/genui/a2ui-catalog-extractor/package.jsonpackages/genui/a2ui-catalog-extractor/readme.zh_cn.mdpackages/genui/a2ui-catalog-extractor/src/cli.tspackages/genui/a2ui-cli/AGENTS.mdpackages/genui/a2ui-cli/README.mdpackages/genui/a2ui-cli/bin/cli.jspackages/genui/a2ui-cli/package.jsonpackages/genui/a2ui-prompt/AGENTS.mdpackages/genui/a2ui-prompt/README.mdpackages/genui/a2ui-prompt/package.jsonpackages/genui/a2ui-prompt/rslib.config.tspackages/genui/a2ui-prompt/src/index.tspackages/genui/a2ui-prompt/tsconfig.build.jsonpackages/genui/a2ui-prompt/tsconfig.jsonpackages/genui/a2ui-prompt/turbo.jsonpackages/genui/a2ui/package.jsonpackages/genui/a2ui/tsconfig.build.jsonpackages/genui/server/agent/a2ui-catalog.tspackages/genui/server/agent/a2ui-prompt.tspackages/genui/tsconfig.json
✅ Files skipped from review due to trivial changes (8)
- biome.jsonc
- packages/genui/tsconfig.json
- packages/genui/a2ui-catalog-extractor/README.md
- packages/genui/a2ui-prompt/AGENTS.md
- packages/genui/a2ui-prompt/README.md
- packages/genui/a2ui-catalog-extractor/readme.zh_cn.md
- packages/genui/server/agent/a2ui-prompt.ts
- packages/genui/a2ui-prompt/tsconfig.build.json
f015684 to
6e56865
Compare
6e56865 to
843f798
Compare
Summary by CodeRabbit
New Features
generate catalogandgenerate promptcommands and a published executable.Documentation
Checklist