Skip to content

feat(cli): astryx discover browses the integrations you have and could add - #6802

Merged
josephfarina merged 2 commits into
mainfrom
discover-integration-manager
Oct 1, 2026
Merged

josephfarina merged 2 commits into
mainfrom
discover-integration-manager

Conversation

@josephfarina

@josephfarina josephfarina commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

User need

astryx discover only shows the integrations an app already has, and only the ones with components. There's no way to see what else exists, what a package adds, or which versions are out. So people and agents hand-roll things an integration already ships.

Problem and solution fit

Discover becomes a read-only manager for integrations.

  • astryx discover lists what you have, then what you could add.
  • astryx discover <package> shows what it adds, every release, and the install command to copy. <package>@<version> shows any version.
  • astryx discover <words> searches every kind of item (components, templates, docs, themes, codemods, agent docs) in what you have and in what sources list. --type, --installed, --available and --limit filter it.
  • What exists comes from discover sources. A source is a function the project sets as discover in astryx.config, or an integration exports as a discover named export. A team with a private registry plugs it in and the CLI never has to know where it lives.

It never installs anything. The package manager does that, and autolink already loads a new integration.

Current specification

spec:AST-051, added here and approved as current. The new options follow spec:AST-042 FR4 and FR5. The named export follows spec:AST-031 without the consent gate, since sources only read.

Public delta and caller burden

  • astryx discover <package>@<version> and astryx discover <package>/<item> for every item kind, with a new JSON type discover.item.
  • --type <kind>, --installed, --available, --limit <n>. --installed with --available is refused with ERR_INVALID_OPTION.
  • discover in astryx.config and the discover named export, typed as DiscoverSource from @astryxdesign/cli/authoring, plus parseDiscoverCatalog. Documented in astryx docs authoring discover-source and astryx docs cli/integrations.
// astryx.config.ts, or astryx.integration.ts
export const discover: DiscoverSource = async ({signal, package: name, version}) => {
  // {schemaVersion: 1, source, packages}. Each package has every version and
  // what the requested (else latest) version adds.
  return readCatalog({signal, name, version});
};

Existing JSON fields keep their meaning and new data is additive (meta.available, meta.sources, per-kind lists, installed, latest, versions, and kind and installed on search matches). Three things behave differently.

  • discover.list data now lists every loaded integration, not only the ones with a components root. One with no components shows components: [].
  • Search now matches templates, docs and package names too.
  • A free-text query always returns the list, even for an exact component name or a single match. discover Button used to open Button's doc. Now it lists every Button match across all packages, and discover @acme/ui/Button opens it (DEC-4).

A source's last good answer is saved in the per-user cache (XDG_CACHE_HOME or ~/.cache, ~/Library/Caches, LOCALAPPDATA), never in the project. No new env vars. Without a source nothing new shows up and callers decide nothing new.

Design and alternatives

Sources are functions, not URLs. A URL can't sign in to a private registry unless the CLI handles credentials, and a URL built into the CLI ties the public CLI to one host (DEC-2). No discover add either. Installing is the package manager's job (DEC-1). A free-text query always lists, so the same query never flips between a doc and a list depending on what's installed (DEC-4). Whether the CLI ships a built-in public source is left open (OQ1).

Evidence

A demo app with one installed integration and a source that lists three packages.

$ astryx discover

Installed

name:       @acme/widgets
category:   @acme/widgets
components: Gauge
version:    1.4.0
latest:     1.5.0

Available
from Acme registry (2026-09-30)

name:       @acme/charts
components: BarChart, LineChart
version:    2.0.0
templates:  pages/Report
docs:       charts-guide
source:     Acme registry

name:    @acme/themes
version: 0.3.0
themes:  ocean, sunset
source:  Acme registry

$ astryx discover @acme/charts

name:       @acme/charts
category:   @acme/charts
components: BarChart, LineChart
version:    2.0.0
templates:  pages/Report
docs:       charts-guide
installed:  false
latest:     2.0.0
source:     Acme registry

Versions
3 published, newest first

- 2.0.0  2026-09-20  latest
- 1.9.0  2026-08-02

1 prerelease is not listed. See any version: pnpm exec astryx discover @acme/charts@<version>

Add it

pnpm add @acme/charts

Astryx loads an integration on the next command once it is a dependency.

See one item: pnpm exec astryx discover @acme/charts/<item>

$ astryx discover chart --available

Found 4 matches for "chart"

- pnpm exec astryx discover @acme/charts/charts-guide  (doc, not installed)
- pnpm exec astryx discover @acme/charts  (package, not installed)
- pnpm exec astryx discover @acme/charts/BarChart  (not installed)
- pnpm exec astryx discover @acme/charts/LineChart  (not installed)

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

  • pnpm exec vitest run packages/cli 5522 passed, plus pnpm -F @astryxdesign/docsite generate && pnpm -F @astryxdesign/docsite test
  • pnpm -F @astryxdesign/cli typecheck:strict
  • node .github/scripts/cli-api-types-verify.mjs
  • pnpm check:repo
  • eslint on the changed files

@vercel

vercel Bot commented Sep 30, 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 9:22pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Sep 30, 2026
@astracat-bot

astracat-bot Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

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

@github-actions

github-actions Bot commented Sep 30, 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

11 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
DropdownMenu Default neutral light 640,760
DropdownMenu Default neutral dark 43,588
Chat Default neutral dark 34,710
Chat Default neutral light 34,172
SideNav Resizable in AppShell probe dark 3,208
Chat Full AI Chat probe dark 2,653
Chat Full AI Chat probe light 2,653
Markdown Default probe dark 980
Markdown Default probe light 980
Markdown Default neutral dark 839
Markdown Default neutral light 839

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

github-actions Bot added a commit that referenced this pull request Sep 30, 2026

@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 building this out with docs, tests, and a changeset. I am holding approval for one maintainer decision, plus two smaller fixes worth doing in the meantime.

Maintainer decision needed first. This adds a new capability — browsing integrations a project could add through discover sources, with the versioned catalog, the saved per-user copy, the new filter options, and the discover config field and named export — and proposes it in a new draft spec for owner approval. No current spec governs that capability yet, so approval needs a maintainer to provide or identify the governing spec for this addition (for example, approving the proposed record as current, settling the source trust, catalog, cache, and option behavior it describes). I have asked that question on the PR; nothing needs to be removed or split for this reason alone.

Scope. The change is 3,347 verified changed lines. Before approval, please either split it into reviewable parts or show why it has to land as one inseparable capability. This stays required after the spec question is settled.

One behavior fix. When a search term exactly names an installed component but also matches something else (another kind or an available item), discover should return the match list, keeping the direct document only when nothing else matches. Right now the exact name returns the document immediately, so the other matches are never shown. A test with an overlapping name would lock this in.

Worth checking too: version lists are shown as newest first in the order the source returns them, with no sort or check — a misordered catalog would display the wrong order and default.

[Automated review]

Comment thread packages/cli/api/discover/discover.mjs Outdated
if (!target.version && !target.item && only !== 'available') {
const exact = findComponent(packages, query);
if (exact && (type == null || type === 'component')) {
return await docFromResult(exact, {lang, zh});

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.

This exact-name shortcut returns the component document before any source or other-kind match is considered. When the same term also matches a template, doc, package, or available item, those matches are never shown. Please keep the direct document only when nothing else matches, and add a test with an overlapping name.

@josephfarina
josephfarina force-pushed the discover-integration-manager branch from 2db03b8 to 102aca3 Compare September 30, 2026 23:51
@josephfarina

Copy link
Copy Markdown
Contributor Author

Pushed 102aca3 with the two fixes from the automated review.

  • Versions are now sorted newest first by publish time, whatever order a source sends them. There's a test with a misordered catalog.
  • An exact installed component name still opens its doc, like it does today, so existing astryx discover <Name> calls keep their response type. The PR text, the function doc and the spec said otherwise, and they now match the code. A single partial match still returns the list when anything else matches. Tests cover both, in the search leaf and through the CLI.

The spec question and the size question are still open.

@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 the follow-up push — both behavior fixes land well. Approval is still held for one maintainer decision, plus two corrections.

Maintainer decision needed first. This adds a new capability — browsing integrations a project could add through discover sources, with the versioned catalog, the saved per-user copy, the new filter options, and the discover config field and named export — and proposes it in a new draft spec for owner approval. No current spec governs that capability yet, so approval needs a maintainer to provide or identify the governing spec for this addition (for example, approving the proposed record as current, settling the source trust, catalog, cache, and option behavior it describes). That question is already open on this PR; nothing needs to be removed or split for this reason alone.

Scope. The change is 3,518 verified changed lines. Before approval, please either split it into reviewable parts or show why it has to land as one inseparable capability. This stays required after the spec question is settled.

One test fix. The saved-copy test fails on macOS: it expects the saved answer under the redirected Linux cache directory, but on macOS the cache lives under ~/Library/Caches, so the expected directory never appears and the focused suite is red there (1 failed, 134 passed in this review's run). Please make the test compute the expected location per platform, or make the code honor the redirected location in tests.

Fixed in this revision. Versions are now sorted newest first by publish time whatever order a source sends, with a misordered-catalog test. The exact installed component name keeps opening its doc as it does today, and the proposal and function docs now match the code on that, so existing calls keep their response type.

[Automated review]

@josephfarina
josephfarina force-pushed the discover-integration-manager branch from 102aca3 to 86e0c4c Compare October 1, 2026 00:19
@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec 86e0c4c

@josephfarina

Copy link
Copy Markdown
Contributor Author

Pushed 86e0c4c.

  • discover <words> now always returns the list, even for an exact component name or a single match. discover Dial lists every Dial match across all packages, and discover @scope/pkg/Dial opens the doc. The spec records it as DEC-4, and the PR text, function doc, response types and changeset say the same thing.
  • The saved-copy test works out the cache folder per platform, so it passes on macOS and Windows too.
  • discover.item is now in the capability manifest and the response types list.
  • AST-051 is approved as current.

On the size. This is one capability, the read-only browser AST-051 describes, and every file in the diff serves it.

Part Changed lines
Tests 1,132
Command, docs, response types, spec, changeset, route inventory 1,221
Adapter that calls sources and keeps the saved copy, plus the catalog views 592
List, package, item and search leaves, and the dispatcher 592
Source contract (DiscoverSource, catalog check, config field, loader) 298

None of the parts does anything on its own. Every view reads the same source contract, and the contract only makes sense next to the views that read it. A split would leave main with half a manager for at least a release, like sources you can list but not search or open. There's no cleanup or unrelated change in here.

@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 the follow-up push — this is ready from my side.

The spec question is settled for this revision: the governing record is now approved through the repository's owner-approval gate, so the discover manager, its source contract, the saved per-user copy and the new filter options all have an established home. Nothing needs to be removed or split for that reason.

On scope, the breakdown you posted lines up with what I could verify — tests are the largest part, and the rest is the source contract, the adapter and views, the leaves and handler, and docs, all serving the one capability — so I am comfortable with it landing as a single inseparable change rather than asking for a split.

The remaining fixes also land well: a free-text query now consistently lists its matches, even for an exact component name, with the package path opening a single item; versions are sorted newest first whatever order a source sends; discover.item is in the manifest; and the saved-copy test works out the cache folder per platform. I reran the focused discover tests on macOS and the full CLI suite from the repo root, and both pass.

One heads-up for callers in the release notes: because free-text search now always returns the list, scripts that opened a component with a bare name should use the package path form instead.

[Automated review]

Asking for an item that a source's package doesn't list said the whole package wasn't found. Now it says the item isn't in that package and suggests close names.
@josephfarina

Copy link
Copy Markdown
Contributor Author

Round 3. Running every command against a real catalog turned up one bug. Asking for an item that a source's package doesn't list said the whole package wasn't found. Now astryx discover @test/charts/Nope says "Nope" not found in @test/charts (ERR_UNKNOWN_COMPONENT) and suggests close names. Added a test for it. The spec and the response shapes don't change.

@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec 63c95bc

@josephfarina
josephfarina merged commit 9c4d44d into main Oct 1, 2026
41 checks passed
@github-actions
github-actions Bot deleted the discover-integration-manager branch October 2, 2026 06:24

This branch was successfully deployed

1 active deployment
Preview — 63c95bcd 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