# Phase 4: Distribution - Context

**Gathered:** 2026-04-12
**Status:** Ready for planning

<domain>
## Phase Boundary

Package the screen-timelapse MCP server as a cplugs marketplace plugin with zero-config installation. Covers: DIST-01, DIST-02, DIST-03.

</domain>

<decisions>
## Implementation Decisions

### Plugin structure (DIST-01)
- **D-01:** Follow cplugs plugin convention: `.claude-plugin/plugin.json` manifest at plugin root
- **D-02:** Plugin directory structure: `.claude-plugin/plugin.json`, `dist/` (built output), `package.json`, `node_modules/` (production deps only)
- **D-03:** plugin.json contains: name ("screen-timelapse"), version (from package.json), description, author, keywords
- **D-04:** The plugin root IS the project directory — no separate plugin package needed. The project builds in place and the marketplace points to it.

### Build pipeline (DIST-01)
- **D-05:** tsup bundles TypeScript to `dist/index.js` (already configured in package.json)
- **D-06:** Build step: `npm run build` produces the dist/ output ready for plugin use
- **D-07:** Production install: `npm install --omit=dev` for minimal node_modules in distributed plugin
- **D-08:** Native dependencies (sharp, node-screenshots) ship prebuilt binaries — no build tools needed at install time

### Installation flow (DIST-02)
- **D-09:** `/plugin install screen-timelapse@cplugs` copies the plugin from marketplace to cache
- **D-10:** Post-install, the plugin's MCP server is available via the registered command
- **D-11:** No interactive prompts during install — fully automated

### MCP server registration (DIST-03)
- **D-12:** Plugin provides an MCP server configuration that registers automatically
- **D-13:** MCP server command: `node {plugin_path}/dist/index.js` using stdio transport
- **D-14:** Server name in MCP config: "screen-timelapse"
- **D-15:** No environment variables or manual configuration required for basic functionality

### Marketplace publishing
- **D-16:** Plugin published to cplugs marketplace at `~/.claude/plugins/marketplaces/cplugs/plugins/screen-timelapse/`
- **D-17:** Marketplace entry includes: .claude-plugin/plugin.json, dist/, package.json, node_modules/
- **D-18:** README.md in marketplace root updated to list screen-timelapse

### Claude's Discretion
- Exact tsup configuration details (format, target, etc.)
- Whether to include a post-install script or rely on pre-built artifacts
- Plugin icon or additional metadata fields
- Whether to add a CHANGELOG.md to the plugin

</decisions>

<canonical_refs>
## Canonical References

**Downstream agents MUST read these before planning or implementing.**

### Existing Implementation
- `package.json` — Build scripts, bin entry, dependencies
- `src/index.ts` — MCP server entry point
- `tsconfig.json` — TypeScript configuration

### Plugin Pattern Reference
- `~/.claude/plugins/marketplaces/cplugs/plugins/spt/.claude-plugin/plugin.json` — Reference plugin.json format
- `~/.claude/plugins/marketplaces/cplugs/plugins/spt/` — Reference plugin directory structure
- `~/.claude/plugins/installed_plugins.json` — Installation record format

### Distribution Target
- `~/.claude/plugins/marketplaces/cplugs/plugins/screen-timelapse/` — Target publish directory

</canonical_refs>

<code_context>
## Existing Code Insights

### Reusable Assets
- `package.json` bin entry already configured: `"screen-timelapse-mcp": "./dist/index.js"`
- tsup already in devDependencies for bundling
- MCP server uses StdioServerTransport — compatible with plugin MCP registration

### Established Patterns
- cplugs plugins have: `.claude-plugin/plugin.json`, optional `hooks/`, optional `skills/`
- Installed plugins tracked in `~/.claude/plugins/installed_plugins.json`
- Plugin cache at `~/.claude/plugins/cache/{marketplace}/{plugin}/{version}/`

### Integration Points
- `.claude-plugin/plugin.json` — New file needed in project root
- `tsup.config.ts` or `package.json` tsup config — May need adjustment for clean dist output
- `~/.claude/plugins/marketplaces/cplugs/plugins/` — Publish target

</code_context>

<specifics>
## Specific Ideas

- The plugin should work immediately after `/plugin install` — no build step for end users
- Native deps (sharp, node-screenshots) auto-download prebuilt binaries during npm install
- The dist/ directory should be committed to the marketplace (pre-built) so users don't need TypeScript tooling

</specifics>

<deferred>
## Deferred Ideas

None — discussion stayed within phase scope

</deferred>

---

*Phase: 04-distribution*
*Context gathered: 2026-04-12*
