Overview
The shared package (@tempad-dev/shared) provides shared contracts, schemas, and types used by both the browser extension and MCP server.
Location: packages/shared/
NPM Package: @tempad-dev/shared (private)
Repository: https://github.com/ecomfe/tempad-dev
Responsibilities
- Zod schemas for MCP tools
- TypeScript types for tool parameters and results
- Constants for payload and message limits
- WebSocket protocol types
- Figma utility functions (color, gradient, stroke)
Tech Stack
- Language: TypeScript
- Schemas: Zod
- Build Tool: tsdown
Directory Structure
Key Commands
Building
dist/index.js- ESM exportdist/index.d.ts- TypeScript typesdist/mcp/- MCP schemas and typesdist/figma/- Figma utilities
Testing
Quality Checks
MCP Schemas
Tool Schemas
File:src/mcp/tools.ts
Defines Zod schemas for all MCP tools:
Constants
File:src/mcp/constants.ts
Defines limits and constraints:
Protocol Types
File:src/mcp/protocol.ts
WebSocket message shapes:
Figma Utilities
Color Formatting
File:src/figma/color.ts
Color conversion utilities:
Gradient Utilities
File:src/figma/gradient.ts
Gradient formatting for CSS:
Stroke Utilities
File:src/figma/stroke.ts
Stroke formatting for CSS:
Code Style Guidelines
Additive Schema Changes
Good: Add optional fieldsType Inference
Always infer types from Zod schemas:Testing Strategy
Strict Pure Coverage
These files have enforced coverage:src/index.tssrc/mcp/constants.tssrc/mcp/errors.tssrc/mcp/index.tssrc/mcp/protocol.tssrc/mcp/tools.tssrc/figma/index.tssrc/figma/color.tssrc/figma/gradient.tssrc/figma/stroke.tssrc/figma/style-resolver.ts
Test Files
Location:tests/
Pattern: *.test.ts (Node runtime only)
Example Test
Boundaries and Constraints
Coordinated Schema Changes
Never change schemas without updating downstream packages:- Update shared - Make schema change
- Update mcp-server - Handle new schema
- Update extension - Use new schema
Asset URI Format
Do not changeasset:// URI format without cross-package review.
Payload Caps
ChangingMAX_PAYLOAD_SIZE or MAX_ASSET_SIZE requires:
- Extension validation
- MCP server validation
- Documentation update
Dependencies
Do not add new dependencies without approval. Current dependencies:zod- Schema validation (required)
Verification Checklist
Always Run
Coverage Check
Downstream Validation
After schema changes:Change Migration Strategy
Adding Optional Fields
- Add field with
.optional()in Zod schema - Update TypeScript types (auto-inferred)
- Test in isolation
- Update downstream packages
Deprecating Fields
- Mark field as deprecated in comments
- Make field optional if not already
- Update downstream packages to stop using
- Remove in next major version
Renaming Fields
Avoid renaming. Instead:- Add new field
- Deprecate old field
- Support both during transition
- Remove old field in major version
Package Configuration
Exports
Frompackage.json:
Files
Onlydist/ is published (if package were public):
Related Documentation
In source repo:- Testing architecture:
docs/testing/architecture.md - Extension requirements:
docs/extension/requirements.md - Extension design:
docs/extension/design.md