Skip to content

feat(cli): support multi-component lookups - #6867

Merged
josephfarina merged 1 commit into
mainfrom
joeyfarina/multi-component-lookups-20261001
Oct 1, 2026
Merged

josephfarina merged 1 commit into
mainfrom
joeyfarina/multi-component-lookups-20261001

Conversation

@josephfarina

@josephfarina josephfarina commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

User need

Agents often know several components they need to inspect. Running one CLI process per component repeats setup work and makes partial failures easy to miss. They should be able to ask once and get one complete result.

Problem and solution fit

astryx component Button Badge Text now accepts ordered exact selectors. It keeps duplicates, resolves every selector, and returns every success or failure before it exits. Existing detail controls like --props, --source, --showcase, --blocks, --detail, --lang, --zh, --dense, and --package apply to each selector.

astryx discover is unchanged. It still treats its arguments as one free-text query.

Current specification

spec:AST-053 is current. The component contract landed in #6868, and the eligible-lookup contract was generalized in #6871. It owns complete ordered receipts, duplicate preservation, the shared BatchResponse and BatchRow vocabulary, aggregate work bounds, ambiguity, and exit 1 when any row is unresolved. spec:AST-042 requires every admitted exact selector to be classified against AST-053.

Public delta and caller burden

Before:

astryx component Button --json
astryx component Badge --json

After:

astryx component Button Badge --json
  • Zero CLI selectors still return component.list.
  • One CLI selector still returns the existing detail or error envelope.
  • Two or more CLI selectors return component.batch with {count, results}.
  • Each row echoes the selector and reports found, not_found, ambiguous, or error.
  • Package-qualified selectors accept package/Component, @scope/package/Component, and exact package versions such as @scope/[email protected]/Component.
  • The CLI prints the complete receipt, then exits 1 when any row is unresolved. JSON and text use the same exit status.
  • A batch accepts at most 100 selectors in every projection. A larger request returns top-level ERR_INVALID_ARGUMENT before any component resolves, with no partial receipt.

The API uses input shape, not array length. component() browses, component('Button') returns one result, and every array returns component.batch, including component([]) and component(['Button']). A found row contains the same typed result that one selector would return. The public API exports shared BatchResponse and BatchRow types, and ComponentBatchResponse specializes them.

Real output

These are exact stdout receipts from this head.

Two found components, exit 0
astryx --detail brief component Spacer Separator
Component batch

count: 2

Results

Spacer

selector: Spacer
status:   found

Result

Spacer(orientation: horizontal|vertical, variant: subtle|strong)  <- from '@astryxdesign/core/Divider'
  A visual separator that divides content into distinct sections. Use to create...
  Targets: astryx-divider preferred attrs: data-orientation, data-variant variants: orientation, variant
  label, isFullBleed, xstyle


Separator

selector: Separator
status:   found

Result

Separator(orientation: horizontal|vertical, variant: subtle|strong)  <- from '@astryxdesign/core/Divider'
  A visual separator that divides content into distinct sections. Use to create...
  Targets: astryx-divider preferred attrs: data-orientation, data-variant variants: orientation, variant
  label, isFullBleed, xstyle

Exit 0.

One found and one missing, exit 1 after the full receipt
astryx --detail brief component Spacer MissingWidget
Component batch

count: 2

Results

Spacer

selector: Spacer
status:   found

Result

Spacer(orientation: horizontal|vertical, variant: subtle|strong)  <- from '@astryxdesign/core/Divider'
  A visual separator that divides content into distinct sections. Use to create...
  Targets: astryx-divider preferred attrs: data-orientation, data-variant variants: orientation, variant
  label, isFullBleed, xstyle


MissingWidget

selector: MissingWidget
status:   not_found
code:     ERR_UNKNOWN_COMPONENT
error:    No component named "MissingWidget"

Exit 1.

All missing as JSON, exit 1 after both rows
astryx --json component MissingWidget MissingPanel
{
  "apiVersion": 1,
  "type": "component.batch",
  "data": {
    "count": 2,
    "results": [
      {
        "selector": "MissingWidget",
        "status": "not_found",
        "code": "ERR_UNKNOWN_COMPONENT",
        "error": "No component named \"MissingWidget\""
      },
      {
        "selector": "MissingPanel",
        "status": "not_found",
        "code": "ERR_UNKNOWN_COMPONENT",
        "error": "No component named \"MissingPanel\""
      }
    ]
  }
}

Exit 1.

Duplicate selectors stay duplicate rows, exit 0
astryx --detail brief component Spacer Spacer
Component batch

count: 2

Results

Spacer

selector: Spacer
status:   found

Result

Spacer(orientation: horizontal|vertical, variant: subtle|strong)  <- from '@astryxdesign/core/Divider'
  A visual separator that divides content into distinct sections. Use to create...
  Targets: astryx-divider preferred attrs: data-orientation, data-variant variants: orientation, variant
  label, isFullBleed, xstyle


Spacer

selector: Spacer
status:   found

Result

Spacer(orientation: horizontal|vertical, variant: subtle|strong)  <- from '@astryxdesign/core/Divider'
  A visual separator that divides content into distinct sections. Use to create...
  Targets: astryx-divider preferred attrs: data-orientation, data-variant variants: orientation, variant
  label, isFullBleed, xstyle

Exit 0.

Empty programmatic batch
await component([])
{
  "type": "component.batch",
  "data": {
    "count": 0,
    "results": []
  }
}

The searchable guide is available through astryx docs cli/component-lookups. astryx search 'look up several components' --type doc returns that guide first.

Design and alternatives

I kept the old zero and one selector CLI contracts instead of always returning an array. I also kept lookup separate from discovery, preserved input order and duplicates, and made ambiguity explicit instead of guessing a package. Arrays always mean batch in the API so filtering a list can't silently change its response type.

Evidence

  • Deterministic chaos coverage includes empty arrays, one item, order, duplicates, all found, mixed outcomes, all failed, and oversized rejection before resolution.
  • Projection coverage runs --props, --source, --showcase, and --blocks across every found row.
  • Detail and language coverage includes full, compact, brief, en, dense, --zh, and --dense.
  • Ownership coverage includes ambiguity candidates, unscoped and scoped packages, exact installed versions, version mismatches, and --package conflicts.
  • JSON and text tests require the same exit status and complete receipts.
  • Shared BatchResponse and BatchRow exports are verified through the packed public API.
  • Generated help, manifest data, response type docs, the CLI README, and cli/component-lookups document the surface.

Scope

  • One capability is added.
  • Unrelated fixes, cleanup, and policy changes were removed or split.
  • Consumer docs, focused tests, and migration evidence ship with the feature.
  • Public text and artifacts contain no internal Meta context.

Testing

  • Full CLI Node suite: 349 files passed, 5,551 tests passed, 2 expected failures.
  • Focused component, ownership, docs, route, search, response-contract, and oversized-batch tests passed.
  • typecheck:strict, typecheck:json-api, typecheck:authoring, and typecheck:template-docs passed.
  • The packed public API verifier passed with the shared batch types.
  • pnpm check:repo, pnpm check:changesets, generated README checks, formatting, and the public-boundary scan passed.
  • The five receipts above were replayed on this head with exit codes 0, 1, 1, 0, and 0.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 1, 2026
@vercel

vercel Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Oct 1, 2026 10:41pm UTC

Request Review

@astracat-bot

astracat-bot Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 1, 2026, 11:13 PM UTC

@josephfarina
josephfarina force-pushed the joeyfarina/multi-component-lookups-20261001 branch from edc7e21 to bc52f8c Compare October 1, 2026 20:37

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for putting this together — the batch lookup itself reads cleanly: one ordered receipt, duplicates kept, failures shown per selector before the nonzero exit, and the existing zero/one-selector responses untouched. The focused tests for ordering, projections, ambiguity, exact versions, the all-fail case, and text/JSON exit behavior look solid.

Approval needs one maintainer decision first. The new batch contract — the component.batch receipt, its found / not_found / ambiguous / error rows, exact package-version selectors, and exit-after-receipt behavior — is currently recorded only in the new draft spec AST-053, which is marked as a draft with no approver yet and is not part of the current spec on main. The current CLI spec covers programmatic parity, documentation, and the shared text vocabulary, but it doesn't yet authorize this batch contract.

Could a maintainer please provide or identify the governing spec for this addition — for example by approving AST-053 (or pointing to an equivalent current record) — so the contract has a settled home? Once that is in place, this should be straightforward to re-review. No code changes are being asked for on this point alone.

[Automated review]

@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR

🧪 Sandbox Preview

View Sandbox for this PR

No new or modified components detected.

Bundle Size Summary

No component packages changed.

Accessibility Audit

Status: No accessibility violations detected.

Visual Regression

14 of 420 shot(s) changed.

A change here is a question, not a failure: check whether the after is the
picture you intended. Record that review on the PR. Baseline maintenance is an
explicit dispatch of CI; this report never rewrites the baseline or adds a release gate.

component story theme mode pixels
Chat Full AI Chat probe light 155,733
Chat Full AI Chat probe dark 155,005
Chat Default neutral dark 33,205
Chat Default neutral light 32,876
Chat Empty State probe light 23,531
Chat Empty State probe dark 22,622
ChatAutoScroll Scroll Behavior Comparison neutral dark 15,378
ChatAutoScroll Scroll Behavior Comparison neutral light 14,107
Chat With Attachments probe light 13,229
Chat With Attachments probe dark 11,065
Markdown Default probe dark 897
Markdown Default probe light 897
Markdown Default neutral dark 882
Markdown Default neutral light 858

Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for putting this together — the batch lookup itself reads cleanly: one ordered receipt, duplicates kept, failures shown per selector before the nonzero exit, and the existing zero/one-selector responses untouched. The focused tests for ordering, projections, ambiguity, exact versions, the all-fail case, and text/JSON exit behavior look solid, and the governing spec question from earlier is now settled.

A few corrections are needed before this can merge:

  • Please add the documented aggregate work bound the current batch spec requires: define a finite limit that safely accepts at least two selectors in every mode, reject requests beyond it before any lookup runs (top-level invalid-argument error, exit 1, no partial batch), and cover that oversized case in the API and CLI tests. Right now a batch of any size is accepted.
  • Please move the batch shape onto the shared response types the spec names: the shared CLI response foundation should own and publish BatchResponse and BatchRow, with the component types specializing them, instead of only defining a component-local batch typedef. The wire format itself does not need to change.
  • Please rebase onto current main and regenerate the overlapping generated surfaces (README, manifest, response types, and doc routes) rather than hand-merging them, then rerun the focused component, manifest, docs, and search tests.

Once those are in, this should be straightforward to re-review.

[Automated review]

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for putting this together — the batch lookup reads cleanly: one ordered receipt, duplicates kept, failures shown per selector before the nonzero exit, and the existing zero/one-selector responses untouched.

The multi-selector contract now has a settled home in the current spec, and this revision covers the pieces that were still open before: a documented limit of 100 selectors that is refused before any lookup runs (with no partial receipt), the shared batch response and row types owned by the response foundation with the component types specializing them, and generated help, manifest, response-type, and guide surfaces that all agree. The focused coverage for ordering, duplicates, projections, ambiguity candidates, exact package versions, empty and one-item arrays, all-fail receipts, oversized rejection, and matching JSON/text exit behavior looks solid.

I did not find a concrete defect that needs a code change. Approving from my side — a final human read of the new response type, selector grammar, and exit behavior is still worthwhile, since that surface becomes permanent public API once it ships.

[Automated review]

@josephfarina
josephfarina merged commit 505e3d8 into main Oct 1, 2026
43 checks passed
josephfarina added a commit that referenced this pull request Oct 1, 2026
Main's #6867 changed the generated README tables, so this takes main's README;
the tables are regenerated in the next commit. The CLI blog post told readers
that `astryx layout` sketches a page from an expression, and `astryx blog`
serves that post to agents from the published feed, so the sentence goes with
the command.
josephfarina added a commit that referenced this pull request Oct 2, 2026
Take main's component command docs for the new batch-lookup behavior (#6867);
keep the integration-docs test suite deleted (bcc68ed) — batch coverage
arrives via main's new component-batch.test.mjs; regenerate README.

Co-authored-by: Cursor <[email protected]>
@github-actions
github-actions Bot deleted the joeyfarina/multi-component-lookups-20261001 branch October 2, 2026 06:24

This branch was successfully deployed

1 active deployment
Preview — 08c6367d Deployed Oct 1, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant