feat(lang-core): generate prompts from a subset of the library (componentAllowlist)#658
Open
Shinyaigeek wants to merge 1 commit into
Open
feat(lang-core): generate prompts from a subset of the library (componentAllowlist)#658Shinyaigeek wants to merge 1 commit into
Shinyaigeek wants to merge 1 commit into
Conversation
) library.prompt() always emits every component in the library. For a library with ~54 components that is ~20k tokens even when a screen only needs a handful — bloating the prompt and reducing generation stability for smaller models. Add an opt-in PromptOptions.componentAllowlist that restricts the prompt to a subset: - componentAllowlist.components — only these components appear. Omit for today's behavior (all components); fully backward-compatible. - The library root is always kept so the output stays self-consistent. - Sub-component dependencies are pulled in automatically (transitive closure over the schema refs the library already tracks), so the prompt never references a signature it doesn't show. The root is kept but not used as a closure seed, since roots typically render every component. componentAllowlist.includeDependencies: false opts out. - componentGroups are filtered to the kept set; empty groups are dropped. - Unknown names fail fast with an "Available components: ..." message, matching the existing root validation. Surfaced on the CLI as `openui generate --component-allowlist Card,Table` with `--no-include-dependencies`. Works for user-defined components too — there is no builtin/custom distinction. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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 #633.
Problem
library.prompt()always emits every component in the library. For a library with ~54 components that's ~20k tokens, even when a given screen only needs a handful (e.g.Card/Table/LineChart). That bloats the prompt and — with more component choices — lowers selection accuracy for smaller models. It's especially painful on the CLI / coding-agent path, where the generated prompt stacks on top of the agent's own context.Solution
An opt-in
componentAllowlistonPromptOptions:componentAllowlist.components— when set, only these components appear. OmitcomponentAllowlistfor today's behavior (all components). Fully backward-compatible.includeDependencies: falseopts out and emits exactly the listed components plus root.componentGroupsare filtered to the kept set; empty groups are dropped.Available components: ...message, matching the existingrootvalidation.includeDependencieslives insidecomponentAllowlistso it can't float as a standalone flag and the dependency it controls is unambiguous.CLI
Works for user-defined components too — there's no builtin/custom distinction; it operates on whatever was passed to
createLibrary().Verification
includeDependencies: false, group filtering, unknown-name error, unset default); full lang-core suite passes (79).openuiLibrary: full prompt ≈ 20,340 chars;--component-allowlist Card,Table,LineChart --no-include-dependenciesdrops it to ≈ 9,274.lang-coreand the CLI. Docs updated (system-prompts.mdx,cli.mdx).🤖 Generated with Claude Code