stnd.build

@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 from stnd 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

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

  1. Add it to LINT in src/registry.js (code, slug, rule, severity, title).
  2. Write the rule and build issues with issue("ERR_…", { file, message, repair }) — the registry supplies the rest.
  3. Write the page apps/stnd.build/modules/manual/content/diagnostic/<slug>.md. A test fails until it exists.