Expose SDK runtime action client
Merged
UN
4mo ago+2711+2711+0123456789012345678901234567890123456789-1226-1226-0123456789012345678901234567890123456789
Summary
- Exposes
runActionandPmClientfrom the SDK runtime/barrel so integrations can execute pm actions in-process without spawning the CLI. - Moves the MCP action dispatch path onto the SDK runtime surface so MCP tools and SDK consumers share the same implementation.
- Documents the runtime SDK usage and expands SDK/docs/MCP regression coverage, including extension activation/deactivation around workspace contracts.
PM tracking
- Implements
pm-xzhzunder the SDK customization lineagepm-usfg. - Accepts and closes
pm-muhwas the architecture decision supporting the SDK runtime-first path. - Closes #439.
Verification
node scripts/run-tests.mjs test -- tests/unit/sdk/sdk-index.spec.ts tests/integration/mcp-handshake.spec.ts tests/unit/mcp/mcp-server-branch-residual.spec.tsnode scripts/run-tests.mjs test -- tests/unit/docs-examples/sdk-app-embedding.spec.ts tests/unit/docs-examples/sdk-contract-consumer.spec.tspnpm typecheckpnpm buildpnpm lint(ESLint, jscpd 0 clones, static quality gate)pnpm quality:docs-skillspnpm security:scanpnpm audit --audit-level moderatepm validate --check-resolution --check-history-drift(history drift ok; existing closed-item resolution metadata warnings remain)pnpm changelog:pm && pnpm changelog:pm:checknode scripts/run-tests.mjs coverage-> 264 files, 5424 tests, 100% statements/branches/functions/lines- Installed-package smoke in a fresh temp consumer: packed
@unbrained/pm-cli, installed it, imported@unbrained/pm-cli/sdk/runtime, initialized a tracker, and usedPmClient/runActionfor create/list/search/get/update/context/direct-context/close. node scripts/release/sentry-telemetry-gate.mjs --json --telemetry-mode best-effort --sentry-window-days 14 --max-critical 0 --max-high 0passed with recent critical/high Sentry counts at 0 and telemetry rows present.greptile review --agent --branch origin/mainran before push. The CLI returned cached review88db4c20-531f-4c98-8148-df5f43caf6d2; both returned comments were already fixed in the pushed head (src/mcp/server.tsno duplicate helper;src/sdk/runtime.tsdeactivates after activation).
External state checked
- No open Dependabot, code scanning, or secret scanning alerts via GitHub APIs before PR creation.
pm-changeloglatest available npm version is2026.6.30; package-owned changelog generation/check passed with that version.- CodeFactor public page reported Rating A and no issues when checked before PR creation.
Summary by cubic
Expose an in-process action client in the SDK so integrations can run pm actions without spawning the CLI; MCP tools now use the same dispatcher. Adds workspace contracts caching and typed action alias support, with tighter dispatch and safer example parsing.
-
New Features
PmClientandrunActionare exported from@unbrained/pm-cli/sdk/runtimeand re-exported in@unbrained/pm-cli/sdk; MCPpm_runand narrow tools use this dispatcher; docs add usage, shared SDK/MCP activation serialization, and per-call runtime overrides.- Supports typed action aliases (list-* status,
ctx, task lifecycle, andpackage-*flows) via the shared runtime path. - Workspace contracts memoization with
clearWorkspaceContractsCacheto reset long‑lived hosts.
-
Bug Fixes
- Dispatch fixes: corrected
plantop-level dispatch from narrow tool calls and routed aliases through the runtime. - Hardening: replaced regex sanitization with a linear scanner; guarded SDK runtime test hooks to test environments only; wrapped example JSON parsing with contextual errors and handled empty
pm contractsstdout.
- Dispatch fixes: corrected