Skip to content

[CLI] Discover results name their source package and tolerate typos - #7147

Merged
josephfarina merged 9 commits into
mainfrom
feat/discover-provenance-typo-tolerance
Oct 22, 2026
Merged

josephfarina merged 9 commits into
mainfrom
feat/discover-provenance-typo-tolerance

Conversation

@josephfarina

Copy link
Copy Markdown
Contributor

Discover provenance (kt-cl9z) + typo tolerance (kt-fx71). Additive JSON fields only, patch changeset.

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

vercel Bot commented Oct 7, 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 22, 2026 7:37pm UTC

Request Review

@astracat-bot

astracat-bot Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 22, 2026, 7:57 PM UTC

@github-actions

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

46 of 494 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 753,933
Selector Indicator Space Bottom Sheet Wide Start neutral light 740,072
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 26 more.


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 — the JSON provenance and typo tolerance look right, and the new tests cover them well. Requesting two small fixes so the surrounding projections match:

  • DiscoverAvailableEntry doesn't declare the package field that meta.available entries now carry at runtime. Please add it to the typedef in discover.type.mjs (mirroring DiscoverListEntry) so the published types expose what the JSON sends.

  • In text mode, discover <package>/<Component> names the package only on stderr, so piped stdout loses it. The component-detail view prints a package: record on stdout for docs (stderr is for verbatim source) — please do the same here.

One optional tidy while you're there: the search leaf's header/rank comments still describe fuzzy hits as always throwing ERR_NOT_FOUND, which is no longer true for guarded matches.

[Automated review]

Every discover JSON result now names its package per the provenance rule
(cli-surface INV28): single-artifact responses (discover.detail,
discover.detail.doc, discover.item) carry package in the envelope, and
list entries (discover.list) carry package on each item. Text output
matches.

discover <words> now has the same typo tolerance as search: a near-miss
name (edit distance 1-3, with minimum-length guards) returns results
instead of "not found".
… names its package on stdout

DiscoverAvailableEntry declares the package field the entries carry, the
computer-installed entries carry it too, and text mode prints the package
record on stdout beside the doc. The search leaf's comments describe the
guarded near-miss matches.
@josephfarina
josephfarina force-pushed the feat/discover-provenance-typo-tolerance branch from 50691b9 to b442b4d Compare October 22, 2026 00:09
@josephfarina

Copy link
Copy Markdown
Contributor Author

Rebased onto main b098123 (one conflict in detail/doc/doc.mjs: it keeps main's {@link} resolution and adds package to the envelope) and addressed the review at b442b4d:

  • DiscoverAvailableEntry declares package, like DiscoverListEntry. The computer-installed available entries now carry it too, so every meta.available entry matches the type (global-local G36/G43 expectations updated).
  • Text mode: discover <package>/<Component> prints package: <name> as a record on stdout beside the doc, not on stderr. A new assertion in discover.sources.test.mjs fails without the change.
  • Optional, done: the search leaf's header and its function comment describe the guarded near-miss matches.
    Local: api/discover, discover commands, inv28, api/search (281/281), global-local G36/G43/G44; typecheck:strict is clean; README tables in sync.

@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec b442b4d

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

Requesting changes: the provenance fields, the stdout package: line and the available-entry typedef all check out, but two required fixes remain.

  • Document the new package fields in foundation/response/response-types.doc.mjs (then regenerate the README) and in the returns of api/discover/discover.doc.mjs, as AST-017 FR13/DEC-4 require for new response fields.
  • Rank near-miss names above title, summary, keyword and description matches in rank() (api/discover/search/search.mjs), since AST-051 FR4 ranks matches by how closely the name matches, and add a test for that order.

Optionally, file the typo tolerance as its own [feat] changeset and fix the "two-edit" test title that exercises a one-edit case.

[Automated review]

if (dist >= 1 && dist <= 3) {
/** @type {Record<number, number>} */
const MIN_LENGTHS = {1: 5, 2: 8, 3: 11};
if (Math.min(lower.length, name.length) >= MIN_LENGTHS[dist]) return 4;

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.

A near-miss name returns 4 here, after tier 3, and tier 3 also covers title, summary, keyword and description hits whose name does not match at all. So for speedomter, an item that only mentions the word in its summary outranks Speedometer. AST-051 FR4 ranks matches "by how closely the name matches". Please rank near-miss names above text-only hits (for example between the substring and text tiers), add a test for that order, and update the rank() comment above, which still lists tiers 0–3 only.

* astryx --json discover @scope/name[@version]
* @typedef {object} DiscoverDetailResponse
* @property {'discover.detail'} type
* @property {string} package The npm package this result is about.

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 field and the other new package fields are declared here, but the consumer references still describe these payloads without them. Those references are foundation/response/response-types.doc.mjs (its discover members, and the README "Response types" table generated from it) and the returns in api/discover/discover.doc.mjs. AST-017 FR13/DEC-4 asks for the consumer-doc projection in the same change. Please add the fields there and regenerate the README (pnpm -F @astryxdesign/cli readme).

expect(res.data.matches.map(m => m.component)).toContain('Alpha');
});

it('a two-edit miss on an 8+ letter name returns results', async () => {

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.

Optional: this title says two-edit, but AlpheCard → AlphaCard is one edit, as the comment below notes. A real two-edit installed case, and a three-edit case on an 11+ letter name, would cover the other guards.

`discover.item`) carry `package` in the envelope, and list entries
(`discover.list`, and each entry of its `meta.available`) carry `package`. Text output matches: an opened doc prints its `package:` line on stdout.

`discover <words>` now has the same typo tolerance as `search`: a near-miss

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.

Optional: AST-051 FR4 permits near-miss matching but does not require it, so this is a new compatible capability rather than a correction. AST-017 FR7 would file this paragraph as its own [feat] changeset. Both are patch, so only the changelog section changes.

@josephfarina

Copy link
Copy Markdown
Contributor Author

Addressed the review at 5e83318 (merged with main):

  • Docs: the new package fields are documented in response-types.doc.mjs (README regenerated) and in discover.doc.mjs returns. That covers list entries and meta.available entries (equal to name), detail, and the detail doc.
  • Ranking: rank() now puts a near-miss name (within the typo guards) above a title, summary, keyword or description match (AST-051 FR4). A new test fails on the old order.
  • Test title: the "two-edit" test is retitled to the one-edit case it exercises.
  • Changeset: kept as one; this is one piece of work.

@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec 5e83318

@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec 1cf32b6

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

Requesting changes for one documentation gap; the provenance fields, the stdout package: line, the typedefs and the near-miss search all check out. discover.item now carries package in its envelope, but its descriptions in foundation/response/response-types.doc.mjs and in the returns of api/discover/discover.doc.mjs still list only the item's own fields, so please add "The envelope's package names the same package." to both and regenerate the README with pnpm -F @astryxdesign/cli readme, as AST-017 FR13 asks for every response field. Optionally, the JSDoc above rank() still calls tier 3 the text tier, and ordering near misses by distance would keep a one-edit name above a three-edit one.

[Automated review]

'The validated ComponentDoc for one installed component, for an @scope/name/Component query, plus package, the npm package that owns the component.',
},
{
value: 'discover.item',

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.item now carries package in its envelope (api/discover/detail/item/item.mjs:42, :63), but this description still lists only the item's own fields. As component.detail does, please add "The envelope's package names the same package." and regenerate the README with pnpm -F @astryxdesign/cli readme; AST-017 FR13 asks for every response field in the consumer docs.

'The validated ComponentDoc for one installed component, for an @scope/name/Component query, plus package, the npm package that owns the component.',
},
{
type: 'discover.item',

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.

Same gap in the discover() reference: this discover.item return does not mention the new envelope package.

if (dist >= 1 && dist <= 3) {
/** @type {Record<number, number>} */
const MIN_LENGTHS = {1: 5, 2: 8, 3: 11};
if (Math.min(lower.length, name.length) >= MIN_LENGTHS[dist]) return 3;

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.

Optional: every near miss returns 3, so distance never orders two of them and installed-first decides; for Navigations, an installed NavigationBar three edits away lists above an available Navigation one edit away. Returning 3 + dist / 10 would keep the closer name first. The JSDoc above rank() also still calls 3 the title, summary, keyword or description tier.

@josephfarina

Copy link
Copy Markdown
Contributor Author

Addressed the 16:59 review at d360c57 (merged with main 813c1d5): discover.item's descriptions in response-types.doc.mjs and in discover.doc.mjs returns now add "The envelope's package names the same package.", and the README is regenerated. Also done: rank()'s JSDoc names the near-miss tier, and near misses order by edit distance (3.0/3.1/3.2), so a one-edit name sorts above a two-edit one. Tested.

@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec d360c57

@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec c510342

@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 changes are required: every discover result now names its package in JSON and text, the types and response-type docs cover each new field (including the discover.item envelope), and guarded near-miss names rank between name substrings and text matches, as AST-051 FR4 sets. One optional follow-up: the changeset says discover has "the same typo tolerance as search", but search skips edit distance for multi-word queries while discover compares the whole phrase, so discover "cable view" now matches TableView; either skip the near-miss tier for queries with spaces or reword that line.

[Automated review]

`discover.item`) carry `package` in the envelope, and list entries
(`discover.list`, and each entry of its `meta.available`) carry `package`. Text output matches: an opened doc prints its `package:` line on stdout.

`discover <words>` now has the same typo tolerance as `search`: a near-miss

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.

Optional: search applies edit distance only to one-word lookups (api/search/_score.mjs:109–112), while discover compares the whole query with the name, spaces included, so discover "cable view" now matches TableView. Either skip the near-miss tier for a query with whitespace, or reword this to "the same length guards as search".

@josephfarina
josephfarina merged commit 33b8bfe into main Oct 22, 2026
62 checks passed
@github-actions
github-actions Bot deleted the feat/discover-provenance-typo-tolerance branch October 23, 2026 06:23

This branch was successfully deployed

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