Contributing
Setup
Install just, fnm, and uv, then set up the development environment:
just dev
This installs Node.js 24 from .nvmrc, installs the locked JavaScript dependencies with
fnm exec -- npm ci, synchronizes the Python environment including the docs group, and
downloads Playwright’s Chromium runtime for visual tests. just install remains a compatible
entry point for the same setup. Run just dev again after dependency changes or just mr-proper.
Dependencies are downloaded from the official npm registry (registry.npmjs.org) and PyPI
(pypi.org). Node.js releases are installed through fnm from the official Node.js distribution.
Linux hosts may also need Playwright system libraries; install those using your system’s
package manager or run uv run --group docs playwright install-deps chromium with the required
permissions. Integration tests download their isolated VS Code test runtime on first use.
The full visual campaign also requires plantuml and Graphviz on PATH for its successful
diagram cases. In GitHub Actions only the visual jobs install them, with Playwright’s system
libraries, through just dev-ci visual, from cached Ubuntu package archives; on macOS use
brew install plantuml graphviz.
Windows
just check and just ci-static run on Windows; the visual and real VS Code stages run on Linux
and macOS only, so just preflight runs the static stage there and leaves the others to CI. The recipes need a POSIX shell: install Git for Windows and put sh, bash and
cygpath on PATH (its usr\bin folder, or one shim per tool with Scoop), plus node (for
example fnm default 24 and fnm env in your PowerShell profile). The justfile calls npm.cmd
through fnm on Windows. just dev sets git config core.longpaths true in the repository, so
worktrees and checkouts whose paths pass Windows’ 260-character limit do not fail with “Filename
too long”. Python 3.12 comes from .python-version: the next interpreter may lack
prebuilt wheels and need a C compiler. Tests that create symbolic links are skipped unless
Windows allows them (Developer Mode or administrator rights), and the hang-watchdog tests, which
read the process list with ps, are skipped; the Linux job runs them all.
Dependency Updates
Run just update to upgrade JavaScript dependencies, regenerate the npm lockfile against the
public registry, upgrade the Python environment and lockfile, and refresh Playwright Chromium.
The Node.js runtime stays on the version selected by .nvmrc; its type declarations stay on
Node 24, and the VS Code API declaration floor stays aligned with engines.vscode.
The Python tools (docs, visual captures, release scripts) require Python 3.11 or later, the floor
of Pillow 13; the lockfile selects newer releases for newer interpreters.
Run just preflight after updating.
CI uses STUDIO_NPM to run the Node.js version selected by actions/setup-node without fnm.
Dependency overrides
The overrides field in package.json forces two parsers of the MyST packages onto current
releases. The MyST packages still declare release lines that no longer get fixes:
-
markdown-it^14.3.1:myst-parser,myst-to-html,markdown-it-myst,markdown-it-dollarmathandmarkdown-it-amsmathask for^13(or^12 || ^13). Markdown-It 13 has had no release since 13.0.2 (2023), so parser fixes only reach the 14 line. Markdown-It 14 also bringslinkify-it5, solinkify-itneeds no override of its own. -
csv-parse^7.0.3:myst-directivesasks for^5.5.5, a line without releases since 5.6.0 (2024). It parses the CSV of thecsv-tabledirective.
Nothing writes into node_modules: there is no postinstall script. myst-parser and
myst-to-html are pinned to exact versions, and three source patches (the import-path correction
for myst-to-html and markdown-it-dollarmath with Markdown-It 14, and the single line split of
markdown-it-myst) are applied in memory by scripts/myst-patches.mjs. The esbuild bundle uses it
as a plugin; Node-run code (unit, contract and security tests, visual:render, site) loads it
with node --import ./scripts/register-myst-patches.mjs. A package version or file content that
differs from the reviewed one fails the build or the run with a message asking for a review.
Revisit the overrides when you update a MyST package, during just update, or when an advisory
names one of these parsers. Run npm ls markdown-it csv-parse: remove an override once every
package that pulls the parser asks for the forced line itself. Check that the parser is still on a
patched release, and remove the matching patch of scripts/myst-patches.mjs when Markdown-It 14
support arrives in the MyST packages.
Cleanup
just clean removes compiled output, reports, the generated Pages site, VSIX packages,
generated README gallery captures, and Python test caches. Dependencies, .env, manual images,
and source fixtures are preserved. Campaign screenshots are generated under
out/reports/e2e/screenshots/ (static-page scenarios in visual/<group>/, named
vNN-<slug>-<theme>-<width>.png, step captures …--<step>.png); the obsolete test/visual/screenshots/ directory is not tracked.
just mr-proper also removes .env, node_modules/, .venv/, the downloaded VS Code test
runtime, and local tool caches. It returns the local build environment to an uninstalled checkout.
Architecture
src/ is split into layers, one folder each. The dependencies point down the list: a layer may
import the layers below it, never one above it.
| Folder | What it holds | May import |
|---|---|---|
src/core/ |
Host-neutral logic: protocol (core/protocol/), rendering, sanitizing, source mapping, edit operations, comments, frontmatter, the registries of settings (core/configuration/), palette actions (core/palette/) and MyST directives (core/directives/), page assets built in Node (core/preview/) |
core and npm packages; no vscode, no DOM-only package, no Node built-in |
src/host-api/ |
The port interfaces every host implements (documents, files, settings, watchers, processes...) | core types |
src/page/ |
The preview page, bundled for the browser: runtime, typed features, page modules (page/modules/) |
core, npm packages |
src/node-services/ |
Node implementations of ports and Node-only services (file system, processes, Sphinx build, watchers) | core, host-api, Node, npm packages |
src/session/ |
The host-neutral controllers: PreviewManager, PreviewSession, feature controllers, page HTML |
core, host-api (paths through src/core/path/hostPath.ts, no Node built-in) |
src/host-memory/ |
An in-memory host for tests and future headless hosts | core, host-api |
src/host-vscode/ |
The VS Code host (with src/extension.ts): activation, port adapters, test hooks |
everything except page and other hosts; the only code that imports vscode |
Tests mirror this tree under test/ (test/core/render/ tests src/core/render/).
test/security/, test/integration/ and test/visual/ are suites that span the layers.
just check enforces the layout:
-
just check-min-vscodetype-checkssrc/against@types/vscode1.95, theengines.vscodeminimum, withtsconfig.vscode-min.json: it mapsvscodeto the npm alias@types/vscode-min(npm:@types/vscode@1.95.0), while the main build keeps the newer@types/vscode. It fails on any API newer than 1.95. Raise the alias together withengines.vscodeand@types/vscode. -
just check-boundariesruns dependency-cruiser with the rules of.dependency-cruiser.cjsover a transpiled copy ofsrc/(type-only imports count). The few known exceptions are listed there, each with its reason and its removal plan: Node built-ins still used by some core files (synchronous file access and the PlantUML process before the ports cover them, and purepatharithmetic) and three node-services modules the session layer still imports directly. The list only shrinks. Never add an exception to make a new import pass: move the code, or put the access behind a port, as the frontmatter schema discovery does with theSchemaFilesport (src/core/frontmatter/schemaFiles.ts, implemented insrc/node-services/schemaFiles.tsand handed over asHostServices.schemaFiles). -
just check-limitsholds the file-size ratchet: at most 800 lines per file insrc/and 1 500 intest/. The files that were larger are listed inscripts/file-size-baseline.jsonand may only shrink; when one shrinks, lower its entry withnode scripts/check-file-sizes.mjs --update(the check says so). The same target fails on any@ts-nocheckor@ts-ignoreinsrc/. -
just check-exportsfails when a runtime export (function, class, constant) ofsrc/is mentioned by no other module ofsrc/,test/orscripts/: make it private or delete it. Exported types are not checked. The check matches names, so it can miss a dead export that shares its name with a live one, but it never reports a live one. A deliberate exception goes inscripts/unused-exports-allowlist.jsonwith its reason; an entry that is no longer needed fails the check. -
just check-markerschecks the requirement markers (a#S<n>fragment names a declared scenario or path;@implements_reqnever has one; see “Scenario and path markers” in the project guidelines): every in-force, non-exempt SwRS has an@implements_reqin a source directory; a marker block (markers with no code line between them) names at most 3 requirement IDs; a companion marker file (*.markers.ts, or any file undersrc/ortest/with a// Companion of: <path>line) names an existing host, marks only existing requirements, and writes each marker line as// @tests_req <ID> — <scenario>(or@implements_req … — <code point>), the name being found in the host or its folder. The blocks and companion lines that were already wrong are inscripts/marker-baseline.jsonand may only shrink; when one shrinks, lower its entry withnode scripts/check-marker-companions.mjs --update(the check says so). Never add a file to the baseline. See “Marker placement” inrequirements/guidelines/project.guidelines.md. -
Benches: which marker a test carries depends on where it runs, a convention of the Studio (okfreq only counts markers by verb).
@tests_req <StRS-ID>#S<n>is a path walked on the simulated bench, run on every pull request;@accepts_req <StRS-ID>#S<n>is a path walked end to end in real VS Code undertest/integration/, run on pushes tomain. The only exceptions are the StRS of the release (CORE-007), the site (CORE-008) and the built VSIX (TRUST-014), whose@accepts_reqsits on the test closest to that product undertest/build,test/security,test/siteortest/core.just check-markersfails an@accepts_reqelsewhere, one on a SwRS, and a@tests_req StRS-...undertest/integration/. It also fails a@tests_reqor@accepts_reqthat has no#S<n>on a requirement that declaresscenarios:(such a marker needs a fragment), one that has a fragment on a requirement that declares none (such a marker has none), and a fragment that names an undeclared id. A@tests_req <SwRS-ID>#S<n>names the scenario it checks. -
just check-settingsfails when thecontributes.configurationofpackage.jsondiffers from what the settings registry generates (see “Add a setting”).
Inside the core
-
The renderer (
src/core/render/mystRenderer.ts) is an ordered list of named passes:TREE_PASSESon the parsed MyST tree, thenHTML_PASSESon the produced HTML. Each pass lives in a module of its theme (mystBlockTransforms.ts,mystInlineTransforms.ts,mystContextTags.ts,mystTables.ts,mystNormalize.ts, ...). The order is part of the output: add a pass at the place it must run.normalizeNodedispatches on the node kind through theNODE_RULEStable ofmystNormalize.ts. -
The frontmatter is split by job in
src/core/frontmatter/:frontmatterParse.ts(find and parse the block),frontmatterValidate.ts(schema fields),frontmatterSerialize.ts(the text patches of the properties editor) andokfFrontmatter.ts(schema discovery and the analysis, which reads schema files only through theSchemaFilesport). -
The page stylesheet is built in TypeScript:
src/core/preview/previewStyles.tsconcatenates the per-feature modules ofsrc/core/preview/styles/in cascade order. The modules stay TypeScript strings, not.cssfiles, because the unit, visual and integration suites import the stylesheet from the compiledout/tree, where a.cssimport would not resolve.
Extension points
Four registries hold what used to be spread over many files. Each keeps the pure data in core
and the code that needs the page or a host in its own layer.
Add a palette action (a button of the edition palette, an entry of the / menu):
-
Add its descriptor to
PALETTE_ACTIONSinsrc/core/palette/paletteActions.ts, at the place it should show: label, icon, group, modes (strictshows in every mode,gfmin GFM and MyST,mystin MyST only), scopes, and the optional shortcut, popover, panel, host list or dialog and/menu data (slash: aliases, variants,menuOnly). -
A new icon goes in
PALETTE_ICONS(src/core/palette/paletteIcons.ts); the descriptor’siconmust name one. -
Add its handler to
handlersincreateEditActions(src/page/modules/editActions.ts):applyreturns the text edit;available,explain,current,validateColorand computedoptionsare optional; the edit functions live in the subject modules next to it (inlineEditActions.ts,blockEditActions.ts,linkEditActions.ts,tableEditActions.ts,colourEditActions.ts). TypeScript refuses a descriptor without a handler and the reverse. -
The palette and the
/menu pick the action up from the registry; nothing else to wire. Test the edit intest/page/modules/editActions.test.ts.
Add a MyST directive plug-in (a directive that needs more than what the MyST writer does):
-
Create
src/core/directives/<name>.tsexporting aMystDirectiveDescriptor(src/core/directives/directive.ts): the directivenames, therenderpass on the parsedmystDirectivenode (helpers insrc/core/render/mystNode.ts), the sanitizerattributesrules of the HTML attributes the pass writes (data-*attributes only: the registry refuses any other name), thestylerules of its output and thepaletteActionsthat insert it (ids ofPALETTE_ACTIONS). -
Register it in
MYST_DIRECTIVES(src/core/directives/registry.ts). The renderer runs the pass for every directive of those names and the sanitizer applies the attribute rules. -
Place its stylesheet with
${directiveStyle("<id>")}insrc/core/preview/styles/contentBlockStyles.ts, where the rules belong in the cascade. -
Test the plug-in in
test/core/directives/and its rendering intest/core/render/(mystFeatures.test.ts, ormystPaletteRendering.test.tsfor what the palette inserts).
Add a setting:
-
Add it to its section table in
src/core/configuration/settingsRegistry.ts(PREVIEW_SETTINGS,EDITING_SETTINGS, …; a new section also needs an entry inSETTING_CATEGORIES): thepackage.jsonschema fields in the order they are written (type,enum,enumDescriptions,default,minimum,maximum,step,markdownDescription,order), andnormalize, which turns the stored value into the value the core uses. A setting the page needs at startup is astartupSetting(the content patch then compares it) and one it also follows while open aliveSetting; both give the page’sreadof the boot context entry. AliveSettingstill needs its own update message: add it tosrc/core/protocol/hostToPage.ts, post it from the session when the setting changes (aspostShowCommentsdoes forpreview.showComments) and handle it insrc/page/features/hostHandlers.ts. -
Run
just generate-settings: it writes thecontributes.configurationofpackage.json, which is never edited by hand (just check-settingsfails otherwise). -
Read it on the host with
readSettings(or the section module,previewConfiguration.ts, …), which also types it. Boot settings (thestartupSettingandliveSettingentries ofPREVIEW_SETTINGS) reach the page at startup without more code: the host writespreviewBootSettings(configuration)and the page readsreadPreviewBootSettings(context).
Add a message (between the page and the host; both sides use the typed router of
src/core/protocol/router.ts, one handler per type):
-
Page to host: add its interface to the
PageToHostMessageunion and its payload validator toPAGE_TO_HOST_VALIDATORSinsrc/core/protocol/pageToHost.ts. The envelope (document id, revision, request) is checked before the validator runs. The table is typed by the union, so a type without a validator does not compile. -
Host to page: add its interface to the
HostToPageMessageunion and its rule to the table increateHostMessageFilter(src/core/protocol/hostToPage.ts): the addressing (render,documentorown-id) and, when the page must refuse some payloads, a validator. The filter only matches the message to the page and checks its payload; it cannot tell whether the host had a reason to send it. -
Give a page-to-host message its gate in
PAGE_MESSAGE_GATES(src/session/pageMessages.ts), the rule that drops a stale message before its handler runs, and its handler withrouter.on(type, …)in theregistermethod of the session feature controller that owns it (src/session/features/). The page posts it through itsPageHost. -
Register the handler of a host-to-page message with
hostMessages.on(type, …)in the page feature that owns it, or insrc/page/features/hostHandlers.tsfor the runtime’s own features. The host sends it withpreview.postToPage(…). -
Test the validator or the filter rule in
test/core/protocol/(pageToHost.test.ts,hostToPage.test.ts).test/session/previewManager.test.tschecks that every page-to-host type has exactly one handler and pins their count: raise it by one.tscrefuses a page-to-host type without a gate or a validator, and a host-to-page type without a filter rule. Runnpx tsc -p .andnpm run test:unit.
Checks
How we test explains each test level and the requirement it proves.
Run the package-local checks before opening a pull request:
just check
just sphinx-check
just e2e
just site
just preflight
just package
The full integration and screenshot campaigns require a local VS Code installation and the
Playwright browser runtime. They can be run with just integration, just visual, and just e2e.
Generated reports are stored under out/reports/; the README-derived Pages tree is stored under
out/site/. just preflight runs every stage and returns a failure if any stage fails.
On macOS a locked screen stops ci-integration and ci-acceptance at once (exit code 3) and
preflight skips report and gallery.
On macOS the real VS Code window tests use /Applications/Visual Studio Code.app when it exists
(CI downloads the current stable build); set STUDIO_VSCODE_EXECUTABLE to the Contents/MacOS/Code
binary of another build to run them there. They need an unlocked session: each test window must
become the active window once, or VS Code sees no focused editor and undo, cursor commands and
typed keys reach nothing. macOS keeps a newly launched app in the background while you work in
another app, so each test window (the trusted, untrusted and scroll-sync suites, the reload
campaign and the acceptance windows that take real input) is first brought to the front, and the
run waits until VS Code reports the window focused; on a locked screen it fails at once with the
window state instead of timing out later.
Losing the focus afterwards, for example by switching to another app, does not affect the run.
Bringing a window to the front goes through System Events, so the first run asks once per app
(each VS Code build, and the terminal or editor that runs npm) to allow it under System Settings >
Privacy & Security > Automation; allow it, or the run fails with a message that names the
permission.
CI runs the same stages as parallel jobs, each calling one target after just dev-ci:
just ci-static (check-no-merge-commits against the target branch, justfile format, check, audit, sphinx-check),
just ci-visual 1 and just ci-visual 2 (the jobs visual and visual-2, one part of the screenshot
campaign each, in parallel; just ci-visual runs both parts one after the other, then merges them),
just ci-viewer-graph, just ci-integration, just ci-acceptance <group> (the acceptance job,
one shard per e2e group that has an acceptance file), then just ci-report (first merges the two
visual parts into one run manifest, index and machine-check report, then merges the visual,
integration and acceptance outputs into the review index, out/reports/e2e/e2e-manifest.json and
out/reports/acceptance/acceptance-manifest.json; it fails when a visual part, a stage manifest, or
the manifest of an acceptance group, is missing or failed) and just ci-gallery (gallery and site
from the existing outputs, no E2E re-run).
On a pull request, CI runs only the simulated tests, which make up the required checks job:
ci-static (on Linux, and again on Windows in the static-windows job), ci-visual (in two jobs:
Playwright/Chromium against a mock host, and in part 1 then the page tests that need Chromium, run
with STUDIO_REQUIRE_CHROMIUM=1 so that a Chromium that cannot start fails them; the static jobs
have no Chromium and skip those tests; their report is under out/reports/breakout/. The table and
code block breakout width tests assert the widths and the owner’s verdicts on Windows, the
reference, and are report-only on Linux CI: they print the widths and the verdicts and name each
difference from Windows, and never fail on one. The tests of the aligned-float layout, of the style
cost of one comment and of the selected text of a scroll assert wherever Chromium runs),
ci-viewer-graph (the use case map tests, in a job of their own so that the visual jobs keep their
time budget: they write the JSON requirements report and check in
Chromium, in pinned fonts, that no text or pill of any use case map overlaps another at 1280 px and
at 800 px, with captures of six frozen maps under out/reports/requirements-viewer-graph/; the same target runs the
gallery link tests in Chromium) and
just ci-report visual, which reports the real VS Code
stages as skipped. The real VS Code window jobs (ci-integration, the ci-acceptance shards and
the stress repetitions) are heavy, so they run on every push to main and never on a pull
request. On a branch, start them with
gh workflow run ci.yml --ref <branch> -f heavy=true (the gallery and site artifact,
studio-site-attempt-<n>, are built too when integration and report succeed; -f gallery=false
skips them, for example in a stress loop), or with “Run workflow” in the Actions tab. Run them, or
npm run test:integration and npm run test:acceptance locally, before merging a change to the
extension host, the webview or the real-window tests.
On a push to main that changes the package version (a release), the release-check job detects
the change, and the release is tagged only when the three heavy jobs (integration, every
acceptance shard and stress) succeed (see “Releases” below).
The acceptance tests (test/integration/acceptance/) walk main paths of the use cases in real
VS Code, one window per file: trusted, Restricted Mode, or one whose extension under test is the
built VSIX. npm run test:acceptance runs them all (-- --group <id> for one e2e group of
test/shared/e2eGroups.ts), and each group writes
out/reports/acceptance/<group>/acceptance-manifest.json. just ci-acceptance [GROUP] starts the
stage over: it first removes the earlier acceptance manifests, those of the other groups too.
A flake that only shows in the real window can be hunted with the toc-loop job, a repro tool that
never gates a merge and never runs on its own:
gh workflow run ci.yml --ref <branch> -f toc_loop=30 [-f toc_delay_ms=300] repeats the toc
scenario in one trusted window (just ci-toc-loop, at most 40 rounds, launch deadline 30 minutes,
step timeout 35). toc_delay_ms (0 to 2000) injects a random pause around the edit toggle and
after a host theme change. Failed rounds are counted, not fatal, and the job is red if any failed;
out/reports/e2e/toc-loop-summary.json is rewritten after each round.
just preflight calls these targets in sequence. Each stage records its own start time and they share
a run id, so just ci-visual, just ci-viewer-graph, just ci-integration, just ci-acceptance
and just ci-report also work one by one; just clean starts a fresh campaign. The two visual
parts are the exception: without a pinned STUDIO_E2E_RUN_ID, just ci-report refuses a visual
stage whose parts ran one by one, so that an older part never passes beside a newer one; run
just ci-visual with no part. just dev-ci is for CI machines only: npm ci replaces
node_modules.
The focused site and gallery commands are:
just gallery
just site
just gallery runs the complete E2E campaign and copies the three selected real-input captures
into images/. It also runs scripts/generate-readme-images.py, which uses Pillow to derive the
compact install, feature, and theme images under images/readme/ from passing visual and real VS
Code captures. It only overwrites those selected and derived filenames plus images/gallery.json;
unrelated manual images and future video assets remain untouched. just site builds the E2E
evidence, gallery, and static Pages tree. The published out/site/gallery.html includes every
screenshot recursively from out/reports/e2e/screenshots/, not just the README selections. Each
caption shows the sidecar summary. Selecting an image opens the full sidecar on the left and the
image on the right; on narrow screens the sidecar appears above the image. Each screenshot has its
own URL, gallery.html#<capture id>, which opens it directly, and Back and Forward step through
the screenshots seen. The capture id is the path below the screenshot root without the file
extension, with visual/ dropped (the scenario id, plus --<step>) and the run folder of a
real-window capture dropped (the registry id <group>/rNN-<slug>), so it stays the same from one
CI run to the next; when two captures share an id, only the first in name order keeps it and the
others take their full path. Historical captures remain visible with their original metadata and
are not certified as part of the latest passing campaign.
just site and just ci-gallery first write the requirements report (just requirements-report),
and the published out/site/requirements/ (“Requirements” in the site navigation) is built from
it, written by test/site/requirementsViewer/. The home holds the three layers, the areas, the
chain from use case to test as a diagram, one real requirement as an example and the counts of
active requirements (per scope, marker coverage, exemptions, known issues; retired ones apart),
with the cards “StRS paths tested”, “StRS paths accepted”, “StRS covered” (it follows okfreq’s current
coverage mode) and “SwRS scenarios tested”, and the columns “Paths tested” and “Paths accepted” of
the area table. The paths and scenarios are counted from the scenarios: of each requirement; the
files that test or accept each one come from out/reports/requirements/requirements-trace.json
(okfreq trace requirements --json, written by just requirements-report and
just requirements-report-json next to the report). Without that file the cards read “n/a” for the
tested and accepted counts and no file is listed.
Each area, use case and behaviour has its own page (requirements/<area>/<requirement id>/): a use
case with a ### Main paths section is drawn as a map and lists each path with its tested and accepted
files (with a “waived” badge when the StRS has an acceptance waiver), a behaviour lists its scenarios with their
tests (an untested one is marked “missing”) and the files that implement and test it, and the retired requirements show behind the History button.
The old address out/site/requirements.html redirects there. Without the report the site still
builds and the home says it was not generated. The pages follow the reader’s light or dark colour
scheme, and the viewer has its own search.
The shared logo source is images/logo.svg.
After editing it, run fnm exec -- npm run logo:generate to regenerate the PNG used by the README
and VS Code Marketplace, and the Sphinx favicon. Chromium must be installed through just dev.
The generated site uses the SVG directly for its header and favicon.
The static-site URL tests cover rendered Markdown documents, the repository’s out/reports/ path,
copied assets with query and fragment suffixes, and absolute URLs. The site publisher maps local
report artifacts into the published reports/ tree without relativizing external URLs.
The E2E review index is only passed when the visual and integration artifacts share the current
campaign UUID, start time, and command. A failed review:begin stops test:e2e; stale visual
manifests cannot certify a later run. just ci-report holds the manifest of each acceptance group
to the campaign of the visual stage too: both started less than two hours apart, or in the same CI
run.
Mutation testing of src/core
just mutation-core [SAMPLE] runs a mutation campaign (StrykerJS 10.1.1, a pinned devDependency) on src/core against the test/core unit tests. It is a manual campaign, not part of just check, just preflight or CI: the whole of src/core takes hours, so run it in the background and give it a sample, comma-separated globs of src/core files (or the environment variable STUDIO_MUTATION_FILES), for example just mutation-core "src/core/find/**/*.ts".
The target compiles, runs the checker self-test (it stops there when the TypeScript 7 check cannot work), runs the core phase (scripts/stryker.config.mjs), then the others phase (scripts/stryker.others.config.mjs: only the holes of the core phase, against the tests of the other layers), then writes out/reports/mutation/summary.md and summary.json with scripts/mutation-report.mjs: score per sub-folder and per SwRS, tests that kill nothing, a greedy set of redundant tests, tests not judged, holes with a label, and test files left out. The Stryker plugins are in scripts/mutation/: a node:test runner (stable test IDs, per-test coverage), a TypeScript 7 checker through typescript/unstable/sync (the stock checker cannot run on TypeScript 7), and an ignorer for message strings. Stryker’s sandbox is .stryker-tmp/ (git-ignored).
Preview performance probe
The probe measures the live preview on a large generated chapter (about 99 KB, 80 sections,
80 links, 8 Mermaid diagrams, see test/probe/largeChapter.ts). Run it before and after a change to the
webview runtime, the content patch or the edit lock, and compare the JSON reports.
npm run probe
It runs without a VS Code window: it builds the real preview page, opens it in headless Chromium
with a stub host and writes out/reports/probe/preview-probe.json. It reports the page size, the
script time of each scroll frame (normal CPU and four times slower), the page loads, the Mermaid
redraws and the content blocks rebuilt while ten characters are typed as content patches, and
whether an open inline editor survives a theme change and the Mermaid redraw. The first page is
loaded as VS Code’s webview loader shows it (every link without a title gets its address as
title). With --check (the npm script passes it), it exits with an error when a scroll frame’s
95th percentile goes over 4 ms, a page reloads while typing, typing redraws a diagram or rebuilds
another block than the typed one, or the open editor is lost.
The real-window probe measures the same in VS Code: webview.html assignments while typing in the
text editor, scroll frames of the webview, and an open editor through a save, a colour theme change
and the Mermaid redraw. It writes out/reports/probe/window-probe.json and asserts only what it
needs to run:
STUDIO_REAL_INPUT_SCENARIO=probe npm run test:integration -- --trusted-only
A second real-window measure covers comments on a large document (issue 547): a generated review
document with 22 tables, 11 images and 9 comment threads (test/probe/perf547Document.ts). It drags
over running text and across table cells with the mouse, creates comments from the Comment button,
and writes out/reports/probe/perf-547.json: every sample and the median of selectionRelease and
commentCreate, the number of elements a comment creation restyles, and the longest main-thread
task of each drag and release. The comment author setting stays empty and the fixture folder is its
own Git repository (a local user.name, no commit), so the report also holds authorWait: how long
each comment write waited for the Git user name. A Node step then adds threadIndex
(test/probe/perf547ThreadIndex.ts): the time of createDocumentIndex and of reanchorThreads on
that document and on one four times as large with 36 threads, all anchored, measured outside VS
Code. It sets no limit and fails only when the measure cannot be taken.
just ci-perf-547
On CI it runs on demand only, three times on one commit when two states are compared:
gh workflow run ci.yml --ref <branch> -f perf_547=true.
Scope
Keep the extension standalone. Runtime code and tests must not resolve files from a parent
repository. The Sphinx configuration under sphinx/ is intentionally limited to the MyST
features needed by Studio preview contracts.
Screenshot Review
Run fnm exec -- npm run test:e2e from the extension directory for the complete campaign. The
command checks static captures, all integration hosts, scroll synchronization, frontmatter
interactions, actual Developer: Reload Window restoration, and close/reopen persistence.
The ordered entry point is out/reports/e2e/REVIEW.md. Each new image has an adjacent JSON sidecar
with summary (expected visible content), info (capture identity and environment), and applicable
actions, captured state, checks, and limitations. Markdown review notes may also be generated.
The gallery embeds complete sidecars, so image inspection also works when opened locally without
a server. Legacy Markdown and TXT sidecars remain readable. Static captures use a mock host;
real-window captures use isolated development
profiles. Intentional schema errors and unresolved diagrams are labeled fixture states, not
product failures. Manifests record revision, worktree state, campaign identity, assertions, and
final suite outcomes. Historical runs are excluded from the current review index.
For focused campaigns, use fnm exec -- npm run test:scroll, fnm exec -- npm run test:reload, or
fnm exec -- npm run test:visual.
Static screenshot capture uses four worker threads by default, each with its own Playwright
instance and browser. Reports retain scenario order, and failures still fail the campaign.
For serial debugging after rendering fixtures, run
uv run --no-sync --group docs python test/visual/capture.py --workers 1.
Real VS Code integration scenarios remain serial. The Pages workflow builds out/site/ through
just preflight; just site also runs the E2E campaign before generating the gallery and site.
Static scenarios that hold on CI
The visual jobs render on Linux, whose fonts are wider than the macOS ones, so a scenario that passes locally can fail on CI when it depends on text metrics:
-
A fixture line that must fit on one line at a width keeps a margin of at least one word; it never fits exactly.
-
A scenario scrolls to a stable anchor (the top of the block it shows) with room left for the floating toolbar and the editing bars, never to an offset whose result depends on the height of the text above.
-
Run a changed scenario three times locally, alone and inside its group, before pushing.
The floating toolbar’s width is an input to other layout. The conf.py warning banner reserves
room for it (--sphinx-preview-warning-banner-reserve, SwRS-MDOKFSTUDIO-MYST-081, checked in
test/core/preview/previewStyles.test.ts), README crops must reach the viewport’s right edge,
and the 460 px scenarios leave room for it. A change that adds or removes a toolbar button, or
changes a button’s size, updates these values in the same pull request.
Product-owner gallery and report pruning
npm run review:gallery writes out/reports/e2e/GALLERY.md and one page per feature group in
out/reports/e2e/gallery/. The pages come from the scenario metadata (test/visual/scenarios.ts,
test/shared/e2eGroups.ts) and the last visual run manifest: for each group, every captured
scenario (thumbnail, locks statement, step images, README marks) and a table of the
assertion-only scenarios with what they verify. Open them in VS Code’s Markdown preview. The gallery
says STALE when the last visual run was partial, is from another revision, or lacks scenarios or
images; run the full npm run test:visual first for a fresh one. npm run review:finish (the last
test:e2e stage) refreshes it and links it as item 0 of REVIEW.md. It is unrelated to
gallery:generate, which curates the tracked README images.
The README images cropped from static captures are declared by the readme metadata of their
scenarios (README_BY_ID in test/visual/scenarioIds.ts: file, crop box, width);
scripts/generate-readme-images.py reads it from the render manifest. Do not change a README
scenario’s viewport, fixture, theme, scroll or crop unless the image is meant to change.
To refresh only these headless pictures (no real-window run, no REAL-INPUT-LATEST.md needed), run
npm run visual:render, uv run --group docs python test/visual/capture.py, then
uv run --group docs python scripts/generate-readme-images.py --visual-only; the real-window
pictures in images/readme/ stay untouched. --visual-only also narrows --check <dir> to the
visual-sourced images. --real-only writes only the six real-window pictures, cropped from the latest
passing real-input run under out/reports/e2e/screenshots/ (a downloaded CI artifact works); it needs the
manifest from npm run visual:render but no visual PNGs. The campaign runs with reduced motion, so these captures are settled frames.
A README crop that starts at the top of the page must reach the viewport’s right edge, or it cuts
the floating toolbar (test/site/scenarioInvariants.test.ts checks it).
Real-window captures: registry and parallel runs
Every screenshot taken in a real VS Code window has a stable id <group>/rNN-<slug> registered in
test/shared/captureRegistry.ts (group, suite, one locks sentence, clip, README and curated
flags). All six suites (real-input, checkbox, frontmatter, scroll, reload, untrusted) write
through the same
RealWindowEvidence writer (test/integration/evidence.ts): it rejects an unregistered id, writes
<run folder>/<group>/rNN-<slug>.png with its .md note and .json sidecar, lists the capture in
the captures array of the run manifest.json, and fails a complete suite when a registered
capture of it was not taken. A new capture takes the next free number of its group. Entries with
capture: false keep their assertion and note but write no picture. clip: "preview" crops to the
webview frame (falling back to the whole window), clip: "element" to the changed excerpt, and
clip: "window" keeps the whole VS Code window, which the README crops need.
The LATEST pointer files, INDEX.md and the run folder prefixes (real-input-, checkbox-e2e-,
frontmatter-e2e-, scroll-e2e-, reload-e2e-, and untrusted-e2e- with UNTRUSTED-LATEST.md)
are unchanged; the per-group folders live inside the run folder. Every window with captures gets a
loopback CDP port (STUDIO_CDP_PORT): the trusted and scroll launches, and the Restricted Mode
window, which run-tests spawns directly (--untrusted-only runs it alone).
A new real-window scenario goes into the stress plan (STRESS_SCENARIOS_BY_HOST in
test/shared/stressPlan.ts, by the window that runs it) and must pass the stress CI job before it
stays in the integration job (CI rule 12). just ci-stress runs the trusted window, then the
Restricted Mode window. npm run review:gallery lists the registered captures of the latest runs per group,
and scripts/generate-readme-images.py --check <dir> compares the README images, real-window ones
included, with a baseline directory.
Several real-window runs can be active at once on one checkout. Each run-tests process has an
instance id (STUDIO_E2E_INSTANCE, generated when unset) and gives every VS Code launch its own
user-data directory, extensions directory, CDP port and evidence folders; the manifests carry
instanceId. The LATEST pointers and integration-manifest.json are shared files, so the last run
to finish wins them; use the run folder named in the console for a specific run.
The trusted window runs as two launches, each with its own launch deadline. Part 1 runs setup,
preview-smoke, the steps from project-features to find-in-preview, then those from edit-keys
to workspace-disposal. Part 2 runs setup, preview-smoke, real-input and preview-editing.
The two lists are in test/shared/trustedParts.ts; a new step goes into one of them, gets its runner
in test/integration/trusted-suite.ts and its name in test/build/trustedParts.test.ts.
run-tests (full run and --trusted-only) launches part 1, then part 2, and passes
STUDIO_TRUSTED_PART; a STUDIO_REAL_INPUT_SCENARIO run stays one launch. Each launch prints
TRUSTED LAUNCH: <name> (for example trusted-suite.js part 2/2).
A hung real-window run fails fast and leaves a dump (CI rule 11). Each step of the trusted window
runs under step() (test/integration/stepWatchdog.ts), with a budget per step, STEP start and
STEP done lines in the log, and bounded() around single VS Code calls that must return. The scroll,
Restricted Mode and standalone windows run as one step each, each acceptance file runs its paths
under step() in a window of its own, and the reload campaign has its own 3-minute deadline. Every
suite writes a heartbeat file (out/reports/e2e/heartbeat-<instance>-<suite>.json) every 5
seconds; run-tests stops a launch whose heartbeat is silent for 90 seconds (frozen extension host
or renderer) or that runs past its deadline (15 minutes, STUDIO_LAUNCH_TIMEOUT_MS; a stress run
computes its own, 2 minutes plus 6 s per scenario run (rounds times scenarios) and at most 24 minutes, and
just ci-toc-loop sets 30), kills its VS Code processes and names the last step. Thresholds live in
test/shared/hangWatchdog.ts. Each timeout writes out/reports/e2e/hang-dumps/<time>-<step>/ (when
a trusted part is stopped by LAUNCH TIMEOUT or LAUNCH HANG, that line names the launch and the
folder is <time>-trusted-part-<n>-<step>/):
ps output, the tails of the VS Code logs, the window state and tabs, the heartbeat and screenshots
(through CDP, and of the X display when import or xwd exists). In CI the integration step stops
at 20 minutes, the test step of each acceptance shard at 3 (the toc-loop step at 35, the
perf-547 step at 4), and
just ci-hang-dump adds the processes and logs left behind (post-step/). The acceptance step and
the perf-547 step end before the step budget and the launch deadline can expire: a hang there that
neither the heartbeat nor bounded() catches in time leaves post-step/ and no watchdog dump, with
a STEP start line only if it is inside a step() call.
Run folders of the real-window suites pile up under out/reports/e2e/screenshots/.
npm run review:finish keeps the latest 5 per kind (STUDIO_E2E_KEEP_RUNS changes it). Run
npm run review:prune -- --dry-run to list what would go, npm run review:prune -- --keep 3 to
prune by hand. The pruner only touches run folders inside out/reports, never the folders the
LATEST pointers name, and never a folder that holds a git-tracked file.
Build And Install Locally
Build an ignored VSIX without publishing it:
just package
The artifact is written to:
out/reports/package/markdown-okf-schema-studio.vsix
Packaging uses vsce to rewrite relative README links only inside the VSIX. Image URLs target
https://media.githubusercontent.com/media/gsemet/markdown-okf-schema-studio/v<VERSION>/, and document
links target the same tag on GitHub. The source README keeps its relative paths for GitHub.
Commit the README images before creating the matching release tag: Marketplace loads them
anonymously from GitHub, not from the images bundled inside the VSIX. Local packages whose tag
has not been pushed can therefore show broken images in the extension details page.
Screenshots use Git LFS: the media endpoint serves image bytes rather than raw LFS pointer files.
Push the LFS objects along with the tag. Publishing a new version containing the images is required
to repair an already published release.
Install or update the default VS Code profile with:
just install-vsix
Install into a named profile with:
just install-vsix "My Profile"
The install recipe reports the VSIX path and the VS Code Install from VSIX... action when the
code CLI is unavailable. After installation or an update, reload the current VS Code window
manually.
How to Release
Releases start with a committed version change, not a manually created tag.
The extension version lives in package.json; package-lock.json must match it.
The Python project’s version is tooling metadata and is not the extension release version.
The release notes, the announcement thread and their images are committed in the version pull
request, under docs/releases-notes/YYYY-MM-DD-vX.Y.Z/, and just check fails without valid notes:
see release-process.guidelines.md, which also
gives the order of a release. Make the version commit (step 3) only after a green heavy run of main HEAD (step 1), or of the
top branch of the stack when the version PR tops it (see “The version PR on top of a stack” in the
release guideline).
-
Merge everything the release needs into
main. The push runs the heavy jobs (integration,acceptanceandstress) onmainHEAD: wait for all of them, everyacceptanceshard included, to be green on that exact commit, reading the result of each job, because a redstressdoes not turn this run red:gh run list --workflow ci.yml --branch main --limit 3 gh run watch <run-id> gh run view <run-id> --json jobs --jq '.jobs[] | select(.name == "integration" or .name == "stress" or (.name | startswith("acceptance ("))) | "\(.name) \(.conclusion)"'A red job: fix, merge, run again. A flake:
gh run rerun <run-id> --failedonce, then treat it as red. When the version PR tops a ready stack, merge nothing first: dispatchgh workflow run ci.yml --ref <top-branch> -f heavy=trueand wait for green on that head. Do not make the version commit before this run is green. The heavy run of the version push (step 5) stays the final gate. -
Fetch release tags and commit the changes to include in the release:
git fetch origin --tagsThen check that
## UnreleasedinCHANGELOG.mdhas one user-facing line, ending with its references (see “CHANGELOG line” in the pull-request guideline), for everyfeatandfixcommit since the last release tag, and treat a missing one as a gap of its PR: a fix PR adds it before the version commit. Each PR adds its own line, appended at the end of## Unreleased(test, CI, build and documentation commits get none). This check is the release’s safety net:git log --format='%h %s' "$(git describe --tags --abbrev=0)"..origin/main | grep -E '^\S+ (feat|fix)' -
Calculate the next version with Python Commitizen:
just bump-versionfeat:commits produce a minor bump. A!before the colon or aBREAKING CHANGE:footer produces a major bump, including before version 1.0. Fixes, documentation, maintenance, other changes, and an empty release range produce a patch bump. Classification uses committed history since the baseline release tag; uncommitted feature changes do not count. The baseline is the newer of the current manifest version and the latest reachable stable release tag.To choose a version instead:
just version 1.2.3Both commands update the npm manifest and lockfile, the two plugin manifests (
plugin.json,.claude-plugin/plugin.json) and the plugin entry of the GitHub Copilot catalog (.github/plugin/marketplace.json), and create a commit with subjectchore: version X.Y.Z. Neither creates a local tag. Only these files are committed; unrelated staged work stays staged. Commit or stash existing edits to these version files before running the command. Explicit versions must be stableX.Y.Z, newer than the baseline, and not already tagged.The commands leave
CHANGELOG.mdalone. First runjust changelog-refs, which adds the commit of each line of## Unreleased(just changelog-refs origin/main --skip-missingwhen the version PR tops a stack, whose commits are not onmainyet). Then add a## X.Y.Z - YYYY-MM-DDheading (the version just computed, today’s date) right under## Unreleased, so the lines move under it and## Unreleasedstays empty, then amend the version commit. The version commit carries noSigned-off-bytrailer, so the amend has no-s:git commit --amend --no-edit CHANGELOG.md -
Validate the version commit, then push it and merge it into
main:just preflight git show --stat HEADIf
just preflightstops atci-integrationbecause the screen is locked, do not wait: dispatchgh workflow run ci.yml --ref <branch> -f heavy=trueat once on the release branch and go on; itsintegrationjob andacceptanceshards are the real-window proof.Keep release images and their Git LFS objects committed and pushed, since Marketplace image URLs use the release tag.
-
The push of the version commit to
mainruns the heavy jobs (integration,acceptanceandstress) in its own CI run:release-checksees that the pushed version changed (scripts/version.py --bump-since). After successful main-branch CI, the tagging job checks whether the pushed version changed and whethervX.Y.Zexists remotely. It verifies matching lockfile versions and an increasing version, then tags the exact tested commit, but only whenchecksand the three heavy jobs of that run succeeded. Otherwise it creates no tag, writes “Release not tagged” with the result ofchecks,integration,acceptanceandstressto the job summary, and fails (an integration or acceptance failure also failsreportandchecks; the summary is written all the same). Only that push can tag the version: see “Recovering from a red heavy job” below. Ordinary pushes (no version change) leave the tags unchanged. It never commits files back tomain. -
CI dispatches Release VSIX with that tag on the default branch, as a run of its own. A tag pushed by
GITHUB_TOKENstarts no workflow, but a dispatch does; and a dispatch (not a reusable-workflow call) is needed so that the OIDC token namesrelease.yml, the workflow both trusted publishers are registered for. Watch that Release VSIX run (gh run list --workflow release.yml --limit 3), not only the CI run. The release job verifies the tag, manifest, and default-branch ancestry, prepares the reviewed notes of the tag, packages the extension, publishes to the VS Code Marketplace with trusted publishing (OIDC), attaches the VSIX, the notes and their images to a GitHub release, then publishes the same VSIX to Open VSX with trusted publishing. The notes must be valid before publication. After the release job, watch both registries as described in step 6 of the release guideline. CI also calls Deploy GitHub Pages with the tag: it builds the site from the end-to-end reports of that same run (its heavy jobs are green) instead of running the suite again. A later manual Pages dispatch of the tag finds that run as well (scripts/select_e2e_run.pyaccepts a manual heavy run or the release push of the commit).
Recovering from a red heavy job
A flake that fails integration, an acceptance shard or stress on the push of a version change
is recovered in the same CI run, with no new commit and no manual tag:
-
Open the run: Actions, workflow CI, the run of the version commit on
main. Itstag-releasesummary says “Release not tagged” and lists each result. -
Choose Re-run jobs > Re-run failed jobs, then Re-run jobs. With the GitHub CLI:
gh run rerun <run-id> --failed gh run watch <run-id> -
GitHub re-runs the failed jobs and the jobs that depend on them, including skipped ones: the heavy job (of the
acceptancematrix, the failed shards only), thenreportandchecksafter an integration or acceptance failure,tag-release, thenrelease(which dispatches Release VSIX, a separate run) andpages. Jobs that passed keep their results and outputs, sorelease-checkstill reports the version change. The re-run uses the same commit and push event, andtag-releasetags that commit when everything is green. -
Each attempt uploads its own artifacts: every artifact name of the CI workflow ends with
-attempt-<n>(for examplestudio-reports-attempt-2), and each consumer downloads the name that the producing job reports.reporttherefore merges the attempt-1 visual stage with the re-run integration stage, and Pages uses the merged reports of the newest attempt that ranreport. A download by a fixed name would return the attempt-1 artifact. The visual stage comes from two artifacts,e2e-visual-attempt-<n>ande2e-visual-2-attempt-<n>, one per part, andreportmerges their manifests first. Each acceptance shard uploadse2e-acceptance-<group>-attempt-<n>, andreportkeeps the newest attempt of each group (scripts/select-acceptance-attempts.mjs). The visual, integration and acceptance stages of one CI run form one campaign however far apart they started, so a re-run hours or days later still passesreport. To fetch the reports of a run by hand, usejust site-from-run <run-id>, which picks the newest attempt. -
Once the tag exists, only re-run the failed jobs. Re-running
tag-releasethen finds the existing tag, outputs no tag and skipsreleaseandpages. A failed publication is re-run in the Release VSIX run; in the CI run, re-run onlyrelease(if the dispatch itself failed) orpages.
When the failure is a real bug, or the same job fails again after a re-run, fix the cause in a
new pull request, then release a new version (just version). GitHub allows re-runs for 30 days
and at most 50 attempts per run; after that, release a new version.
GitHub Configuration
Create a GitHub environment named release, allowing releases from the default branch
and v* tags. The workflow publishes to the VS Code Marketplace and to Open VSX with Trusted
Publishing (GitHub Actions OIDC) and reads no stored token:
-
A Marketplace Trusted Publishing policy “Release workflow” exists on the
GaetanSemetpublisher: provider GitHub Actions, repository ownergsemet, repositorymarkdown-okf-schema-studio, workflowrelease.yml, environmentrelease. -
An Open VSX trusted publisher exists on the
GaetanSemet/markdown-okf-schema-studioextension (open-vsx.org, Settings, Trusted Publishers): provider GitHub, ownergsemet, repositorymarkdown-okf-schema-studio, workflowrelease.yml, environmentrelease. The namespaceGaetanSemetmust stay verified and equal to thepublisherfield ofpackage.json. NoOVSX_PATsecret exists:ovsxgives a token precedence over OIDC. -
The
packagejob ofrelease.ymlgrantsid-token: write; thereleasejob ofci.ymlonly dispatches it (actions: write). -
Renaming
release.ymlor thereleaseenvironment breaks both publications until the Marketplace policy and the Open VSX trusted publisher are updated. Callingrelease.ymlas a reusable workflow breaks the Open VSX publication (the token would name the caller). -
VSCE_PATis no longer used by the workflow. It stays in thereleaseenvironment until a release published with--oidchas succeeded; the owner then deletes it.
The workflow’s normal GITHUB_TOKEN is used for tags and GitHub releases.
Repository rules must permit the CI token to create version tags. Environment approval
rules, when configured, pause publication after tagging. All committed dependency settings
and GitHub jobs use public PyPI and npm registries; corporate proxy and CA settings belong
only in the developer’s local environment, never in workflow files or lockfile URLs.
Recovery and Release Notes
If tagging succeeded but publication failed, re-run the failed job of the Release VSIX run or dispatch
Release VSIX with the existing vX.Y.Z tag. Do not move the tag or bump again just
to retry. Marketplace and Open VSX publications skip an already published version, allowing a
retry to finish the GitHub release. Manual pushes of valid vX.Y.Z tags also run this workflow.
If the Marketplace token exchange (OIDC) fails, the job fails before the GitHub release is
written. Fix the cause, then dispatch Release VSIX with the existing tag. In an emergency the
owner publishes locally with vsce publish and the PAT they keep. There is no automatic fallback
to the PAT.
If the Open VSX step fails, the step is last: the Marketplace and the GitHub release are already
done and the job is red. Fix the cause if any, then re-run the failed job or dispatch Release
VSIX with the existing tag. The Marketplace step skips the duplicate, the GitHub release step
rewrites the release body from the reviewed notes file (a hand edit made on GitHub in between is
lost: redo it), and Open VSX is retried. In an emergency the owner publishes the VSIX of the
GitHub release by hand with npx ovsx publish <file.vsix> -p <token> and a personal Open VSX
token never stored in GitHub. There is no automatic fallback to a token.
A tag older than 1.4.0 has no notes folder: dispatch Release VSIX with notes: placeholder,
then replace the notes by hand.
To check the notes of the current version locally:
just release-notes-check