--- name: temps-plugin description: > Design, build, test, and distribute external Temps plugins with TypeScript/Bun or Rust. Use for creating a plugin, adding an embedded console UI or deployment-event automation, testing host permissions and AI, deploying it as a Temps service, publishing its image, or submitting a plugin to the public catalog. Not for in-process TempsPlugin backend crates. --- # Create and ship a Temps plugin Deliver a working external plugin, a source repository that builds its image, and evidence of what was verified. Continue an existing project when provided; preserve its identity, storage, and user changes. Publishing is a separate outcome from building or deploying. TypeScript and Rust plugins are built, deployed and published the same way: from the `Dockerfile` and workflow that `plugin init` writes. A plugin runs only as a Temps service, from its image: do not suggest copying/symlinking a binary into the host plugin directory; Temps does not start plugin executables. Do not silently change the user's implementation language. ## 1. Establish the contract Record the plugin's purpose, intended user, entry point in Temps, input/output, persisted data, required host permissions, resource limits, and supported host/SDK versions. Resolve only missing decisions that affect the implementation. Prefer TypeScript + Bun for a new plugin; retain Rust for existing Rust plugins or an explicit choice. Read applicable repository instructions. Inspect the installed CLI's `plugin --help` and the SDK's exports instead of assuming commands from another release exist. The canonical starter is what `plugin init` writes (TypeScript, or Rust with `--rust`); the Rust source is `crates/temps-plugin-sdk/examples/service-plugin.rs`. The GitHub [TypeScript template](https://github.com/gotempsh/temps-plugin-template) may differ from it; compare its `Dockerfile` and workflow against a fresh `plugin init` project before relying on it. Lack of a CLI command is not a reason to invent one. Current evidence sources in a Temps checkout: - `apps/temps-cli/src/commands/plugin/`: init, add (image, local image, build), build, services, add-service, remove, grants and dev simulator. - `crates/temps-external-plugins/src/service_runtime.rs`: how Temps attaches to a plugin service. - `docs/adr/122-a-plugin-is-a-temps-service.md`: the runtime contract. - `crates/temps-plugin-protocol/`: protocol, permissions, manifest and events. - `sdks/node/packages/plugin-sdk/src/` and `crates/temps-plugin-sdk/src/`: SDK APIs. - Root `DESIGN.md`, `web/src/components/ui/`, and `web/src/globals.css`: current console design. Read [development.md](references/development.md) when scaffolding or changing runtime behavior, [design.md](references/design.md) for UI work, and [publishing.md](references/publishing.md) before preparing a distributable repository. ## 2. Scaffold an independently buildable project When supported by the installed CLI: ```sh bunx --bun @temps-sdk/cli plugin init my-plugin --name my-plugin # TypeScript bunx --bun @temps-sdk/cli plugin init my-plugin --name my-plugin --rust # Rust ``` This command scaffolds local files, including a `Dockerfile` and the `.github/workflows/publish-image.yml` workflow; it does not publish. Inspect generated files before continuing. Replace placeholder identity, author, repository, version and description; keep package metadata (`package.json` `temps` or `Cargo.toml` `[package.metadata.temps]`) and runtime manifest consistent. Commit the lockfile. Keep credentials, local databases, logs, auth material, and simulator session files out of Git. The plugin runs as a Temps service from the image its `Dockerfile` builds. Verify that a clean checkout builds that image (`plugin add --build` on a development instance). See the publishing reference for the embedded-asset consequence and for a project created before this flow. ## 3. Build the product Use the SDK to own the protocol handshake and transport. Keep protocol stdout clean; log diagnostics to stderr. Use verified caller context for authorization, typed errors, and plugin-owned storage in its assigned data directory. Host data and host-brokered AI come through the SDK, never database/provider credentials copied from the host. Declare the minimum host permissions and handle absent configuration and revoked grants visibly. Manifest declarations request permissions; administrators grant them. The plugin runs in its service's container and reaches Temps only through the platform API with those grants; it is never given the control-plane database or the instance data directory. Register discoverable navigation for a UI plugin. Use the selected Temps design standard, embed assets, and test its real proxy path. For deployment automation, subscribe to `deployment.succeeded`, keep receipt handling quick, and use bounded persistent jobs, idempotency, cancellation and explicit environment/project settings. ## 4. Verify the lifecycle at three levels 1. **Unit and integration checks:** success, validation, failures, persistence/restart, bounded work, and relevant security cases. Typecheck or `cargo check`, and build the image. 2. **Local plugin simulator:** real plugin process + SDK protocol + mock host. Exercise sidebar UI, event delivery, duplicates, denied/granted/revoked permissions, and role restrictions. 3. **Temps instance:** add a reviewed revision as a plugin from its image (`plugin add --build`, or `--image` for a published one), open it through Temps, trigger the intended user workflow, change permissions, redeploy the same service and approve the update that waits. Verify persistence and relevant actor/audit attribution where supported. Read [development.md](references/development.md) for simulator commands. A standalone unauthenticated UI preview proves layout only. Simulator/mock AI results are not real provider calls or a real Temps instance. A received event is not proof the job finished. Do not label end-to-end verification complete unless the deployed workflow was exercised; record a concrete limitation when that environment is unavailable. ## 5. Distribute, list, and maintain plugins The default workflow, the same for TypeScript and Rust, is **push a version tag → the Publish image workflow publishes the image → share the printed `plugin add --image` line → optional catalog PR**. No npm publication, publisher token, or registry signing key is needed. Read [publishing.md](references/publishing.md) for exact metadata and listing examples. `plugin publish` was removed; it only prints how a plugin is published. Prepare and validate all artifacts before an external publication step. Respect the user's existing authorization: creating a skill or building a plugin does not itself request a release tag, a public image, a catalog PR, or deployment into production. When publication is requested, show the concrete repository/version/permissions and execute only that scope. Never ask users to paste credentials into chat. Finish with source location, preview/deployment instructions, declared permissions, verification evidence, distribution/catalog state and remaining limitations. For updates, retain the stable identity, version deliberately, migrate storage safely, and test a redeploy of the same service. A plugin changes when an administrator approves the build its redeployed service runs; until then the plugin is disconnected.