Platform adapter (MESA Pro → open base)
Pro talks to the base through exactly one seam: modu <verb> --json in a subprocess. It never
imports mesa source and never writes .modu/ directly (the sole Pro-owned namespace is
.modu/mcp/context/,2026-12-04 退役后改走 base modu memory)。
Resolve the binary
MESA_MODU_BINMODU_BINmoduonPATH
Use runModu(args, { projectDir, bin?, env?, timeoutMs? }) from src/platform/modu.mjs.
Result contract
{ ok, code, json?, stdout, stderr, error?, hint? }
okis true only for exit 0 andjson.ok !== false.- A nonzero exit is a normal result; callers map
json.error/stderrto MCP errors. MODU_NOT_FOUND/MODU_INVALID_JSON/MODU_SPAWN_FAILEDare adapter-level failures.- The caller passes
--json; the adapter does not guess which verbs support it. projectDirbecomes the child cwd, so--project .and relative paths behave as in the CLI.
Handshake
Before a Pro release, run:
modu contract --json # { ok, package, version, subpaths, schema }
Pro pins the base CLI minor line and refuses to start when schema.pageSpec or required subpaths
are missing. @modu/contracts version and CLI contract output are checked against the same
CONTRACTS_VERSION.
Tool primitives
src/tools/read.mjs — getContract, listCatalog, listGaps, validate.
src/tools/write.mjs — submitRequirement, applySpec, applyLogic, replaceMenu,
upsertDatasource.
Write primitives send the JSON payload over stdin (--file -), so config never leaks into argv
and the base CLI remains the only .modu/ writer. runModu accepts input as a string or object.
Porting an MCP tool
- Replace direct
.modu/reads/writes with the matching base verb (catalog,gap,spec apply,logic apply,menu replace,datasource upsert,validate,requirement submit). - MCP-only state (knowledge/context) 曾放
.modu/mcp/context/;2026-12-04 收敛后 context_* 直接读写 basemodu memory,文件卡片只读兜底。 - Return
jsonon success,{ error, hint, details }on failure; never retry a paid action. - Run
node --test; the adapter tests use fake binaries (no base checkout needed).
Pinned contracts release
Base release asset (private): contracts-v0.7.0 → modu-contracts-0.7.0.tgz (sha256
a26283a5180b4f36d5ebafe209a234d4d51abc3b637545a61d3d6a5733907895) + SHA256SUMS.
Download and verify the checksum before installing; see mesa/docs/requirements/contracts-distribution.md.
Pro must not follow a moving latest; pin the tarball version in its lockfile.
Credentials
Never put tokens or keys in CLI arguments (they leak into process lists). Pass them through env
references that the base resolves (*_FILE / tokenRef); the adapter inherits process.env plus
an explicit env overlay.
源文件 · mesa-pro/docs/platform-adapter.md