Skip to content

feat(cli): doctor's kept-cache row prints a short brief; --json keeps the whole message - #12607

Merged
josephfarina merged 2 commits into
mainfrom
doctor-kept-cache-brief
Nov 18, 2026
Merged

josephfarina merged 2 commits into
mainfrom
doctor-kept-cache-brief

Conversation

@josephfarina

@josephfarina josephfarina commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

User need

Default astryx doctor text is read in full by agents on every run. The gather-cache (kept catalog cache) row had grown to about 2 KB as more kinds of kept results were added, about a third of the whole default report on a typical project. A reader needs only four facts from that row: where the cache is, how much it holds, how to see everything it keeps, and how to clear it.

Problem and solution fit

  • The row's JSON message stays whole, so no fact is lost.
  • The check gains an optional brief field. Text prints brief in the message's place. The brief names only the folder, its entry count and size, the command that lists every kept item and the size limits (astryx doctor --json), and the exact command that clears the caches.
  • The clear command removes the catalogs folder and, when it exists, the transpile cache folder, so nothing stays kept without being named. Before, the row only said that deleting the folder clears it.

Current specification

spec:AST-081 FR7 says what doctor's cache row names. This PR adds one sentence there, which is the basis for the text form: "Text output prints the row's brief in place of that message: the folder, its entry count and size, the doctor --json command that prints the whole message, and the command that removes the catalogs folder and, when it exists, the transpile folder." brief is its own JSON field, and text prints it under a legend that names it (message (or brief)), so every printed value maps to a JSON key (architecture:cli-surface INV5). spec:AST-017 FR13: brief is in the response type (doctor.type.mjs) and in the consumer schema docs (doctor.doc.mjs, printed by astryx docs cli/api/functions/doctor).

Public delta and caller burden

Text, before (one row, 1,997 bytes):

[info]  gather-cache - Kept catalog cache - search, build, component, template, theme, discover, docs and doctor keep
        what they gather (search's catalogs, each integration's check results, ... and doctor's docs
        checks and theme-wiring scan) in /home/dev/.cache/astryx/catalogs (12 entries, 4.7 MB); each is used only
        while nothing it read has changed, ... and deleting the folder clears it. ... The folder holds at most 64 MB,
        ...; the transpile cache in /home/dev/.cache/astryx/transpiled keeps its copies in 256 subfolders, ...

Text, after (281 bytes):

[info]  gather-cache - Kept catalog cache - 12 entries (4.8 MB) in /home/dev/.cache/astryx/catalogs. `npx
        @astryxdesign/[email protected] doctor --json` lists every kept item and the size limits. To clear the caches, run: rm
        -rf /home/dev/.cache/astryx/catalogs.

The legend reads Each check: status, id, label, message (or brief), fix only when a check has a brief.

JSON: additive only. DoctorCheck gains optional brief (typed in doctor.type.mjs, documented in doctor.doc.mjs). message, ids, statuses, the summary, and exit codes are unchanged. Checked by comparing doctor --json before and after with brief removed: identical.

removeFolderCommand now also takes a list of folders (rm -rf a b; on Windows Remove-Item -Recurse -Force -LiteralPath a, b).

Design and alternatives

A per-check brief keeps the data model explicit: the JSON consumer gets the same short form, and the text view needs no special case for one check id.
Rejected: shortening message itself (JSON would lose facts); printing the first sentence of every check's message (changes every other row and drops facts without naming a route).

Evidence

Bytes of default astryx doctor (text) on a consumer project (the sandbox app's files, Core linked, packed CLI, fresh cache after search, component, template --list, docs, build, theme --list, discover, and a mistyped component; same paths in both):

default doctor kept-cache row
before 5,993 B 1,997 B
after 4,330 B 281 B

That is 1,663 B (28%) less per run. Only the legend line and the kept-cache row differ.

Blind A/B: three agents with no context, each given one version of that output and no tools, answered the same five questions.

Question Old output New output
Where is the cache, and how much does it hold? Folder, 12 entries, 4.7 MB (also the 64 MB cap and the transpile folder) Folder, 12 entries, 4.8 MB
How do I see every kept item? "Not stated." npx @astryxdesign/[email protected] doctor --json
How do I clear the caches? (exact command) "The output gives no CLI command"; inferred rm -rf of the folder and was unsure about the transpile folder rm -rf /home/dev/.cache/astryx/catalogs
Where are the full details and limits? "Not stated"; guessed docs cli doctor --json, which the row says shows the size limits
What should I fix in this project? The two warnings, with their commands The same

Result: the new output is better on the questions about listing and clearing, and the same on the rest. (A first draft of the brief said only "lists every kept item"; its reader answered question 4 with "not stated", so the brief now also says that --json shows the size limits. That reader gave the same answers as above on the other questions.)

Writing rubric results

Record changed: spec:AST-081 FR7, one sentence added.

R1 narration: none; the sentence states what text output prints.
R2 research: none in the record; the bytes and the A/B live in this description.
R3 evidence: no evidence cell changed.
R4 rejected alternatives: none in the record.
R5 change references: none.
R6 answered open questions: none.
R7 project status: none.

Scope

Components: CLI doctor (api/doctor/doctor.mjs, clients/cli/commands/doctor.mjs)

  • One capability is added.
  • Unrelated fixes, cleanup, and policy changes were removed or split.
  • Consumer docs, focused tests, and migration evidence ship with the feature.
  • Public text and artifacts contain no internal Meta context.

No doc sample quotes this row, so no doc sample changed.

Testing

  • vitest --project node: test/packed-gather-cache.records.test.mjs (new: the brief's exact shape, the transpile folder joining the clear command once it exists, text printing the brief and not the message, the legend), test/packed-gather-cache.hosted.test.mjs, test/packed-gather-cache.malformed.test.mjs (their count masks now share one helper that also covers the brief), api/doctor/old-transpile-cache.test.mjs (new: several folders, POSIX and PowerShell), clients/cli/commands/doctor.test.mjs, api/doctor/doctor.test.mjs, clients/cli/commands/text-json-parity.test.mjs: all pass.
  • node .github/scripts/cli-api-types-verify.mjs: pass.
  • tsc --project tsconfig.strict.json: no errors in changed files. The only errors are the missing built @astryxdesign/theme-neutral output in two templates on this machine, which this change does not touch.
  • pnpm check:knowledge: aligned. Prettier: clean.

@vercel

vercel Bot commented Nov 18, 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 18, 2026 8:25am UTC

Request Review

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

astracat-bot Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 18, 2026, 8:32 AM UTC

@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 18, 2026
@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · cd95478

Storybook · Sandbox · built from this PR's head

Package size: @astryxdesign/cli 5.42 MB packed (+804 B); no new dependencies.

API changes: cli +1 · ~0 · −0

1 API change (advisory)
Package Where Signature Usage
+ cli ./api · Types · type DoctorCheck brief?: string | undefined import type {DoctorCheck} from '@astryxdesign/cli/api'; const x: DoctorCheck = {brief: …}

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

@josephfarina
josephfarina marked this pull request as ready for review November 18, 2026 07:38
@josephfarina

Copy link
Copy Markdown
Contributor Author

Owner decision (engineering owner, covering this pull request): in default doctor text output, the kept-cache row prints a short brief in place of its full message: the folder, its entry count and size, the doctor --json command that prints the whole message, and the exact command that clears the kept folders. The JSON output only gains an optional brief field; the message, ids, statuses and exit codes stay as they are. spec:AST-081 FR7 states this.

@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec daea8fd

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 18, 2026

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

Changes requested. The short kept-cache row matches the approved spec sentence and the focused tests pass, but the new brief field needs its consumer docs and the description needs one correction.

Blocking

  • packages/cli/api/doctor/doctor.doc.mjs (the doctor() returns description that astryx docs cli/api/functions/doctor prints) lists every check field except the new optional brief, and AST-017 FR13 requires every response field in the consumer-facing schema docs, so add brief there.
  • The description says the CLI conventions guide lets a long prose field print "a short form", but the guide and cli-surface INV4 allow only its first sentence, so please cite the approved AST-081 FR7 sentence as the basis instead.

Worth a look

  • Under Yarn Plug'n'Play the text row is now identical to a plain run and no longer says that the run keeps no catalog; one clause when summary.pnp is set would keep that fact.
Claims and files checked

Review mode: full; reason: no-earlier-review

  • Claim: the text row is short where it was a paragraph of about 2 KB: verified (2,063 to 480 bytes in a packed-CLI run).
  • Claim: the row names the folder, entry count and size, the --json pointer and a clear command: verified (doctor.mjs:2851, records test).
  • Claim: the clear command adds the transpile folder once it exists: verified (doctor.mjs:2845-2846, records test).
  • Claim: JSON keeps message and adds an optional brief, which text prints, with the legend reading message (or brief) only then: verified (commands/doctor.mjs:71-73, :101-107).
  • Claim: ids, statuses, the summary and exit codes do not change: verified (diff, doctor tests).
  • Claim: doctor --json lists every kept item: imprecise, it prints the kinds of kept results, not the entries (non-blocking).
  • Claim: before, the row only said that deleting the folder clears it: verified (base message).
  • Claim: the spec record gains one sentence about text output: verified.
  • Claim: text stays a projection of JSON and the legend names the printed key: verified.
  • Claim: the conventions guide allows a short form: false, it allows the first sentence (blocking).
  • Claim: brief is typed and documented: typed (doctor.type.mjs:22), consumer docs missing (blocking).
  • Claim: consumer docs ship with the feature: false (blocking).
  • Claim: removeFolderCommand takes several folders in POSIX and PowerShell form: verified (old-transpile-cache.test.mjs).
  • Claim: the report shrinks from 5,993 to 4,330 bytes and the row from 1,997 to 281: not repeated on that project; this review measured 6,335 to 4,763 and 2,063 to 480 bytes.
  • Claim: a blind A/B with three agents favours the new output: not checkable from the repository.
  • Claim: only the legend line and the kept-cache row differ: verified (only gather-cache sets brief).
  • Claim: the listed tests pass: verified (7 files, 517 passed, 1 skipped).
  • Claim: API type verification, knowledge check and Prettier pass: verified.
  • Claim: strict typecheck shows no errors in changed files: verified (CI's typecheck job passed at this head).
  • Claim: no doc sample quotes this row, no internal context, nothing unrelated: verified.
  • File: .changeset/doctor-kept-cache-brief.md: wording note (non-blocking).
  • File: docs/specs/AST-081-global-mode/spec.md: clear (owner-approved for this head).
  • File: packages/cli/api/doctor/doctor.mjs: non-blocking notes (Plug'n'Play clause, wording).
  • File: packages/cli/api/doctor/doctor.type.mjs: clear.
  • File: packages/cli/api/doctor/old-transpile-cache.test.mjs: clear.
  • File: packages/cli/clients/cli/commands/doctor.mjs: clear.
  • File: packages/cli/test-utils/packed-gather-cache-fixture.mjs: clear.
  • File: packages/cli/test/packed-gather-cache.hosted.test.mjs: clear.
  • File: packages/cli/test/packed-gather-cache.malformed.test.mjs: clear.
  • File: packages/cli/test/packed-gather-cache.records.test.mjs: clear.
  • File: packages/cli/api/doctor/doctor.doc.mjs (unchanged): blocking, missing brief.

Automated review (maintainer link)

label: 'Kept catalog cache',
status: 'info',
message: `search, build, component, template, theme, discover, docs and doctor keep what they gather (search's catalogs, each integration's check results, template discovery's records, the component list and whether the installed Core still matches the stored one, Core's and integrations' components with the doc parts the component matcher scores, Core hooks' declared keywords, integrations' theme records, what theme build checks a theme against in Core's component docs, the JavaScript theme build compiles from a theme's local TypeScript or JSX modules, what theme build finds when it checks a theme's pseudo-class keys and token names, the lookup commands' not-found hint's name summaries, npm's list of the files an integration package packs, the CLI's own docs tree, discover's record of the integrations a project loads and what each adds, and what it searches in its sources' saved copies, which search's discover line reads, and doctor's docs checks and theme-wiring scan) in ${summary.dir} (${summary.entries} ${summary.entries === 1 ? 'entry' : 'entries'}, ${size})${summary.pnp ? ", but not in a run under Yarn Plug'n'Play's loader, such as `yarn astryx`, which gathers every time" : ''}; each is used only while nothing it read has changed, the installed CLI's own files judged by its build id and folder (an upgrade, a reinstall or a copy in another folder changes them; in-place edits aren't supported), and deleting the folder clears it. A lookup command's not-found path may also create the folder, for its name index, and so may an integration package's \`integration check\` of itself, for npm's list. On Linux, when a debug handler is set, runs also keep the locale and time zone here. The folder holds at most ${summary.limitBytes / (1024 * 1024)} MB, dropping oldest entries first; the transpile cache in ${summary.transpiledDir} keeps its copies in ${SUBFOLDERS} subfolders, each holding at most 1/${SUBFOLDERS} of that, and drops the copies made longest ago first.`,
brief: `${entries} (${size}) in ${summary.dir}. \`${formatCliCommand('doctor --json', ctx.cwd)}\` lists every kept item and the size limits. To clear the caches, run: ${removeFolderCommand(kept)}.`,

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, two small points on the brief:

  • Under Yarn Plug'n'Play (summary.pnp) this text is now identical to a plain run, so yarn astryx doctor no longer says that the run keeps no catalog. Appending something like "This run keeps none (Yarn Plug'n'Play)." when summary.pnp is set keeps that fact.
  • doctor --json prints the whole message, which names every kind of kept result rather than each entry; "prints the whole message" (the spec sentence's wording) is more accurate than "lists every kept item". The changeset uses the same phrase.

@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec cd95478

@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. Both earlier requests are addressed: the doctor() docs now describe the optional brief field, and the description cites the approved AST-081 FR7 sentence as the basis for the text form.

The two non-blocking points on the brief still stand as optional follow-ups: a Yarn Plug'n'Play run no longer says in text that it keeps no catalog, and "prints the whole message" would describe doctor --json more exactly than "lists every kept item".

Claims and files checked

Review mode: incremental; reason: none

  • Changed rules (0): none.
  • Claim: the default text row is short where it was a paragraph of about 2 KB: verified (a 1,879-character message becomes a 410-character brief in a packed-CLI run; records test).
  • Claim: the row names the folder, its entry count and size, the doctor --json command and the exact clear command: verified (doctor.mjs:2851).
  • Claim: the clear command also names the transpile folder when it exists: verified (doctor.mjs:2845-2846, records test).
  • Claim: JSON keeps the whole message and adds an optional brief, which text prints in its place under the legend message (or brief): verified (commands/doctor.mjs:71-73, :101-108).
  • Claim: ids, statuses, the summary and exit codes do not change, and --json is identical apart from brief: verified (the message template is unchanged; doctor tests).
  • Claim: doctor --json lists every kept item and the size limits: imprecise, it prints the message, which names every kind of kept result rather than each entry (non-blocking).
  • Claim: agents read the default report in full, and the row was about a third of it: consistent with the repository's agent guide and an earlier packed run (2,063 of 6,335 bytes); not re-measured on the author's project.
  • Claim: before, the row only said that deleting the folder clears it: verified (base message).
  • Claim: the global-mode record gains the quoted sentence: verified (AST-081 FR7).
  • Claim: brief is its own JSON field and the legend names it, so every printed value maps to a JSON key: verified (cli-surface INV5; commands/doctor.mjs:101-104).
  • Claim: brief is in the response type and in the consumer schema docs that astryx docs cli/api/functions/doctor prints: verified (doctor.type.mjs:22, doctor.doc.mjs:51, docs output at this head).
  • Claim: removeFolderCommand takes a list in POSIX and PowerShell form: verified (old-transpile-cache.test.mjs:99-119).
  • Claim: the rejected alternatives (shortening message, first sentence of every row): design rationale, consistent with the code.
  • Claim: the report shrinks from 5,993 to 4,330 bytes and the row from 1,997 to 281: not repeated on that project; the same direction here.
  • Claim: a blind A/B with three agents favours the new output: not checkable from the repository.
  • Claim: only the legend line and the kept-cache row differ: verified (only gather-cache sets brief).
  • Claim: the record edit adds one sentence with no narration or project status: verified.
  • Claim: no doc sample quotes this row: verified.
  • Claim: public text carries no internal context: verified.
  • Claim: the listed tests pass: verified (7 files, 517 passed, 1 skipped; the doc readers, 5 files, 499 passed).
  • Claim: API type verification, the knowledge check and Prettier pass: verified; the strict typecheck runs in CI's typecheck job, still running.
  • File .changeset/doctor-kept-cache-brief.md: clear (wording note above).
  • File docs/specs/AST-081-global-mode/spec.md: clear (approved for this head).
  • File packages/cli/api/doctor/doctor.doc.mjs: clear.
  • File packages/cli/api/doctor/doctor.mjs: two non-blocking notes on line 2851.
  • File packages/cli/api/doctor/doctor.type.mjs: clear.
  • File packages/cli/api/doctor/old-transpile-cache.test.mjs: clear.
  • File packages/cli/clients/cli/commands/doctor.mjs: clear.
  • File packages/cli/test-utils/packed-gather-cache-fixture.mjs: clear.
  • File packages/cli/test/packed-gather-cache.hosted.test.mjs: clear.
  • File packages/cli/test/packed-gather-cache.malformed.test.mjs: clear.
  • File packages/cli/test/packed-gather-cache.records.test.mjs: clear.

Automated review (maintainer link)

@josephfarina
josephfarina merged commit 21d736b into main Nov 18, 2026
81 checks passed
@github-actions
github-actions Bot deleted the doctor-kept-cache-brief branch November 19, 2026 06:04

This branch was successfully deployed

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