Repository navigation
feat: a project plugin kind recognises a project type from its manifest - #6610
Conversation
A project plugin is a directory whose package.json declares stimPlugin.kinds.project and a stimPlugin.project block with id, name and markers. The new machine setting plugins lists such directories by absolute path. A folder that holds every marker as a file is a project root of that type with no platform: worktree add and warm register it, status names the type, and ios, android, macos and start refuse with STIM_NO_PROJECT naming the type and the plugin. Stim reads the manifest only and imports no plugin code. The list is read lazily and again when config.json or a named package.json changes on disk, so stimd follows the setting without a restart. A plugin cannot declare the id of a bundled integration or of an earlier entry, and a manifest Stim does not accept is skipped and reported by plugin list, plugin test, doctor and settings set plugins. The kind is experimental and is the first one that loads from outside the package; LLP 0023 records that. Refs #6599
|
Fresh review of b673ca8 (slice 1 of #6599). One confirmed blocking finding and one Windows test failure, so no Confirmed, blocking1. One unreadable
|
| Command | Result |
|---|---|
stim status |
Unexpected error: EACCES: permission denied, stat '<dir>/package.json' |
stim logs |
same |
stim plugin list |
same (it should list the entry as not accepted) |
stim settings unset plugins --scope machine |
same, and config.json is unchanged |
The only way out is to edit config.json by hand. Importing the registry directly, findProjectRoot, isMobileProject and configuredProjectPlugins() all throw EACCES. A symlink loop as the entry throws ELOOP. I did not run stimd. It reads the same registry, so I infer it breaks the same way.
A realistic trigger, not reproduced here: a plugin repository under a TCC-protected folder such as ~/Documents while stimd runs under launchd without access to it. stat then fails with EPERM.
readProjectPlugin and holdsMarkers already catch their own fs errors, so stamp() is the only hole. Catching there and returning a stamp such as error:<code> lets readProjectPlugin report the entry as unreadable. An unreadable entry also belongs in the registry test table.
2. The marker table writes a file named *.godot, which Windows refuses
packages/stim-cli/src/__tests__/project-registry.test.ts, the test.each for skipped plugins: every row runs write(join(dir, marker)) for '*.godot'. Windows forbids * in file names, and project-registry.test.ts is not excluded on win32, so all 10 rows should fail in the Windows unit suite of Full suite. I did not run it on Windows. The glob row does not need the file: manifest validation rejects the marker before any stat. Dropping '*.godot' from the written list keeps the row's contract.
Confirmed, not blocking (behaviour changes to name)
3. A plugin match keeps the workspace at a root the bundled redirect used to hand to the app
The plugin match is application: true (plugin-projects.ts:114). That makes keepsWorkspace true (project-registry.ts:276-284), and startServerWorkspace returns early (workspace/project.ts:54) before sameRepositoryApps runs.
Layout: a git repository whose root holds a tooling package.json and project.godot, with a React Native app in app/ registered in config.json. findServerWorkspace(<repo root>) gives:
- without the plugin:
{ root: "<repo>/app", from: "<repo>" }, which prints "Using the Stim workspace ... is not a React Native or Expo app"; - with the plugin:
{ root: "<repo>", from: null }.
So logs, stop, reload, ports, services, web, share, test and revive run from that root now target the Godot folder, which has no Metro. The layout is narrow, and the issue arguably wants the Godot root treated as its own project. Still, it is user-visible behaviour the issue did not describe.
4. On an operation the bundled integration does not answer, the plugin's refusal is the only one, and it overstates
The plugin answers every operation. Where the bundled match returns undefined, its message is the only result. Both cases below were run on this head:
- A React Native app with
ios/App.xcodeprojand aproject.godot:projectProblem(root, 'macos')returns "<root>is a Godot project, recognised through the plugin p, which gives Stim no build or run for it." - A
Package.swiftroot with a marker, forios: the same message.
On origin/main these calls fall through to "No project integration supports macos at <root>." That comes from reading the code: I could not import the main checkout's sources, because its built core is stale. "No build or run" is wrong for a root that has a bundled iOS or macOS build. The layouts are narrow. Answering only ios, android and dev-server (the prototype's set), or wording the message for this one operation, would avoid it.
Checked, no finding
- Cache (
projectPlugins).- The key covers the
config.jsonpath, so a changedSTIM_HOMEinvalidates it. It also covers inode, size and mtime for the config and each named manifest. - A manifest that appears or disappears changes its stamp from
absent, and the list is read again. - Stamps are taken before the reads, so a race can only cause an extra reread, never a stale result.
loadConfighas no cache of its own.- Every touched test file makes a fresh
mkdtemphome inbeforeEachand removes it, withSTIM_HOME, inafterEach. So the module-level snapshot cannot carry over between tests.
- The key covers the
~expansion matches the sharedabsolutePathsvalidator (settings-registry.ts:1327), which refuses~and/before any read. Cosmetic: that refusal says "too broad to discover in", which is wording formaintenance.discoverRoots.- Markers and ids.
- Path separators, globs,
.,.., the empty list, non-strings and control characters are refused. - A marker that is a directory does not match, because
isFile()follows symlinks. - A bundled id and an earlier entry's id are refused.
- Path separators, globs,
- Refusal text where a bundled integration reports a problem.
- React Native's problems are either
unreadable, which still wins, or "depends on neither react-native nor expo" withapplication: false. The plugin's message replaces the second, which is the intended tooling-package.jsoncase. - Exact (Android, dev server) and native Android (Android) come first in the list and keep their own messages.
- The plugin is never a provider, so it cannot cause an
ambiguousresult.
- React Native's problems are either
statusappLine. It adds oneisMobileProjectinspection per row with nobundleId, plus the plugin check, which is cheap. Mobile roots are excluded, so React Native and Exact rows are never relabelled. A Swift package orweb.urlroot that holds a marker printsproject: <Name>. That is narrow and arguably right.- Commands and settings.
- The
settings set pluginswarning uses the uncachedreadProjectPlugins, which does not stat throughstamp(). - Also checked: the doctor fix text,
plugin listwithsource: "machine", andplugin teston a directory with no entry module (thedirectoryKindsfallback).
- The
packages/core/plugin-loader.tsis untouched, including the cache-provider path and the// compat C15 permanentblock.- Gates.
node scripts/plugin-api-report.mjs --checkexits 0, and thestim/pluginreport (354 lines) is unchanged.plugin.api.txtadds lines only.node scripts/build-compat.mjsexits 0; it ignores--checkand runs its check. No bump is needed: a plugin match never builds, and a worker with nopluginssetting behaves as before.guide-budget.test.tspasses.
- Documentation. The guide, the website page and
docs/releases/unreleased.mdmatch the code, includingstim webstill servingweb.url. - Tests. The four touched files pass locally (148 tests), and so does
guide-budget.test.ts. Each new case names a distinct rule. CI unit jobs were still pending when I checked. - LLP 0023. The
Maintainer decision:quote "Yes, lets build the plugin and test end to end" matches issuecomment-7231963979 word for word. The LLP names the setting name and the directory-only form as not approved.
Product decisions the maintainer has not stated
The pull request body lists four: the setting name plugins, directory-only references, the status line and source: "machine". I agree with all four and found these others:
stim webis not refused in a plugin project. The issue's slice 1 text listswebamong the commands that refuse. The diff leaveswebserved by anyweb.url. It is documented as a known limit, but it departs from the recommended options the maintainer approved.- Directory-only narrows the approved recommendation. Open decision 1 recommended "an absolute directory or a package installed under the Stim home". The body already names directory-only as a choice.
plugin testaccepts a broader input. It now accepts any directory whosepackage.jsonhas no resolvable entry module, for every kind and not onlyproject(commands/plugin.ts:83-110). Before, that refused with "does not resolve".- The workspace redirect change in finding 3.
An unreadable plugins entry (EACCES, EPERM, ELOOP on its package.json) threw out of project detection, so status, logs, plugin list and settings unset failed. The entry is now skipped with its reason and read again once it becomes readable. worktree warm registers a plugin project, so a worktree made with git worktree add shows in status as stim worktree add's does. The refusal says what the plugin adds instead of what Stim does for the folder, which was false in a root that a bundled integration also builds. plugin test reads a directory's package.json directly only when it declares the project kind, so the other kinds refuse an unresolvable directory as before. The marker table test no longer writes a file name Windows forbids. Refs #6599
|
Round 2 review of 8355f16 (slice 1 of #6599). No confirmed blocking finding, so this adds Round 1 fixes
Confirmed, not blocking1. In a long-lived process, an entry whose
|
| Sequence in one process | projectPluginAt(<folder>) |
|---|---|
chmod 000 <plugin>/package.json, lookup, chmod 644, lookup |
null, then still null |
readable lookup, chmod 000, lookup |
match, then still a match (cached) |
The second row does no harm: the cached manifest is still valid. The first contradicts the commit message ("read again once it becomes readable"). Only processes that live across the change keep the stale entry: stimd and the Desktop engine. Each CLI command starts with an empty snapshot. Restarting the process or editing config.json or the manifest clears it. A narrow case, so not blocking. Adding ctimeMs to the stamp would cover it. The new registry test makes the directory unreadable, so it does not catch this.
Notes, not findings
- What
warmregistration exposes to cleanup.upsertProject(workspace, {})makes the plugin root a candidate for the dormant stage and the ladder. They select fromconfig.projectswith no check of the project type (daemon/stages.ts:338). Onmain,stim worktree addalready registers the worktree root for every repository type (worktree.ts:826-836). Sowarmnow gives a plaingit worktree addworktree the same exposure, not a wider one. Device creation, ports and builds are not reached, because every operation refuses. Plausible, not reproduced: Godot 4's generated.gitignoreignores/android/, and the dormant reduction removes an untracked, fully ignoredandroid/build(regenerable-dirs.ts:18,:309-314). In a Godot project,android/buildis the installed Android build template, which users sometimes edit. A registered Godot worktree idle foridle.dormantDayscould lose those edits. "Install Android Build Template" brings the template back, but not the edits.mainhas the same exposure throughstim worktree add. Slice 2 or a cleanup rule for the kind might want to keep it. warmedWorkspacewith two registered candidates.appsUndernow also counts a registered path that holds the markers. Layout: a repository root withproject.godot, registered, plus a registered React Native app inapp/, andwarmrun from the root. The source set now has two entries, sowarmfalls back tonearest, which is the Godot root. Onmainit pickedapp/. This is the same layout as thestartServerWorkspacelimit in the body, and it changes nothing whenwarmruns fromapp/.
Checked, no finding
- The stat-error stamp for ELOOP and for a directory with mode 000: both change when the cause is fixed, so the list is read again.
warmstdout stays empty.registerWarmedWorkspacewrites only when the workspace is not already registered, and its failure goes to stderr.build-compat.jsondigest update: only the digest changes.- Touched tests pass locally:
project-registry.test.ts,plugin-command.integration.test.tsandworktree-refresh.integration.test.ts, 84 tests. CItest (node 24)andmerge gatewere still pending when I checked.
Product decisions the maintainer has not stated
Beyond the four the body lists and those round 1 named (stim web not refused, directory-only, the plugin test input, the workspace redirect):
stim worktree warmregisters a folder that is not a mobile app. Before,warmregistered only iOS or Android apps, and printed "no iOS or Android app at this directory, so warm registers nothing in status here". The body lists this under rules to check, not as a product decision. It also makes the folder a target of automatic cleanup (see the first note).
Description
A repository of a framework Stim does not bundle, such as a Godot game, gets working
stim worktreecommands, but Stim treats it as bare:worktree addprintsno iOS or Android app at this directory,statusshowsapp: ? (bare), andiosgives the genericSTIM_NO_PROJECT. Each new framework needed a pull request here.This is slice 1 of #6599: recognition only. It adds no build, no run and no cleanup rule.
Solution
A new plugin kind,
project, whose whole contract is a block in the plugin'spackage.json:{ "name": "stim-plugin-godot", "stimPlugin": { "kinds": { "project": 1 }, "project": { "id": "godot", "name": "Godot", "markers": ["project.godot"] } } }A folder that holds every marker file is a project root of that type. Stim reads the manifest and never imports the plugin's code. Project detection is synchronous and runs in
status,stop,logs, discovery and stimd, so adetect()function would have put plugin code in all of them.Product decisions in this diff:
plugins: a list of absolute plugin directories. A machine-scope setting that lists plugins is approved; the name and the directory-only form are choices made here. Package names are not accepted, because no install location is decided.projectas the exception, with an integer that may change in a minor release.stim statusprintsproject: Godot (plugin stim-plugin-godot)in place ofapp: ? (bare). JSON payloads are unchanged.stim plugin list --jsongainssource: "machine"for these entries.stim worktree warmregisters a plugin project, where it said it registers nothing in a folder that is not an iOS or Android app.stim worktree addalready registers the root for every repository type, so warm gives a plaingit worktree addworktree the same standing, including as a target of the dormant stage and the pressure ladder.Rules a reviewer should check:
null, so a root that is also an Exact or React Native app keeps its bundled build and run. A pluginidequal to a bundled integration's, or to an earlier entry's, is refused.config.jsonor a namedpackage.jsonchanges (inode, size, mtime), at onestatSyncper plugin per lookup. A directory Stim cannot stat is a rejected entry with its reason, not an error.stim plugin test <dir>readspackage.jsondirectly only for a manifest that declaresproject. A directory of another kind with no entry module refuses as onmain.Known limits, left as they are:
stim webin such a project still answersSTIM_WEB_NO_URL, because the bundled web integration serves any root with aweb.url.stim doctorin a recognised plugin project lists the refusal as a "costs time" finding, as it does for any root with no operation.worktree addorwarmare handled.logs,stop,reloadandportsrun there no longer redirect to a registered app in a subfolder (startServerWorkspace).stim logsin a plugin project still says to runstim start,iosorandroidfirst.Test plan
Run against this branch's build in a scratch
STIM_HOME, with the plugin in its own repository outside this checkout (apackage.jsonand a README) and a Godot-shaped git repository (project.godot, an ignored.godot/):worktree add,ios,statusSTIM_NO_PROJECT,app: ? (bare)stim settings set plugins '["<plugin dir>"]'plugin listshowsproject 1 selected by plugins;plugin test <dir>passes 7 of 7worktree addandwarm.godotcarriedgit worktree add, thenstim worktree warmstatusnames the typeios,android,macos,startSTIM_NO_PROJECT: "The plugin stim-plugin-godot recognises as a Godot project and adds no build or run for it."statusproject: Godot (plugin stim-plugin-godot)exact.mjs,app.jsonandproject.godotstim ios --planplans the Exact build;stim androidgives Exact's own refusalexact, kind integer 2, duplicate idgodot, missing directorysettings setwarns for each and writes;plugin listshows each reason;doctorreports aplugin-reffinding for each;iosandstatusin the Godot project are unchangedpluginsentry made unreadable withchmod 000, beside the good oneplugin listshows theEACCESreason;statusandsettings set pluginsrunstim settings unset plugins, thenworktree add,ios,statusNot tested:
Automated: registry cases for marker matching, the id rules, a marker inside a React Native app, an unreadable entry, and rereading after a setting or manifest change; command tests for
plugin list,plugin test,settings set plugins, thestatusline, and warm after a plaingit worktree add.Part of #6599. Slices 2 and 3 and open decisions 4 to 9 stay on the issue, which stays open.