// PLUGIN DEV

Plugin Development Docs

Know HTML? You can write plugins.

Quick Start

A plugin is essentially a web page (HTML / CSS / JS). Write the page, then package it with the plugin packager inside CosmosBox into a .cbplugin file — send it to anyone and it installs and runs.

A faster path: one-click AI generation — describe what you want in the AI chat ("make a digital wooden fish"), and the AI produces an installable plugin.

Directory Structure

A plugin can be a single file or a multi-file directory (.cbplugin is essentially a zip package):

my-plugin/ — plugin package structure
my-plugin/
├── manifest.json // plugin manifest (required)
├── index.html // entry page (entry points to it)
├── style.css // optional assets
└── app.js // optional scripts

manifest.json Fields

manifest.json — complete example
{
"pluginId": "a3f8c1d2-9b4e-4f6a-8c5d-1e2f3a4b5c6d", // UUID v4 unique ID (auto-generated by the packager)
"id": "mobi.reader", // legacy short ID (compat)
"name": "MOBI Reader",
"version": "1.2.0",
"author": "YuzhouHe",
"description": "Reads MOBI / AZW3 ebooks",
"icon": "📖", // Emoji / image URL / Base64
"entry": "index.html",
"permissions": ["file.read", "storage"],
"fileTypes": ["mobi", "azw3"] // file routing: external files open automatically by type
}
FieldRequiredDescription
pluginIdUUID v4 unique ID, system-level collision protection; let the packager auto-generate it
idLegacy short ID (e.g. mobi.reader); omit for new plugins, kept for compatibility
nameDisplay name of the plugin
versionSemantic version, e.g. 1.2.0
authorAuthor name
descriptionOne-line description, shown in the plugin market
iconEmoji, image URL or Base64 image
entryRelative path of the entry file (usually index.html)
permissionsPermission declarations (e.g. file.read / storage), granted one by one in the permission center
fileTypesDeclared file extensions for file routing (auto-open from outside)

Packaging Flow

  1. Choose the plugin type: single file / multi-file directory
  2. Fill in the code: paste HTML or select a folder
  3. Configure manifest.json: name / version / entry / permissions / file types
  4. Choose encryption: public plugins → .cbplugin; paid/private plugins → .encplugin (AES encryption + double password confirmation to prevent typos)
  5. Generate the package: one click, ready to share / import & install
🛠️
Batch packaging: the development environment provides the pack_plugins.ps1 script — run it once after editing plugins to regenerate all .cbplugin files (auto-skips .git / node_modules / build directories).

Encrypted Plugins .encplugin

.cbplugin.encplugin
PurposePublic sharingPaid / private distribution
ContentPlaintext zipAES encrypted
ImportInstall directlyEnter password (auto password dialog when opened externally)

⚠️ Encrypted plugin passwords cannot be recovered — losing the password means the plugin can never be decrypted. Keep it safe.

Sandbox & Permissions

Plugins run inside a sandboxed WebView — open and secure at once:

MechanismDescription
CSP header injectionMeta tag + HTTP header dual path, restricts external script loading
eval / Function disabledFull Object.defineProperty coverage, no dynamic code execution
Network rate limitPlugin network requests limited to 60/min to prevent abuse
Path isolationPlugins can only read/write their own sandbox directory (path traversal protection)
Permission centerpermissions declarations + per-item grants, every action auditable
JS bridgeNative capabilities via bridge API (storage / clipboard / files…), base library auto-injected by the host

Plugin Unique ID (UUID v4)

Plugin IDs use UUID v4 (122 bits of random entropy) — collisions are practically impossible, so duplicate user-side IDs never overwrite or delete each other. We recommend letting the packager generate it; when specifying manually, use the full UUID format (8-4-4-4-12) — the packager validates it.

One-Click AI Plugin Generation

Describe what you need directly in the CosmosBox AI chat:

AI chat
You → Make a digital wooden fish; tapping it makes a sound with animation
AI → ✅ Plugin "Digital Wooden Fish" generated — install & run with one click

AI-generated plugins get the base library injected automatically (storage / clipboard / dark-mode adaptation) and can be installed from the plugin center right away; not happy with it? Ask the AI to keep editing it in the editor page.

📤
Built your own plugin? Submit it via plugin submission to get it into the plugin market (submission channel coming soon).
MATRIX MODE: ON — enter again or press ESC to exit