Repository navigation
chore(cli): lint the CLI structure rules - #6617
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 Regression1 of 420 shot(s) changed. View the report A change here is a question, not a failure: check whether the after is the
Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
There was a problem hiding this comment.
Thanks for adding the mechanical gate — enforcing these already-agreed CLI structure rules in pnpm lint is the right direction, and the exact-category allowlist that fails when an entry goes stale is a strong design. It matches the governing direction: "The checks and the closure of the gaps above land as separate changes."
One issue blocks approval: the gate currently passes while some real environment access is not recorded, so the allowlist is not yet exact. The governing INV21 claim is that environment access happens only in "_adapter.mjs and any underscore-prefixed helper that only it imports", and that the entry and leaves "they do not import filesystem, network, or subprocess modules, the Project seam, or discovery and loader functions".
- The import scanner in
scripts/check-cli-structure.mjsonly readsfrom '...'specifiers, so runtime dynamic imports are invisible to it.packages/cli/api/gap-report/gap-report.mjsalready usesawait import('node:child_process')to rungh, but its INV21 allowlist entry lists onlyprojectanddiscovery— the new check reports the tree as clean anyway, and a future handler or API module could bypass the check the same way. Please make the scanner classify runtime dynamic imports (without flagging JSDoc type-only imports), then either record this category or move the fallback behind that subject's adapter, and add a mutation test for the dynamic-import case. - The API exemption covers every file whose name starts with
_, which is broader than INV21. For example,packages/cli/api/swizzle/_github.mjsimportsnode:child_processand is imported directly by thecopyleaf, so that subprocess access also passes with no allowlist entry. Please either narrow the exemption to adapter-only helpers or record this as an explicit known gap.
The other checks correspond to their governing claims: INV22 — "It reads no files, loads no project, runs no discovery, and starts no subprocess or network request"; INV23 — a handler "does not pad strings to a width, align columns, or draw tables"; FR3 — items and values must use the shared blocks, "never columns or tables that a command builds from characters itself"; FR1 — a command "MUST perform it by calling one function exported from @astryxdesign/cli/api"; and FR2 — an exported function "MUST have reference documentation that states its parameters". The counts the check reports, the FR1/FR2 name checks, the text-layout checks, and the stale-entry behaviour for static imports all look right. Once the two gaps above are closed, this should be ready.
[Automated review]
20d9a19 to
f1ef228
Compare
There was a problem hiding this comment.
Thanks for adding the mechanical gate, and for closing the two gaps from the last round — this is ready to approve. Enforcing these already-agreed rules in pnpm lint matches the governing direction: "The checks and the closure of the gaps above land as separate changes."
What was verified at this revision:
- INV21, where environment access happens only in the adapter — "reading or writing files, network requests, subprocesses, loading the project or its modules, and discovery that reads the disk happen in the subject's adapter:
_adapter.mjsand any underscore-prefixed helper that only it imports", and the entry and leaves "they do not import filesystem, network, or subprocess modules, theProjectseam, or discovery and loader functions". The scanner now classifies literal dynamic imports, so gap-report's dynamicnode:child_processuse is recorded in its allowlist entry, and the exemption is computed from the import graph — only adapter-only helpers are exempt, while the subprocess helper imported by the swizzle leaf is scanned and recorded as a gap. The gate passes exactly: 74 API modules checked. - INV22 — "It reads no files, loads no project, runs no discovery, and starts no subprocess or network request" — checked over 17 handlers with eight recorded gaps.
- INV23 — "A handler does not pad strings to a width, align columns, or draw tables" — and FR3 — "Items and field values MUST use Record, Section, or List blocks, never columns or tables that a command builds from characters itself" — checked in the script and in ESLint, with two recorded gaps.
- FR1 — "Every command or subcommand that performs an operation MUST perform it by calling one function exported from
@astryxdesign/cli/api" — checked over 28CommandDocfunctions with one recorded gap. - FR2 — "Every function exported from
@astryxdesign/cli/apiMUST have reference documentation that states its parameters" — checked over 37 exports, currently clean.
One small non-blocking note: the CONTRIBUTING row and the script header describe private helpers as if they were exempt, while the check actually exempts only helpers that adapters alone import and scans the rest. Tightening that wording to match the code would save the next contributor a surprise; it does not change the gate's behaviour, which fails closed here.
[Automated review]
f1ef228 to
9791899
Compare
There was a problem hiding this comment.
Thanks for adding the mechanical gate — this is ready to approve. Enforcing these already-agreed rules in pnpm lint matches the governing direction: "The checks and the closure of the gaps above land as separate changes."
What was verified at this revision:
- INV21, where environment access happens only in the adapter — "reading or writing files, network requests, subprocesses, loading the project or its modules, and discovery that reads the disk happen in the subject's adapter:
_adapter.mjsand any underscore-prefixed helper that only it imports", and the entry and leaves "they do not import filesystem, network, or subprocess modules, theProjectseam, or discovery and loader functions". The scanner classifies literal dynamic imports, so gap-report's dynamicnode:child_processuse is recorded in its allowlist entry, and the exemption is computed from the import graph — only adapter-only helpers are exempt, while the subprocess helper imported by the swizzle leaf is scanned and recorded as a gap. The gate passes exactly: 74 API modules checked, including the two environment imports that landed on main after this PR was first drafted (the integration validator and the upgrade runner), both recorded with their exact categories. - INV22 — "It reads no files, loads no project, runs no discovery, and starts no subprocess or network request" — checked over 17 handlers with eight recorded gaps.
- INV23 — "A handler does not pad strings to a width, align columns, or draw tables" — and FR3 — "Items and field values MUST use Record, Section, or List blocks, never columns or tables that a command builds from characters itself" — checked in the script and in ESLint, with two recorded gaps.
- FR1 — "Every command or subcommand that performs an operation MUST perform it by calling one function exported from
@astryxdesign/cli/api" — checked over 28CommandDocfunctions with one recorded gap. - FR2 — "Every function exported from
@astryxdesign/cli/apiMUST have reference documentation that states its parameters" — checked over 37 exports, currently clean.
The CONTRIBUTING wording now also matches the implemented rule — a helper is exempt only when adapters alone import it — so the note from the last round is closed too.
[Automated review]
Add mechanical enforcement for the architecture invariants and spec requirements that were review-only until now. check-cli-structure.mjs (runs in pnpm lint via check:repo): - INV22: command handlers must not import environment modules (node:fs, node:child_process, Project, discovery). 8 known gaps allowlisted with exact category tracking — a new violation in an allowlisted file fails, and a stale entry (removed import) also fails. - INV21: API modules other than adapters (_*.mjs) must not import environment modules. 29 known gaps allowlisted the same way. - INV23/FR3: handlers must not use .padEnd(), .padStart(), .repeat(), or new Block() for text layout. 2 known gaps allowlisted. - FR1: every executable CommandDoc fn must name a function exported from api/index.mjs. 1 known gap (themeTemplate). - FR2: every function exported from api/index.mjs must have a FunctionDoc whose name matches. Currently clean. eslint.config.js: - INV23/FR3: no-restricted-syntax selectors ban padEnd, padStart, repeat, and new Block in command handlers. build-theme.mjs and docs.mjs exempted via config block (the script provides the exact-entry gate). CONTRIBUTING.md: - Six new rows in the "enforced for you" table documenting each check.
9791899 to
c448a98
Compare
There was a problem hiding this comment.
Thanks for adding the mechanical gate — this is ready to approve. Enforcing these already-agreed rules in pnpm lint matches the governing direction: "The checks and the closure of the gaps above land as separate changes."
What was verified at this revision:
- INV21, where environment access happens only in the adapter — "reading or writing files, network requests, subprocesses, loading the project or its modules, and discovery that reads the disk happen in the subject's adapter:
_adapter.mjsand any underscore-prefixed helper that only it imports", and the entry and leaves "they do not import filesystem, network, or subprocess modules, theProjectseam, or discovery and loader functions". The scanner classifies literal dynamic imports, so gap-report's dynamicnode:child_processuse is recorded in its allowlist entry, and the exemption is computed from the import graph — only adapter-only helpers are exempt, while the subprocess helper imported by the swizzle leaf is scanned and recorded as a gap. The gate passes exactly: 74 API modules checked, including the integration validator and the upgrade runner, both recorded with their exact categories. - INV22 — "It reads no files, loads no project, runs no discovery, and starts no subprocess or network request" — checked over 17 handlers with eight recorded gaps.
- INV23 — "A handler does not pad strings to a width, align columns, or draw tables" — and FR3 — "Items and field values MUST use Record, Section, or List blocks, never columns or tables that a command builds from characters itself" — checked in the script and in ESLint, with one recorded script gap (
docs.mjs). At this revision the stale script entry forbuild-theme.mjsis removed, since that handler no longer uses the banned patterns. - FR1 — "Every command or subcommand that performs an operation MUST perform it by calling one function exported from
@astryxdesign/cli/api" — checked over 28CommandDocfunctions with one recorded gap. - FR2 — "Every function exported from
@astryxdesign/cli/apiMUST have reference documentation that states its parameters" — checked over 37 exports, currently clean.
One small non-blocking note: the ESLint layout exemption still lists build-theme.mjs even though it no longer needs it; the script gates that file with no allowlist entry, so nothing slips through, but dropping the redundant ESLint entry would keep the two configs in step.
[Automated review]



Maintainer impact
The CLI architecture invariants (INV20–23) and the command admission spec (AST-042 FR1–FR3) are current authority with no mechanical enforcement. Review applies them, but a new violation slips past when review misses it. This change adds lint checks so they fail in CI.
Intended invariant
architecture:cli-surfaceINV21–23 andspec:AST-042FR1–FR3.Change
Six checks, all running inside
pnpm lintviacheck:repo:check-cli-structure.mjsexact-entry allowlistcheck-cli-structure.mjsexact-entry allowlist.padEnd(),.padStart(),.repeat(), ornew Block()for text layoutno-restricted-syntax+check-cli-structure.mjsCommandDocfnmust name a function exported fromapi/index.mjscheck-cli-structure.mjsexact-entry allowlistthemeTemplate)api/index.mjsfunction export must have aFunctionDocwhosenamematchescheck-cli-structure.mjsCurrent-main baseline: Two imports landed after this PR was first drafted: the integration validator reads discovery, and the upgrade runner reads the filesystem. The initial gate records those existing categories. After the gate lands, any new category or stale entry fails, so the list only shrinks. The contributor table and script now say that an underscore helper is exempt only if adapters alone import it.
Allowlist design: each entry tracks the exact violation categories a file has. A new category in an allowlisted file fails. A stale entry (the violation was fixed but the entry remains) also fails. The list can only shrink.
If #6616 merges first and removes handler violations, this PR’s stale-entry check will fail on the removed entries — delete them and the check passes. If this PR merges first, #6616 must delete the entries it makes stale.
Order with the other open CLI PRs: Prefer #6616 first, then rebase this PR and remove the now-stale
build-theme.mjspadEndallowlist entry; the combined structure check and focused parity tests pass with that entry removed. #6626 also rewritesdocs.listand editscli-surface; whichever lands second must rebase and preserve thepackagetext projection. If #6626 changes thedocs.mjstext-layout calls, refresh this PR’s exact-category entry. #6702 exportsthemeTemplate, so if it lands before this PR, remove the now-stale FR1 gap too. These are order-dependent maintenance steps, not four independent approvals.Evidence
pnpm lintcatches each violation kindMutation proofs (each introduced a deliberate violation, confirmed the check failed, then restored):
.padStart()in clean handler → caught by both ESLint and scriptfnnot exported → caughtFunctionDoc→ caught.padStart()in allowlisteddocs.mjs→ caught by scriptScope
Testing
Current-head local evidence:
pnpm check:repo: passed (includescheck:cli-structure)lintpassed; isolated local whole-repo ESLint crashed after the repository checks had passedpnpm check:cli-structure: 10 doc-types, 17 api folders, 17 handlers INV22, 74 api modules INV21, 28 CommandDoc fns FR1, 37 exports FR2pnpm -F @astryxdesign/cli typecheck:strict: 0 errorsprettier --check CONTRIBUTING.mdandgit diff --check: clean