@stnd/diagnostics
Circle 3 — Specialized Satellite & Plumbing · Active · Utility
Role: The framework’s known errors and its laws in one place: a registry (code, doc page, rule), pure lint rules, and the laws as data.
When to use: Check a file against the laws (
lintSource), build a documented issue (issue), or read the laws and error pages fromstnd check, the MCP audit or a script — instead of re-typing them.
Quick Start (TL;DR)
import { lintSource, find } from "@stnd/diagnostics";
const issues = lintSource(source, "modules/core/layouts/Base.astro");
// → [{ code: "ERR_FOUNDATION_IMPORTS_FEATURE", doc, repair, … }]
find("ERR_CROSS_MODULE_IMPORT"); // → { title, slug, rule, severity }
The framework’s known errors and its laws, defined once.
ELI5
Standard has rules (“the shell never imports a feature”) and errors (”ERR_FOUNDATION_IMPORTS_FEATURE, see this page”). They used to be re-typed in the CLI, in the MCP server and in scripts, so they drifted. This package holds them in one place and everyone else reads from it.
What’s inside
| Part | What it is |
|---|---|
Registry (LINT, RUNTIME, find, docUrl) |
Every known error: its ERR_* code (for lint errors), the law/rule it enforces, its severity and its page on stnd.build/manual/diagnostic/<slug>. |
Rules (lintSource, lintModuleBoundaries, …) |
Pure checks: (source, path) → issues. No file system, no Astro — they run anywhere. Each issue carries a code, a message, the doc link and a repair (problem, solution, bad, good). |
Laws (LAWS, CONVENTIONS) |
The non-negotiable laws and conventions as data, for the MCP server and any tool that explains them. |
@stnd/diagnostics/node |
findFiles and lintFile: the file-tree half, for the CLI and scripts. |
Who uses it
@stnd/cli—stnd checkwalks the files and prints the issues.@stnd/mcp— the module audit reuses the boundary rules; the server serves the laws.apps/stnd.build— a test keeps the registry and thediagnostic/pages in step (Law 7: every error is documented).
Rules today
| Code | Enforces |
|---|---|
ERR_SEMANTIC_TAG_REDUNDANT, ERR_HYBRID_ELEMENT_STYLING, ERR_EXTERNAL_CDN |
markup purity |
ERR_ARBITRARY_RHYTHM_MULTIPLIER |
vertical rhythm |
ERR_ASTRO_BUSINESS_LOGIC |
Law 3 — .astro holds no logic |
ERR_CROSS_MODULE_IMPORT, ERR_FOUNDATION_IMPORTS_FEATURE, ERR_MULTIPLE_FOUNDATION_MODULES |
Law 4 — vertical slices |
ERR_HOOK_SERVER_ON_ACTION |
hooks integrity |
Adding an error
- Add it to
LINTinsrc/registry.js(code, slug, rule, severity, title). - Write the rule and build issues with
issue("ERR_…", { file, message, repair })— the registry supplies the rest. - Write the page
apps/stnd.build/modules/manual/content/diagnostic/<slug>.md. A test fails until it exists.