Repository navigation
fix(cli): docs finds a topic by its title, keywords, or a route typed with other separators - #11990
Conversation
… and keywords A docs read now opens a page typed in another spelling of its own route or child name: spaces, hyphens, slashes, dots and underscores all separate words, and word order does not count. Words that only name a page give suggestions: the pages whose route, title or declared keywords carry a typed word, closest first, at most five, and a namespace's children are ordered the same way. The docs tree now carries each guide's and flat topic's declared keywords.
…ocs misses Word matches now take the place of the topics-and-namespaces list only when no other command's entry matches, never add to that command's list, and are never longer than the list they replace. The route that list leads with stays first when the typed text names it, and so does a namespace child list's first child, so a page found only by shared words never moves a named route down.
|
/approve-spec 4524738 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
There was a problem hiding this comment.
Approval waits on one spec decision from an engineering owner, and three fixes are needed.
astryx docs now opens a route or child name typed with other separators or in another word order (tokens.tokens-color, tokens-color/tokens, api cli, quick start), but no current record states that rule: spec:AST-046 FR5 does not cover it, and FR6 says an unknown route fails with ERR_UNKNOWN_TOPIC. To settle it, add the rule to spec:AST-046 in this pull request and have an engineering owner approve that head with /approve-spec <full head SHA>; the author may do this as an engineering owner. The /approve-spec already posted approves no record, because the pull request changes none.
- An integration's flat topic never gets keyword suggestions:
flatTopicInputsreadskeywordsonly when a topic's catalog entry has nocategory(packages/cli/api/docs/_adapter.mjs:496-505), and integration topic records always set one (packages/cli/foundation/discovery/docs-discovery.mjs:710), so a topic that declaressmokerstill gets the full list forastryx docs smoker. - The description says that before this change any spelling other than the exact route was a miss and that
astryx docs tokens.tokens-colorlisted every namespace and topic, butmainalready openstokens-colorandtokens/colorand suggests onlytokensandcolorfortokens.tokens-color, so please correct that wording. spec:AST-083FR7 places a change to the docs suggestion order under FR6, which asks the description to report the measured comparison on the evaluation sets, so please add the per-set results that show no row is worse.
Claims and files checked
Review mode: full; reason: no-earlier-review
Claims (description and changeset):
- A route or child name typed with dots, spaces, underscores, slashes or reordered words opens its page: verified (probes such as
tokens.tokens-colorandapi cli;docs.spelling.test.mjs:121-138). - Before this change, any spelling other than the exact route was a miss: false.
mainalready opens case-folded routes, bare child names andtokens/color(_adapter.mjs:1894). - Before this change,
tokens.tokens-colorlisted every namespace and topic: false.mainsuggestedtokensandcolor; the full list appears only when no name shares a typed word. - A miss suggests the pages whose route, title or declared keywords share a typed word, closest first: verified for titles, the CLI's own topics and integration guides; false for an integration's flat topic (
_adapter.mjs:496-505). - Word matches appear only when no other command's entry matches, and never join that command's list: verified (
_adapter.mjs:2414-2425,docs.entry-command.test.mjs). - The new list is never longer than the list it replaces, and holds at most five: verified (
_adapter.mjs:2286-2291). - A route the typed words name, and a namespace child list's first child, stay first: verified (
namedFirst,docs.spelling.test.mjs:199-209). - The docs tree carries each guide's and flat topic's declared keywords: false for an integration's flat topic (
docs-discovery.mjs:710). themingsuggests the Theming topic first: verified (theme, titled Theming, alone).- Exact routes, section reads and a miss that another command matches behave as before: verified (CLI docs suites pass).
- The new and changed tests are the regression proof: verified. The new spelling and order tests fail on
mainand pass here. - One measured case got worse while many more improved: unverified, because no evaluation results are reported.
- Lint, formatting, type checks and the repository checks pass: verified by CI's lint and typecheck jobs and a local prettier, eslint, changeset and CLI-structure run.
- No new public API: verified. The spelled-route reading is new behavior with no governing clause yet.
- No internal context in public text: verified.
Files:
.changeset/docs-topic-spellings.md: its keyword claim is false for an integration's flat topic.packages/cli/api/docs/_adapter.mjs: flat-topic keywords are read only on one branch (:496-505); the spelled lookup (:1846) awaits the spec decision.packages/cli/api/docs/docs.entry-command.test.mjs: non-blocking; the "one fewer" test no longer checks the count.packages/cli/api/docs/docs.spelling.test.mjs: clear; it has no integration flat-topic keyword case.packages/cli/foundation/discovery/docs-discovery.mjs: guides carry keywords (:689) but flat-topic records do not (:704-714).packages/cli/foundation/doc-compiler/tree.mjs: clear; the typedef at:103promises flat-topic keywords.packages/cli/foundation/text/suggest-order.mjs: clear.packages/cli/foundation/text/suggest-order.test.mjs: clear.
| ); | ||
|
|
||
| it( | ||
| 'keeps the docs that share a word after the command, one fewer', |
There was a problem hiding this comment.
Non-blocking: the title still promises "one fewer", but the assertions no longer check the count, as the old plain.suggestions.slice(0, -1) comparison did. Assert the docs list's length with the command, or retitle the test.
PR Analysis Report🔎 Preview ·
|
…ation topic keywords AST-046 FR5 now states that a docs read opens a page typed in another spelling or word order of its route or child name, only when exactly one non-experimental doc answers. FR6 states that an unknown route or name still fails with ERR_UNKNOWN_TOPIC, with suggestions ordered by route, title and declared keywords, at most five and never more than the topics-and-namespaces list, a named route kept first. An integration's flat topic now carries its declared keywords from discovery, so word-match suggestions find it even though its record always sets a category.
|
/approve-spec b040370 |
There was a problem hiding this comment.
Approved pending CI: CI has not finished on this head yet.
astryx docs now opens a route typed in another spelling and suggests pages by their title and keyword words, and spec:AST-046 FR5 and FR6 state both rules with an engineering owner's approval for this head. The earlier keyword gap for an integration's flat topic and the description wording are fixed, and the measured comparison is reported with no worse row.
- Miss (non-blocking):
orderDocSuggestionsfinds a page's parent withname.slice(0, name.lastIndexOf('/'))(packages/cli/foundation/text/suggest-order.mjs:441-443), so a top-level route such asiconscounts as a child oficonand drops out of a closest list when both match; look up a parent only when the route has a/.
Claims and files checked
Review mode: full; reason: spec-record
Claims (description and changeset):
- Before this change, a route opened only in the spellings the lookup already knew,
tokens.tokens-colorwas a miss that suggestedtokensandcolor, and a miss whose words named no route listed every namespace and topic: verified by runs on the base. - A route or child name typed with spaces, hyphens, slashes, dots, underscores or in another word order opens its page: verified (
docs.spelling.test.mjs:130-172;tokens.tokens-color,color tokensandapi cliopen on this head). - When no other command's entry matches, a miss suggests the pages whose route, title or declared keywords share a typed word, closest first: verified (
docs.spelling.test.mjs:174-254;themingsuggests the Theming topic first). - A named route stays first, and the list is never longer than the one it replaces and holds at most five: verified (
_adapter.mjs:2269-2290); the five cap sits in_adapter.mjs, not insuggest-order.mjsas the file list says. - Word matches never join the list another command's entry leads: verified (
docs.entry-command.test.mjs:209-274). - The docs tree carries each guide's and flat topic's declared keywords, an integration topic's included: verified (
docs-discovery.mjs:691,:713,:1155,:1194;docs.spelling.test.mjs:194-202). - The docs-tree record states the spelling and word-match rules and its verification row names the new states: verified.
- Exact routes and section reads open as before, and a miss another command's entry matches keeps that command's list: verified (identical base and head runs; entry-command tests pass on both).
- The new spelling test fails without the fix: verified (13 of the 73 tests in the changed files fail on the base).
- The measured comparison shows no set or project worse, with one lookup whose first suggestion got worse: consistent with the ordering rule (no interval lies entirely below zero); not re-run, because the evaluation sets are not in the repository.
- Search answers are unchanged: verified (search does not read the new keywords for guides or flat topics; search suites pass).
- Lint, formatting and type checks pass: formatting and lint verified on the changed files; CI's type check passed and its lint job was still running.
- No new public API: verified.
Files:
.changeset/docs-topic-spellings.md: clear.docs/specs/AST-046-docs-tree/spec.md: clear; owner-approved for this head.packages/cli/api/docs/_adapter.mjs: clear.packages/cli/api/docs/docs.entry-command.test.mjs: non-blocking; the "one fewer" test no longer checks the count.packages/cli/api/docs/docs.spelling.test.mjs: clear.packages/cli/foundation/discovery/docs-discovery.mjs: clear.packages/cli/foundation/doc-compiler/tree.mjs: clear.packages/cli/foundation/text/suggest-order.mjs: non-blocking; the top-level parent lookup above.packages/cli/foundation/text/suggest-order.test.mjs: clear.
| return kept | ||
| .filter(r => { | ||
| const parent = byRoute.get( | ||
| r.item.name.slice(0, r.item.name.lastIndexOf('/')), |
There was a problem hiding this comment.
Miss (non-blocking): for a top-level route lastIndexOf('/') is -1, so this slice cuts off the last letter and icons is looked up with icon as its parent. orderDocSuggestions('icon set', [{name: 'icon'}, {name: 'icons'}, {name: 'shape'}], {closest: true}) returns only icon. The CLI's own docs have no such pair, but an integration's top-level route can make one. Look up a parent only when the route contains /.
User impact
Someone reading docs from the CLI types a topic the way they remember it: a route with other separators or in another word order (
astryx docs tokens.tokens-color), or a page's title words (astryx docs theming). Before, a route opened only in the spellings the lookup already knew (tokens-color,tokens/color);astryx docs tokens.tokens-colorwas a miss that suggestedtokensandcolor, and a miss whose words named no route listed the namespaces and topics. Nowastryx docsopens a page typed in another spelling of its own route or child name, and a miss suggests the pages whose route, title or declared keywords share a typed word, closest first.Problem and solution fit
The fix reads spaces, hyphens, slashes, dots and underscores as word separators and ignores word order when it matches a typed route. When the typed words only name a page and no other command's entry matches, the miss orders its suggestions by the words they share with the page's route, title and declared keywords. A route that the typed words name stays first, and the list is never longer than the list it replaces.
Expected behavior and authority
spec:AST-083/FR7andspec:AST-083/DEC-2: a not-found answer keeps its facts, and the order inside its suggestion list is a measured quality.spec:AST-046/FR5andspec:AST-046/FR6(edited in this pull request to describe its behavior): a read opens a doc typed in another spelling or word order of its route or child name, and an unknown route or text still fails withERR_UNKNOWN_TOPIC, with word-match suggestions that never outnumber the topics-and-namespaces list and keep its named first route first.Smallest restoration
packages/cli/api/docs/_adapter.mjs: a typed route matches in any spelling of its words; word-match suggestions replace the topics-and-namespaces list only when no other command's entry matches, never add to that command's list, and are never longer than the list they replace; a named route and a namespace child list's first child stay first.packages/cli/foundation/text/suggest-order.mjs: orders suggestions by shared words, closest first, at most five.packages/cli/foundation/doc-compiler/tree.mjsandpackages/cli/foundation/discovery/docs-discovery.mjs: the docs tree carries each guide's and flat topic's declared keywords, an integration topic's included.docs/specs/AST-046-docs-tree/spec.md: FR5 and FR6 state the spelling and word-match rules; the verification row names the new states.Evidence
astryx docs tokens.tokens-coloris a miss that suggeststokensandcolor.astryx docs tokens.tokens-coloropenstokens/tokens-color, andastryx docs themingsuggests the Theming topic first.packages/cli/api/docs/docs.spelling.test.mjs(new; an integration topic that declares a keyword comes first for that word, and the test fails without the fix),packages/cli/api/docs/docs.entry-command.test.mjsandpackages/cli/foundation/text/suggest-order.test.mjs.Measured comparison (
spec:AST-083/FR6). The judged first answer after a failed lookup, base against head; the paired change over each whole set, with its 95% interval:docsthat now lead with the page that covers them (sizes, radius, density, data visualization, light and dark mode, the command list).Known trade-off. In one measured case, the first suggestion got worse. The typed name named no doc, and no other command's entry matched it. Before, the miss listed every namespace and topic, and the one the reader wanted happened to sort first. Now the list leads with the pages whose route, title or keywords share a typed word, and a page about authoring themes, which shares one generic word with the name, comes first. The wanted namespace shared no word with the name, so no rule based on the typed words could have put it first. We accept this case because, on the same measurement, many more misses now get the right first suggestion or open the right page. It is not special-cased: a rule for that one name would fit the rule to a test case.
Writing rubric results
AST-046 edits (FR5, FR6 and their verification row):
Scope
Components: CLI docs command (
api/docs), suggestion order (foundation/text), docs tree compiler (foundation/doc-compiler,foundation/discovery)Testing
vitest --project node packages/cli: only the known environment-bound failures, which fail the same way on a cleanmain.eslint,prettier --check,tscstrict,pnpm check:cli-structure,pnpm check:knowledgeandpnpm check:changesetspass.