Skip to content

fix(cli): docs finds a topic by its title, keywords, or a route typed with other separators - #11990

Merged
josephfarina merged 3 commits into
mainfrom
docs-topic-spellings
Nov 16, 2026
Merged

josephfarina merged 3 commits into
mainfrom
docs-topic-spellings

Conversation

@josephfarina

@josephfarina josephfarina commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

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-color was a miss that suggested tokens and color, and a miss whose words named no route listed the namespaces and topics. Now astryx docs opens 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

  • Why does the miss happen? The docs read matched a typed route only in the few spellings it already knew, and the miss hint knew only routes, not the titles or keywords that each page declares.
  • Why does it harm the task? A reader who typed a close spelling, or the words of a page's title, got a list of other names instead of the page.
  • Why does that harm matter? They guess again, or open the wrong page.

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/FR7 and spec: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/FR5 and spec: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 with ERR_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.mjs and packages/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

  • Reproduction before the change: astryx docs tokens.tokens-color is a miss that suggests tokens and color.
  • Result after the change: astryx docs tokens.tokens-color opens tokens/tokens-color, and astryx docs theming suggests the Theming topic first.
  • Representative unchanged path: exact routes and section reads open as before, and a miss that another command's entry matches keeps that command's list.
  • Regression test or other mutation-sensitive proof: 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.mjs and packages/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:

  • Held-out failed lookups:
    • Core-only project: +1.0 points [0.0, +2.0]. The right first answer improved for several names; two names lost theirs (docs topics typed with a plugin or team word).
    • Multi-integration project: +0.5 [-0.2, +1.3]; XDS project: +0.5 [-0.2, +1.3]. Small gains, and one name lost in each (the same one).
  • Fresh failed lookups:
    • Core-only: +1.6 [+0.7, +2.6]; multi-integration: +1.2 [+0.4, +2.0], with no losses; XDS: +1.0 [+0.3, +1.9], with one name lost.
    • The gains are mostly topic words typed at docs that now lead with the page that covers them (sizes, radius, density, data visualization, light and dark mode, the command list).
  • No set or project is worse. Search answers are byte-identical, and the typo grid shows no change.

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):

  • R1 narration: none; both additions state present-tense behavior.
  • R2 research: none in the record.
  • R3 evidence: the verification row names states, not pull requests.
  • R4 rejected alternatives: none added.
  • R5 change references: none.
  • R6 open questions: none touched.
  • R7 project status: none added.

Scope

Components: CLI docs command (api/docs), suggestion order (foundation/text), docs tree compiler (foundation/doc-compiler, foundation/discovery)

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Testing

  • vitest --project node packages/cli: only the known environment-bound failures, which fail the same way on a clean main.
  • eslint, prettier --check, tsc strict, pnpm check:cli-structure, pnpm check:knowledge and pnpm check:changesets pass.

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

Copy link
Copy Markdown
Contributor Author

/approve-spec 4524738

@vercel

vercel Bot commented Nov 16, 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 Nov 16, 2026 6:14am UTC

Request Review

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

astracat-bot Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 16, 2026, 6:24 AM UTC

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

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: flatTopicInputs reads keywords only when a topic's catalog entry has no category (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 declares smoker still gets the full list for astryx 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-color listed every namespace and topic, but main already opens tokens-color and tokens/color and suggests only tokens and color for tokens.tokens-color, so please correct that wording.
  • spec:AST-083 FR7 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-color and api cli; docs.spelling.test.mjs:121-138).
  • Before this change, any spelling other than the exact route was a miss: false. main already opens case-folded routes, bare child names and tokens/color (_adapter.mjs:1894).
  • Before this change, tokens.tokens-color listed every namespace and topic: false. main suggested tokens and color; 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).
  • theming suggests 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 main and 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 :103 promises flat-topic keywords.
  • packages/cli/foundation/text/suggest-order.mjs: clear.
  • packages/cli/foundation/text/suggest-order.test.mjs: clear.

Automated review (maintainer link)

Comment thread packages/cli/api/docs/_adapter.mjs Resolved
Comment thread packages/cli/api/docs/_adapter.mjs Resolved
);

it(
'keeps the docs that share a word after the command, one fewer',

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.

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.

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · b040370

Storybook · Sandbox · built from this PR's head

Package size: @astryxdesign/cli 4.97 MB packed (+3.4 kB); no new dependencies.

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

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

Copy link
Copy Markdown
Contributor Author

/approve-spec b040370

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

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): orderDocSuggestions finds a page's parent with name.slice(0, name.lastIndexOf('/')) (packages/cli/foundation/text/suggest-order.mjs:441-443), so a top-level route such as icons counts as a child of icon and 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-color was a miss that suggested tokens and color, 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 tokens and api cli open 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; theming suggests 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 in suggest-order.mjs as 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.

Automated review (maintainer link)

return kept
.filter(r => {
const parent = byRoute.get(
r.item.name.slice(0, r.item.name.lastIndexOf('/')),

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.

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

@josephfarina
josephfarina merged commit a62484b into main Nov 16, 2026
86 of 87 checks passed
@github-actions
github-actions Bot deleted the docs-topic-spellings branch November 17, 2026 06:03

This branch was successfully deployed

1 active deployment
Preview — b0403702 Deployed Nov 16, 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