Skip to content
Open
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
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ When asked to add an existing pull request to an existing stack, preserve its co
- **Child processes run on Electron's own Node, not the system Node.** `npm install`, `npm run <script>`, and the Playground server are spawned on Electron's binary with `ELECTRON_RUN_AS_NODE=1` — this is the mechanism behind "zero prerequisites." *Which* binary is `nodeExecPath()` in `src/node-shims.cjs`, the one resolver used by both the shims `ensureNodeShimDir` writes and the runner spawn in `src/main.js`: `process.execPath` on Windows and Linux, and on macOS the `Contents/Frameworks/… Helper.app` binary beside it when that exists, falling back to `process.execPath` when it does not. The Helper is the same Electron, and its `Info.plist` is the only one of the two that carries `LSUIElement`; without it, any child that assigns `process.title` (npm does, and so does every Gutenberg build worker) gets checked in with LaunchServices under the main bundle and earns a Dock tile (#518). On Windows this requires shimming `node`/`npm`/`npx` into `PATH` so child `npm` processes can find a `node` binary at all. On macOS, a signed Electron removes `NODE_OPTIONS` from any process the app did not start itself, which includes everything launched through the bash shims, so those shims split `NODE_OPTIONS` the way Node does, pass it on as arguments and unset the variable, so unsigned builds do not apply it twice and signed ones print no `node_main.cc` warning for it (#525). Only the shim's own child gets the options; what that child starts inherits no `NODE_OPTIONS`.
- **Git has no host dependency.** The app ships its own Git binary via `dugite` (#364), unpacked from `app.asar` and resolved only through `src/git-binary.cjs`, which also builds the environment it runs with (host system and global config off, prompting off, no `GIT_*` variable inherited from the host and nothing from a Node child). `require('dugite')` lives in that one file; `src/git-run.cjs` is the only place the binary is spawned, and `src/git-read.cjs` holds every read and its parser. Spawning a `git` found on `PATH`, or calling dugite's `GitProcess` from anywhere else, is a regression. As of #384 every read outside the write flows (status, branches, history, blobs, the patch walk) runs on the bundled binary, and since #385's first flow so does the new-site clone (`src/git-clone.cjs`: partial, `--filter=blob:none`, repo config written at clone time); Ticket branches (park, start, switch, delete, and the move onto the current trunk, one three-way `merge-tree` of the single WIP commit read in `src/git-read.cjs` and committed by the primitives) write through `src/git-write.cjs`, one Git command per primitive, with the checkout's progress read by `src/git-progress.cjs`, the single parser of Git's human-facing lines that the clone shares; the trunk update (`src/trunk-update.js`: fetch from the site's own `origin`, update-ref, forced checkout; the two discards: forced checkout plus `clean -fd`) writes through the same primitives, with `streamGit` in `src/git-run.cjs` as the one runner for the commands that report progress; patch apply and revert (`src/patch-apply.js`) run on `git apply` through the same primitives, all or nothing by Git's own rule, with the Trac path rewrite, the per-hunk wording of a refusal and the snapshot that undoes a half-written apply kept in JS and never writing on their own. A pull request is checked out, not applied (#458): `src/pr-checkout.js` fetches `refs/pull/N/head` from the site's own `origin` through `fetchBranch`, puts `pr/N` at it and switches through `ticket-branches.js`; `appliedPatch` remains the record for Trac attachments and local `.diff`/`.patch` files only. Since #386 the app has one Git engine: `isomorphic-git` is gone from `package.json` (it reaches the bundle only as a transitive dependency of `@wp-playground/storage`), and every test fixture is built by the bundled binary. The suites that used to build theirs with the old engine go through the fixture layer in `tests/unit/helpers/git.cjs`; the suites that cover a single primitive (`git-read`, `git-write`, `git-clone`, `git-run`, the fetch suite) still call the binary directly, because a fixture built by the layer above the primitive under test would beg the question. A site the old engine cloned (shallow, no `remote.origin.promisor`) is detected by `isLegacySite` in `src/git-read.cjs` and refused by every write handler in `main.js` through `legacySiteBlock` (`code: 'legacy-site'`); only reads, the patch export of the checked-out branch, opening a pull request and deletion still work there, and the sentence both sides show lives in `src/renderer/legacy-site.cjs`. A merge, rebase, cherry-pick, revert or three-way apply started outside the app and left unfinished is read by `mergeInProgress` in `src/git-read.cjs` (the `u` records of `status --porcelain=v2` plus the head files and rebase directories `git status` itself reads under `.git`, never remembered in process) and refused by `mergeInProgressBlock` (`code: 'merge-in-progress'`) in front of the trunk update, both discards, linking and unlinking a ticket, switching, the move onto trunk, applying and reverting a patch, and deleting the ticket that is checked out; the sentence naming the files and the terminal commands that end it lives in `src/renderer/merge-in-progress.cjs`, and the app offers no action of its own for it (#352). Only porcelain-stable output (`--porcelain=v2`, `-z`, explicit `--format`) is ever parsed. Patch/diff generation is done by hand in `main.js`, not `git diff`: one status scan against the branch point each ticket recorded (#108), nothing staged, and `/dev/null` naming whichever side of an addition or a deletion does not exist — the app reads its own patches back when a mentor applies one, and that filename is the only thing its parser reads an add or a delete from (#85).
- **`electron-store` is the only persistence layer** — no separate DB. It holds the site registry and per-site metadata; treat it as the single source of truth for "known sites." **Nothing may yield between reading the store and writing it back.** The `get` and `set` are synchronous, so the event loop is the only thing serialising writers, and it only serialises them while nothing awaits in between. A writer that reads, awaits anything, and then writes what it read hands back a snapshot another writer has moved on from, and that writer's change is gone (#172). The value that made it matter is a ticket branch's recorded base, the one thing a branch cannot recompute. Handlers that write a fixed set of top-level keys do this inline and are fine as they are; a change that has to be computed from the record, or that replaces a nested map such as `branches`, goes through `changeSiteMeta` in `src/main.js`, which takes a function of the record and applies it at the moment of the write. Computing that value from an earlier read is the bug, whichever helper writes it.
- **A tool outside the window reaches the app through one door, the control channel (#764).** `src/control-channel.cjs` listens on a Unix socket in the profile directory (a named pipe on Windows, with a name that is random at every start, since pipe names are shared by every account on the machine and a predictable one could be taken first), started in `whenReady` after the single-instance lock, which is what makes removing a stale socket file safe. It is deliberately not a TCP port: a loopback port can be reached from any page the contributor has open, the exposure `src/deep-link.cjs` keeps to one verb, and the socket file is the user's alone (mode 0600). One request per connection, a line of JSON each way. What can be asked for is the `controlActions` map in `src/main.js` and nothing else, and `ipc-wiring` pins its keys so that a new action is a reviewed change. The reads (`sites.list`, `site.log`, `site.mail`) are answered by main, shaped by `src/control-sites.cjs`, whose `resolveSite` turns the site a tool named into a path out of the registry, so no path a tool sends is ever opened. **An action that changes a site is not carried out by main.** It goes through `windowAction`, which refuses unless the `toolAccess` setting is on (off by default, in Settings → Tools), and then hands the request to the window (`src/control-window.cjs` is the waiting, `src/renderer/control-requests.cjs` what the window does with it). The window carries it out with the function its own button calls, because the terminal's lock, the build watch, and the install and build after a change are sequenced in the renderer and nowhere else: a second caller in main would do the Git and none of that, and the page would not know. So a new write action is an entry in `SITE_ACTIONS` or `APP_ACTIONS` naming an existing press and how its end is read, never a second implementation of a flow, and what it answers with comes from `site:status`, not from the page's copy of it. Nothing that loses or sends work is offered: no delete, discard, revert, Trac attachment or pull request. The `toolkit` command is `src/cli.cjs`, Node built-ins only, run through a shim the app writes to `<userData>/bin` at every start with `cliShim` and `nodeExecPath()`, so it needs no Node on the host; the shim passes the endpoint, and, from a packaged app only, how to open the app when it is closed.
- **A tool outside the window reaches the app through one door, the control channel (#764).** `src/control-channel.cjs` listens on a Unix socket in the profile directory (a named pipe on Windows, with a name that is random at every start, since pipe names are shared by every account on the machine and a predictable one could be taken first), started in `whenReady` after the single-instance lock, which is what makes removing a stale socket file safe. It is deliberately not a TCP port: a loopback port can be reached from any page the contributor has open, the exposure `src/deep-link.cjs` keeps to one verb, and the socket file is the user's alone (mode 0600). One request per connection, a line of JSON each way. What can be asked for is the `controlActions` map in `src/main.js` and nothing else, and `ipc-wiring` pins its keys so that a new action is a reviewed change. The reads (`sites.list`, `site.log`, `site.mail`) are answered by main, shaped by `src/control-sites.cjs`, whose `resolveSite` turns the site a tool named into a path out of the registry, so no path a tool sends is ever opened. **An action that changes a site is not carried out by main.** It goes through `windowAction`, which refuses unless the `toolAccess` setting is on (off by default, in Settings → Tools), and then hands the request to the window (`src/control-window.cjs` is the waiting, `src/renderer/control-requests.cjs` what the window does with it). The window carries it out with the function its own button calls, because the terminal's lock, the build watch, and the install and build after a change are sequenced in the renderer and nowhere else: a second caller in main would do the Git and none of that, and the page would not know. So a new write action is an entry in `SITE_ACTIONS` or `APP_ACTIONS` naming an existing press and how its end is read, never a second implementation of a flow, and what it answers with comes from `site:status`, not from the page's copy of it. Nothing that loses or sends work is offered: no delete, discard, revert, Trac attachment or pull request. The `toolkit` command is `src/cli.cjs`, Node built-ins only, run through a shim the app writes to `<userData>/bin` at every start with `cliShim` and `nodeExecPath()`, so it needs no Node on the host; the shim passes the endpoint, and, from a packaged app only, how to open the app when it is closed. The skill that teaches an agent the command is `docs/public/skills/wordpress-contributor-toolkit/SKILL.md`, published with the docs; a command added or renamed changes it and `docs/guide/toolkit-command.md` in the same pull request.
- Long-running child-process output (installs, scripts, server) is streamed to the renderer via correlated IDs (`installId`/`runId`), not returned synchronously — expect async event handlers, not return values, when tracing that flow.
- **Electron is pinned at 43.6.0 and must not move above it until the upstream V8 bug is fixed.** Electron 43.7.0 and later crash the Playground server child with `SIGBUS` (`KERN_PROTECTION_FAILURE` on a `V8Worker` thread) about a second after "Start development server" on Apple Silicon macOS; 43.7.5 crashes 5/5 and 43.6.0 starts 5/5 in a bisect of `src/server-runner.js` run directly on each Electron Helper as Node. Plain Node 24.21.0 and both Playground CLI versions in range are unaffected, and the crash disappears only under V8's `--liftoff-only`, so it lives in the optimizing WebAssembly compiler of the V8 backports 43.7.0 carries (electron/electron#53766). Nothing that runs on a pull request starts the Playground server on Electron's bundled Node: the packaged smoke never clicks "Start development server", the journeys that do (in `mail.spec.js`, `logs.spec.js`, `dev-server.spec.js`, `site-links.spec.js`, `auto-start.spec.js` and `i18n.spec.js`) replace the handler that starts the server with a stub, and only the manual-dispatch `real-setup.yml` workflow starts it for real. So an Electron bump that passes CI can still kill the dev server. Before moving the pin, start the dev server on an Apple Silicon Mac with the candidate version, or run `real-setup.yml` on it, and say which in the PR.

Expand Down
2 changes: 2 additions & 0 deletions docs/guide/toolkit-command.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Open **Settings**, choose **Tools**, and press **Copy command**. Paste what it c

![The Tools tab of the settings, with the command's path, a Copy command button and the switch that lets tools change sites](/screenshots/settings-tools.png)

If your tool can use [Agent Skills](https://agentskills.io), give it the app's skill as well, which teaches it the commands and the traps: [`SKILL.md`](https://wordpress.github.io/contributor-toolkit/skills/wordpress-contributor-toolkit/SKILL.md).

## Letting a tool change your sites

Out of the box the command can only read. To let it change a site, turn on **Let tools on this computer change my sites** in that same tab.
Expand Down
Loading
Loading