Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,20 @@ inside a sandbox — no Node.js APIs, no direct file or network access.
Everything reaches the outside world through capabilities you declare in the
manifest, and users see exactly what you asked for at install time.

## Plugin operations (unreleased)

The development operations protocol lets a plugin declare a host-rendered form,
entry points and a sandbox handler. No React or renderer code is required.
Start with the [authoring guide](docs/operations.md), then the complete
[text deduplication](examples/text-tools/README.md) and
[media merge](examples/media-merge/README.md) examples.

This interface is **not released**. Use the guide's matching-source build
instructions, not the published scaffold above. The development CLI includes an `operation` template; see the guide for local
SDK dependency setup. Example engine ranges and package versions do not establish support in
an already released host, including beta.47. New components/capabilities require
host support; compatible plugin-only UI and business changes can update live.

## Quick start

```bash
Expand All @@ -45,6 +59,7 @@ Templates:
|---|---|
| `basic-resolver` (default) | A `beforeCreate` hook that inspects and rewrites downloads (`site-resolver` category) |
| `post-action` | An `afterComplete` hook that fires a desktop notification (`post-action` category) |
| `operation` (unreleased) | A text deduplication form, scoped handler, both locales and typecheck/validate/pack/lint scripts |

The scaffolded plugin id starts as `me.<name>`. Set your real publisher (the
`<publisher>.<name>` prefix) either by editing `id` in `motrix-plugin.json`,
Expand Down Expand Up @@ -141,6 +156,7 @@ Field reference (enforced by `motrix-plugin validate`):
| `activationEvents` | When the host loads you (e.g. `onTaskType:http`, `onStartup`). Required. |
| `contributes.hooks` | Which lifecycle hooks you implement, each with a `role`. |
| `contributes.commands` | Commands you register: id `<publisher>.<plugin>.<command>`, max 64. Commands marked `public: true` must declare `argsSchema` + `resultSchema` (a bounded JSON-Schema subset — no `$ref`/`oneOf`, ≤ 8 KiB, depth ≤ 8). |
| `contributes.operations` | **Unreleased:** host-rendered forms and scoped operation handlers. See the [operations guide](docs/operations.md). |
| `contributes.configuration` | Your settings schema (same bounded subset). Read values via the `config` capability. |
| `requestedHeapMB` | Sandbox heap, 32 (default) to 64. |
| `l10n` | Directory of locale JSON files. |
Expand Down Expand Up @@ -216,7 +232,7 @@ hooks across the task's lifetime.

| Command | What it does |
|---|---|
| `motrix-plugin init <name> [-t basic-resolver\|post-action] [-p publisher]` | Scaffold a new plugin project |
| `motrix-plugin init <name> [-t basic-resolver\|post-action\|operation] [-p publisher]` | Scaffold a new plugin project |
| `motrix-plugin dev` | Watch-build + run your local Motrix with the plugin loaded (`MOTRIX_BIN` overrides discovery) |
| `motrix-plugin validate` | Validate `motrix-plugin.json` against the official schema; non-zero exit on errors |
| `motrix-plugin pack` | Bundle (esbuild, minified, ES2020) + zip into `dist/<id>-<version>.moext` |
Expand Down
10 changes: 9 additions & 1 deletion README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ pnpm run pack # produce a distributable .moext
里 —— 没有 Node.js API,不能直接访问文件或网络。与外界的一切交互都要
经过你在 manifest 里声明的 capability,用户在安装时能看到你申请了什么。

## 插件操作(尚未发布)

开发中的操作协议允许插件声明宿主渲染的表单、入口和沙箱处理函数,无需编写 React 或 renderer 代码。先阅读 [编写指南](docs/operations.zh-CN.md),再参考完整的 [文本去重](examples/text-tools/README.zh-CN.md) 和 [音视频合并](examples/media-merge/README.zh-CN.md) 示例。

此接口**尚未发布**。请按指南使用匹配源码构建,不能直接使用上方已发布的脚手架流程;开发版 CLI 已包含 `operation` 模板,本地 SDK 依赖配置见指南。示例的引擎范围和包版本不能证明 beta.47 等已发布宿主支持。新组件和能力需要宿主支持;兼容协议范围内的插件界面和业务更新可以热生效。

## 快速开始

```bash
Expand All @@ -41,6 +47,7 @@ pnpm create motrix-plugin my-plugin post-action # template as second argument
|---|---|
| `basic-resolver`(默认) | 一个检查并改写下载的 `beforeCreate` hook(`site-resolver` category) |
| `post-action` | 一个下载完成后发桌面通知的 `afterComplete` hook(`post-action` category) |
| `operation`(尚未发布) | 文本去重表单、受限处理函数、中英文文案及 typecheck/validate/pack/lint 脚本 |

脚手架生成的插件 id 初始为 `me.<name>`。要设置真实的 publisher
(`<publisher>.<name>` 的前缀),可以直接编辑 `motrix-plugin.json` 里的
Expand Down Expand Up @@ -135,6 +142,7 @@ pnpm 内置的 tarball 打包命令,而不是脚手架里的 script。)
| `activationEvents` | host 何时加载你(如 `onTaskType:http`、`onStartup`)。必填。 |
| `contributes.hooks` | 你实现了哪些生命周期 hook,每个都要带 `role`。 |
| `contributes.commands` | 你注册的 command:id 形如 `<publisher>.<plugin>.<command>`,最多 64 个。标记 `public: true` 的 command 必须声明 `argsSchema` + `resultSchema`(受限的 JSON-Schema 子集 —— 不支持 `$ref`/`oneOf`,≤ 8 KiB,深度 ≤ 8)。 |
| `contributes.operations` | **尚未发布:**宿主渲染的操作表单与受限处理函数,见 [操作指南](docs/operations.zh-CN.md)。 |
| `contributes.configuration` | 你的设置 schema(同一受限子集)。运行时通过 `config` capability 读取。 |
| `requestedHeapMB` | 沙箱堆大小,32(默认)到 64。 |
| `l10n` | locale JSON 文件所在目录。 |
Expand Down Expand Up @@ -208,7 +216,7 @@ Role 决定同一 hook 上多个插件的执行顺序:

| 命令 | 作用 |
|---|---|
| `motrix-plugin init <name> [-t basic-resolver\|post-action] [-p publisher]` | 脚手架一个新插件项目 |
| `motrix-plugin init <name> [-t basic-resolver\|post-action\|operation] [-p publisher]` | 脚手架一个新插件项目 |
| `motrix-plugin dev` | watch-build + 启动本机 Motrix 并加载插件(`MOTRIX_BIN` 可覆盖自动定位) |
| `motrix-plugin validate` | 用官方 schema 校验 `motrix-plugin.json`;有错误时非零退出 |
| `motrix-plugin pack` | 打包(esbuild、minified、ES2020)并压成 `dist/<id>-<version>.moext` |
Expand Down
Loading
Loading