Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/unplugin-discovery.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hebilicious/cssforge": patch
---

`cssforge --help` names the bundler plugin, `@hebilicious/cssforge-unplugin`, so a reader of the core package finds it. The package gets npm keywords.
15 changes: 15 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,21 @@ Every module takes a `settings` object beside its `value`.
- The README section for the module says whether a setting reaches the tokens or the CSS. A
CLI flag is an adapter over the same resolution, not a second implementation.

## Skill, agent guide and package metadata

- A change that adds or changes something a user installs or runs (a package, an entry point, a
command, an integration) also updates `skills/cssforge` and `packages/docs/agents.md` in the
same pull request. An agent that only has the skill must be able to find it.
- The skill is distributed on its own. It never refers to the README or to paths in this
repository (`packages/...`, `example/...`, Moon targets); it holds the facts itself in
`references/`, and points to source as `node_modules/@hebilicious/cssforge/src/`.
- When the skill or the agent guide describes an integration choice, it gives the options and
when each fits, rather than prescribing one: the CLI works without a dev server or a build.
It does not document the plugin APIs of each framework.
- Check each behavior the skill states against the code or the tests, not against the README.
- A package's `description` and `keywords` describe that package only, not its sibling
packages.

## Updating the README.md

To update the README, run `moon run cssforge:readme-update` from the workspace root.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1952,7 +1952,7 @@ Motion tokens follow the same rule: `motion.duration.ui.press` and `motion.easin
#### Referencing Fluid Spacing

To reference fluid spacing, use the `@` symbol and the label of the scale; ie:
`spacing_fluid-base@xs`. Do not include the prefix in the reference. The labels follow the
`spacing_fluid.base@xs`. Do not include the prefix in the reference. The labels follow the
following convention :

- 3xs
Expand Down
2 changes: 1 addition & 1 deletion packages/cssforge/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1952,7 +1952,7 @@ Motion tokens follow the same rule: `motion.duration.ui.press` and `motion.easin
#### Referencing Fluid Spacing

To reference fluid spacing, use the `@` symbol and the label of the scale; ie:
`spacing_fluid-base@xs`. Do not include the prefix in the reference. The labels follow the
`spacing_fluid.base@xs`. Do not include the prefix in the reference. The labels follow the
following convention :

- 3xs
Expand Down
5 changes: 5 additions & 0 deletions packages/cssforge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
"name": "@hebilicious/cssforge",
"version": "0.11.0",
"description": "0 runtime design tokens generator for modern style systems.",
"keywords": [
"cssforge",
"design-tokens",
"css-variables"
],
"license": "MIT",
"type": "module",
"main": "./dist/mod.js",
Expand Down
5 changes: 3 additions & 2 deletions packages/cssforge/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,9 @@ cliMain(cssforge, {
version,
context,
toJsonSchema,
// The version is in the help so that a published build shows which one it is.
description: `cssforge ${version}\n\n${cssforge.description}`,
// The version is in the help so that a published build shows which one it is. The bundler
// plugin is a separate package, so the help names it for a reader who only has this one.
description: `cssforge ${version}\n\n${cssforge.description}\n\nTo generate the tokens inside a build instead (Vite, webpack, Rollup and the other bundlers\nunplugin supports), use the bundler plugin: @hebilicious/cssforge-unplugin.`,
commands: [mcpCommand],
output: {
default: "auto",
Expand Down
11 changes: 11 additions & 0 deletions packages/cssforge/tests/cli-entry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,14 @@ test("cli - runs when the entry point is invoked through a symlink", async () =>
await rm(tempDir, { recursive: true, force: true });
}
});

test("cli - help points to the bundler plugin package", () => {
const cliPath = fileURLToPath(new URL("../src/cli.ts", import.meta.url));
const help = spawnSync(process.execPath, [cliPath, "--help"], {
encoding: "utf8",
env: childEnv,
});

expect(help.status).toEqual(0);
expect(help.stdout).toContain("@hebilicious/cssforge-unplugin");
});
4 changes: 4 additions & 0 deletions packages/docs/agents.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ Each release publishes the same version to npm and to JSR.
- Run: the package exposes a `cssforge` executable, so run it directly (`cssforge --mode all`,
or `npx cssforge --mode all` with npm). `cssforge mcp` serves the same commands to an agent
as MCP tools.
- Bundler plugin: `@hebilicious/cssforge-unplugin` is a separate package that generates the tokens
inside a Vite, webpack, Rollup or other unplugin-supported build, and so in any framework built
on one of them. It is an option next to the CLI, which also works without a dev server or a
build. The README's `Bundler Plugin` section lists the supported bundlers and the options.
- JSR: `npx jsr add @hebilicious/cssforge` or `pnpm i jsr:@hebilicious/cssforge`
- Runtime: Node 24 or newer, which loads `cssforge.config.ts` without a loader or `tsx`

Expand Down
52 changes: 31 additions & 21 deletions skills/cssforge/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@ artifacts, resolve variable references, or debug generation issues.

## Source of truth

Always prioritize official project docs and source types:
This skill is self-contained: its references hold what you need. For exact types, read the
TypeScript source the installed package ships in `node_modules/@hebilicious/cssforge/src/`.

1. `references/docs-index.md`
2. `README.md` (project root)
2. `references/token-patterns.md`
3. `references/source-schema-map.md`
4. `references/cli-reference.md`
5. `references/troubleshooting.md`
5. `references/bundler-plugin.md`
6. `references/troubleshooting.md`

Do not invent schema fields that are not present in docs or source types.
Do not invent schema fields that are not present in these references or the source types.

## Workflow

Expand All @@ -28,29 +30,37 @@ Do not invent schema fields that are not present in docs or source types.
- Fix references / generation errors
- Wire CLI scripts and output paths

2. Author config from docs
2. Author the config
- Start from `assets/config-templates/*.ts`.
- Use package import in config:
- `import { defineConfig } from "@hebilicious/cssforge";`
- Mirror patterns from README configuration sections.
- Follow the patterns in `references/token-patterns.md`.

3. Configure generation commands
3. Choose how tokens are generated
- The CLI (next step) works everywhere, with or without a dev server or a build.
- If the project builds with Vite, webpack, Rollup or another bundler that unplugin supports,
the bundler plugin `@hebilicious/cssforge-unplugin` is an option: it generates the CSS
inside the build. Read `references/bundler-plugin.md` before you propose it.

4. Configure generation commands
- Install the package from npm: `npm install --save-dev @hebilicious/cssforge` (the same
version is on the secondary JSR channel: `npx jsr add @hebilicious/cssforge`).
- Run the installed executable directly: `cssforge --mode all` (`npx cssforge` with npm,
`pnpm cssforge` with pnpm).
- Wire it into the project's existing task runner (a `package.json` script, a Makefile,
...) if the project uses one, and pass `--config` and the output flags its layout needs
(`references/cli-reference.md`). `cssforge --watch` rebuilds on each config change.
- For an agent, `cssforge mcp` serves the same commands as MCP tools through stdio.
- For local repo examples, call the built CLI of the sibling package directly: pnpm only
links the workspace `cssforge` binary once `dist` exists, so a fresh checkout has no
`node_modules/.bin/cssforge` before the first build:
- `cssforge-generate`: `node ../../packages/cssforge/dist/cli.js --config ./cssforge.config.ts --mode css --css ./.cssforge/output.css`
- `cssforge-build-local`: `moon run cssforge:pack`

4. Validate outputs
- Run `moon run <project>:cssforge-build-local` then `moon run <project>:cssforge-generate`.
- Verify `./.cssforge/output.css` exists and contains expected custom properties.

5. Troubleshoot with docs
- Use `references/troubleshooting.md` and relevant README sections.
- For schema uncertainty, check `packages/cssforge/src/config.ts` and module types listed in
`references/source-schema-map.md`.

5. Validate outputs
- Run `cssforge check` to validate the config, then `cssforge build` (or the project's own
generation command).
- Verify the CSS output (`./.cssforge/output.css` unless `--css` changes it) exists and
contains the expected custom properties.
- With the bundler plugin, run the project's build; set the plugin's `write` option to get
the stylesheet on disk for inspection.

6. Troubleshoot
- Use `references/troubleshooting.md`.
- For schema uncertainty, check `node_modules/@hebilicious/cssforge/src/config.ts` and the
module types listed in `references/source-schema-map.md`.
82 changes: 82 additions & 0 deletions skills/cssforge/references/bundler-plugin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Bundler Plugin

`@hebilicious/cssforge-unplugin` generates the tokens inside a build, from the same
`cssforge.config.ts`, instead of a separate CLI step. It is built on
[unplugin](https://unplugin.unjs.io), so it works with any framework whose build runs on one
of the bundlers below.

## When to offer it

It is one option next to the CLI. Offer it when the project has a supported build and the
user wants generation tied to that build or to its dev server. Keep the CLI when:

- the work runs without a dev server or a build (a script, CI, or an agent checking output);
- another tool reads the generated files before the build runs;
- the output must be Style Dictionary JSON, JSON or TypeScript (the plugin serves CSS);
- the project uses the JSR package or has no bundler.

## Install

```bash
npm install --save-dev @hebilicious/cssforge @hebilicious/cssforge-unplugin
```

## Entry points

| Bundler | Import |
| --- | --- |
| Vite | `@hebilicious/cssforge-unplugin/vite` |
| Rollup | `@hebilicious/cssforge-unplugin/rollup` |
| Rolldown | `@hebilicious/cssforge-unplugin/rolldown` |
| webpack | `@hebilicious/cssforge-unplugin/webpack` |
| Rspack | `@hebilicious/cssforge-unplugin/rspack` |
| Rsbuild | `@hebilicious/cssforge-unplugin/rsbuild` |
| esbuild | `@hebilicious/cssforge-unplugin/esbuild` |
| Farm | `@hebilicious/cssforge-unplugin/farm` |
| Bun | `@hebilicious/cssforge-unplugin/bun` |

Register the entry point where the project, or its framework, accepts plugins for that
bundler. With Vite:

```typescript
// vite.config.ts
import cssforge from "@hebilicious/cssforge-unplugin/vite";
import { defineConfig } from "vite";

export default defineConfig({
plugins: [cssforge()],
});
```

## Use the stylesheet

```typescript
import "virtual:cssforge.css";
```

TypeScript needs the ambient declaration for that import:

```typescript
/// <reference types="@hebilicious/cssforge-unplugin/client" />
```

The config and every local module it imports are watch files: editing a token regenerates
the stylesheet, and a Vite dev server updates it without a page reload.

## Options

```typescript
cssforge({
// Resolved against the build's working directory. Default: ./cssforge.config.ts
config: "./cssforge.config.ts",
// Also write the stylesheet to disk. Default: false
write: { css: "./.cssforge/output.css" },
});
```

`write: true` uses `./.cssforge/output.css`, the CLI's default path. Set `write` when another
tool needs a real file, when the bundler has no CSS handling for virtual modules, or to import
the tokens into a cascade layer: `@import "virtual:cssforge.css" layer(cssforge)` does not
work, so import the written file with `layer(cssforge)` instead.

The plugin output matches `cssforge --mode css` byte for byte.
10 changes: 4 additions & 6 deletions skills/cssforge/references/cli-reference.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# CLI Reference

The command line, the MCP server and the library target come from the capabilities in
`packages/cssforge/src/capabilities.ts`. Its catalog is `packages/cssforge/cssforge.acidcat.json`. The
entry point is `packages/cssforge/src/cli.ts`, and the operations are in
`packages/cssforge/src/forge.ts`.
`node_modules/@hebilicious/cssforge/src/capabilities.ts`. Its catalog is `node_modules/@hebilicious/cssforge/cssforge.acidcat.json`. The
entry point is `node_modules/@hebilicious/cssforge/src/cli.ts`, and the operations are in
`node_modules/@hebilicious/cssforge/src/forge.ts`.

## Commands

Expand Down Expand Up @@ -49,7 +49,7 @@ On a terminal, each command writes text for a person. For a script, in CI or for
`ConfigLoadFailed`, `InvalidConfig`, `WriteFailed`.
- An invalid flag or value exits with `3`, with the message on stderr.

## Typical commands from docs
## Typical commands

The npm package exposes a `cssforge` executable, so consumers run it directly (`npx cssforge`
with npm, `pnpm cssforge` with pnpm):
Expand All @@ -64,8 +64,6 @@ with npm, `pnpm cssforge` with pnpm):

## Programmatic API

From `README.md`:

- `import { generateCSS } from "@hebilicious/cssforge";`
- `const css = generateCSS(config);`
- `generateCSS(config, { colorFormats: ["hex", "rgb"] })` adds the extra color formats to
Expand Down
39 changes: 15 additions & 24 deletions skills/cssforge/references/docs-index.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,23 @@
# CSS Forge Docs Index

This file maps user requests to official CSS Forge documentation.

## Primary documentation

- Local docs: `README.md`
- Remote docs: `https://raw.githubusercontent.com/Hebilicious/cssforge/refs/heads/main/README.md`
This file maps user requests to the references of this skill.

## What to read for each task

- Installation and setup:
- `README.md` -> `## Installation`, `## Quick Start`
- Token schema and examples:
- `README.md` -> `## Configuration`
- `### Colors`
- `### Spacing`
- `### Typography`
- `### Motion`
- `### Primitives`
- Variable references inside config:
- `README.md` -> `## Referencing Variables`
- Installation and generation commands:
- `SKILL.md` -> workflow steps 3 and 4
- `references/cli-reference.md`
- Token schema and examples (colors, spacing, typography, motion, primitives):
- `references/token-patterns.md`
- `references/source-schema-map.md` for the exact types and settings
- Variable references inside config, and generated variable names:
- `references/token-patterns.md` -> `Reference syntax`, `Variable names`
- Generating tokens inside a build (Vite, Rollup, webpack and other bundlers, and the
frameworks built on them):
- `references/bundler-plugin.md` (package `@hebilicious/cssforge-unplugin`)
- CLI options and outputs:
- `README.md` -> `## CLI Usage`
- `references/cli-reference.md`
- Programmatic usage:
- `README.md` -> `## Programmatic Usage`

## Important rule from docs

README `md:generate` comment blocks are source-of-truth examples. Keep their structure
when adapting configs.
- `references/cli-reference.md` -> `Programmatic API`
- Errors and unexpected output:
- `references/troubleshooting.md`
Loading
Loading