Skip to content

feat: a project plugin kind recognises a project type from its manifest - #6610

Merged
janicduplessis merged 2 commits into
mainfrom
feat/6599-project-plugin-kind
Nov 28, 2026
Merged

janicduplessis merged 2 commits into
mainfrom
feat/6599-project-plugin-kind

Conversation

@janicduplessis

@janicduplessis janicduplessis commented Nov 28, 2026 •

Copy link
Copy Markdown
Collaborator

Description

A repository of a framework Stim does not bundle, such as a Godot game, gets working stim worktree commands, but Stim treats it as bare: worktree add prints no iOS or Android app at this directory, status shows app: ? (bare), and ios gives the generic STIM_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's package.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 a detect() function would have put plugin code in all of them.

Product decisions in this diff:

  • New machine setting 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.
  • An experimental kind that loads from outside the package. LLP 0023 said experimental kinds are built in only; it now names project as the exception, with an integer that may change in a minor release.
  • stim status prints project: Godot (plugin stim-plugin-godot) in place of app: ? (bare). JSON payloads are unchanged.
  • stim plugin list --json gains source: "machine" for these entries.
  • stim worktree warm registers a plugin project, where it said it registers nothing in a folder that is not an iOS or Android app. stim worktree add already registers the root for every repository type, so warm gives a plain git worktree add worktree the same standing, including as a target of the dormant stage and the pressure ladder.

Rules a reviewer should check:

  • Bundled integrations win. A match has no platform and answers every operation with a problem, never null, so a root that is also an Exact or React Native app keeps its bundled build and run. A plugin id equal to a bundled integration's, or to an earlier entry's, is refused.
  • The list follows the setting without a restart. It is cached and read again when config.json or a named package.json changes (inode, size, mtime), at one statSync per plugin per lookup. A directory Stim cannot stat is a rejected entry with its reason, not an error.
  • stim plugin test <dir> reads package.json directly only for a manifest that declares project. A directory of another kind with no entry module refuses as on main.

Known limits, left as they are:

  • stim web in such a project still answers STIM_WEB_NO_URL, because the bundled web integration serves any root with a web.url.
  • stim doctor in a recognised plugin project lists the refusal as a "costs time" finding, as it does for any root with no operation.
  • Maintenance discovery does not treat a plugin project as recognised; only folders registered by worktree add or warm are handled.
  • A marker makes an explicit root, so a marker file in a subfolder of an app stops the walk up to that app. Exact's bundled markers behave the same way.
  • A repository root that holds a marker is its own workspace, so logs, stop, reload and ports run there no longer redirect to a registered app in a subfolder (startServerWorkspace).
  • stim logs in a plugin project still says to run stim start, ios or android first.

Test plan

Run against this branch's build in a scratch STIM_HOME, with the plugin in its own repository outside this checkout (a package.json and a README) and a Godot-shaped git repository (project.godot, an ignored .godot/):

Step Observed
No plugin: worktree add, ios, status The project notice, the generic STIM_NO_PROJECT, app: ? (bare)
stim settings set plugins '["<plugin dir>"]' plugin list shows project 1 selected by plugins; plugin test <dir> passes 7 of 7
worktree add and warm No project notice; stdout empty; .godot carried
Plain git worktree add, then stim worktree warm The worktree is registered and status names the type
ios, android, macos, start Refuse under STIM_NO_PROJECT: "The plugin stim-plugin-godot recognises as a Godot project and adds no build or run for it."
status project: Godot (plugin stim-plugin-godot)
A root with exact.mjs, app.json and project.godot stim ios --plan plans the Exact build; stim android gives Exact's own refusal
Five bad entries beside the good one: invalid JSON, id exact, kind integer 2, duplicate id godot, missing directory settings set warns for each and writes; plugin list shows each reason; doctor reports a plugin-ref finding for each; ios and status in the Godot project are unchanged
A plugins entry made unreadable with chmod 000, beside the good one plugin list shows the EACCES reason; status and settings set plugins run
stim settings unset plugins, then worktree add, ios, status The first row's output again

Not tested:

  • Godot was not installed, so nothing here builds or runs a Godot project. The kind does not either.
  • No stimd operation that reads the registry was driven through a setting change. Rereading in one long-lived process is covered by a registry test.

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, the status line, and warm after a plain git worktree add.

Part of #6599. Slices 2 and 3 and open decisions 4 to 9 stay on the issue, which stays open.

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
@janicduplessis janicduplessis added area: cli packages/stim-cli, including its README and guide area: core packages/core area: website website/ area: docs docs/ and root documents labels Nov 28, 2026
@janicduplessis

Copy link
Copy Markdown
Collaborator Author

Fresh review of b673ca8 (slice 1 of #6599). One confirmed blocking finding and one Windows test failure, so no review: ai-approved yet.

Confirmed, blocking

1. One unreadable plugins entry crashes every command, including the command that would remove it

stamp() in plugin-projects.ts:28-31 calls statSync(path, { throwIfNoEntry: false }). That option only covers ENOENT and ENOTDIR. EACCES, EPERM and ELOOP still throw. projectPlugins() calls it on each entry's package.json (lines 83 and 87) with no catch. It runs from pluginProjectIntegration.inspect, and projectMatches calls that for every directory any registry lookup walks. So the failure is not limited to plugin projects: one bad entry breaks project detection everywhere on the machine.

Reproduced on this head. I used a scratch STIM_HOME whose config.json is {"plugins":["<dir>"]}, ran chmod 000 <dir>, and ran the checkout's bin/cli.ts from a React Native app directory:

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.xcodeproj and a project.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.swift root with a marker, for ios: 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.json path, so a changed STIM_HOME invalidates 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.
    • loadConfig has no cache of its own.
    • Every touched test file makes a fresh mkdtemp home in beforeEach and removes it, with STIM_HOME, in afterEach. So the module-level snapshot cannot carry over between tests.
  • ~ expansion matches the shared absolutePaths validator (settings-registry.ts:1327), which refuses ~ and / before any read. Cosmetic: that refusal says "too broad to discover in", which is wording for maintenance.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.
  • 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" with application: false. The plugin's message replaces the second, which is the intended tooling-package.json case.
    • 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 ambiguous result.
  • status appLine. It adds one isMobileProject inspection per row with no bundleId, plus the plugin check, which is cheap. Mobile roots are excluded, so React Native and Exact rows are never relabelled. A Swift package or web.url root that holds a marker prints project: <Name>. That is narrow and arguably right.
  • Commands and settings.
    • The settings set plugins warning uses the uncached readProjectPlugins, which does not stat through stamp().
    • Also checked: the doctor fix text, plugin list with source: "machine", and plugin test on a directory with no entry module (the directoryKinds fallback).
  • packages/core/plugin-loader.ts is untouched, including the cache-provider path and the // compat C15 permanent block.
  • Gates.
    • node scripts/plugin-api-report.mjs --check exits 0, and the stim/plugin report (354 lines) is unchanged. plugin.api.txt adds lines only.
    • node scripts/build-compat.mjs exits 0; it ignores --check and runs its check. No bump is needed: a plugin match never builds, and a worker with no plugins setting behaves as before.
    • guide-budget.test.ts passes.
  • Documentation. The guide, the website page and docs/releases/unreleased.md match the code, including stim web still serving web.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 web is not refused in a plugin project. The issue's slice 1 text lists web among the commands that refuse. The diff leaves web served by any web.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 test accepts a broader input. It now accepts any directory whose package.json has no resolvable entry module, for every kind and not only project (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
@janicduplessis

Copy link
Copy Markdown
Collaborator Author

Round 2 review of 8355f16 (slice 1 of #6599). No confirmed blocking finding, so this adds review: ai-approved and marks the pull request ready. One confirmed non-blocking defect in the fix, and two notes.

Round 1 fixes

  1. stamp() errors. Fixed. plugin-projects.ts:28-35 catches and returns error:<code>, readProjectPlugin reports the entry as unreadable, and detection no longer throws. A directory that becomes unreadable or readable again changes the stamp (error:EACCES versus ino:size:mtime), so the list is read again. One case is not covered; see finding 1.
  2. *.godot file in the test. Fixed. The row still fails at manifest validation, which is the contract it protects.
  3. warm after a plain git worktree add. Fixed (worktree.ts:333-361). For a root that holds the markers, findProjectRoot returns the root itself (an explicit root), so nearest === target and the code falls through to the registered scan and then returns app. Verified against the new worktree-refresh case.
  4. Refusal wording. Fixed. The new text says only what the plugin adds, so it is true in a root that also has a bundled build.
  5. plugin test <dir> for other kinds. Fixed. directoryKinds returns null unless kinds.project is set, so a cache-provider, transport or agent-driver directory with no resolvable entry module refuses with STIM_BAD_ARG as on main. The only difference: when that directory's package.json is invalid JSON, the refusal now quotes the JSON error instead of the resolver's. The exit code and code are the same.

Confirmed, not blocking

1. In a long-lived process, an entry whose package.json was unreadable stays rejected after it becomes readable

stamp() keys on ino:size:mtimeMs (plugin-projects.ts:31). chmod changes only ctime. When the plugin directory is searchable but the package.json file itself is mode 000, statSync succeeds and readFileSync fails. The entry is rejected, and the snapshot stores a normal stamp. After chmod 644 the stamp is the same, so projectPlugins() keeps returning the rejected entry.

I reproduced it on this head in one Node process, with a scratch STIM_HOME whose config.json names a valid Godot plugin and a folder holding project.godot:

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 warm registration exposes to cleanup. upsertProject(workspace, {}) makes the plugin root a candidate for the dormant stage and the ladder. They select from config.projects with no check of the project type (daemon/stages.ts:338). On main, stim worktree add already registers the worktree root for every repository type (worktree.ts:826-836). So warm now gives a plain git worktree add worktree 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 .gitignore ignores /android/, and the dormant reduction removes an untracked, fully ignored android/build (regenerable-dirs.ts:18, :309-314). In a Godot project, android/build is the installed Android build template, which users sometimes edit. A registered Godot worktree idle for idle.dormantDays could lose those edits. "Install Android Build Template" brings the template back, but not the edits. main has the same exposure through stim worktree add. Slice 2 or a cleanup rule for the kind might want to keep it.
  • warmedWorkspace with two registered candidates. appsUnder now also counts a registered path that holds the markers. Layout: a repository root with project.godot, registered, plus a registered React Native app in app/, and warm run from the root. The source set now has two entries, so warm falls back to nearest, which is the Godot root. On main it picked app/. This is the same layout as the startServerWorkspace limit in the body, and it changes nothing when warm runs from app/.

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.
  • warm stdout stays empty. registerWarmedWorkspace writes only when the workspace is not already registered, and its failure goes to stderr.
  • build-compat.json digest update: only the digest changes.
  • Touched tests pass locally: project-registry.test.ts, plugin-command.integration.test.ts and worktree-refresh.integration.test.ts, 84 tests. CI test (node 24) and merge gate were 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 warm registers a folder that is not a mobile app. Before, warm registered 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).

@janicduplessis janicduplessis added the review: ai-approved A fresh AI review found nothing left to fix label Nov 28, 2026
@janicduplessis
janicduplessis marked this pull request as ready for review November 28, 2026 02:50
@janicduplessis
janicduplessis merged commit 808fea1 into main Nov 28, 2026
63 of 64 checks passed
@janicduplessis
janicduplessis deleted the feat/6599-project-plugin-kind branch November 28, 2026 03:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli packages/stim-cli, including its README and guide area: core packages/core area: docs docs/ and root documents area: website website/ review: ai-approved A fresh AI review found nothing left to fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant