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: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ 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)
## Plugin operations (SDK 2.2.0+)

The development operations protocol lets a plugin declare a host-rendered form,
The 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.
The operation protocol, API and CLI template are available in **SDK 2.2.0**.
They require a compatible Motrix host; beta.48 is the planned first supporting
release, and beta.47 is incompatible. SDK publication does not establish host
availability. New components/capabilities require host support; compatible
plugin-only UI and business changes can update live. See the guide for setup.

## Quick start

Expand All @@ -59,7 +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 |
| `operation` (SDK 2.2.0+) | 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 @@ -156,7 +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.operations` | **SDK 2.2.0+:** 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
10 changes: 5 additions & 5 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ pnpm run pack # produce a distributable .moext
里 —— 没有 Node.js API,不能直接访问文件或网络。与外界的一切交互都要
经过你在 manifest 里声明的 capability,用户在安装时能看到你申请了什么。

## 插件操作(尚未发布)
## 插件操作(SDK 2.2.0+)

开发中的操作协议允许插件声明宿主渲染的表单、入口和沙箱处理函数,无需编写 React 或 renderer 代码。先阅读 [编写指南](docs/operations.zh-CN.md),再参考完整的 [文本去重](examples/text-tools/README.zh-CN.md) 和 [音视频合并](examples/media-merge/README.zh-CN.md) 示例。
操作协议允许插件声明宿主渲染的表单、入口和沙箱处理函数,无需编写 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 等已发布宿主支持。新组件和能力需要宿主支持;兼容协议范围内的插件界面和业务更新可以热生效。
操作协议、API 和 CLI 模板已随 **SDK 2.2.0** 发布。运行仍需要兼容的 Motrix 宿主,beta.48 是计划中的首个支持版本,beta.47 不兼容;SDK 发布不代表宿主功能已发布。新组件和能力需要宿主支持;兼容协议范围内的插件界面和业务更新可以热生效。依赖安装方式见指南。

## 快速开始

Expand All @@ -47,7 +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 脚本 |
| `operation`(SDK 2.2.0+) | 文本去重表单、受限处理函数、中英文文案及 typecheck/validate/pack/lint 脚本 |

脚手架生成的插件 id 初始为 `me.<name>`。要设置真实的 publisher
(`<publisher>.<name>` 的前缀),可以直接编辑 `motrix-plugin.json` 里的
Expand Down Expand Up @@ -142,7 +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.operations` | **SDK 2.2.0+:**宿主渲染的操作表单与受限处理函数,见 [操作指南](docs/operations.zh-CN.md)。 |
| `contributes.configuration` | 你的设置 schema(同一受限子集)。运行时通过 `config` capability 读取。 |
| `requestedHeapMB` | 沙箱堆大小,32(默认)到 64。 |
| `l10n` | locale JSON 文件所在目录。 |
Expand Down
62 changes: 30 additions & 32 deletions docs/operations.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Authoring plugin operations (unreleased)
# Authoring plugin operations (SDK 2.2.0+)

**English** | [简体中文](./operations.zh-CN.md)

> Development implementation, not a released SDK/host contract. Use a matching
> development checkout of the SDK and a Motrix build that implements the required
> capabilities. Examples and the operation template require
> `>=2.0.0-beta.48 <3.0.0`; beta.48 is the planned first supporting host release,
> not a claim that these features have shipped. Beta.47 is rejected, including
> development builds still reporting that version. Matching SDK packages remain
> unpublished, and a public JSON Schema URL does not establish support. The
> examples are not marketplace releases.
> The operation schema, API and CLI template are published in SDK 2.2.0.
> Runtime support still requires a Motrix host implementing the declared
> capabilities. Examples and the template require `>=2.0.0-beta.48 <3.0.0`;
> beta.48 is the planned first supporting host release, not a claim that it has
> shipped. Beta.47 is rejected, including development builds with that version.
> Raise the minimum if the host feature ships later. SDK publication and a
> public JSON Schema URL do not establish host support. These examples are not
> marketplace releases.

## Start with a complete example

Expand All @@ -29,44 +29,43 @@ For a TypeScript author, adapting an example is a small task; defining a new
operation from scratch has a moderate learning cost. The main work is aligning
schema fields, UI references, locale keys and file grants. No React or CSS is
needed. This is a source-based assessment, not a measured usability study.
The development CLI provides an `operation` template that creates the initial
The CLI provides an `operation` template that creates the initial
references and files for you. `basic-resolver` and `post-action` remain lifecycle-hook
templates. Types are still handwritten; schema-to-TypeScript generation and UI
preview are not implemented.

### Generate your own operation project

The development CLI now includes `operation`, starting from text deduplication.
From the SDK repository root, choose an unused project name:
Use the published SDK 2.2.0 CLI from any working directory, choosing an unused
project name:

```sh
pnpm install --frozen-lockfile
pnpm build
node packages/plugin-cli/dist/bin/motrix-plugin.js init my-operation -t operation -p acme
pnpm --package=@motrix/plugin-cli@2.2.0 dlx motrix-plugin init my-operation -t operation -p acme
cd my-operation
pnpm add -D @motrix/plugin-api@file:../packages/plugin-api @motrix/plugin-cli@file:../packages/plugin-cli
pnpm install
pnpm run typecheck
pnpm run validate
pnpm run pack
pnpm run lint
```

This local dependency step is necessary while the operation API/CLI are
unreleased. The generated version ranges do not imply published support. If you
create the project elsewhere, adjust the two `file:` paths to the matching built
SDK packages. Do not change the host's schema or permissions to install it.
The generated project declares API/CLI 2.2.0 or compatible newer versions; local
SDK links are not required. The immutable 2.2.0 CLI still prints an outdated
"unreleased" notice and generates source-checkout setup instructions. For that
version, use `pnpm install` as above instead of the generated `file:` setup.
This documentation and the next CLI release correct the wording. The host
compatibility requirement remains in force; never change its schema or permissions
to install the example.

Alternatively, from the SDK root, the create wrapper supports:
Alternatively, use the published create wrapper:

```sh
node packages/create-motrix-plugin/bin/create.mjs my-operation operation
pnpm create motrix-plugin@2.2.0 my-operation operation
```

It defaults to publisher `me`; use the full CLI's `-p` option for a custom one.
Once matching versions are released, the public entry points will be
`motrix-plugin init my-operation -t operation -p acme` and
`pnpm create motrix-plugin my-operation operation`. They are not a claim that
currently published packages contain the template.
For SDK development only, build this repository, invoke its CLI binary and use
matching local API/CLI dependencies to test changes that are not yet published.

The generator creates the complete manifest, handler, English/Chinese locales,
strict package-based `tsconfig.json`, esbuild config, package scripts, `.gitignore`
Expand Down Expand Up @@ -99,12 +98,11 @@ Neither command publishes or signs anything. Install through the compatible
host's normal third-party package flow and review the requested permissions.

The examples deliberately use this checkout's CLI and ambient API declaration;
there is no separate example dependency installation. Installing the currently
published npm packages is not a substitute for building these development
sources. When moving an example into a standalone project, use matching released
CLI/API packages once available, and replace the relative ambient declaration
include with the package's `types` setup. Keep `motrix:plugin-api` external when
bundling. `pack` validates and bundles; it does not replace TypeScript checking.
there is no separate example dependency installation. Standalone projects can
use the published CLI/API 2.2.0 packages and package-based `types` configuration,
as generated by the template, instead of the relative ambient declaration include.
Keep `motrix:plugin-api` external when bundling. `pack` validates and bundles;
it does not replace TypeScript checking.

## Ownership and files

Expand Down
24 changes: 11 additions & 13 deletions docs/operations.zh-CN.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# 编写插件操作(尚未发布)
# 编写插件操作(SDK 2.2.0+)

[English](./operations.md) | **简体中文**

> 本文描述开发中的实现,不代表已经发布的 SDK 或宿主契约。请使用匹配的 SDK 开发源码和具备所需能力的 Motrix 构建。示例与 operation 模板要求 `>=2.0.0-beta.48 <3.0.0`;beta.48 是计划中的首个支持版本,不代表这些功能已发布。beta.47 会被拒绝,包括仍使用该版本号的开发构建。配套 SDK 包仍未发布,公开 JSON Schema 地址也不能证明已支持;示例不是已经上架的插件。
> 操作 Schema、API 和 CLI 模板已随 SDK 2.2.0 发布。运行仍需宿主提供声明的能力。示例和模板要求 `>=2.0.0-beta.48 <3.0.0`;beta.48 是计划中的首个支持版本,不代表宿主功能已发布。beta.47 会被拒绝,包括仍使用该版本号的开发构建;若宿主功能延期,必须提高最低版本。SDK 发布及公开 JSON Schema 地址不能证明宿主支持;这些示例不是已上架插件。

## 从完整示例开始

Expand All @@ -11,33 +11,31 @@

两个目录都包含完整清单、处理函数、中英文语言文件和 TypeScript 配置,是可以执行的源码示例。下文代码片段只解释局部字段,不是完整清单。

对熟悉 TypeScript 的开发者,修改现有示例的工作量较小;从零定义操作的学习成本中等。主要难点是对齐参数 Schema、UI 引用、翻译键和文件授权,无需编写 React 或 CSS。这是基于源码的评估,没有经过开发者可用性研究。开发版 CLI 已提供 `operation` 模板,自动生成初始引用和文件;`basic-resolver` 和 `post-action` 仍为生命周期 Hook 模板。类型仍需手写维护,尚未实现从 Schema 生成 TypeScript 类型或 UI 预览。
对熟悉 TypeScript 的开发者,修改现有示例的工作量较小;从零定义操作的学习成本中等。主要难点是对齐参数 Schema、UI 引用、翻译键和文件授权,无需编写 React 或 CSS。这是基于源码的评估,没有经过开发者可用性研究。CLI 已提供 `operation` 模板,自动生成初始引用和文件;`basic-resolver` 和 `post-action` 仍为生命周期 Hook 模板。类型仍需手写维护,尚未实现从 Schema 生成 TypeScript 类型或 UI 预览。

### 生成自己的操作项目

开发版 CLI 现已提供 `operation` 模板,以文本去重为起点。从 SDK 仓库根目录开始,使用尚未占用的项目名:
在任意工作目录使用已发布的 SDK 2.2.0 CLI,选择尚未占用的项目名:

```sh
pnpm install --frozen-lockfile
pnpm build
node packages/plugin-cli/dist/bin/motrix-plugin.js init my-operation -t operation -p acme
pnpm --package=@motrix/plugin-cli@2.2.0 dlx motrix-plugin init my-operation -t operation -p acme
cd my-operation
pnpm add -D @motrix/plugin-api@file:../packages/plugin-api @motrix/plugin-cli@file:../packages/plugin-cli
pnpm install
pnpm run typecheck
pnpm run validate
pnpm run pack
pnpm run lint
```

操作 API/CLI 尚未发布时,需要上述本地依赖步骤,生成的版本范围不代表已发布支持。若在其他位置创建项目,将两个 `file:` 路径调整为匹配且已构建的 SDK 包位置。不能通过修改宿主 Schema 或权限来安装。
生成项目声明 API/CLI 2.2.0 或兼容的新版本,无需链接本地 SDK。已发布的 2.2.0 CLI 仍会显示过时的“尚未发布”提示,并生成源码依赖安装说明;该版本请按上方执行 `pnpm install`,不用生成文档里的 `file:` 配置。本次文档和下一版 CLI 会修正文案。宿主兼容性要求仍有效,不能通过修改宿主 Schema 或权限来安装。

也可以从 SDK 根目录使用 create 包装器:
也可使用已发布的 create 包装器:

```sh
node packages/create-motrix-plugin/bin/create.mjs my-operation operation
pnpm create motrix-plugin@2.2.0 my-operation operation
```

它默认使用发布者 `me`;自定义发布者请使用完整 CLI 的 `-p`。配套版本正式发布后,公开入口为 `motrix-plugin init my-operation -t operation -p acme` 和 `pnpm create motrix-plugin my-operation operation`,这不代表当前已发布包包含该模板。
它默认使用发布者 `me`;自定义发布者请使用完整 CLI 的 `-p`。仅在开发 SDK 未发布改动时,才需要构建本仓库、调用仓库内 CLI,并使用匹配的本地 API/CLI 依赖。

生成器提供完整清单、处理函数、中英文语言文件、基于安装包的严格 `tsconfig.json`、esbuild 配置、package scripts、`.gitignore` 和成对 README。操作、命令和激活 ID 自动使用项目的发布者与名称。模板只申请所选文件读写权限,包含插件页面及单任务菜单入口,使用 `preserve-inputs`。提供明确的 typecheck、validate、pack、lint 脚本;pack 不代替类型检查,处理函数类型仍需手写维护。生成项目不会安装、启动、签名或发布插件。

Expand All @@ -57,7 +55,7 @@ node ../../packages/plugin-cli/dist/bin/motrix-plugin.js lint

将 `text-tools` 换成 `media-merge` 即可运行另一个示例。`pack` 会自行打包 `src/index.ts`,将未签名 `.moext` 写入示例目录下被 Git 忽略的 `dist/`。`lint` 读取构建后的 bundle,必须放在 **pack 之后**。这些命令不会签名或发布。通过兼容宿主的正常第三方安装流程安装,并检查所申请的权限。

示例直接使用当前仓库的 CLI 和 ambient API 类型声明,不需要为示例单独安装依赖。安装当前 npm 已发布包不能替代构建这些开发源码。将示例移到独立项目时,应在匹配版本正式发布后使用配套 CLI/API 包,将相对路径类型声明改成包的 `types` 配置;打包时保持 `motrix:plugin-api` 为 external。`pack` 负责校验和打包,不代替 TypeScript 类型检查。
示例直接使用当前仓库的 CLI 和 ambient API 类型声明,不需要为示例单独安装依赖。独立项目可使用已发布的 CLI/API 2.2.0 及模板生成的包级 `types` 配置,替代相对路径类型声明。打包时保持 `motrix:plugin-api` 为 external。`pack` 负责校验和打包,不代替 TypeScript 类型检查。

## 文件与职责

Expand Down
8 changes: 4 additions & 4 deletions examples/media-merge/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Media merge operation example (unreleased)
# Media merge operation example (requires a compatible host)

**English** | [简体中文](./README.zh-CN.md)

Expand All @@ -9,7 +9,7 @@ This teaching copy uses **`example.media-merge`** and a distinct display name so
it can be installed as an unsigned third-party example without impersonating the
official plugin or requiring its signing key. It is not a marketplace release.

**Requires the unreleased operations implementation in both the SDK and host.**
**SDK 2.2.0 is published; runtime support requires a compatible Motrix host.**
`engines.motrix` is `>=2.0.0-beta.48 <3.0.0`, targeting beta.48 as the first
supporting host release. This is a release target, not published availability.
Beta.47 is rejected, including development builds still reporting that version.
Expand Down Expand Up @@ -48,8 +48,8 @@ publish. Install using the compatible host's normal third-party package flow.
Review `ffmpeg`, `files.selected.read` and `files.selected.write` permissions.
There is no network permission or download lifecycle hook. A published CLI with
an older embedded schema cannot validate this example. The TypeScript include is
checkout-relative by design; standalone projects need matching API types when
those packages are released.
checkout-relative by design; standalone projects can use the published
API/CLI 2.2.0 packages with package-based types.

## Behavior and UI

Expand Down
Loading
Loading