Repository navigation
feat(cli): experimental theme: data safety, names that build, checked settings and token values - #11180
Conversation
… links), every accepted name builds, settings checked on load, token values checked by type
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
| 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
There was a problem hiding this comment.
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.mjscopiesfindAstryxProjectfromfoundation/fs/paths.mjs, whichupgradealready 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_BUSYfor two minutes; treat a lock whose recorded pid is not running as stale. - The shared
astryx-theme-lockstemp folder takes the first user's permissions, so on a shared Linux host every other user's command fails withERR_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: 14pxinto the phone rule, which contradicts the 16px mobile reading base ofdesign:mobile-typographyDR1, so leave size tokens out of the copy. isShadowsplits layers on commas inside nested parentheses, so Core's own--shadow-lowvalue and any layer withlight-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
--modeby earlier releases can no longer be removed withundo <theme> <token>, and the refusal suggests a command that also fails, so apply the mode refusal only toset. - The
setandnewhelp,ThemeEditChangeOptions.modeand everycwddoc 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-631runs after the tokens are built and never reaches the theme, and the new test passes on the base unchanged.
| - 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. |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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(withLockandstale()) reimplementstryLockfromfoundation/release/cache.mjs, which already handles owner records, stopped holders and locks from other computers for the CLI, so build the editor's lock ontryLockand delete the copy. - After
set <theme> --font-weight-semibold 700, atext-sizechange writes every--text-heading-*-weightas the base theme's resolved600, so headings drop from 700 to 600 where the base keepsvar(--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.
…ttings and history inside it; links refused; nearest-package root; values under older rules fixable; damaged undo steps dropped one by one; leftovers swept
There was a problem hiding this comment.
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 newprojectRoot()walk in_adapter.mjshas no home-folder or repository stop; build it onfindAstryxProjectandfindPackageRoot, asupgradedoes. - When the step
undogoes back to holds a value from an older release, the suggestedundo <theme> <thing>removes the current valid setting (such astext-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.mjsdeletes any file in a theme folder named likenotes.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, atext-sizechange writes every--text-heading-*-weightas the resolved600, 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(withLockandstale()) reimplementstryLockfromfoundation/release/cache.mjs, which already handles stopped holders and locks from other computers for the CLI; build the editor's lock ontryLockand 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.
…no sweep, rollback of exactly what a run wrote, links refused anywhere in a theme, upgrade's project walk, stale builds found by show
There was a problem hiding this comment.
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/lockswhen Core is installed in the home folder, becausecoreModules()in_adapter.mjswalks to the filesystem root instead of using the CLI'sfindProjectCoreDir; take the lock folder from the Core the command reads and take no lock without one. - After a CLI update, the first
showof 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.
| * @param {string} root | ||
| * @returns {string | null} | ||
| */ | ||
| function coreModules(root) { |
There was a problem hiding this comment.
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`, |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
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 howfindings (R10, R11) are with the how fixer.themes/), never one that was there.ERR_THEME_BUSY. A failure after the settings are saved is "saved, not checked", exit 0.b-2,x--y,brand-did not build; the suggested<name>-2toocamel()drops every dash and capitalizes the next letter or digit. The suggestion is now<name>-copy.themes/<name>and wrote outside the applstatofthemes/andthemes/<name>: a link or a file is refused before anything is writtensetstarts a new one with a note, andundorefuses with the fixmode dark-onlydid not change the buildpalette.config.jsonandtokens/settingsProblem(): shape and every value checked by thesetrules on every load, and on the history step undo restores. The refusal isERR_THEME_INVALIDnaming the key, withundo <theme>.ERR_THEME_NO_EFFECT) when every color is a grayERR_FILE_EXISTSchangedTokens$TMPDIRERR_UNKNOWNcommander.optionMissingArgumentis unmapped), so this is a stable change; listed for the stable laneit.failsneutralProfilein the palette configit.failsit.failsnewon one namethemes/projectRoot(): the nearest folder whose package.json declares Core, else the current folder. A--pathis re-based.--fonttakes anything;{}<>\, newlines and unbalanced quotes--text-sizetakes 0, negatives, hex^\d+(\.\d+)?$, 10 to 32 px; also checked on loadsetnewrewrites the suggestions intonew <theme> --<dial> …, keeping the other flags--headingstwice--like <word>themes/left--like ""--like/name helpnew <theme>suggested. The rest is in hunt2.Infinity--moderemoves it in both modes--mode(ERR_THEME_NO_MODE); a top-levellight-dark()in a shadow is refused--text-*-weighttyped as number (1–1000 or a keyword); line heights acceptnormal, lengths and %var()naming a token of another type is refused (app variables stay allowed)--font-*/--text-*tokens are written into a coarse-pointer adaptation rule tooisSafeValueon token and property values: no;{}<>, newline, comment,!important, or unbalanced brackets or quotesvar()graph is followed; a cycle is refusedhow --list tokens <word>env(),min/max/clamp; no negative radius--token=value,--mode Dark, empty flags, whitespace values, "a easing"setrefuses<color>,<value>and others (ERR_THEME_BAD_VALUE)nowunder a dial; (c) docs.load-names. (b)nownames the dial still writing the token. (c) Type doc, undo descriptions and summary say what applies.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):
commander.optionMissingArgumenttoERR_UNKNOWNCLI-wide.$TMPDIR.Testing
vitest: theme-edit suites (with the newtheme-hunt.test.mjsand 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; 4it.failsremain, named above.typecheck:strict,cli-api-types-verify,readme:check,check:cli-structure,eslintandprettier --checkon every changed file (the changeset included),check-changesets.Follow-up after review
node_modules/.cache(a per-user folder if that is read-only).upgradeuses.light-dark(rgba(…))colors and negative offsets are accepted again; an older one-mode shadow can be undone.