Files
thedotmack-claude-mem/scripts
Alex Newman fb869ffd7c build(sdk): cmem-sdk package skeleton + tsup build + import guard (phase 2)
Wires up the deferred SDK export slot from commit ae454cfc — the
package.json `exports` map has pointed at `./dist/index.js` and
`./dist/sdk/index.js` since v12.x, but neither file ever shipped.

What this adds:

- `src/index.ts`: top-level `.` export, re-exports the SDK surface.
- `src/sdk/index.ts`: public SDK API — `CmemClient` / `CmemClientOptions`
  / `ChromaOptions` types + a `createCmemClient(...)` stub that throws
  a clear "Phase 3 not implemented yet" error. The types reflect the
  Chroma-required posture (no `enabled: false` toggle); `ChromaOptions`
  is tuning-only.
- `tsup.config.ts`: SDK bundler — ESM, node20, `dts: true`, sourcemaps,
  `clean: false` (preserves the rest of dist), externals for `pg`,
  `@anthropic-ai/sdk`, `node:*`. The "bun" type lib is dropped from
  the SDK build so consumer Node apps don't need it (plan §2 line 170).
- `scripts/check-sdk-bundle.cjs`: import guard. Greps the emitted
  bundle for forbidden tokens — `express`, `bullmq`, `ioredis`,
  `better-auth`, `react`, `bun:sqlite`, `@anthropic-ai/claude-agent-sdk` —
  and fails the build with a context snippet on any match. Live-tested
  both directions (injecting `import 'express';` makes the guard fail
  with exit 1; removing it makes it pass).
- `package.json`: `build:sdk` and `check:sdk-bundle` scripts; `build`
  chain now runs sync-plugin-manifests → build-hooks → build:sdk →
  check:sdk-bundle. `tsup@^8.5.1` in devDeps.

Emitted artifacts after `npm run build`:
- `dist/index.js` + `dist/index.d.ts`
- `dist/sdk/index.js` + `dist/sdk/index.d.ts`

Verification:
- Build green; check:sdk-bundle reports "is clean" against all 7
  forbidden tokens.
- Scratch `node` import of `dist/sdk/index.js` resolves and throws
  the expected stub error.
- Typecheck: 0 errors. Tests: 2070 pass / 0 fail / 18 skip.

Plan §2 (plans/2026-05-25-cmem-sdk-and-server-rename.md).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-29 14:31:04 -07:00
..