Self-contained
The rules that keep an extension working on any server - no dependencies on other extensions, their storage or extra npm packages.
An extension must work on its own. The user can add or remove any extension at any time, and a third-party extension will be installed into servers where no other extension is guaranteed to be present. So the default is no dependencies on other extensions, and as few dependencies of any kind as possible.
The rules
- Don't import from another extension's folder. No
../tasks/lib/board, no../notes, not even for a type. If you need a shape another extension also uses, define your own inlib/. Duplicated types are fine; a cross-folder import is not. - Don't read another extension's storage. Your
host.storage,useStoredand collections are scoped to your own extension id by the host; there is no API for another extension's keys, and you must not try to reach them by any other route. Another extension's internal layout is theirs to change. - Don't call another extension's actions or tools. The assistant chains tools across extensions on its own. Your code shouldn't. The exception is an extension whose whole job is to act for the user (automation, agents), which declares the
toolspermission and says so in its README (see Tools). - Only import from the modules the frame provides:
react(withreact/jsx-runtime),react-dom,@spacemix/sdk,@spacemix/sdk/react,@spacemix/ui,lucide-reactandmotion/react. Those are the contract, and the bundle doesn't carry its own copy.@spacemix/sdkhashost;@spacemix/sdk/reacthas the hooks (useCollection,useStored,useRoute,useLinkTarget,useVisible,useEnv,useHostand the widget hooks). The app's own code (apps/desktop/src) isn't reachable from a frame at all. - Don't add npm packages for one extension. Before adding a dependency, check whether
@spacemix/uior the SDK already covers it, or whether forty lines of local code would. A package is justified only when it's the whole point of the extension (a parser, a protocol client) and there's no realistic way to write it locally. The Studio can't build an extension that imports one. - Store your own data under your own id. Collections and
host.storageare already scoped to the extension. Don't try to share keys with another extension to "sync" with it.
Data from other extensions
Some extensions really are about other extensions' data: a dashboard, an activity log, an automation. They use the shared core facilities, never another extension's internals:
- Events. Every collection reports its creates, updates and deletes, and extensions declare more. An extension with the
eventspermission receives them all (see Notifications and events). - Widgets. Dashboards shows data from every extension through widgets, which are part of the core and see other extensions only through their read-only assistant tools (see Widget reference).
- Tools. An extension with the
toolspermission runs other extensions' assistant tools as the user (see Tools).
The Permission type also has data:<ns>:read and data:<ns>:write, meant for reading or writing another extension's collections. No host API uses them today: declaring one gives nothing. Don't rely on them; see Permissions.
Whatever you use, degrade gracefully when the other extension isn't installed: an empty state, not an error. Say in your README why you need another extension's data.
A test
Copy the folder into a fresh checkout that has no other extensions and no new packages installed. It should build and run as it is. Building it in the Studio is a stricter version of the same test: the Studio resolves only your own files and the frame's modules.