Repository navigation
[CLI] Discover results name their source package and tolerate typos - #7147
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report📚 Storybook Preview🧪 Sandbox PreviewNo new or modified components detected. Bundle Size SummaryNo component packages changed. Accessibility AuditStatus: No accessibility violations detected. Visual Regression46 of 494 shot(s) changed. A change here is a question, not a failure: check whether the after is the
and 26 more. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
de12aa9 to
503615a
Compare
503615a to
6304daa
Compare
6304daa to
a3cddbd
Compare
a3cddbd to
d46c529
Compare
d46c529 to
50691b9
Compare
There was a problem hiding this comment.
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:
-
DiscoverAvailableEntrydoesn't declare thepackagefield thatmeta.availableentries now carry at runtime. Please add it to the typedef indiscover.type.mjs(mirroringDiscoverListEntry) 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 apackage: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.
50691b9 to
b442b4d
Compare
|
Rebased onto main b098123 (one conflict in
|
|
/approve-spec b442b4d |
There was a problem hiding this comment.
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
packagefields infoundation/response/response-types.doc.mjs(then regenerate the README) and in thereturnsofapi/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; |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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 () => { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
|
Addressed the review at 5e83318 (merged with main):
|
|
/approve-spec 5e83318 |
|
/approve-spec 1cf32b6 |
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
|
Addressed the 16:59 review at d360c57 (merged with main 813c1d5): |
|
/approve-spec d360c57 |
|
/approve-spec c510342 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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".
Discover provenance (kt-cl9z) + typo tolerance (kt-fx71). Additive JSON fields only, patch changeset.