Skip to content

refactor(plugins): standardize built-in plugin layout (app/ + src/{node,client-script} + playgrounds/) - #340

Merged
antfu merged 7 commits into
mainfrom
chore/plugin-structure-restructure
Sep 3, 2026
Merged

refactor(plugins): standardize built-in plugin layout (app/ + src/{node,client-script} + playgrounds/)#340
antfu merged 7 commits into
mainfrom
chore/plugin-structure-restructure

Conversation

@antfubot

@antfubot antfubot commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

What

Restructure all nine built-in plugins to one consistent layout, so each plugin cleanly separates its frontend web app, node side, injected browser scripts, and playground:

plugins/<name>/
  app/              # frontend web app (framework SPA), built by Vite
  src/
    node/           # all node-side code (definition, setup, cli, rpc, constants/types/vite/engine/registry as present)
    client-script/  # injected client scripts (client runtime + page script "if any"), built by tsdown
  playgrounds/      # play target hosts the built plugin
  • tsdown builds src/node and src/client-script; the framework (Vite) builds app.
  • dev mounts the usable web app in dev mode with HMR while bridging the node side live (RPC + WebSocket + __connection.json), mounted as a post-middleware so Vite serves the HMR SPA and the devframe host only answers its own routes.
  • play builds first, then boots a playground against the built plugin.
  • Export subpaths track the new folders: ./client becomes ./client-script (and a11y/data-inspector ./inject becomes ./client-script/page-script); node subpaths retarget under dist/node/.

Per-plugin shape

  • a11y, inspect, og, assets, code-server, data-inspector: tsdown builds both the node side and the browser scripts (a11y and data-inspector ship a self-contained page script).
  • messages (Vue), terminals (Svelte): app/ holds the SPA host plus the Vite-built component library; tsdown builds src/node only; the ./client component-library export is kept.
  • git (Next.js): app/ holds the Next app, src/node/ holds the definition and cli; tsdown builds node, Next builds the app.

Incidental fixes

  • inspect: dropped a composite: true tsconfig that only passed via turbo cache, and fixed the pre-existing latent type errors it masked, so the package typechecks from a cold cache like every other plugin.
  • git: made the static-export copy robust to Next 16 export file modes (node cpSync was hitting EACCES).
  • Regenerated alias.ts, tsconfig.base.json paths, knip.jsonc entries, and the tsnapi API snapshots to match.

Validation

  • pnpm lint, pnpm knip: clean
  • pnpm typecheck (--force, cold cache): 39/39
  • API snapshots: 246 passed; plugin unit tests: 227 passed across all nine
  • dev bridge smoke-tested on a11y, og, and messages (panel + __connection.json served with HMR)

Note: two unrelated Next examples (next-runtime-snapshot) hit a pre-existing environment-only cpSync/Next-export EACCES in the sandbox during a full pnpm build; that code is untouched here and fails the same way on main in this environment.

This PR was created with the help of an agent.

… + playgrounds/

Establish the canonical built-in plugin layout on a11y:
- app/ holds the framework SPA (was src/spa), built by Vite into the --assets package
- src/node/ holds all node-side code (definition, setup, cli, rpc)
- src/client-script/ holds both browser scripts (client runtime + page script), built by tsdown
- playgrounds/ holds the same-origin playground host (was demo/)
- dev serves the panel under its base path with HMR + a live node-side bridge
- play builds then boots the playground against the built plugin
- rename the ./client export subpath to ./client-script
…pector to app/ + src/{node,client-script} + playgrounds/

Apply the a11y layout to the five model-fitting plugins:
- app/ holds the framework SPA (Vite-built into each --assets package)
- src/node/ consolidates all node-side code (definition, setup, cli, rpc, constants/types/vite, engine/registry where present)
- src/client-script/ holds the browser scripts (client runtime, and the injected page script for data-inspector), built by tsdown
- playgrounds/ boots the built plugin via the play script; dev serves the panel with HMR + a live node bridge
- rename ./client to ./client-script (and ./inject to ./client-script/page-script for data-inspector)
- regenerate alias.ts, tsconfig.base.json paths, knip entries, and API snapshots
… typecheck

Adapt the new layout to the three divergent plugins:
- messages (Vue) and terminals (Svelte): app/ holds the SPA host plus the
  Vite-built component library; tsdown builds src/node only; keep the ./client
  component-lib export; add dev (HMR + node bridge), play, and playgrounds/
- git (Next.js): app/ holds the Next app, src/node/ holds the definition + cli;
  tsdown builds node, Next builds the app; repoint build/dev scripts and configs
- inspect: drop the load-bearing composite tsconfig so its package typechecks
  fresh (not just via turbo cache), fixing the pre-existing latent type errors
  it masked (distributive Omit for the history record, string-widened RPC method
  wrappers, definitions.get access, widened connection backend union, and export
  DevframeInspectCommandInfo from the root for the dev-server test)
- reconcile alias.ts, tsconfig.base.json paths, knip entries, and API snapshots
Next's static export emits entries with restrictive modes that node's cpSync
inherits and then trips over (EACCES); recreate the tree with explicit
directory/file permissions instead.
@coldtea-pr-lens

coldtea-pr-lens Bot commented Sep 3, 2026

Copy link
Copy Markdown

◈ PR Lens

🟢 +0 new · 🟠 ~18 changed · 🔴 -0 removed · 2 flows · 30 files · commit 032dceb


Architecture

Architecture diagram for devframes/devframe at 032dceb

18 components touched across 5 lanes.

Open full size


Inside the changed components — 3 views

Component view — A11y Inspector Architecture

Internal modules and runtime communication channels within the accessibility inspector plugin.

Architecture view of Component view — A11y Inspector Architecture in devframes/devframe

Component view — Data Inspector Architecture

Internal components of the data inspector including the Vue workbench, isomorphic query engine, and source registry.

Architecture view of Component view — Data Inspector Architecture in devframes/devframe

Component view — Code Server Architecture

Launcher UI and process supervisor components for the code-server plugin.

Architecture view of Component view — Code Server Architecture in devframes/devframe

Data flow

Data flow diagram for devframes/devframe at 032dceb

A11y In-Page Scanning and Overlay · Data Inspector Query Execution

Open full size


The other flows — 1 sequence

Data Inspector Query Execution

Sequence diagram of Data Inspector Query Execution in devframes/devframe

Drill down
Client Runtimes & UI — 4 components
🟡 CHANGED A11y Client Script

Self-contained injected page script executing axe-core scanner on the host DOM.

🟡 CHANGED A11y Solid Panel App

SolidJS UI rendering scan reports and driving highlight overlays via the in-page channel.

🟡 CHANGED Data Inspector Vue App

Vue SPA query workbench connecting to backend over Devframe RPC.

🟡 CHANGED Code Server Launcher App

Vue launcher interface displaying status and embedding the editor frame.

Built-in Devframes — 14 components
🟡 CHANGED A11y Inspector Devframe

Accessibility inspector providing DOM scanning via axe-core, live violation highlighting, and a SolidJS inspection panel.

🟡 CHANGED Git Dashboard Devframe

Git dashboard interface built with Next.js static export communicating with the Git RPC service.

🟡 CHANGED Inspect Devframe

Introspection panel displaying registered commands, RPC functions, active instances, and agent manifests.

🟡 CHANGED Terminals Devframe

Terminal manager and stream viewer supporting preset execution and interactive sessions.

🟡 CHANGED Assets Devframe

Static asset manager supporting file uploads, live directory watching, and file previews.

🟡 CHANGED Data Inspector Devframe

Interactive Jora query workbench and data shape inspector over registered process data sources.

🟡 CHANGED Code Server Devframe

Supervisor launcher and embedder for web-based VS Code and code-server instances.

🟡 CHANGED Messages Devframe

Centralized feed viewer capturing diagnostic logs, notifications, and tool messages.

🟡 CHANGED Open Graph Devframe

Open Graph metadata analyzer and social preview simulator.

🟡 CHANGED A11y Node & RPC Setup

Registers a11y RPC functions and runtime configuration on devframe node context.

🟡 CHANGED Data Inspector Node & Registry

Node setup managing data source registry and RPC dispatch.

🟡 CHANGED Jora Query Engine

Isomorphic query and skeleton analysis engine.

🟡 CHANGED In-Process Inject Endpoint

Node import bootstrap registering runtime data sources from host processes.

🟡 CHANGED Code Server Supervisor

Process supervisor managing code-server lifecycle and binary detection.


View

  • Architecture lens
  • Data flow lens
  • Expand every detail
  • Show unchanged neighbours

Tip

Run PR Lens on your own machine: npx skills add coldteadotai/pr-lens installs the agent skill. Then tell your coding agent: "Diagram the change you just made with PR Lens and attach it to the pull request."

🪧 More tips
  • Draw a diff before it is even a pull request: npx @coldtea/pr-lens-cli analyze --base origin/main reads the diff with your own model key, and npx @coldtea/pr-lens-cli render .pr-lens/graph.json draws the same lenses on your machine.
  • The boxes under View are live. Tick Architecture lens or Data flow lens to choose which diagrams appear, or Expand every detail to open every drill-down at once. The comment redraws in place a few seconds later.
  • Show unchanged neighbours lists the components this change did not touch alongside the ones it did, so the drill-down shows what the changed code sits next to.
  • GitHub will not let you zoom an image in a comment. The link under each diagram opens it full size on a page of its own, where you can.
  • The CLI's render picks up .github/pr-lens.yml automatically and applies your corrections (renames, exclusions, lane pins) at draw time.
  • Would you rather run it from CI on a key of your own? Add .github/workflows/pr-lens.yml with coldteadotai/pr-lens/packages/action@v0 and a model key in your repository secrets, say GEMINI_API_KEY. The Action asks Gemini by default, or OpenAI and any endpoint speaking /chat/completions through its provider input.
  • PR Lens is free for open source. A star on the repository is what keeps it going.
  • Push a new commit and the whole comment re-renders for the new head. An older run never overwrites a newer one, so a slow render cannot put a stale diagram back.
  • The diagrams follow your GitHub theme, so dark mode gets the dark render and light mode the light one, and the moving dots show this pull request's data in motion.

◈ Rendered by PR Lens · crafted with ❤️ by the Coldtea team · Something drawn wrong?

@vercel

vercel Bot commented Sep 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
devframe Ready Ready Preview Sep 3, 2026 5:20am UTC

…ect wrapper

Rename the browser/injected surface for clarity, per review:
- a11y: the injected browser script is now ./client-script (src/client-script/index.ts, no page-script subfolder); drop the confusing 'page script' term. Keep a11yClientScriptBundlePath (deprecated aliases for the old names).
- data-inspector: the node --import module is now ./inject (src/inject/, restored name), since it runs in the user's Node process, not the browser.
- inspect/og/assets/code-server: the connectX wrapper was only used by each plugin's own SPA, so move it into app/connect.ts and drop the ./client-script export; these plugins now build only their node side with tsdown. Trim the barrel to the types the app actually uses.
- reconcile alias.ts, tsconfig.base.json paths, knip entries, and API snapshots
inspect no longer needs the composite tsconfig that made it opt out of the
typecheck gate; it now typechecks cleanly, so remove the exception (its
presence fails verify-typecheck-coverage once the package has a typecheck script).
@antfu
antfu merged commit 0abf43f into main Sep 3, 2026
14 checks passed
@antfu
antfu deleted the chore/plugin-structure-restructure branch September 3, 2026 06:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants