Skip to content

feat(cli): discover lists the official Astryx packages first, from a list built into each release - #7495

Merged
josephfarina merged 8 commits into
mainfrom
josephfarina/discover-official-list
Oct 20, 2026
Merged

josephfarina merged 8 commits into
mainfrom
josephfarina/discover-official-list

Conversation

@josephfarina

@josephfarina josephfarina commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

User need

A person or agent in a new app, or in an empty folder, asks astryx discover what they could add. Today the answer is "No discover source is configured", even though the CLI already ships the seven official themes for theme list. An app that installed an official theme never sees it as installed. The add text for a theme says the package loads on the next command, which is wrong: a theme still needs theme add. And the add command pins no version, so it can install a theme newer than the app's Core.

Problem and solution fit

  • A generator next to the theme bundle generator writes packages/cli/assets/discover/official-packages.json. It keeps each package the release workflow publishes (the workflow's own @astryxdesign/, private and canaryOnly rule) that adds at least one item discover lists, read with the CLI's own integration loader, contribution inventory and theme descriptor reader. pnpm build regenerates it, and a drift test fails when the committed file is stale.
  • The discover adapter reads the list after every other source, so a project's or an integration's source keeps its entry for an official package (FR7 as it stands); the list adds the rest. Every entry takes the CLI's own version; a canary CLI also lists the canary-only packages, as prereleases. Entries from the list name their source Astryx, meta.sources reports the list last, and a list that cannot be read is reported like a failed source.
  • Official packages come first in both lists, whichever source supplied their entry.
  • A declared official package the list supplies counts as installed, with its installed version, and meta.configured stays whenever no integration is listed.
  • On a package page, an official entry's add command pins the project's Core version when the package releases with Core, and otherwise the CLI's version. For a theme, the add text ends with astryx theme add <slug>.
  • In a project that loads no integration and has no discover source of its own, every query still answers with the list, as in 0.7.0; the text says why instead of printing usage lines that would loop.
  • Command, API, response-type and source docs say where official packages come from. One patch changeset.

Current specification

spec:AST-051 as amended by the paired spec pull request "discover lists the official packages first, from a list built into each release (AST-051)": FR1, FR2, FR6, FR11 and DEC-5. This lands after it.

Public delta and caller burden

Before, published 0.7.0 in an empty folder:

$ astryx discover --available
No discover source is configured.
...
Find Astryx packages on npm: npm search @astryxdesign

After:

$ astryx discover --available
Available
from Astryx

name:        @astryxdesign/theme-butter
version:     0.7.1
description: Warm, creamy yellows with a friendly blue accent. ...
themes:      butter
source:      Astryx
...

$ astryx discover @astryxdesign/theme-gothic
...
Add it

npm install @astryxdesign/[email protected]

Then use its theme:

astryx theme add gothic

JSON: discover.list always carries meta.available and meta.sources; data includes declared official packages; install for an official package is pinned. No new command, option or setting.

Compatibility (spec:AST-017, against published 0.7.0)

Patch tier. Every 0.7.0 result keeps its type, exit code and values; the change adds entries, fields and matches. Checked side by side with published 0.7.0:

  • Empty project (no integrations, no source of its own): discover, discover gothic, discover @astryxdesign/theme-gothic and a blank query all return discover.list, exit 0, data: [], meta.configured: false, as before; meta.available and meta.sources are added.
  • A project whose own source lists official packages: discover @astryxdesign/[email protected] and discover @astryxdesign/theme-gothic give the same detail as 0.7.0 (source, versions, install), and a declared official package that source lists still shows as it did. The list adds the other official packages and puts official packages first; meta.sources gains the official list as its last entry, so existing indexes keep their meaning.
  • Order within the lists is not part of the contract; official packages are placed first.

Next minor: answer queries in a project with no integration and no source of its own (package pages, search, and errors such as ERR_NOT_FOUND there), which changes released results and needs its own [breaking] changeset.

Known limit until then: an app with no integration and no source of its own, which is most plain apps, sees the official packages in the list, but the package page with the pinned add command and the theme add text appears only in projects that load an integration or have their own source.

Design and alternatives

The list is built into the release because official packages change only when Astryx releases, so it is exactly as current as the CLI that carries it, works offline and in an empty folder, and needs nothing beyond the CLI's own tarball. Searching the package registry at run time was rejected (network on every run, unrelated scope matches, and no way to know what a package adds without running it), as was a hosted catalog. The list is read after the other sources so a project's or an integration's source keeps the entry it gives an official package; reading it first would replace those entries.

Evidence

  • pnpm vitest run --project node packages/cli scripts/check-cli-official-packages.test.mjs scripts/check-cli-theme-bundle.test.mjs: 394 test files, 6,317 tests pass (2 more are marked expected failures).
  • The new and changed tests fail on bare main: 24 failures across the adapter, command and drift tests.
  • pnpm check:repo, run script by script: every check passes, check:changesets included.
  • A side-by-side run against published 0.7.0 in an empty project and in a project whose own source lists official packages (above).
  • typecheck:json-api, typecheck:authoring and cli-api-types-verify: pass. typecheck:strict: the same two errors as bare main (@astryxdesign/theme-neutral/built in two page templates, which needs pnpm build).
  • ESLint on every changed file: 0 errors. Copyright headers, exports sync and the generated README check: pass.
  • npm pack --dry-run includes assets/discover/official-packages.json.
  • The generator lists 11 packages (8 released with Core, 3 canary-only) in about 0.3 s; the file is about 9 KB.

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.

#7147 (source package names and typo tolerance in discover results) edits the same discover code; whichever lands second needs a rebase. It does not change source order or where official packages come from.

Why one pull request

The official list is one behavior with three parts that only work together: the generator that writes the list at release time, the file it writes, and discover reading that file after every other source and pinning from it (spec:AST-051 FR11, DEC-5). Landing the generator or the file without the reader ships a list nothing reads; landing the reader without the file makes discover fail its check. The tests cover them as one: the check test compares the committed file with the generator's output, and the discover tests read that file. Splitting would leave main with half the feature between merges, and the project keeps one change in one pull request.

Testing

pnpm bundle:cli-official-packages
node scripts/generate-cli-official-packages.mjs --check
pnpm vitest run --project node packages/cli scripts/check-cli-official-packages.test.mjs scripts/check-cli-theme-bundle.test.mjs
pnpm -F @astryxdesign/cli typecheck:json-api
pnpm -F @astryxdesign/cli typecheck:authoring
pnpm -F @astryxdesign/cli typecheck:strict
node .github/scripts/cli-api-types-verify.mjs
node packages/cli/scripts/generate-cli-readme.mjs --check
pnpm check:knowledge && pnpm check:cli-structure && pnpm check:changesets

Second commit: version consistency and released answers

Testing against published 0.7.0 found that the official entries could contradict their own add command and change answers that 0.7.0 gave. This commit fixes each case and keeps the change patch-tier.

  • One version per official entry, the one the add command pins. It is the project's Core version (installed, or declared exactly before install) for a package released with Core and for a canary-only package. With no Core, it is a release CLI's own version, or a canary CLI's own version for a canary-only package. Otherwise the entry lists no version and the add command pins none, because a canary CLI may have been published without some packages and a declared range names no single version. The page, discover <package>@<that version> and the add command now agree.
  • Canary-only packages are not listed beside a released Core, because their exact Core peer cannot install there.
  • A source keeps its entry for any official package whose integration it publishes under another name, such as a fork or a mirror. The official list is merged in source order, so the first entry per integration is still the source's; official packages are put first only where discover shows them.
  • Declared official packages come from the project's own package.json, the nearest one above the current folder, so an installed theme shows as installed from src/. npm aliases are recognized, and a peer dependency alone no longer counts as installed. Packages that a project's or an integration's source lists keep 0.7.0's reading.
  • Released error codes are kept. For a package only the official list supplies, a version or item it does not show answers ERR_UNKNOWN_PACKAGE, as 0.7.0 did; the message says which version discover shows.
  • Plain apps and empty folders: each package in meta.available carries its install command (an additive field), and the text points at those commands instead of at queries that would only return the list again.
  • Drift: a published theme package whose folder does not match its theme file now fails the generator, --check and the build, and the drift test checks that every listed stable package releases with Core.
  • Text: a theme's page points at /<item>, not /<ComponentName>; the prerelease count no longer counts the version it shows; a page with no version skips the Versions section; "N published" reads "N known".

Compatibility (spec:AST-017, against published 0.7.0)

Patch tier, [feat] changeset. 12 projects × 33 query forms in --json (396 runs) against published 0.7.0: 267 supersets, 41 errors that now answer, 86 identical error codes, and 0 changed exit codes or error codes. The other 2 runs are --limit 2 cuts where new official matches rank above an older match. Before this commit, 14 runs changed error codes.

Evidence for this commit

  • 25 of the new and changed tests fail on the previous head and pass here.
  • CLI node suite plus both drift tests: 394 files, 6,335 tests pass (2 more are marked expected failures).
  • check:repo script by script, typecheck:json-api, typecheck:authoring, cli-api-types-verify, check:cli-structure, ESLint on changed files, copyright, exports sync, README check and the official list --check all pass. typecheck:strict shows the same 2 errors as bare main (@astryxdesign/theme-neutral/built, which needs pnpm build).

Third commit: latest keeps its meaning, and a declared Core range is pinned

  • latest is the newest release the CLI knows: its own version on a release CLI, or the project's Core version when that is a newer release. A project on an older Core is no longer told its Core is the latest.
  • An official entry released with Core lists both versions, the latest release and the project's Core version (installed, or declared exactly), so discover <package>@<either> works. Its add command still pins the project's Core version. When the page shows the latest release and the command installs another version, the text says so: "This installs 0.6.8, the version that matches this project's Core."
  • A Core range in a fresh clone is pinned. When the project declares Core as a semver range (for example ^0.6.8) and has not installed it, the add command pins that range so the package manager resolves the matching release: npm install "@astryxdesign/theme-gothic@^0.6.8". The spec is quoted because ^, <, >, | and spaces mean something to a shell. A declaration that names no version, such as a path, a workspace protocol or a dist-tag, pins nothing.

Known limit: canary pins

On a canary CLI, a canary-only package is pinned to the CLI's own canary version when the project has no Core, and a package released with Core is pinned to an installed canary Core's version. A canary publish that skipped a package makes that one command fail with ETARGET. This is accepted for canary users: a release CLI never pins a canary, and on a canary CLI with no Core, packages released with Core are left unpinned.

Evidence for this commit

  • 12 new and changed tests fail on the previous head and pass here.
  • The printed range command installs for real: in a clone that declares "@astryxdesign/core": "^0.6.8", npm install "@astryxdesign/theme-gothic@^0.6.8" installs Core 0.6.8 and gothic 0.6.8.
  • 396-run comparison against published 0.7.0 (12 projects × 33 query forms, --json): 267 supersets, 45 errors that now answer, 82 identical error codes, 0 changed exit codes or error codes. The other 2 runs are the known --limit 2 cuts.
  • CLI node suite plus both drift tests: 394 files, 6,337 tests pass (2 more are marked expected failures). check:repo script by script, typecheck:json-api, typecheck:authoring, cli-api-types-verify, ESLint, copyright, exports sync, the README check and the official list --check all pass. typecheck:strict shows the same 2 errors as bare main (@astryxdesign/theme-neutral/built, which needs pnpm build).

…list built into each release

Each CLI release carries a generated list of the official packages: every
package the release workflow publishes that adds at least one item discover
lists, read with the CLI's own integration and theme readers. A drift test
fails when the committed list no longer matches the repository.

Discover reads the list after every other source, so a project's or an
integration's source keeps its entry for an official package; the list adds
the rest. Official packages come first in what discover shows, read like any
other package, and name their source Astryx. Entries take the CLI's own
version; a canary CLI also lists the canary-only packages, as prereleases. A
declared official theme package counts as installed. On a package page, an
official entry's add command pins the project's Core version when the package
releases with Core, otherwise the CLI's version, and a theme's add text ends
with `theme add <slug>`. A project that loads no integration and has no source
of its own still gets the list for every query.
@vercel

vercel Bot commented Oct 13, 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 20, 2026 8:10pm UTC

Request Review

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

astracat-bot Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 20, 2026, 8:40 PM UTC

@github-actions

github-actions Bot commented Oct 13, 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

40 of 486 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
Selector Indicator Space Bottom Sheet Narrow End RTL neutral light 754,077
Selector Indicator Space Bottom Sheet Wide Start neutral light 740,188
Chat Full AI Chat probe light 230,823
Chat Full AI Chat probe dark 229,805
RichTextEditor Markdown parity: side by side probe dark 94,866
RichTextEditor Markdown parity: side by side probe light 89,762
Collapsible Dividers probe dark 66,445
Collapsible Dividers probe light 66,445
Chat Default neutral dark 36,304
Chat Default neutral light 35,767
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,406
Chat With Attachments probe dark 11,232
ProgressBar With Target Mark probe dark 7,895
ProgressBar With Target Mark probe light 7,895
Markdown Default neutral dark 7,573
Markdown Default neutral light 7,566

and 20 more.


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

…eep released answers

An official entry now shows, lists and pins one version, so the package
page, a lookup by version and the add command agree: the project's Core
version, installed or declared exactly, for a package released with Core
and for a canary-only package; with no Core, a release CLI's own version,
or a canary CLI's own version for a canary-only package. Otherwise it
lists none and the add command pins nothing, because a canary CLI may
have been published without some packages and a declared range names no
single version. Canary-only packages are no longer listed beside a
released Core, which they cannot be installed with.

A source keeps its entry for any official package whose integration it
publishes under another name, so a fork or mirror stays in the list and
in search; the official list is merged in source order and put first only
where discover shows it. Declared official packages are read from the
project's own package.json, the nearest one above the current folder,
including npm aliases; a peer dependency alone no longer counts as
installed. For a package only the official list supplies, a version or
item it does not show answers ERR_UNKNOWN_PACKAGE, as before.

Each package the project could add carries its add command, and in a
project that loads no integration and has no source of its own the list
points at those commands instead of at queries that only return the list.
A published theme package whose folder does not match its theme file now
fails the generator, and the drift test checks that every listed stable
package releases with Core.
…ns the project's Core, range included

An official entry's latest release is again the newest release the CLI
knows: its own version on a release CLI, or the project's Core version
when that is a newer release, so an update check is not told the
project's older Core is the latest. An entry for a package released with
Core lists that latest release and the project's Core version, so a
lookup of either works, and its add command pins the project's Core
version.

In a fresh clone that declares Core as a semver range and has not
installed it, the add command pins that range, quoted for the shell, so
the package manager resolves the release that matches the project's
Core. A declaration that names no version, such as a path, a workspace
protocol or a dist-tag, pins nothing. When the page shows the latest
release and the command installs another version, the text says which
version it installs and why.
Conflict: packages/cli/authoring/discover/discover.doc.mjs, the DiscoverSource
description. Keeps #7495's sentence on the official list the CLI carries
(another source's entry for an official package is kept) and main's newer
wording for a failing source (the last good answer that source gave for the
same request, or reported as failed when it saved none).

Also regenerated packages/cli/assets/discover/official-packages.json
(pnpm bundle:cli-official-packages): main's lab added and renamed
components and templates since #7495's base, and the check test compares the
file with what the generator builds.
#7494 renumbers the official-list requirement to AST-051 FR11 (FR10 is now
"A package can link its docs site"); the six comments that cite it follow.
Comments only; no behavior change.

@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.

Changes requested: the official package list, its drift check and the discover wiring follow spec:AST-051 FR11, but one FR11 rule is not met and the change needs splitting or a reason it cannot be split.

  • When a project declares @astryxdesign/core as workspace:*, a file: path or a dist-tag and has not installed it, an official entry's add command is unpinned, while FR11 says it pins the latest release; pin = core?.version ?? core?.range ?? entryLatest ?? undefined; in packages/cli/api/discover/_adapter.mjs, with the three matching rows in _adapter.test.mjs updated, fixes it.
  • At 2,548 authored lines, please split the change (for example the generator, committed list and drift test first, then the discover wiring) or explain why it has to land as one.

[Automated review]

Comment thread packages/cli/api/discover/_adapter.mjs Outdated
Comment on lines +748 to +753
pin =
core == null
? canaryCli
? undefined
: cli
: (core.version ?? core.range);

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.

spec:AST-051 FR11 pins “the project's Core version, else the Core range the project declares, else the latest release”. When Core is declared as workspace:*, a file: path or a dist-tag and is not installed, projectCore returns {} and this pins nothing, so a release CLI prints an unpinned install beside version: <CLI version>. Falling back to the entry's latest release keeps every other case:

        pin = core?.version ?? core?.range ?? entryLatest ?? undefined;

The rows for workspace:*, file:../core and latest in _adapter.test.mjs would then expect '0.7.1'.

Comment on lines +5 to +6
* @file Writes the official package list that `astryx discover` reads before
* every other source (spec:AST-051 FR11) to

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.

Discover reads this list after every other source (spec:AST-051 FR11 and DEC-5), not before. Lines 15-16 also still say every entry takes the CLI's own version, while entries now list the project's Core version too.

…no plain range

- The official list's pin for a package released with Core is the project's
  Core version, else the Core range it declares, else the latest release
  (spec:AST-051 FR11). A Core declared as `workspace:*`, a `file:` path or a
  dist-tag, and not installed, gave no range and no pin; it now pins the
  latest release. The `workspace:*`, `file:../core` and `latest` rows expect
  it.
- generate-cli-official-packages.mjs: discover reads the list after every
  other source (FR11 and DEC-5), and each entry lists the CLI's own version
  and the project's Core version, with the pin rule above.

@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.

Changes requested: the official package list, its drift check and the discover wiring now follow spec:AST-051 FR11, including the pin for a Core declared as workspace:*, a file: path or a dist-tag, so what remains is the size of the change. At 2,554 authored lines it is over the 2,000-line bar, and the “Why one pull request” note does not show the parts are inseparable: the generator, committed list and drift test (494 lines) can land first with no behaviour change. Please split them out and, because the discover wiring alone is still 2,060 lines, move one layer (for example counting declared official packages as installed, or the text changes) to a follow-up, or show concretely why the wiring cannot be split.

[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.

Changes requested: the official package list, its drift check and the discover wiring follow spec:AST-051 FR11, and the change's size is accepted as one piece of work, so one FR11 pin rule is all that remains. When a project declares @astryxdesign/core as a range with a space after an operator, such as ~ 0.6.8 or >= 0.6.8 < 0.7.0, and has not installed it yet, isSemverRange in packages/cli/api/discover/_adapter.mjs rejects the range and the add command pins the latest release (@0.7.2), which falls outside that range. Dropping whitespace after an operator before the check (for example spec.trim().replace(/([<>]=?|=|\^|~)\s+/gu, '$1')), pinning that normalized range, and adding those two rows to the fresh-clone pin test in _adapter.test.mjs fixes it.

[Automated review]

Comment thread packages/cli/api/discover/_adapter.mjs Outdated
if (typeof spec !== 'string') continue;
const exact = spec.trim().replace(/^=\s*/u, '');
if (isValidSemver(exact)) return {version: exact};
return isSemverRange(spec) ? {range: spec.trim()} : {};

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.

~ 0.6.8 and >= 0.6.8 < 0.7.0 are valid ranges (node-semver reads both as >=0.6.8 <0.7.0), but the whitespace split in isSemverRange (line 359) leaves a bare ~ or >= that fails RANGE_PART, so this returns {} and the add command pins the latest release (@0.7.2), outside the declared range. spec:AST-051 FR11 pins “the Core range the project declares”. Normalizing first keeps every other case:

const range = spec.trim().replace(/([<>]=?|=|\^|~)\s+/gu, '$1');
return isSemverRange(range) ? {range} : {};

Rows for ~ 0.6.8 and >= 0.6.8 < 0.7.0 in the fresh-clone pin test (_adapter.test.mjs:469) would cover it.

…operator

node-semver accepts a space between an operator and its version (`~ 0.6.8`,
`>= 0.6.8 < 0.7.0`), but the range check split on whitespace, so such a
declaration counted as no range and add pinned the latest release, outside
it. Each operator is now joined to its version first, and the joined range
is pinned. Two rows in the fresh-clone pin test.

@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.

No further changes requested: the official package list, its drift check and the discover wiring follow spec:AST-051 FR11, and a Core range declared with a space after an operator (~ 0.6.8, >= 0.6.8 < 0.7.0) is now pinned as that range in every official add command. One optional tidy-up for the description, not the code: it counts 7 themes and 4 canary-only packages where the list has 8 packages released with Core and 3 canary-only, and it cites FR10 where the list is FR11.

[Automated review]

@josephfarina
josephfarina merged commit 9e97808 into main Oct 20, 2026
56 checks passed
@github-actions
github-actions Bot deleted the josephfarina/discover-official-list branch October 21, 2026 06:22

This branch was successfully deployed

1 active deployment
Preview — b9d8f472 Deployed Oct 20, 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