Repository navigation
feat: edge-deployable reads + capability-injection seams + faster tests - #68
Merged
Merged
Conversation
…der, no engine) Pre-publication: free to restructure (see AGENTS.md). New /read entry is self-contained (4KB, no config/schema/server/pglite/ai/mcp/node:*), providing block/markdown renderers + a minimal ReadStore query API for edge deploys. Refs #63.
Kody blog example rebuilt on @tanstack/cms-core/read: a ~15-line ReadStore over Neon (HTTP) plus the shared renderers — no CMS engine, no WebSocket pool. Pre-bundles to ~12KB and renders /, /post/:id stably on workerd. Adds the read.test.ts unit suite (9 tests) for the /read entry. Refs #63. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…eam 1)
Core no longer dynamically imports @tanstack/cms-store-postgres/pglite as an
implicit fallback when a config omits `storage`. Instead `storage` is required
and accepts a `StorageFactory` the engine resolves once with the data dir:
import { createPgliteStorage } from '@tanstack/cms-store-postgres/pglite'
defineCms({ storage: createPgliteStorage })
A missing `storage` now throws a NOT_CONFIGURED CmsError naming the exact
import to add. Because core never references a storage package, a server
bundle that injects e.g. createPostgresStorage no longer drags PGlite+WASM
into its graph — the whole point of the seam.
- config: `storage?: StorageAdapter | StorageFactory`; new StorageFactory /
StorageFactoryContext types.
- storage.ts: replace getDefaultAdapter/requireDefaultAdapter/ensureDefaultAdapter
with a synchronous `baseAdapterFor`; drop the async prime-then-sync-read dance
(simplifies the d6040b5 hazard away). Remove ensureDefaultAdapter call sites
(transfer, content-migrations, base schema-registry).
- new opt-in `setDefaultStorageFactory` escape hatch (null by default, so
production still errors and bundles stay clean) + `@tanstack/cms-store-postgres/testing`
vitest setup that wires it to createPgliteStorage — restores the embedded
engine for tests without editing every defineCms call site.
- migrate all 25 in-repo configs to inject `storage: createPgliteStorage` and
add the dep; wire the test setup into core/api/client/cli/ui-react/base.
Green: core 656, api 226, client 37, ui-react 146, cli 27, base 42. sherif clean.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Interfaces no longer dynamic-import @tanstack/ai-isolate-quickjs or
@tanstack/ai-code-mode from inside the engine. `defineCms({ interfaces })`
now requires a `runtime` (type-enforced), and a new opt-in entry supplies the
default:
import { quickjsInterfaceRuntime } from '@tanstack/cms-core/interfaces-quickjs'
defineCms({ interfaces: { collection: 'interfaces', runtime: quickjsInterfaceRuntime() } })
Only that entry statically imports the QuickJS/code-mode (WASM) packages, so a
build that doesn't enable interfaces never pulls them. Missing runtime throws a
NOT_CONFIGURED CmsError naming the import.
- new InterfaceRuntime / IsolateDriver / IsolateContext / IsolateBinding
structural types in the client-safe interfaces module (no peer imports).
- server/interfaces.ts reads config.interfaces.runtime; dynamic imports gone.
- new ./interfaces-quickjs entry (exports + tsdown); core already devDeps the
two peers.
- api/interface-ops narrows the structural driver to code-mode's own type at
the createCodeMode boundary.
- all 8 interface config sites inject quickjsInterfaceRuntime().
Green: core 656, api 226, ui-react 146, base 42. sherif clean.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…m 3)
`cmsTools` no longer loads @tanstack/ai itself. `defineCms({ ai })` takes a
`runtime` built by `aiRuntime()` from the new `@tanstack/cms-core/ai` entry
(the only place that statically imports @tanstack/ai). Core is now entirely
free of @tanstack/ai — a server bundle without agent tools never pulls it.
Missing runtime → NOT_CONFIGURED CmsError naming the import.
- new CmsAiRuntime type (toolDefinition typed opaquely, narrowed server-side)
+ CmsAiConfig.runtime; new ./ai entry (exports + tsdown).
- the @tanstack/ai loader (chat/image/tools) moves out of core/optional.ts to
@tanstack/cms-api (ai.ts, re-exported from the index); api ops + prm agents
repoint to it. optional.ts keeps only the generic isMissingModule/missingPeer.
- api test helper injects aiRuntime() by default; app/base + app/prm configs
and their agent-tool tests inject it; optional-peers stubs ./ai under the
@tanstack/ai-absent mock.
Green: core 656, api 226, ui-react 146, base 42, prm 10. sherif clean.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Neither the core main entry nor the api main entry references the MCP SDK now.
WebMCP (browser): `startWebMcpServer` moves from the `@tanstack/cms-core`
main entry to its own `@tanstack/cms-core/webmcp` entry (SDK still dynamically
imported inside, so importing the entry stays SSR-safe). ui-react/ui-dom import
from the subpath.
HTTP MCP (server): `cmsMcp` (and `@tanstack/ai-mcp`) move to the
`@tanstack/cms-api/mcp` subpath, out of the api main entry. `/api/mcp` is no
longer auto-served — `handleMcpApi(request, mcp)` takes the server and
`createCmsApiHandler({ mcp: cmsMcp })` mounts it; unmounted → NOT_CONFIGURED
naming the import. A single-file api bundle without MCP never pulls
`@tanstack/ai-mcp`. The ui-react `/api/mcp` virtual route wires `cmsMcp`, so
including that route is the opt-in; the headless-api starter mounts it (and
gains `ai.runtime`, since MCP tools are agent tools).
Green: core 656, api 226, ui-react 146, ui-dom 12, starters (team-ops,
admin-only, headless-api, contact-cards). sherif clean.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… (seam 5) New packages/core/tests/bundle-seams.test.ts esbuilds each core entry and asserts against the metafile that `core`, `core/server`, and `core/read` pull NO optional capability (PGlite, @tanstack/ai, ai-code-mode, QuickJS, MCP SDK, MCP-B, ai-mcp, store-postgres, sucrase), while `core/ai` and `core/interfaces-quickjs` DO carry theirs. This pins the seams at bundle time — a dynamic import can't sneak a capability back in, since a single-file bundler would inline it. Adds esbuild as a core devDep. AGENTS.md documents the capability-injection rule + the inject/opt-in-entry table for all five capabilities. Also mounts cmsMcp in the prm /api/mcp test. Full sweep green: test:types (37), test:lib (24), test:definitions (27/27), test:starters, all example configs, bundle-seams (5/5), sherif. (Pre-existing unrelated failure: react-onboarding publint styles.css export — untouched.) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…follow-up) The Packed Consumer check builds a fresh app from the packed tarballs; its generated cms.config and smoke-test defineCms relied on the removed implicit PGlite default and hit MISSING_STORAGE at boot. Inject `storage: createPgliteStorage` (the fixture already installs store-postgres). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- cms-tools: the agent-tool cast uses a type-only `import('@tanstack/ai')` to
keep the precise type without a value import (bundle seam); annotate it with
an oxlint-disable for consistent-type-imports.
- api: merge the new `loadTanstackAi` imports into the existing `./ai` import
lines (import/no-duplicates).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Measured: a PGlite VM costs ~400ms to boot (WASM + baked catalog) while the CMS migrations on top are only ~13ms — so the test cost was dominated by booting a fresh VM per `defineCms`, not by schema work. The `@tanstack/cms-store-postgres/testing` setup now shares ONE in-memory VM per process and gives each config an isolated schema via a table prefix keyed by its resolved data dir. This mirrors the old embedded default's semantics exactly (same dataDir shares — so close+reopen still sees its data — distinct dataDirs isolate), but pays the 400ms boot once instead of per config. A passed-in pool isn't closed by storage.close(), so the shared VM survives per-config teardown. Result: core 48s→28s, api ~26s→5.5s; no test changes needed. app/base keeps on-disk persistence via the new `./testing-disk` variant — its recover-owner test spawns a subprocess that reads the database file, which an in-memory VM can't serve. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
|
Caution Review failedThe pull request is closed.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
This was referenced Dec 3, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Consolidates the former 3-PR stack (#65 → #66 → #67) into one change against
main. Edge-deployable reads, four capability seams, and the test-speed win, together.1. Edge read path (
@tanstack/cms-core/read)A self-contained, tree-shakeable read/render entry (~4 KB, zero engine/config/schema/node imports): block + markdown renderers, a minimal
ReadStore, published-query helpers. Plus the@jherr/blogKody example rebuilt on it (Neon-over-HTTP, ~12 KB worker, no engine).2. Capability injection — core imports no optional capability
AI, code-mode, MCP, and the embedded PGlite storage default become opt-in capabilities the app injects, enforced at bundle time (a dynamic
import()isn't enough — a single-file bundler inlines it).storage: createPgliteStorage@tanstack/cms-store-postgres/pgliteai: { runtime: aiRuntime() }@tanstack/cms-core/aiinterfaces: { collection, runtime: quickjsInterfaceRuntime() }@tanstack/cms-core/interfaces-quickjsstartWebMcpServer@tanstack/cms-core/webmcpcreateCmsApiHandler({ mcp: cmsMcp })@tanstack/cms-api/mcpMissing capability →
NOT_CONFIGUREDnaming the exact import.bundle-seams.test.tsesbuilds each entry and assertscore/server/readpull none of these while the opt-in entries carry theirs. All 25 in-repo configs migrated;AGENTS.mddocuments the rule.3. Test perf
Measured: a PGlite VM costs ~400 ms to boot; our migrations add ~13 ms. The test setup now shares one in-memory VM per process, isolating configs by
dataDir-keyed prefix — core 48 s → 28 s, api 26 s → 5.5 s, no test changes.app/baseuses an on-disk variant (its recover-owner test reads the DB from a subprocess).Verification
test:types(37),test:lib(24 projects — core 661, api 226, ui-react 146, base 42, prm 10, …),test:oxlint(23),test:definitions(27/27),test:starters, all 10 example configs, bundle-seams 5/5, sherif. Pre-existing unrelated red:react-onboarding:test:build(publintstyles.css). All breaking changes are in-repo only (pre-publication; seeAGENTS.md).🤖 Generated with Claude Code