Repository navigation
Add the virtual:nodespace-extensions build entry and the extension-api alias - #3395
Conversation
Pragmatic code review (initial)Review Type: Initial Review (no prior reviews or comments on this PR; whole diff SummaryClean, tightly scoped implementation of the ADR-082 §2.1 seam. With Checks I ran (read-only,
Requirements Check (issue #3311)Scope
Acceptance criteria
No contradictions with the issue text beyond the deviations the PR already explains. FindingsNo 🔴 or 🟡 findings. 🟢 Suggestion: glob metacharacters in the entry directory are not escaped (silent miss)📁 packages/desktop-app/vite-plugins/nodespace-extensions-entry.js:54-68
Escaping the posix dirname fixes it (verified for both engines): const escapeGlob = (p) => p.replace(/[()[\]{}*?!+@|\\]/g, '\\$&');
// `${escapeGlob(toPosix(dirname(entry)))}/**/*.test.ts`Keep it inside this file (plain JS, no imports beyond Node), and extend the 🟢 Suggestion: the guard test can be defeated by
|
mstomar125
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review: APPROVE (posted as a comment - GitHub blocks self-approval). Full findings in the review comment above.
e095d3b to
0a7c490
Compare
Address review (round 1)The initial review was APPROVE with two optional suggestions and one nit. Commit Addressed
Skipped
Acknowledged, no change
Other changes since the review
Re-Review DecisionDecision: RE-REVIEW NEEDED Rationale: new logic (the glob escape and its Tailwind/Vitest asymmetry) and new type re-exports were added in response to feedback and a coordinator request. |
Pragmatic code review (re-review)Review Type: Re-Review (initial review and the address-review comment exist; scope is Previous Review Summary
Checks I ran (read-only,
Previous feedback, item by item1. Glob metacharacters in the entry directory: ✅ addressed, and the asymmetry is correct.
2. 3. Detect 4. Barrel pin comment: ✅ addressed. One-line note above 5. Notes (postinstall/ New changesSettings re-exports (
FindingsNo 🔴 or 🟡 findings. 🟢 A: the escape unit test covers only half of the regex's character class📁 packages/desktop-app/src/tests/build/nodespace-extensions-plugin.test.ts:107-111 The test string contains 🟢 B: the content-glob comment could name its residual limit📁 packages/desktop-app/vite-plugins/nodespace-extensions-entry.js:68-71 Leaving the content glob unescaped is right, and it works for the realistic cases ( RecommendationAPPROVE - all prior feedback is addressed or justifiably skipped, the Tailwind/Vitest escape asymmetry is verified against the actual library code, the barrel is complete with a type pin that demonstrably catches drops and reshapes, and the boundary ratchet and issue-reference/wording checks are clean. The two notes above are optional. |
mstomar125
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review (re-review): APPROVE (posted as a comment - GitHub blocks self-approval). Full findings in the review comment above.
0a7c490 to
0889497
Compare
Address review (round 2, after the re-review)The re-review was APPROVE with two optional notes. Both taken in Addressed
Re-Review DecisionDecision: NO RE-REVIEW NEEDED Rationale: the round-2 changes are a longer test string, one extra test and a comment sentence; the escape function, the wiring and the workflow are unchanged from what the re-review approved. State at push
|
…i alias A build can now inject extensions without core importing them. The virtual module default-exports [] in core; with NODESPACE_EXTENSIONS=<module path> it re-exports that module's default export instead. The root layout imports it and calls registerExtensions before AppShell renders. - vite-plugins/nodespace-extensions-entry.js: resolves the variable to an absolute path (throws naming the variable and path when the file is missing) and derives the Tailwind content and Vitest include globs from it. - vite-plugins/nodespace-extensions.js: the Vite plugin. It resolves and loads the virtual module, always dedupes svelte and @tauri-apps/api, and for an entry outside the app root restates the workspace root in server.fs.allow and adds the entry's directory. - Wired into vite.config.js, tailwind.config.js and all four Vitest configs, so an injected entry is built, styled, served in dev and its *.test.ts files run under core's setup. The unit and e2e tiers get the @nodespace/extension-api alias directly (they do not use sveltekit()); the others get kit.alias. - src/lib/extension-api/index.ts: the minimal host API barrel, with an explicit export list. - release.yml: both Tauri build jobs fail before the build when NODESPACE_EXTENSIONS is present; a bun:test test pins the guard, its behaviour, and that nothing in the workflow sets the variable. - .gitignore: un-ignores src/tests/build/, which the root build/ rule hid. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…not be skipped over - extensionTestGlobs escapes glob syntax in the entry directory: Vitest's file scanner reads an unescaped "ext (1)" as a pattern and finds no tests. extensionContentGlobs stays unescaped on purpose, because Tailwind escapes the base directory itself and normalizes a backslash escape into a separator. - The guard test also asserts the guard step has no continue-on-error. - A comment on the barrel's runtime export pin says to update it when the barrel gains one. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The settings-section and database settings-slot types now live in ui-extensions, so an extension written against @nodespace/extension-api can use SettingsSectionContribution, SettingsSlot, SettingsSlotContribution and SettingsSlotContributionFor. A compile-time test (checked by svelte-check) pins that every contribution type the barrel re-exports is identical to the host's. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The escape test now uses a directory containing every character escapeGlob handles (a backslash in its own test, skipped on Windows where it is a path separator), and the content-glob comment says which directory names Tailwind still cannot match. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
0889497 to
d9ee691
Compare
Closes #3311
What
A build can now inject extensions without core importing them (ADR-082 §2.1).
virtual:nodespace-extensionsdefault-exports[]in core. WithNODESPACE_EXTENSIONS=<module path>set it re-exports that module's default export instead. Unset, nothing changes.src/routes/+layout.svelteimports it and callsregisterExtensions(extensions)at the top of the script body, so contributions exist beforeAppShellrenders.server.fs.allow), Vitest picks up its*.test.tsfiles under core's setup, andsvelte/@tauri-apps/apiresolve from core'snode_modules(resolve.dedupe).@nodespace/extension-apiis an alias forsrc/lib/extension-api/(new; it re-exports the extension and contribution types, including the settings-section and settings-slot types, andEXTENSION_API_VERSION; the rest is a later issue).kit.aliascovers SvelteKit and svelte-check; the unit and e2e Vitest tiers get a direct alias because they do not usesveltekit().NODESPACE_EXTENSIONSis present.The transitional
import './pro-plugin'is untouched.Files
vite-plugins/nodespace-extensions-entry.js(env parsing + glob helpers),vite-plugins/nodespace-extensions.js(the plugin),src/lib/extension-api/index.ts,src/tests/build/{nodespace-extensions-plugin,virtual-extensions-module}.test.ts,src/tests/fixtures/sample-extension-entry.ts,scripts/release-workflow-extensions-guard.test.ts.vite.config.js,svelte.config.js,tailwind.config.js,vitest.{config,browser,webkit,e2e}.config.ts,src/vite-env.d.ts,src/routes/+layout.svelte,.github/workflows/release.yml,CLAUDE.md(one sentence),.gitignore.scripts/check-pro-boundary.tsis not touched.ui-extensions.tsis not touched; the barrel re-exports what already exists there.Deviations from the issue
extensionTestGlobs(entry)takes noroot, and it escapes glob syntax in the directory (ext (1)would otherwise be read as a pattern and find no tests).extensionContentGlobsdeliberately does not: Tailwind 3 escapes the base directory itself and turns a backslash escape into a path separator, so escaping there makes it match nothing (verified both ways with a directory namedoot (1), against the real Vitest scanner and a real build). The issue left absolute-vs-root-relative to the acceptance check; an absolute glob works under Vitest 3.2.7 (recorded below), so arootparameter would be dead.resolveExtensionsEntryalso rejects a directory, not only a missing path (statSync().isFile()): a directory would resolve to its index in Vite but makedirname(entry)the parent, so Tailwind and Vitest would scan the wrong tree.hmr: false,watch: nullandlogLevel: 'silent'so a server per test never binds the HMR socket or leaks a watcher..gitignore: the rootbuild/rule hid the mandatedsrc/tests/build/directory, so that directory is un-ignored (the app's realbuild/output stays ignored).release.ymlwithBun.YAML.parse(no new dependency). Besides the structural asserts in the issue, it extracts the guard's script and runs it under bash with the variable set, empty and unset, and asserts no other step's script mentions the variable.vite devon a private port with the same variable rather than the fulldev:tauri(which needs the Tauri shell and a sidecar build on a shared machine); the vite config, plugin and layout are the same code path. See below.Ratchet
bun run scripts/check-pro-boundary.tsexits 0 and--changedreports 0 hits in every file this PR touches. This PR adds and removes no marker and does not editBASELINES(the ratchet's notices about counts below their ceilings come from other merged changes; the issue's "BASELINES equal the printed counts" criterion is intentionally not applied, per the standing rule that ceilings are tightened elsewhere).Verification (acceptance criteria)
Resolution
bun run --cwd packages/desktop-app buildsucceeds, no "injecting" line, virtual module isexport default [];(checked on the dev server too).NODESPACE_EXTENSIONS=src/tests/fixtures/sample-extension-entry.ts ... buildsucceeds; the fixture'ssample-extensionid is in the emitted chunk.NODESPACE_EXTENSIONS=does-not-exist.ts ... buildexits 1:NODESPACE_EXTENSIONS does not name an existing file: <abs>/packages/desktop-app/does-not-exist.ts.Out-of-tree entry (temporary directory outside the repo;
index.tsimports a type from@nodespace/extension-api, importssvelteand@tauri-apps/api/core, and lazily loadsoot.svelte, which uses$stateand the classw-[1337px]that core does not use).w-\[1337px\]{width:1337px}is inbuild/_app/immutable/assets/0.*.css.NODESPACE_EXTENSIONS=<tmp>/index.ts bunx vitest run <tmp>runs<tmp>/sample.test.tsunder core's config (2 passed): it resolves@nodespace/extension-apiand@tauri-apps/api/coreand mounts a$statecomponent. Without the variable: "No test files found".vite devwith the same variable serves/@fs/<tmp>/index.tsand/@fs/<tmp>/oot.svelte(HTTP 200) while/@fs/etc/hostsstays 403; driven in Chromium, the app shell renders the injected component inapp-shell-overlay, clicking it goesoot 0->oot 1, and its computed width is 1337px (Tailwind reached the out-of-tree file in dev too). Without the variable the same page has no injected element and the virtual module isexport default [];. The console errors in both runs are only the missing daemon (ERR_CONNECTION_REFUSED).Checks
svelte-check: 0 errors, 2453 files; it resolvesvirtual:nodespace-extensionsand@nodespace/extension-api.quality:fix(desktop-app) andquality:scripts:fixclean.bun run test:changedpasses on the final tree: skill installer tsc, frontend (Happy-DOM), scripts, skill, browser andrust:test(release.ymlis an unrecognized path for the gate scope, so it reaches every tier).Tests and mutation results
Each new test was mutated by reverting or breaking the behavior it guards; every mutation below failed the named test.
src/tests/build/nodespace-extensions-plugin.test.ts(26) andvirtual-extensions-module.test.ts(3):@tauri-apps/apidropped: the config test and the out-of-tree Vite-server test fail.fs.allowwithout the workspace root / without the entry directory / also set for an in-root entry: the three config tests fail.resolveIdclaiming every id / without the NUL prefix,loadnot checking the id / unquoted / not normalized /export *instead of default / wrong empty value: the resolveId and load tests (and the server tests) fail.configResolvedlogging every time / logging without an entry,enforce: 'pre'removed: fail.null, relative path not resolved against the root, a directory accepted, empty content globs, wrong test glob: fail.kit.aliasremoved, unit-tier alias removed, layout call removed, layout call moved insideonMount, barrel changed toexport *: fail.( ) [ ] { } * ? ! + @ |and backslash), the test glob left unescaped, the content glob escaped: fail (the last one also drops the class from a real build with a directory namedoot (1)).scripts/release-workflow-extensions-guard.test.ts(10): guard removed from either job,continue-on-erroradded to the guard, guard exiting 0, guard testing a different variable, guard using-n(misses an empty value), guard moved after the build,shell: bashremoved, anif:added, the variable set at workflow / job / step level, and a step exporting it throughGITHUB_ENV: each fails.Config wiring (not unit-testable, mutated against the out-of-tree probes): dropping the Tailwind globs removes the class from the built CSS; dropping
extensionTestGlobsfromincludegives "No test files found"; dropping the entry directory fromfs.allowturns the dev-server request into 403; removing the plugin or the alias from the e2e config makes a probe import fail to resolve (probe removed); removing thevite-env.d.tsdeclaration orkit.aliasmakes svelte-check fail.Notes for the reviewer
vite-env.d.tstype-imports@nodespace/extension-api, so it only resolves aftersvelte-kit syncwriteskit.aliasinto the generated tsconfig (thesyncstep ofbuildand thepostinstalldo that).injecting extensions from ...prints once per Vite config resolve, and SvelteKit resolves the config several times per build, so it can appear more than once in a build log.🤖 Generated with Claude Code