Skip to content

Latest commit

 

History

History
63 lines (51 loc) · 4.16 KB

AGENTS.md

File metadata and controls

63 lines (51 loc) · 4.16 KB

AGENTS — TanStack CMS monorepo

Status: pre-publication — restructure freely

This library is pre-publication. None of the @tanstack/cms-* / @tanstack/search-* packages are on npm, and nothing outside this repo depends on them. That means:

  • Break public APIs at will. Rename, move, split, merge, or delete modules, exports, entry points, and types whenever it makes the design better. No backward-compatibility burden, no deprecation cycles, no changesets required for consumer-facing breaks.
  • Reshape package boundaries freely — new entry points (e.g. a tree-shakeable /read surface), new packages, re-layering of core internals, etc.
  • The only bar is internal consistency: the monorepo must still build and its tests must pass after a change. Update all in-repo call sites (apps, examples, starters) as part of the same change.

Don't preserve an awkward API out of compat fear — spindle, fold, and mutilate as needed, then make the whole repo green.

Architectural direction (edge-first reads)

Deploying to edge runtimes (e.g. Kody/workerd) proved that the read/render path must be tree-shakeable to a tiny bundle with no server engine — no @tanstack/cms-core/server barrel, no embedded PGlite (WASM/eval), no AI / code-mode / MCP, no node:*. See issues #63 (edge-read refactor) and #64 (Kody platform ask for the write/admin engine). Target split:

  • read path (public pages): pure query + renderers, edge-deployable.
  • write / admin / migrate path: the heavy engine, runs on a warm/Node-ish runtime, never in the hot read worker.

Capability injection — core never imports an optional capability

The engine ships no built-in storage, AI, code-mode, or MCP. Each is an opt-in capability the app injects via defineCms, supplied by a dedicated entry whose static imports pull the heavy dependency. Core never imports these packages, so they only enter a bundle when the app imports the opt-in entry. This is enforced at bundle time (not just runtime) by packages/core/tests/bundle-seams.test.ts — a dynamic import() is not enough, because a single-file bundler inlines it.

Capability Inject into defineCms Opt-in entry Heavy dep
Storage storage: createPgliteStorage (a StorageFactory) @tanstack/cms-store-postgres/pglite PGlite (WASM)
AI agent tools ai: { runtime: aiRuntime() } @tanstack/cms-core/ai @tanstack/ai
Code-mode interfaces interfaces: { collection, runtime: quickjsInterfaceRuntime() } @tanstack/cms-core/interfaces-quickjs QuickJS + @tanstack/ai-code-mode
WebMCP (browser) import startWebMcpServer @tanstack/cms-core/webmcp MCP SDK + MCP-B
HTTP MCP (server) createCmsApiHandler({ mcp: cmsMcp }) @tanstack/cms-api/mcp @tanstack/ai-mcp

Rules for new work:

  • Never statically or dynamically import an optional capability from a core engine module (index, server, read, config, storage, schema, …). If a feature needs one, add a capability type to the config (typed opaquely or via import type, which is erased) and a dedicated opt-in entry that provides it; the engine reads the injected value.
  • Fail with an actionable error. A missing capability must throw a NOT_CONFIGURED CmsError naming the exact import to add — never silently fall back to a package of its own.
  • MCP tools are agent tools: an app serving /api/mcp also needs ai.runtime.
  • Tests get the embedded engine back via the @tanstack/cms-store-postgres/testing vitest setupFiles (it calls setDefaultStorageFactory, an opt-in escape hatch that stays null in production so bundles remain clean).