Skip to content

feat(cli): experimental theme: data safety, names that build, checked settings and token values - #11180

Merged
josephfarina merged 5 commits into
mainfrom
themes-v2-hunt1
Nov 11, 2026
Merged

josephfarina merged 5 commits into
mainfrom
themes-v2-hunt1

Conversation

@josephfarina

@josephfarina josephfarina commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

What

Two commits on astryx experimental theme: the seeded chaos test (200 steps, fixed seed), and the fixes for the data-safety and high findings from the chaos runs (F1–F21) and the per-command hunts R01 (editor new), R04 (type dials), R06 (exact tokens) and R08 (undo, the lock). Preview findings (R12, R13, R14, chaos F5 and F13) are with the preview fixer. editor how findings (R10, R11) are with the how fixer.

Finding Status How Test
F1 (critical): a refused undo deleted the theme folder fixed Before a build, the whole theme folder is snapshotted. A failed build restores every file exactly. It removes only the folders this call made (the theme folder and themes/), never one that was there. chaos F1 is now a normal test; theme-hunt "a failed build puts every file back"
F2 (critical): concurrent commands collide; lost updates; saved changes reported as failed fixed A per-process render folder that removes only its own files. A lock per theme (and per preview) in the system temp folder, never in the project. Commands on one theme run one after the other; past 30 s → new ERR_THEME_BUSY. A failure after the settings are saved is "saved, not checked", exit 0. theme-hunt "on one theme, both changes land"; review-fixes concurrency test
F3 / R01#1: b-2, x--y, brand- did not build; the suggested <name>-2 too fixed camel() drops every dash and capitalizes the next letter or digit. The suggestion is now <name>-copy. chaos F3; theme-hunt names
R01#3: a refused new deleted a link at themes/<name> and wrote outside the app fixed lstat of themes/ and themes/<name>: a link or a file is refused before anything is written theme-hunt link
F4: damaged history fixed (review commit) The history is read and checked before writing: set starts a new one with a note, and undo refuses with the fix chaos F4 ×2
F6: mode dark-only did not change the build fixed (review commit) Colors the theme sets get one value; other-mode settings are named chaos F6
F7: a refused color change rewrote the palette files fixed The folder snapshot covers palette.config.json and tokens/ chaos F7
F8 (settings shape) / R04#3 / R08 validation fixed settingsProblem(): shape and every value checked by the set rules on every load, and on the history step undo restores. The refusal is ERR_THEME_INVALID naming the key, with undo <theme>. chaos F8 (settings); theme-hunt "bad value or shape"
F10: vibrancy with only a gray fixed Refused (ERR_THEME_NO_EFFECT) when every color is a gray chaos F10
F15 / R01#10: 300-character name, a file in the way fixed Names are at most 64 characters; a file or link where the theme goes → ERR_FILE_EXISTS theme-hunt names
F17: damaged build gives an empty changedTokens not yet hunt2 —
F18: jiti cache in $TMPDIR not yet The cache comes from the shared theme build loader (stable code); listed for the stable lane —
F14 / R01#14: a missing option value → ERR_UNKNOWN not here The mapping is in the CLI-wide json-shim (commander.optionMissingArgument is unmapped), so this is a stable change; listed for the stable lane chaos F14 stays it.fails
F9: undo leaves neutralProfile in the palette config not here Moves to the palette commit (the config writer rewrite) chaos F9 stays it.fails
F5, F8 (preview data), F13 preview fixer — chaos F5 and F8 (preview) stay it.fails
R01#2: two new on one name fixed The theme lock: the second command waits, then sees the theme exists lock tests
R01#4 / R06#15: subfolder makes a second themes/ fixed projectRoot(): the nearest folder whose package.json declares Core, else the current folder. A --path is re-based. theme-hunt root
R01#5: --font takes anything fixed Trimmed; refuses empty, ;{}<>\, newlines and unbalanced quotes theme-hunt font
R01#6: --text-size takes 0, negatives, hex fixed ^\d+(\.\d+)?$, 10 to 32 px; also checked on load theme-hunt text size
R01#7: refused flags suggest set fixed new rewrites the suggestions into new <theme> --<dial> …, keeping the other flags theme-hunt "suggests new"
R01#8: --headings twice fixed One setting per axis; two values on one axis are refused theme-hunt headings
R01#9: repeated flags, stray words fixed A flag given two different values is refused; a stray word is refused, with --like <word> theme-hunt stray
R01#11: empty themes/ left fixed Removed when this call made it —
R01#12: --like "" fixed Refused theme-hunt
R01#13: weak --like/name help partly Case-insensitive did-you-mean; slugified name suggestion; new <theme> suggested. The rest is in hunt2. theme-hunt
R04#1: text-size 0 → Infinity fixed As R01#6 theme-hunt
R04#2: a scale drops base heading weights and ratio fixed The base ratio is read back from its sizes; base heading weights are carried unless a dial or token sets them theme-hunt "keeps the base theme heading weights"
R06#1: a shadow with --mode removes it in both modes fixed Only colors take --mode (ERR_THEME_NO_MODE); a top-level light-dark() in a shadow is refused theme-hunt
R06#2: only color, size and number type-checked fixed Validators for time, easing, font, shadow and outline style; --text-*-weight typed as number (1–1000 or a keyword); line heights accept normal, lengths and % theme-hunt
R06#3: a non-plain color breaks both modes fixed CSS-wide keywords and broken color functions are refused; a var() naming a token of another type is refused (app variables stay allowed) theme-hunt
R06#4: exact type tokens ignored on phones fixed Exact --font-* / --text-* tokens are written into a coarse-pointer adaptation rule too theme-hunt "reaches phones"
R06#5: syntax, display and icon-hue tokens refused as unread fixed Added to the tokens never refused as unread (Core reads them under variants or in global CSS) theme-hunt
R06#8: values the build drops reported as applied fixed isSafeValue on token and property values: no ;{}<>, newline, comment, !important, or unbalanced brackets or quotes theme-hunt
R06#9: self-referencing values fixed The var() graph is followed; a cycle is refused theme-hunt
R06#10: the unknown-token suggestion fails fixed how --list tokens <word> theme-hunt
R06#12: valid sizes refused / bad ones accepted fixed All CSS length units, env(), min/max/clamp; no negative radius theme-hunt
R06#13/#14 (part): --token=value, --mode Dark, empty flags, whitespace values, "a easing" fixed Specific refusals; lowercased mode; trimmed values —
R11 (core part): literal placeholders accepted fixed set refuses <color>, <value> and others (ERR_THEME_BAD_VALUE) theme-hunt
astracat on the merged review PR: (a) built-theme copy in the theme folder; (b) undo now under a dial; (c) docs fixed (a) Only real relative imports keep the copy beside the module (comments stripped); tests match the .load- names. (b) now names the dial still writing the token. (c) Type doc, undo descriptions and summary say what applies. theme-hunt; show-text test

Everything else in those reports (mediums and lows, R02 into the palette commit, R03, R05, R07, R09, R15–R18 experimental-only items) is in hunt2.

For the stable lane (not changed here):

  • The json-shim maps commander.optionMissingArgument to ERR_UNKNOWN CLI-wide.
  • The shared theme build leaves jiti's file cache in $TMPDIR.

Testing

  • vitest: theme-edit suites (with the new theme-hunt.test.mjs and the chaos test), experimental theme suites and copies, build-theme through the copies, palette, text/JSON parity, door conformance, response and error codes, docs graph, global-mode notes, doc loads, outside-project, test-utils. All pass; 4 it.fails remain, named above.
  • typecheck:strict, cli-api-types-verify, readme:check, check:cli-structure, eslint and prettier --check on every changed file (the changeset included), check-changesets.

Follow-up after review

  • Locks record pid, host and a token: a lock left by a stopped command is taken at once, a lock is released only by its owner, and locks live in the project's node_modules/.cache (a per-user folder if that is read-only).
  • The project folder is found with the same walk upgrade uses.
  • Phones keep their mobile reading sizes: only exact font families are carried into the phone rule.
  • Shadows with nested light-dark(rgba(…)) colors and negative offsets are accepted again; an older one-mode shadow can be undone.
  • A new text size keeps the base theme's heading weights.
  • A failed change restores only the editor's own files, file by file, and never touches the theme source or other files in the folder; settings and history are saved inside the same rollback.
  • Linked theme folders and settings files are refused; nothing is written through a link.
  • Inside a monorepo, commands act on the nearest package; a package without Core inside a Core app is refused with the folder to run from.
  • Values that older rules allowed can be undone or replaced; a bad history entry drops only the steps before it.
  • Leftover temp files from stopped commands are cleaned up.
  • Simpler safety model: one lock folder (built on the CLI's existing release lock), no cleanup sweep, editor temp files with their own names removed when the command ends, and rollback limited to the files the failed command wrote in that run.
  • The project folder never resolves to the home folder or above a repository root.
  • Any link inside the theme folder is refused and left alone.
  • A build that does not match its settings (after a crash) is detected and rebuilt.

… links), every accepted name builds, settings checked on load, token values checked by type
@vercel

vercel Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 11, 2026 9:47am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 11, 2026
@astracat-bot

astracat-bot Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
❓ Needs maintainer input (for maintainers only) Nov 11, 2026, 10:07 AM UTC

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 6598a39

Storybook · Sandbox · built from this PR's head

Package size: @astryxdesign/cli 3.77 MB packed (+16.6 kB); no new dependencies.

API changes: cli +0 · ~1 · −0

1 API change (advisory)
Package Where Signature Usage
~ cli ./api/experimental · Types · type ThemeEditNewOptions settings?: Record<string, string | undefined> | undefined → settings?: Record<string, string | string[] | undefined> | undefined import type {ThemeEditNewOptions} from '@astryxdesign/cli/api/experimental'; const x: ThemeEditNewOptions = {settings: …}

Not run on this PR: add ci:run-visual, ci:run-a11y or ci:run-rtl to run them.


Generated by PR Enrichment workflow | View full report

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs an engineering owner's decision and several fixes before it can be approved.

Approval waits on an engineering owner deciding direction that no current spec covers for the experimental theme editor: commands now act on the nearest folder whose package.json declares @astryxdesign/core (spec:AST-081 FR7 allows a folder above the working folder only when the record that owns the command's writes says so), commands on one theme wait on a lock in the system temp folder and fail with the new ERR_THEME_BUSY after 30 seconds, and exact type tokens are copied into a coarse-pointer rule of the built theme. An engineering owner records that decision by naming or adding the governing record, or by commenting /approve-spec <full head SHA> on this pull request; the author may do so as an engineering owner.

Blocking findings:

  • At 2,030 authored lines the change is over the 2,000-line limit, so land the seeded chaos suite and the lock and project-root work separately from the value checks.
  • projectRoot() in _adapter.mjs copies findAstryxProject from foundation/fs/paths.mjs, which upgrade already uses, with narrower rules, so call the shared finder instead.
  • A Ctrl-C or killed command leaves its lock file, so every command on that theme fails with ERR_THEME_BUSY for two minutes; treat a lock whose recorded pid is not running as stale.
  • The shared astryx-theme-locks temp folder takes the first user's permissions, so on a shared Linux host every other user's command fails with ERR_UNKNOWN (EACCES); use a per-user lock folder and a documented code.
  • The coarse-pointer copy writes exact type sizes such as --font-size-base: 14px into the phone rule, which contradicts the 16px mobile reading base of design:mobile-typography DR1, so leave size tokens out of the copy.
  • isShadow splits layers on commas inside nested parentheses, so Core's own --shadow-low value and any layer with light-dark(rgba(…), rgba(…)) are refused; split on top-level commas only.
  • --focus-outline-offset -2px, valid CSS that the base accepted, is now refused because only --spacing* tokens may be negative.
  • A shadow saved with --mode by earlier releases can no longer be removed with undo <theme> <token>, and the refusal suggests a command that also fails, so apply the mode refusal only to set.
  • The set and new help, ThemeEditChangeOptions.mode and every cwd doc still describe the old behavior (shadows by mode, any text size, the current folder).
  • The changeset says a text size keeps the base theme's heading weights, but the carry at _settings.mjs:629-631 runs after the tokens are built and never reaches the theme, and the new test passes on the base unchanged.

Automated review (maintainer link)

Comment thread packages/cli/api/theme-edit/_check.mjs Resolved
Comment thread packages/cli/api/theme-edit/_color.mjs Resolved
Comment thread packages/cli/api/theme-edit/_check.mjs Resolved
- Commands on one theme run one after the other, so no change is lost. A command that waits more than 30 seconds is refused with the new code `ERR_THEME_BUSY`.
- Every name the name check accepts builds (`brand-2`). Names are at most 64 characters. `new` refuses a link or a file where the theme goes, a stray word, a flag given two values, and an empty `--like`; `--headings` takes a weight and a tracking; a refused flag suggests a `new` command.
- Settings edited by hand are checked on load, and so is the step `undo` goes back to.
- Token values are checked by their type: time, easing, font, shadow and outline style too, and heading weights as numbers. A value that would break the CSS, read itself, or name a placeholder such as `<color>` is refused. Only colors take `--mode`; a shadow per mode would remove it in both.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The help still says the opposite: experimental-theme-editor-set.doc.mjs:15 ("only colors and shadows may differ by mode") and ThemeEditChangeOptions.mode in theme-edit.type.mjs:42 ("colors and shadows only"). new --text-size ("or a number") and every cwd doc ("The app folder (default: process.cwd())") are stale too.

…topped commands, project-local locks, shared project walk, Core shadows and offsets accepted, phone copy of font families only, heading weights kept

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs an engineering owner's decision and three fixes before it can be approved.

Approval waits on an engineering owner deciding direction that no current spec covers for the experimental theme editor: commands now act on the Astryx project found at or above the folder they run in (spec:AST-081 FR7 allows a folder above only when the record that owns the command's writes says so), commands on one theme wait on a lock and fail with the new ERR_THEME_BUSY after 30 seconds, exact font families are copied into a coarse-pointer rule of the built theme, and new refusals cover token types, --mode on non-colours, text-size outside 10 to 32 px and names over 64 characters. An engineering owner records that decision by naming or adding the governing record, or by commenting /approve-spec <full head SHA> on this pull request; the author may do so as an engineering owner.

Blocking findings:

  • At 2,242 authored lines the change is over the 2,000-line limit, so land the seeded chaos suite and the lock and project-root wrapper separately from the value checks.
  • The lock in _adapter.mjs (withLock and stale()) reimplements tryLock from foundation/release/cache.mjs, which already handles owner records, stopped holders and locks from other computers for the CLI, so build the editor's lock on tryLock and delete the copy.
  • After set <theme> --font-weight-semibold 700, a text-size change writes every --text-heading-*-weight as the base theme's resolved 600, so headings drop from 700 to 600 where the base keeps var(--font-weight-semibold), and the changeset line saying a text size keeps the base theme's heading weights describes what the base already did.

Most earlier findings are fixed at this head: the shared project finder, stale-lock takeover, the per-user lock folder, Core's shadows, negative offsets, phone text sizes and undo of a per-mode shadow.

Automated review (maintainer link)

Comment thread .changeset/experimental-theme-hunt1.md Resolved
…ttings and history inside it; links refused; nearest-package root; values under older rules fixable; damaged undo steps dropped one by one; leftovers swept

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs an engineering owner's decision and six fixes before it can be approved.

Approval waits on an engineering owner deciding direction that no current spec covers for the experimental theme editor: where commands write when run from a subfolder (spec:AST-081 FR7 allows a folder above only when the record that owns the command's writes says so), the per-theme lock with the new ERR_THEME_BUSY, the cleanup of leftovers at the start of every command, the copy of exact font families into the coarse-pointer rule, and the new value refusals. An engineering owner records that decision by naming or adding the governing record, or by commenting /approve-spec <full head SHA> on this pull request; the author may do so as an engineering owner.

Blocking findings:

  • With Core installed in the home folder and no package.json, a command run inside a checkout below it now writes ~/themes/<name>, because the new projectRoot() walk in _adapter.mjs has no home-folder or repository stop; build it on findAstryxProject and findPackageRoot, as upgrade does.
  • When the step undo goes back to holds a value from an older release, the suggested undo <theme> <thing> removes the current valid setting (such as text-size 16) and the step is never passed, although the changeset says that command works; drop or repair that step instead.
  • The leftover sweep in _adapter.mjs deletes any file in a theme folder named like notes.4194311.tmp, although the changeset says other files in the folder are never touched; limit it to the editor's own temporary names.
  • After set <theme> --font-weight-semibold 700, a text-size change writes every --text-heading-*-weight as the resolved 600, so headings drop from 700 to 600, and the changeset line saying a text size keeps the base theme's heading weights describes what the base already did.
  • The lock in _adapter.mjs (withLock and stale()) reimplements tryLock from foundation/release/cache.mjs, which already handles stopped holders and locks from other computers for the CLI; build the editor's lock on tryLock and delete the copy.
  • At 2,760 authored lines the change is over the 2,000-line limit; land the seeded chaos suite and the root, lock and sweep wrapper separately from the value checks.

The rollback now leaves the theme source and other files alone, links are refused, and two commands on one theme both land.

Automated review (maintainer link)

Comment thread packages/cli/api/theme-edit/_edit.mjs Resolved
…no sweep, rollback of exactly what a run wrote, links refused anywhere in a theme, upgrade's project walk, stale builds found by show

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs an engineering owner's decision and three fixes before it can be approved.

Approval waits on an engineering owner deciding direction that no current spec covers for the experimental theme editor: commands acting on the Astryx project above the folder they run in (spec:AST-081 FR7 allows a folder above only when the record that owns the command's writes says so), the per-theme lock with the new ERR_THEME_BUSY, show rebuilding a build made from other settings or another CLI release, the copy of exact font families into the coarse-pointer rule, the heading-weight carry, and the new value refusals. An engineering owner records that decision by naming or adding the governing record, or by commenting /approve-spec <full head SHA> on this pull request; the author may do so as an engineering owner.

Blocking findings:

  • A command refused as outside a project still creates ~/node_modules/.cache/astryx-theme/locks when Core is installed in the home folder, because coreModules() in _adapter.mjs walks to the filesystem root instead of using the CLI's findProjectCoreDir; take the lock folder from the Core the command reads and take no lock without one.
  • After a CLI update, the first show of every theme rebuilds it and says a command stopped while building or the files were edited by hand (_edit.mjs:571), because the stamp includes the CLI version; make the note name the cause the check found.
  • At 3,100 authored lines the change is over the 2,000-line limit; land the seeded chaos suite and the project-root and lock wrapper separately from the value checks.

Since the last review the project walk matches upgrade, the lock is built on tryLock, the leftover sweep is gone, an undo over an older value passes, and a text size keeps the base theme's bold headings.

Automated review (maintainer link)

* @param {string} root
* @returns {string | null}
*/
function coreModules(root) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This walk climbs to the filesystem root for any node_modules holding Core, and withLock makes the folder before the command checks its project. With Core installed in the home folder, show pp run six folders below it is refused as outside a project (ERR_PROJECT_REQUIRED) yet first creates ~/node_modules/.cache/astryx-theme/locks; the base writes nothing. findProjectCoreDir in foundation/fs/paths.mjs already finds the Core a command reads, bounded by its reach and the declaring package: taking the lock folder from it, with no lock when it returns null, keeps one lookup and keeps refused commands from writing.

notes: [
...(stale
? [
`the build did not match ${theme}.settings.json (a command stopped while building, or a hand edit), so it was built again from the settings`,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

settingsStamp() includes the CLI version, and a theme built by the released CLI has no stamp, so the first show after any update lands here and tells the person a command stopped while building or the files were edited by hand. Reproduced by changing the stamp's version: show rewrote w2.settings.ts and returned this note. Naming the cause the check found (an earlier CLI release, or settings that differ from the build) keeps the note true.

[experimental] `astryx experimental theme`: data safety and value checks.

- A refused change puts back only the files that command wrote in that run, each whole, and only while they still hold what it wrote; a file changed by someone else meanwhile, or one it cannot restore, is left and named. The settings and undo history are written inside that rollback, and a refused `new` leaves no trace. A link anywhere in `themes/` or the theme folder is refused, and never followed or removed. A palette.config.json the editor did not write is kept. `show` finds a build that does not match the settings (a command stopped mid-build, a hand edit) and builds it again, saying so. Temp files have their own editor names and are removed by the write that made them; nothing else is ever removed. Run from a subfolder, a command acts on the Astryx project above it, found as `upgrade` finds it: the search stops at a repository root and never takes the home folder. A package without Astryx inside that project is refused with the folder to run from, a package.json that does not parse is never walked past, and reply paths are absolute when the project is above the current folder. Yarn Plug'n'Play and a package.json without Core get their own messages. A full or read-only disk is `ERR_WRITE_FAILED`.
- Commands on one theme run one after the other, so no change is lost. The lock lives in the project's `node_modules/.cache` (a folder that cannot be written is refused with `ERR_WRITE_FAILED`); a lock left by a stopped command, or by one on another computer that stopped, is taken over. A command that waits more than 30 seconds is refused with the new code `ERR_THEME_BUSY`, naming the lock.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: tryLock takes a lock from another computer only after 20 minutes, or after 60 s of observed silence, which a 30 s wait never sees. After a command stops on another computer, every command on that theme fails with ERR_THEME_BUSY for 20 minutes. Saying so here, or shortening the foreign rule for this lock, would match what happens.

* @experimental May change or be removed in a patch release.
* @typedef {object} ThemeEditHowOptions
* @property {string} [cwd] - The app folder (default: process.cwd()).
* @property {string} [cwd] - The folder to start from (default: process.cwd()); commands act on the Astryx project at or above it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: themeEditHow is re-exported without the adapter (_adapter.mjs:49), so it uses cwd as given, while this line says it acts on the project above. Wrap how like the other commands, or keep the old wording here.

@josephfarina
josephfarina merged commit fdb9213 into main Nov 11, 2026
67 checks passed
@github-actions
github-actions Bot deleted the themes-v2-hunt1 branch November 12, 2026 06:06

This branch was successfully deployed

1 active deployment
Preview — 6598a39a Deployed Nov 11, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant