Repository navigation
feat(cli): experimental exportIconIndex() and rankIconIndex() - #12128
Conversation
The icon counterpart of exportSearchIndex() and rankSearchIndex(). A catalog that must not load package code stores each package's icon index once, where loading is safe, and ranks the stored indexes per query. icon() search and rankIconIndex() share one ranking function, so icon() answers exactly as before.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
| Package | Where | Signature | Usage | |
|---|---|---|---|---|
| + | cli |
./api · Functions · function exportIconIndex |
function exportIconIndex @experimental: (options?: { cwd?: string | undefined; package?: string | undefined }) => Promise<IconIndex> |
import {exportIconIndex} from '@astryxdesign/cli/api'; exportIconIndex(…) |
| + | cli |
./api · Functions · function rankIconIndex |
function rankIconIndex @experimental: (query: string, indexes: IconIndex | IconIndex[], options?: { set?: string | undefined; limit?: number | undefined }) => Promise<IconSearchResponse> |
import {rankIconIndex} from '@astryxdesign/cli/api'; rankIconIndex(…) |
Not run on this PR: add ci:run-visual for Visual, ci:run-a11y for Accessibility, ci:run-rtl for RTL.
Generated by PR Enrichment workflow | View full report
There was a problem hiding this comment.
Changes are needed, and the new API needs an owner decision before it can be approved.
exportIconIndex() and rankIconIndex() are a new experimental API that no current record admits yet: spec:AST-084 FR0 and spec:AST-017 FR27 decide only how icon-set APIs are marked experimental, and spec:AST-033 FR2 covers only exportSearchIndex()/rankSearchIndex(). Approval needs an engineering owner to identify a current claim that covers the pair, or to approve one this pull request adds (the index shape, the same-CLI-version refusal, and that equal scores keep the order the indexes are given) by commenting /approve-spec <full head SHA>; the author may do so as an engineering owner.
Blocking, whatever that decision is:
rankIconIndex()copiesicon()'s default limit and its query and limit checks (icon-index.mjs:21and:92-113) instead of sharing them the waysearch()andrankSearchIndex()sharecheckSearchArgs, and the copies already differ:{limit: null}throws whereicon()uses 10, and a missing query givesERR_INVALID_ARGUMENTwhereicon()givesERR_MISSING_ARGUMENT..changeset/icon-index-api.mdcredits no contributor, socheck:changesetsfails the required Lint job; add@josephfarinaon its own line after the body.
Not blocking: the rankIconIndex() doc says an index ranks exactly as icon(query) does, but glyphs/trash answers icon.detail from icon() and an empty search from rankIconIndex(), so scope that sentence to word searches or refuse such a query.
Claims and files checked
Review mode: full; reason: no-earlier-review
- Claim: two new experimental functions in
@astryxdesign/cli/api: verified (api/index.mjs:52). - Claim:
exportIconIndex()returns the setsicon()searches as plain JSON with no folder paths: verified (icon-index.mjs:30-72, test). - Claim:
rankIconIndex()answers icon searches exactly asicon()does: verified for word searches by the parity test;<set>/<id>lookups differ (note above). - Claim:
icon()ranks through the same function and its answers are unchanged: verified (search.mjs:59-97; existing icon tests pass unchanged). - Claim: an index ranks only under the CLI version that made it: verified (
icon-index.mjs:128-134, test). - Claim: equal scores keep the order of the indexes given: verified (test).
- Claim: withdrawn sets are kept so
setgivesicon()'s error: verified (test). - Claim: no scoring code changes: verified (the ranking module is untouched).
- Claim: the named test run, the API type sync, the JSON API typecheck and the published-types check pass: verified.
- Claim: a replay over a three-set icon fixture is byte-identical: not verified, since the fixture is not in the pull request; the in-repo parity test supports it.
- File
.changeset/icon-index-api.md: finding (contributor line). - File
packages/cli/api/icon/search/icon-index.mjs: finding (copied default and checks). - File
packages/cli/api/icon/rankIconIndex.doc.mjs: note (parity sentence). - File
packages/cli/api/icon/exportIconIndex.doc.mjs: clear. - File
packages/cli/api/icon/icon.type.mjs: clear. - File
packages/cli/api/icon/search/search.mjs: clear. - File
packages/cli/api/icon/search/icon-index.test.mjs: clear. - File
packages/cli/api/icon/experimental-markers.test.mjs: clear. - File
packages/cli/api/index.mjs: clear. - File
packages/cli/test/lazy-dependencies.test.mjs: clear.
rankIconIndex() and icon() now share one query, limit and default check. A <set>/<id> query, which icon() reads as one icon, is refused by rankIconIndex(). AST-033 FR2a records the experimental pair: the index shape, the same-CLI-version rule and the equal-score order.
There was a problem hiding this comment.
Changes are needed for one CI fix; the API's direction is settled, since an engineering owner approved the new record clause at this head.
- Miss: the required Lint check fails at
pnpm check:cli-structurebecausepackages/cli/api/icon/search/search.mjs:67writes thesetstype asArray<import('../../../foundation/discovery/icon-set-discovery.mjs').DiscoveredIconSet | …>, which the check reads as a discovery import, so declareDiscoveredIconSetandIconIndexSetwith@typedef {import(…)}at the top of the file and write@param {Array<DiscoveredIconSet | IconIndexSet>} sets(the last review missed this because Lint stopped earlier, at the Changeset check).
The earlier blockers are fixed: rankIconIndex() shares icon()'s default and argument checks, the Changeset credits its author, and a <set>/<id> query is refused with a pointer to icon().
Not blocking: the new FR2a clause does not mention exportIconIndex()'s package option, so one clause there would make the record cover per-package indexes.
Claims and files checked
Review mode: full; reason: spec-record
- Claim: two new experimental functions and two experimental types in the CLI's programmatic API: verified (
packages/cli/api/index.mjs:52,icon.type.mjs:393-416). - Claim:
exportIconIndex()returns the setsicon()searches as plain JSON{version, sets, withdrawn}with no folder paths, andpackagekeeps one package's sets: verified (icon-index.mjs:57-76, tests). - Claim:
rankIconIndex()answers a word search asicon()does, shares its query, limit and default checks, and refuses a<set>/<id>query: verified (icon-index.mjs:96-134,_options.mjs:79-131, parity test). - Claim:
icon()andrankIconIndex()share one ranking function and no scoring code changes: verified (search.mjs:59-97; the ranking module is untouched). - Claim:
icon()output is unchanged and every existing icon test passes unchanged: verified (local run). - Claim: an index ranks only under the CLI version that made it, with an error naming both versions: verified (
icon-index.mjs:124-129, test). - Claim: equal scores keep the order the indexes are given: verified (test).
- Claim: withdrawn sets are kept so a
setthat names one givesicon()'s error: verified (test). - Claim: no new command: verified (no command doc changes).
- Claim: the record clause states the index shape, the version refusal and index-order ties: verified (
docs/specs/AST-033/spec.md:104-112). - Claim: the named test run (291 tests) and the knowledge check pass: verified (local run).
- Claim: the API type sync, the JSON API typecheck and the published-types check pass, and the strict typecheck reports only two unbuilt-theme errors in page templates: verified (local run).
- Claim: a replay over a three-set icon fixture is byte-identical: not verified, since the fixture is not in the pull request; the in-repo parity test supports it.
- Claim: public text carries no internal context: verified.
- Claim: the writing rubric results for the record clause: verified (present tense; no research, references or status).
- Changeset: an experimental patch adding the two functions as the icon counterpart of the search index pair, with
icon()'s answers unchanged and same-version ranking, crediting the author: verified (check:changesetspasses). - File
packages/cli/api/icon/search/search.mjs: finding (the type at line 67 fails the required Lint check). - File
docs/specs/AST-033/spec.md: note (the clause does not name thepackageoption). - File
.changeset/icon-index-api.md: clear. - File
packages/cli/api/icon/_options.mjs: clear. - File
packages/cli/api/icon/icon.mjs: clear. - File
packages/cli/api/icon/icon.type.mjs: clear. - File
packages/cli/api/icon/search/icon-index.mjs: clear. - File
packages/cli/api/icon/exportIconIndex.doc.mjs: clear. - File
packages/cli/api/icon/rankIconIndex.doc.mjs: clear. - File
packages/cli/api/icon/search/icon-index.test.mjs: clear. - File
packages/cli/api/icon/experimental-markers.test.mjs: clear. - File
packages/cli/api/index.mjs: clear. - File
packages/cli/test/lazy-dependencies.test.mjs: clear.
| - **FR2a — Icon search has a stored index too.** `exportIconIndex()` and | ||
| `rankIconIndex()` in `@astryxdesign/cli/api` are experimental, the icon | ||
| counterpart of the search index pair. `exportIconIndex()` returns the icon | ||
| sets `icon()` searches in a folder as plain JSON, `{version, sets, |
There was a problem hiding this comment.
Non-blocking: this clause does not mention the package option of exportIconIndex(), which is how a catalog makes one index per package for the multi-index ranking below. One clause here would make the record cover it.
search.mjs no longer imports a discovery type (INV21): the shared ranking takes the type rankIcons reads.
|
/approve-spec caff77c |
There was a problem hiding this comment.
Approved pending CI: the CI workflow's test and build jobs have not finished on this head yet. An engineering owner approved the new record clause for the experimental exportIconIndex() and rankIconIndex() pair at this head, and the last review's blocker is fixed: search.mjs no longer trips the CLI structure check, and Lint passes.
Not blocking: the new record clause still does not mention exportIconIndex()'s package option; one sentence there would make the record cover per-package indexes.
Claims and files checked
Review mode: incremental; reason: none
- Claim: two new experimental functions and two experimental types in the CLI's programmatic API: verified (
packages/cli/api/index.mjs:52,icon.type.mjs:393-415). - Claim:
exportIconIndex()returns the setsicon()searches as plain JSON{version, sets, withdrawn}with no folder paths, andpackagekeeps one package's sets: verified (icon-index.mjs:57-76, tests). - Claim:
rankIconIndex()answers a word search asicon()does, shares its query, limit and default checks, and refuses a<set>/<id>query: verified (icon-index.mjs:96-139,_options.mjs:79-131, parity test). - Claim:
icon()andrankIconIndex()share one ranking function that wraps the existing ranking unchanged, with no scoring change: verified (search.mjs:59-92; the ranking module is untouched). - Claim:
icon()output is unchanged and every existing icon test passes unchanged: verified (local run, 342 tests). - Claim: an index ranks only under the CLI version that made it, with an error naming both versions: verified (
icon-index.mjs:124-130, test). - Claim: equal scores keep the order the indexes are given: verified (test; ties sort by set position after score).
- Claim: withdrawn sets are kept so a
setthat names one givesicon()'s error: verified (test). - Claim: no new command: verified (no command doc changes).
- Claim: the record clause states the index shape, the version refusal and index-order ties: verified (
docs/specs/AST-033/spec.md:104-112). - Claim: the named test run and the knowledge check pass: verified (local run).
- Claim: the API type sync, the JSON API typecheck and the published-types check pass, and the strict typecheck reports only two unbuilt-theme errors in page templates: verified (local run).
- Claim: a replay over a three-set icon fixture is byte-identical: not verified, since the fixture is not in the pull request; the in-repo parity test covers the same property.
- Claim: public text carries no internal context: verified.
- Claim: the writing rubric results for the record clause: verified (present tense; no research, references or status).
- Changeset: an experimental patch adding the two functions as the icon counterpart of the search index pair, with
icon()'s answers unchanged and same-version ranking, crediting the author: verified (check:changesetspasses). - File
docs/specs/AST-033/spec.md: note (the clause does not name thepackageoption). - File
packages/cli/api/icon/search/search.mjs: clear (the structure check passes). - File
packages/cli/api/icon/search/icon-index.mjs: clear. - File
.changeset/icon-index-api.md: clear. - File
packages/cli/api/icon/_options.mjs: clear. - File
packages/cli/api/icon/icon.mjs: clear. - File
packages/cli/api/icon/icon.type.mjs: clear. - File
packages/cli/api/icon/exportIconIndex.doc.mjs: clear. - File
packages/cli/api/icon/rankIconIndex.doc.mjs: clear. - File
packages/cli/api/icon/search/icon-index.test.mjs: clear. - File
packages/cli/api/icon/experimental-markers.test.mjs: clear. - File
packages/cli/api/index.mjs: clear. - File
packages/cli/test/lazy-dependencies.test.mjs: clear.
User need
A catalog web page that lists icon-set packages must answer an icon search exactly as
astryx experimental icon <words>does, so every improvement to the CLI's icon ranking reaches the page with no second copy of the ranking. Such a page must not load package code, and reading a folder's icon sets loads each integration's manifest module. Todayicon()only reads installed sets, so the page has no way to call the CLI's own ranking.Problem and solution fit
Same split as
exportSearchIndex()/rankSearchIndex():exportIconIndex({cwd, package?})reads the icon setsicon()would search incwdand returns{version, sets, withdrawn}as plain JSON. It runs where loading packages is safe.rankIconIndex(query, indexes, {set?, limit?})ranks stored indexes and returns the sameicon.searchenvelope asicon()for a word search; it sharesicon()'s query, limit and default checks, and refuses a<set>/<id>query, whichicon()reads as one icon.icon()search andrankIconIndex()call one shared function (rankIconSetsinapi/icon/search/search.mjs), which wrapsrankIconsandansweringMatchesunchanged. No scoring code changes.Current specification
Experimental API (AST-017 FR27), alongside the experimental search-index pair (AST-033). No new command.
Public delta and caller burden
@astryxdesign/cli/api, two new experimental types (IconIndex,IconIndexSet).icon()output is unchanged.ERR_INVALID_ARGUMENTotherwise). Equal scores keep the order of the indexes given, asicon()keeps a project's set order; an index holds no project choice.Design and alternatives
icon()in the catalog was rejected: it needs the packages installed and runs their manifests.rankIconswas rejected: callers would rebuild set loading, the set filter, the answering cut and the envelope, and could drift.setthat names one gives the same error asicon().Evidence
icon-index.test.mjs: for every query in a generated list (ids, words, parts, prefixes, infixes, plurals, phrases, misses), with and without a project set,rankIconIndex(q, JSON round-tripped exportIconIndex())deep-equalsicon(q); same forset,limitand every error;packagefilter; several indexes keep the given order; no folder paths in the index; version refusal.icon()output is byte-identical, andrankIconIndexover the exported index is byte-identical toicon().Scope
Components: cli/api/icon
Testing
vitest run --project node packages/cli/api/icon packages/cli/test/lazy-dependencies.test.mjs(291 pass);pnpm check:knowledgepassespnpm -F @astryxdesign/cli sync:api-types,typecheck:json-api,node .github/scripts/cli-api-types-verify.mjspass.typecheck:strictreports only two pre-existing errors for an unbuilt theme package in page templates, unrelated.Record line
docs/specs/AST-033/spec.mdFR2a records the experimental pair: the index shape{version, sets, withdrawn}, the same-CLI-version refusal naming both versions, and equal scores keeping the order the indexes were given.Writing rubric results