Passa al contenuto principale

Il comando wr

Dentro il container di una bozza, wr è il comando per guardare il sito e controllarlo, per chi sta al terminale come per un'AI. Non ha un elenco di comandi suo: chiede al container quali tool esistono, quindi ogni tool dell'MCP dell'editor è un comando wr, con lo stesso nome e gli stessi parametri.

Sintassi​

wr                    # l'elenco dei comandi
wr help <tool> # un comando, con i suoi parametri
wr <tool> [args] # lo esegue
  • Un comando prende al massimo un parametro posizionale (la prima parola senza --): wr screenshot /about.
  • Ogni parametro è anche un --flag valore (il nome in kebab-case: fullPage è --full-page) o --flag=valore. Un booleano è --flag da solo, e --no-flag lo spegne.
  • --json stampa la risposta come dati, da far leggere a un programma.
  • Un file che un comando crea (uno screenshot) viene salvato in $WR_OUT (/tmp/wr se non c'è) e se ne stampa il percorso.
  • Il codice di uscita è 0 se va tutto bene, 1 se la risposta dice che qualcosa non va (ok è falso, o conta degli errori) e 2 se il comando non ha potuto girare.

Comandi​

Il container offre 54 comandi. Cosa fa ciascuno e i parametri che prende sono in Tool dell'editor; la riga d'uso qui è quella che stampa wr help <tool>. Le descrizioni vengono dal registro e sono in inglese.

ComandoUsoCosa fa
checkwr checkChecks the code (the whole project): images without alt text, headings out of order, links and buttons with no name, repeated ids, SEO. It does not measure the drawn page (contrast, the size of what is pressed, of text, spacing): inspect and diagnose do, for the page they open.
inspectwr inspect [path] [--viewport <mobile|tablet|desktop>]Opens a page in a browser and reports what a visitor would hit: errors in the console, failed requests, the dev server's error screen, what the checks find in the page, and what its drawing says (contrast, the size of what is pressed, of text, spacing: the same list the editor shows for the page it has open). measured says whether that could be done.
screenshotwr screenshot [path] [--viewport <mobile|tablet|desktop>] [--full-page]A picture of a page (a JPEG file), with the same report as inspect.
diagnosewr diagnose [path] [--viewport <mobile|tablet|desktop>]Everything that is wrong right now, in one answer: the dev server's errors, the code's problems, and what the page shows, drawn and measured (the same list as the editor). summary says in one line what was found and where it looked: warnings do not make ok false, so read it.
file-listwr file-list [path]Lists the files of the site (code and data) under a folder, with their size: src/ by default, or public/. Never node_modules, vendor, dist or hidden files.
file-readwr file-read [path]Reads a text file of the site (up to 48 KB) and gives back its content.
file-writewr file-write [path] [--content <string>] [--overwrite]Writes a text file of the site (up to 48 KB): the folders it needs are made, a file that is there is replaced (unless overwrite is false), and it is written whole or not at all. A .json file must be valid JSON. The dev server shows the change at once.
file-deletewr file-delete [path]Deletes a file of the site. One file, never a folder; there is no undo.
dependency-listwr dependency-listLists the packages the site depends on (package.json), with the version it asks for, the one that is installed, and whether it is installed (installed, missing or outdated).
dependency-addwr dependency-add [name] [--version <string>] [--packages <a,b,c>]Adds a package to the site (npm install name@version) and installs it; with a package that is there already, changes the version it asks for. The version is from the registry (1.2.3, ^1.2.3, ~1.2.3, >=1.2.3, a tag such as latest). Several at once with packages (["[email protected]", "[email protected]"], one npm install): for packages that need each other's versions. If npm fails, package.json is as it was.
dependency-removewr dependency-remove [name]Takes a package away from the site (npm uninstall name). The ones the site does not run without (@webround/core, @webround/editor, react, react-dom) are refused.
dependency-installwr dependency-installInstalls what package.json asks for (npm install, from the lockfile): for a project whose package.json was changed by hand, or whose node_modules lacks something.
kit-applywr kit-apply [kit] [--dry-run]Puts a kit on the site (shop: the shop's pages, components, texts and packages). Deterministic and all or nothing: if a file of the site is in the way, nothing is written and every conflict is told. A site that has the kit's packages already is left as it is. dryRun tells what it would do.
page-listwr page-listThe pages of the site: name, component, and whether the shared header and footer are shown on each.
page-createwr page-create [pageName] [--component <string>] [--lazy]Creates a page: its component, its (empty) JSON of values and its entry in the routes.
page-deletewr page-delete [pageName]Deletes a page: its component, its JSON of values, its comments and its entry in the routes.
page-updatewr page-update [pageName] [--new-page-name <string>] [--new-component <string>] [--lazy] [--header] [--footer]Changes a page: renames it or its component, loads it lazily or not, shows or hides the shared header and footer on it.
node-getwr node-get [--page <string>] [--file <string>] [id]One element of a page: what kind it is, the values written in the code (src, href…) and the ones in the JSON (texts per language, hidden…).
node-setwr node-set [--page <string>] [--file <string>] [id] [--key <string>] [--value <value>] [--lang <string>]Sets one value of an element: where it is stored (the code, or the JSON) is decided by its kind's schema. A translated value (a text, an alt, the labels of a menu's entries) is written in the language asked for, and the other languages are kept; a list (items of a nav) is given whole, as a list of { label, href }. A text's content is HTML; plain text is fine.
node-insertwr node-insert [--page <string>] [--file <string>] [--anchor <json>] [--anchor-id <string>] [--mode <before|after|first-child|last-child>] [--block <string>] [--jsx <string>] [--unique-ids] [--json-seed <json>]Adds markup to a page, next to an element or inside one (a section). Give the JSX itself, or the id of a block of the catalog (blocks-list). Ids that are taken are renumbered; the imports and the indentation are taken care of. The result has the final ids.
node-deletewr node-delete [--page <string>] [--file <string>] [id] [--prune-imports]Deletes an element with everything it contains, and the JSON values (texts, translations…) and the comments of all of them. The root of the header or footer cannot be deleted.
node-movewr node-move [--page <string>] [--file <string>] [id] [--anchor <json>] [--anchor-id <string>] [--mode <before|after|first-child|last-child>]Moves an element, with everything it contains, to another place in the same page (or header, or footer). It answers where it was.
node-sourcewr node-source [--page <string>] [--file <string>] [id]The markup of an element with everything it contains, as written in the code, and the JSON values (texts, translations…) of all of them: what node-insert takes, so a copy is one insert away (this is how an element is duplicated).
json-prunewr json-prune [page]Removes from the JSON the values of elements that are no longer in the code (their keys stay behind when an element is deleted or renamed in the code, and come back with the old text if the id is used again). Refuses when some element computes its id: a key that looks unused might be its.
page-outlinewr page-outline [page]What is on a page, as a tree: for each element its id, kind, tag, text, the attributes that matter, what it says in each language (values), whether it is hidden, and where in the code it is. Header and footer are listed on their own (_shared/header, _shared/footer), and the shared components the page uses (a card…) are inside it, each element with its scope (_shared/product-card): that name is the page to use to change them.
page-contentwr page-content [page] [--lang <string>]Everything on a page that is translated (texts, alt texts, labels), in every language of the site, and which languages are missing for each. The default language is called "default" in the values.
blocks-listwr blocks-listThe catalog of ready-made blocks the editor offers (sections, layouts, elements): each is JSX that node-insert takes by its id.
langs-getwr langs-getThe languages of the site: the default one and all the available ones. null while the site is not multilingual.
langs-setwr langs-set [--default <string>] [--available <a,b,c>]Sets the languages of the site. Texts already written in a language that is taken away stay in the JSON (and come back if it is added again).
seo-getwr seo-get [page]What search engines and social networks read: the site's data (address, name, title template, favicon, picture, extra sitemaps) and, for a page, its title and description in every language, picture, noindex and canonical.
seo-suggestwr seo-suggest [page] [--lang <string>]A title and a description for a page, taken from what it says: its first heading and its first paragraph, in the language asked (nothing for a language the page is not translated in). Only a proposal: nothing is written.
seo-setwr seo-set [page] [--lang <string>] [--title <string>] [--description <string>] [--image <string>] [--noindex] [--canonical <string>] [--robots <string>] [--og-title <string>] [--og-description <string>] [--og-image <string>] [--og-type <string>] [--twitter-card <summary|summary_large_image>] [--twitter-site <string>] [--twitter-creator <string>] [--meta <a,b,c>] [--json-ld <value>]Sets what a page tells search engines and social networks. Title, description, pictures and the texts for social networks are written in one language (the default one unless lang says otherwise); an empty text takes the value away.
seo-site-setwr seo-site-set [--site-url <string>] [--site-name <string>] [--title-template <string>] [--favicon <string>] [--image <string>] [--search-console <string>] [--extra-sitemaps <a,b,c>] [--twitter-site <string>] [--twitter-creator <string>] [--lang <string>] [--json-ld <value>]Sets what is the same for the whole site: its public address (needed for canonical links, hreflang and the sitemaps), name, how page titles are shown, the favicon, the default sharing picture, the Google Search Console verification code, and the sitemaps the site does not write itself. An empty text takes the value away.
seo-syncwr seo-syncWrites robots.txt, sitemap-index.xml and sitemap-pages.xml in public/ from the pages, the languages and the SEO data. The dev server does it by itself whenever those change: this is for when it is not running. Needs the site's public address (seo-site-set).
seo-snapshot-targetswr seo-snapshot-targetsThe pages a build prerenders as HTML for search engines and bots (each page in each language, without those marked noindex), with the address of each and the file it is written to.
theme-getwr theme-getThe theme of the site: its custom properties (--wr-*, colors, spacing…; a property has dark too when the site has a dark theme), Google fonts and custom fonts, and dark: whether the site has a dark theme (a .dark block).
theme-setwr theme-set [--item <json>]Sets one item of the theme: a custom property { kind: "property", key: "--wr-…", value, dark? } (a --wr-color-\<name\> is also a class, bg-\<name\>: it is mapped for you; dark is its value in the dark theme, when the site has one), a Google font { kind: "google-font", key: "Inter", weights? } or a custom font { kind: "custom-font", key, faces }. It replaces the item if it is there.
theme-removewr theme-remove [--kind <property|google-font|custom-font>] [--key <string>]Removes one item of the theme.
theme-darkwr theme-dark [--enabled]Turns the dark theme of the site on (a .dark block in theme.css that starts as a copy of the light colors, to be changed with theme-set dark) or off (the block is taken away). A site has a dark theme only if it has that block.
comment-addwr comment-add [--page <string>] [--file <string>] [--id <string>] [--text <string>] [--author <json>]Leaves a comment on an element of a page (or on the page, or on a shared component, when no element is given): a note for the people who work on the site, or for the agent that works on it. It is plain text, kept apart from the site (it is never published).
comment-listwr comment-list [--page <string>] [--id <string>] [--status <open|resolved|all>]The comments left on the site: the open ones by default (what people asked for). Each has where it is (page and element), who wrote it, what the element was, and orphan when the element is no longer in the code. Start here when you are asked to work on the site.
comment-resolvewr comment-resolve [comment] [--resolved]Marks a comment as dealt with (or open again): it stays in the list of resolved ones. Do it after acting on what it asked, so the next run does not do it twice.
comment-deletewr comment-delete [comment]Deletes a comment for good (resolve it to keep it as done).
style-catalogwr style-catalogEvery style property an element can have (padding, text color, width…), with what each one means, its values (with their CSS meaning) and the breakpoints they can be set at. Read this to know what style-set accepts.
style-getwr style-get [--page <string>] [--file <string>] [id] [--set <string>]How an element is styled: for each property set on it, at which breakpoint and to what (in words, with its CSS meaning and the Tailwind class), plus the classes this does not manage (hover:, dark:, your own) and the shared styles it uses (sets). editable: false when the element's classes are written by code. With set instead of id: the same for a shared style.
style-setwr style-set [--page <string>] [--file <string>] [id] [--set <string>] [--property <padding|padding-x|padding-y|padding-top|padding-right|padding-bottom|padding-left|margin|margin-x|margin-y|margin-top|margin-right|margin-bottom|margin-left|gap|gap-x|gap-y|width|height|max-width|font-size|font-weight|text-align|text-decoration|text-color|background-color|gradient-direction|gradient-from|gradient-via|gradient-to|border-color|border-width|border-width-x|border-width-y|border-width-top|border-width-right|border-width-bottom|border-width-left|border-radius|border-radius-tl|border-radius-tr|border-radius-bl|border-radius-br|shadow|opacity|scale|translate-y|transition|duration|ease|animation|display|flex-direction|align-items|justify-content|grid-columns|flex-wrap>] [--breakpoint <base|mobile|sm|md|lg|xl>] [--value <value>] [--state <hover|focus|active>] [--changes <a,b,c>] [--everywhere]Changes how an element looks: one property at one breakpoint ({ property: "padding-x", breakpoint: "md", value: "6" }), or several at once (changes). A value of null takes it away at that breakpoint. Only the classes of that property and breakpoint change; everything else in the element's classes stays. Read style-catalog for the properties and values.
style-copywr style-copy [--page <string>] [--file <string>] [id] [--set <string>] [--from <base|mobile|sm|md|lg|xl>] [--to <base|mobile|sm|md|lg|xl|all>] [--state <hover|focus|active>]Copies the style classes of one screen (and one state) to another, or to all of them. to: a breakpoint (the classes of from are written there: the same properties are replaced, nothing else changes) or "all" (one clean list: the look the element has at from becomes what every screen has, and every breakpoint class is taken away; from "base" that only removes the overrides). hover:, dark: and the project's own classes are never touched.
styleset-listwr styleset-listThe shared styles of the site: each a name (the class is s-name), the Tailwind classes it holds, what that comes to in words, and where it is used. An element uses one by having its class: change the style and every element that uses it changes.
styleset-createwr styleset-create [--page <string>] [--file <string>] [id] [--name <string>] [--classes <string>] [--apply]Makes a shared style. With id: from that element's classes, which move into the style and the element then uses it (apply: false leaves the element as it is); classes of the element that Tailwind cannot apply (its own, other shared styles) stay on it. Without id: from classes (a text of Tailwind classes), or empty. The name is lowercase words (card, hero-title); its class is s-<name>.
styleset-applywr styleset-apply [--page <string>] [--file <string>] [id] [--name <string>]Puts a shared style on an element: everything the element had in its classes is replaced by the style's class (the element then looks like the style and changes with it).
styleset-detachwr styleset-detach [--page <string>] [--file <string>] [id] [--name <string>]Takes a shared style off an element, keeping how it looks: the style's classes are written on the element (where the element has classes of its own for the same thing, its own win). name: only that style (default: every one the element uses).
styleset-detach-allwr styleset-detach-all [name]Takes a shared style off every element that uses it, keeping how each looks (the style's classes are written on each, under the classes the element has of its own). Afterwards the style can be deleted. Not undoable from the editor: it touches many files.
styleset-renamewr styleset-rename [name] [--to <string>]Gives a shared style another name: its rule in theme.css and the class in every element that uses it change together (each keeps its place among the element's other classes). The new name is lowercase words (hero-card); it cannot be one another style has.
styleset-deletewr styleset-delete [name]Deletes a shared style. Refused while any element uses it: it says where, and what to do (styleset-detach-all, or detach it from those elements).