Skip to content

feat(cli): add check and inspect commands for agents - #348

Merged
alexgrozav merged 17 commits into
mainfrom
styleframe-agent-ergonomics-uxf-406
Oct 21, 2026
Merged

alexgrozav merged 17 commits into
mainfrom
styleframe-agent-ergonomics-uxf-406

Conversation

@alexgrozav

Copy link
Copy Markdown
Contributor

Description

This PR makes Styleframe report the mistakes that used to build without a word, gives the CLI a way to check and inspect a configuration, and documents both for AI agents. It collects three PRs that were each reviewed on their own. The first part, validate() and strict (#343), is already on main.

  • feat(cli): add the check command and fail builds on errors #344, check and exit codes. styleframe check [entry] [--json] runs validate() without writing files and exits 1 on any diagnostic. With --json, it prints one { "ok", "diagnostics" } document on stdout. styleframe build prints one warning line per diagnostic, and now exits 1 when the build fails (it used to exit 0). The bundler plugin logs each diagnostic once per build and fails the build under strict: true. Core gains inspect(instance), a JSON-serialisable snapshot of what an instance registers.
  • feat(cli): add the inspect command and a config type check #346, inspect and --typecheck. styleframe inspect [entry] [section] [--json] lists the variables, themes, utilities, modifiers and recipes a configuration registers. styleframe check --typecheck runs the project's tsc on the entry file and reports each type error as a diagnostic. typescript is an optional peer dependency of @styleframe/cli.
  • docs: add an agents page and a readme for nine packages #347, docs for agents. A new page, "Using Styleframe with AI agents" (08.tooling/03.agents.md), covers the loop and the common mistakes. The PR fixes the stale claims in the guide, the Tailwind comparison and the utilities page, and adds a README to the nine published packages that shipped none.

Related issue

None in this repository.

Type of change

  • 🐞 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that changes existing behavior)
  • 📖 Documentation
  • ♻️ Refactor / internal (no functional change)
  • 🔧 Build / tooling / CI

Checklist

  • My commits follow Conventional Commits with a package scope (e.g. feat(theme): …)
  • I ran pnpm build:nodocs && pnpm lint && pnpm typecheck && pnpm test and everything passes
  • I added a changeset (pnpm changeset) for changes to publishable packages, or this change only touches docs/storybook/app/playground/tests
  • I added or updated tests where relevant
  • I updated documentation where relevant
  • I did not edit generated files (dist/, .styleframe/)
  • My PR targets main and stays focused in scope

Notes / screenshots

  • styleframe build exiting 1 on a failed build is a behaviour change for scripts that relied on 0. The @styleframe/cli changeset names it.
  • Builds through the plugin, Inkline's included, now show warnings for unresolved references, undefined theme overrides and duplicate variables. They fail only under strict: true.
  • The branch merges the three PRs with merge commits. Squash-merging this PR into main gives one commit.

A reference to a missing token in a recipe or a utility value built
silently and emitted a var() that is never declared, and a misspelled
theme override or a duplicate variable lost a value without a word.

validate(instance) walks the finished instance and returns every
problem in one pass: unresolved-reference, undefined-theme-override and
duplicate-variable, each with the path that made it and the closest
token name within two edits. transpile() runs it once and returns the
diagnostics beside files, or throws one error listing them all under
the new strict option. variable() and the utility namespace fallback
keep a record on the root of what the finished tree no longer holds.

Nested at-rules keep hyphenated names, so @starting-style and
@font-feature-values emit as written. The theme gains z-index.tooltip,
which the tooltip recipe already used, and the xs chip indicator stops
referencing the undefined font-size.4xs. The transpiler and barrel peer
on the core release that ships validate(). The theme typecheck builds
again without the duplicate wcagContrast declaration.
A plain @token string in a selector or theme still throws when it's
defined, so the docs and changeset now say which references validate()
reports. The default z-index output blocks list the tooltip level, and a
namespace fallback whose variable was defined later says so instead of
claiming no variable exists.
`styleframe build` logged a failed build and exited 0, so neither CI nor an
agent could trust it. It now prints one warning line per diagnostic that
`validate()` finds, exits 1 under `strict: true` without writing files, and
exits 1 when the build fails. The new `styleframe check [--json]` reports
the same diagnostics without writing anything, and exits 1 on any.

The plugin logs each diagnostic once per build, although it transpiles up
to three times, and under `strict` the debounced type generation in the
dev server sends its failure to the error overlay instead of only logging.

Core gains `inspect(instance)`, a JSON-serialisable snapshot of the
variables, themes, utilities, modifiers and recipes an instance defines.
`styleframe check` on an entry that doesn't exist reported a clean config,
because the loader falls back to an empty instance. It now prints
"Config file not found" on stderr and exits 1.

The plugin keyed logged diagnostics on code and path, so a second
unresolved reference in the same value was never logged. It now keys on
the message too.

The check tests now run in a temporary working directory with every
consola level on, so a written file or a stray stdout line fails them.
`check` resolved the entry with `path.resolve`, which drops a trailing slash and collapses `..` by text, so an entry the loader can't find, like `styleframe.config.ts/`, still loaded an empty instance and passed. It now builds the path with `path.join`, as the loader does.
An agent had no way to list what a configuration registers short of
reading its source or the generated CSS. `styleframe inspect [entry]
[section] [--json]` prints the snapshot `inspect()` returns, all of it
or one section, as readable lists or as one JSON document on stdout.

`styleframe check --typecheck` runs the project's own `tsc` on the
entry file, through a temporary tsconfig outside the project that
extends the nearest `tsconfig.json`, and reports each type error as a
`typescript` diagnostic beside the ones `validate()` finds. TypeScript 7
ships no JavaScript compiler API, so it spawns the `tsc` binary, and
`typescript` becomes an optional peer of the CLI.
The temporary tsconfig that `check --typecheck` writes lived in the OS
temp directory, so TypeScript resolved `types` entries like `node` or
`vite/client` from there and reported a false TS2688. It now lives in
the project's `node_modules/.cache`, which resolves the same packages as
the project, and is removed afterwards.

An inherited `incremental` or `composite` made `tsc --noEmit` write
build info into the project, overwriting its `.tsbuildinfo` or leaving
files in its `outDir`. The temporary config turns both off.
Turning `composite` off for every project dropped the `declaration` it
implies, so a project with `declarationMap` or `emitDeclarationOnly`
failed `check --typecheck` with TS5069. Keeping `composite` on instead
rejects any local file the config imports with TS6307. The type check
now asks `tsc --showConfig` for the resolved options and, only for a
composite project, turns `composite` off and `declaration` on.

Creating the temporary directory in a read-only `node_modules`, like
under Nix or in a root-owned image, threw a raw EACCES stack trace. It
now falls back to the system's temporary directory.
Agents that write a Styleframe config made the same mistakes over and
over, because the traps were written down only in the contributor
guides. Add a "Using Styleframe with AI agents" page with the inspect,
check and strict loop and the mistakes that build without a warning,
and fix two claims the output contradicts: the colour levels in the
design system guide are fixed oklch() values, and the Tailwind
comparison now says what the type checks and the build checks cover.
The utilities page warns that an uncalled creator emits no CSS.

Nine published packages listed README.md in their files but shipped
none, so their npm pages were empty. Each now says what it is, how to
install it and where its docs and the agents page are.
A plain "@token" in a selector or a theme declaration still throws
when it's defined; only recipes, utility values and css template
literals report it as a diagnostic. The Tailwind comparison now says
so, in three short paragraphs, and the agents page matches it.

The scanner README says the plugin only scans once scanner.content is
set. The agents page splits its overview, says that check prints no
JSON when a config throws and that --typecheck needs typescript, and
the theme, plugin and core READMEs are more exact about runtime, Bun
and the standalone core import.
A string "@token" in a utility created with an object throws when
it is defined, like one in a selector; only the array form reports
unresolved-reference. The Tailwind comparison and the agents page
now name both forms.
@vercel

vercel Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
styleframe-dev Ready Ready Preview Oct 21, 2026 10:40am UTC
styleframe-dev-storybook Ready Ready Preview Oct 21, 2026 10:40am UTC

Request Review

@alexgrozav
alexgrozav marked this pull request as ready for review October 21, 2026 09:48
@alexgrozav
alexgrozav marked this pull request as draft October 21, 2026 10:22
@alexgrozav
alexgrozav marked this pull request as ready for review October 21, 2026 10:44
@alexgrozav
alexgrozav merged commit e614db7 into main Oct 21, 2026
14 checks passed
@alexgrozav
alexgrozav deleted the styleframe-agent-ergonomics-uxf-406 branch October 21, 2026 10:54
@github-actions github-actions Bot mentioned this pull request Oct 21, 2026

This branch was successfully deployed

2 active deployments
Preview – styleframe-dev — 5329db42 Deployed Oct 21, 2026 by vercel[bot]
Preview – styleframe-dev-storybook — 5329db42 Deployed Oct 21, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant