Forsion plugin

From Changan-Su/Forsion · View interactive version

Forsion plugin is an AI agent skill from the GitHub repository Changan-Su/Forsion. 当用户要给 Forsion / Tangu 做插件、主题、Space、智能体(agent)或捆绑包(bundle)——或要把某个能力做成可分发/可上架商店的扩展——时使用;已装的插件 / Space / 视图不出现、加载失败、更新后不工作要排查时也用(带一份插件体检脚本 tools/check-plugin.mjs)。内置五类官方模板(samples/),讲清各自的格式基线与硬约束(尤其两种"插件"是完全不同的系统),照抄模板改比从零写靠谱。

How to use this skill

Skill file

Forsion 扩展开发

扩展默认按 bundle 发行:一个 Forsion 插件目录内嵌 UI / 引擎插件 / Agent / 技能 / Space,后续追加其他层无需迁移。四类单体形态仍支持,纯数据主题或 Space 可单独发行。先复制 samples/ 中对应的官方模板再改。

| 类型 | 是什么 | 模板 | 最小产物 |

|------|--------|------|----------|

| 捆绑包(默认起点) | 一个 Forsion 插件内嵌引擎插件/Agent/技能/Space | samples/forsion-sample-bundle/ | manifest.json + 约定子目录 |

| 引擎插件 | 给 agent 加工具 / 设置 / 提示片段 | samples/forsion-sample-plugin/ | tangu-plugin.json + dist/index.js |

| 主题 | 换 UI 结构+配色(纯数据) | samples/forsion-sample-theme/ | theme.json + theme.css |

| Space | 视图布局配方(纯数据) | samples/forsion-sample-space/ | space.json |

| 智能体 | 预设人设+记忆+技能的 agent | samples/forsion-sample-agent/ | config.toml + SOUL.md |

⚠️ "插件"有两个互不相干的系统,先分清用户要哪个:

- 引擎插件(本技能 samples/forsion-sample-plugin):后端/Agent 层,tangu-plugin.json + activate(ctx),给模型加工具。

- Amadeus/Forsion 桌面插件:UI 层,manifest.json + 裸 main.js(宿主 new Function('ctx', code) 跑 —— 文件本身就是 setup(ctx) 的函数体,顶层直接 ctx.registerView(…);别包成 function setup(ctx) { … },没人调用它 = 零注册、零报错),加命令/斜杠项/视图/文件类型。桌面端 设置 → 插件 有一键脚手架(hello-amadeus);捆绑包模板的根即这一形态。

要"一套功能跨两层发行"(UI+工具+Agent+Space)时,用捆绑包把它们装进一个目录。

Default workflow: hand in a one-page plan first (2026-11-23+)

When asked to write a new plugin, theme, Space, agent or bundle, or to change one substantially (a new view, Space, engine tool, setting or data format), do not write files first. Read what you need (this skill, the template, the host references), then hand in a one-page plan and wait:

  1. Files: which files you will create or change (manifest.json, main.js, tangu-plugins/<pid>/…, spaces/<slug>/space.json, check.mjs …).
  2. Host APIs and data it depends on: each ctx.* call, and for every host surface where its data comes from and what side effects it has. Look these up in references/host-data-sources.md: ctx.tangu.mountChat resumes or creates a real session, the personal calendar is the engine's human/CALENDAR.db, ctx.tangu.request is callable only with the local managed engine, and so on.
  3. Host gaps found: what the host the plugin targets does not provide for this plan. A missing API, data source or permission there is a stop: name it in the plan and let the user decide. (What only the plugin sandbox lacks, such as the engine, is not a gap: list it under acceptance.) Do not work around it (reading the host's private DOM or modules, copying host code, faking data the real host would not have).
  4. Acceptance: how it will be checked: check.mjs assertions, tools/check-plugin.mjs, the plugin_sandbox steps (desktop plugins, when that tool is available), and what the sandbox cannot show (a bundle's engine half, signed-in or cloud features) and how the user will check that instead.
  5. Decisions for the user: names and IDs, where data is kept, anything with more than one sensible answer.

Write code only after the user confirms. When the user says to go straight ahead ("直接做", "just do it", "no plan needed"), skip the plan and start writing; also skip it for small fixes, troubleshooting (run the checker first, see "Troubleshooting an installed plugin" below) and questions; if troubleshooting turns up a substantial change, plan that change first. Do this whether or not the session is in plan mode. In plan mode you can only read: diagnose read-only and hand the plan in with exit_plan_mode; outside it, hand the plan in as your reply.

Build in serial blocks, not in parallel sub-sessions. While developing a plugin, do not start sub-sessions or parallel delegate runs to build parts at the same time: they all run on the same provider key, hit its rate limit together, and one 429 fails them all. Work one block at a time (for example engine tool → view → Space → checks) and commit each block locally once it works (git init a new plugin folder first), so a failed later block never costs the earlier ones. This is about how you develop; a finished plugin may still hand work to an agent at runtime with delegate(agentSlug) (see "三档路由" below).

Reference files (read the one you need)

Read the matching references/ file before using an API listed below or following a section's reference:

Troubleshooting an installed plugin: Space missing, view blank, "stopped working after an update" (2026-10-10)

When a user says a plugin's Space / view / command is gone, or that a plugin broke after updating the app or the plugin, run the checker first — before reading the code, and before asking the user for logs:

node "<Skill folder>/tools/check-plugin.mjs"                      # every plugin installed in ~/.forsion/plugins
node "<Skill folder>/tools/check-plugin.mjs" <plugin folder>      # one plugin, e.g. the project you are developing
node "<Skill folder>/tools/check-plugin.mjs" <plugin folder> --style   # also: its CSS against the host style contract (report only)
node "<Skill folder>/tools/check-plugin.mjs" <plugin folder> --style --all   # every note, not the first 300 (counting toward zero)

Then read references/troubleshooting.md: what each mark means, how the host hides a Space, the plugin-status UI command, and running without node on PATH. Do not send the user to the developer console or ask for logs before the checker and plugin-status have both come back without an answer. Plugin authors: run the same checker before every release.

Verify a desktop plugin in the plugin sandbox before installing it (2026-10-23+)

When plugin_sandbox is in your tool catalog (the desktop app, a work session on this computer), verify every desktop plugin you write there before you tell the user it works, and never install it into their Forsion yourself:

  1. plugin_sandbox {"action":"start","path":"<plugin folder with manifest.json>"} (relative paths resolve against the working folder). You get the load status (registered views, the Space folders it ships and which were shown or hidden and why, setup error, mount errors, the plugin's own console) and a screenshot of the sandbox window, already on the plugin's first Space (or its first view when it ships no Space).
  2. Fix what you see in the files. Saving reloads the sandbox by itself; look again with plugin_sandbox_inspect (status, screenshot with an optional view id, logs).
  3. Use it like a person would, with plugin_sandbox_inspect (2026-11-03+; never computer use on the sandbox window): read gives an outline of the screen with [e12] references; click / type / press take a target (a reference, css:<selector>, or a control's visible text), type replaces the field's text unless append is true, press takes keys such as Enter, ArrowDown, Mod+K; scroll (amount pixels, negative = up) and space (switch to one of the plugin's Spaces). Each returns a screenshot after the page settles, plus console lines and toasts that appeared meanwhile. Before clicking something that opens a file picker (<input type="file"> included), call files with paths inside the plugin folder (put test fixtures there); a native picker cannot be seen or clicked. Commands still work too: {"action":"command","command":"<command id>","args":{...},"screenshot":true} runs one the plugin registered with ctx.registerCommand.
  4. Tell the user it is running in the sandbox. They can open the window from the sandbox card in the chat or the sandbox card in the right-hand summary panel, try it, report a problem back to this chat, and install it with Install in my Forsion, which asks them first.

Before acting in the sandbox, read references/plugin-sandbox.md. Since 2026-11-15 (desktops declaring plugin.sandbox-v2): read marks toggles (pressed) / (not pressed) and fields that won't take typing (read-only), so check a toggle's state before clicking it; a notification covering the target is closed first; a command still running after ~1.5 s returns pending: true (don't run it again: read the window and continue there); settings opens this plugin's settings page in a separate window (then window: "settings", references s12).

What the sandbox is: a separate Forsion with its own empty vault and data, signed out, without the Tangu engine, where only this plugin is loaded, plus the built-in plugins it lists in requiresPlugins (others, such as Forsion Extend or Calendar, are not there; declare what you depend on). The Ribbon shows only this plugin's Spaces. So a bundle's engine half (plugins/, agents/, skills/), anything that needs a signed-in account or cloud sync, and plugins that declare fileExtensions (blocked for dev copies) cannot be verified there; say so and test those after the user installs. Only one sandbox runs at a time; reset wipes its data and starts fresh; stop closes it.

No plugin_sandbox (mobile, web, cloud sessions, older desktop builds)? Fall back to tools/check-plugin.mjs and ask the user to try it. Coding Studio's Sandbox panel also has a My Forsion tier: that one loads the dev copy into the user's real app and real notes and is not isolated.

通用纪律

  1. 先有动机再做:每个扩展要能指回一条真实痛点,说不出就别做。
  2. 注入模型的文本一律英文:工具 description、参数说明、promptSection —— 给模型读的全英文;用户可见字段用 name/nameEn、description/descriptionEn 双语镜像。
  3. Stable English IDs: external plugin manifest IDs must match ^[a-z0-9][a-z0-9-]{0,63}$ (lowercase ASCII letters, digits and hyphens, 1–64 characters). Use an English name for new IDs; keep existing published IDs stable. Localized name / nameEn are display labels, never storage identities. Namespace command/slash/tool IDs because they share global registries; a theme ID is its data-theme value. Store installs use the host's immutable market-<UUID> effective ID; do not replace it with the manifest ID or rename historical install-folder aliases.
  4. 交付=能跑+能回归:非平凡逻辑留一个 check.mjs(node check.mjs 一条命令),范式见 forsion-plugin-mindmap / activitywatch 的 check 模式。Validation errors name the field: when a tool's arguments or a document your code saves fail validation, put the field path and what is wrong into the tool result (data.example: missing "zh"), not one generic line like "does not match the schema"; the model can only fix what the error shows it. Keep one negative case in check.mjs: break one field on purpose and assert the error names that field.
  5. 动作性能力住引擎侧,渲染端命令只做导航(2026-08-24 拍板):注册任何入口前先问一句——这是导航(开视图/切面板)还是动作(带参数、可 headless 完成的活,比如「分析这条链接」)?动作不要做成命令面板命令:Command.run(): void 类型上就没有参数位,而且命令表活在渲染进程,聊天 agent 与自动化都够不着。正确做法=把能力做成捆绑包的引擎侧资产,零通道基建。先选对形态:靠引擎已有工具就能复现的动作 → 包根 skills/<slug>/SKILL.md(全局技能,默认选它,进所有 agent 的技能目录,use_skill 直接用);要专属人设 / 独立上下文预算 / 稳定的自动化入口 → 才建 agents/<slug>/ 具名 agent(+ 它自己的 skills/),聊天 agent 经 delegate(agentSlug)、自动化经 agent_run 调用(⚠️agent_run 必须指名 agentSlug,只发全局技能的 bundle 靠被指名的那个 agent 身上带着这份技能来够到)。需要桌面主进程能力时引擎侧已有桥工具(如 transcribe_audio 语音转写)。范式=青鸟收藏夹:工作台 UI 归渲染端插件,分析管线归 bundle 内嵌的 bluebird agent+技能,两个入口(人点工作台 / agent 委派)共用同一条引擎管线。

Desktop plugin UI: use the host's parts (2026-10-29+)

A view that draws its own dropdowns, menus, dialogs or tab bars looks foreign in Forsion and stops following the user's theme, language, UI zoom and every later host fix. The host draws these for you: reach for a part first, and hand-draw only what no part covers (your content itself: rows, cards, charts, canvases).

| You need | Use | Not |

|---|---|---|

| Several panes or tabs in a Space | native Panels in space.json; several views in one panel = native tabs (见下「布局:原生 Panel 优先」) | a tab bar inside one view |

| A title row with buttons | ctx.ui.setViewHead(el, { title, actions }) | your own header bar |

| A dropdown (sort, filter, pick one) / 2–5 modes | ctx.ui.mountControl(el, { type: 'select' }) / { type: 'segmented' } | <select>, a listbox you position |

| A ⋯ or right-click menu | ctx.ui.contextMenu({ anchor, align: 'end' }, entries) | a .my-menu div |

| Confirm / ask for a name / a small form | ctx.ui.confirm({ title, danger }); ctx.ui.openDialog({ title, mount, actions }) with your input in mount | window.prompt (does nothing in the desktop app), window.confirm, <dialog>, a modal div |

| A panel anchored to a button | ctx.ui.popover(anchor, { mount }) | position: fixed and your own math |

| Nothing yet | ctx.ui.mountEmptyState(el, { icon, title, line, action }); a list source's empty | a centered line of text |

| A sidebar list | ctx.registerListSource (references/list-sources.md) | a list view in the left pane |

| Buttons and icons | classes .btn .btn.primary .btn.ghost .btn.danger .btn.sm; ctx.ui.icon(name, { size }) | hand-styled <button>, pasted SVGs |

| CSS and labels | ctx.addStyle(css) with public tokens only (样式契约, next); labels as { zh, en } or ctx.i18n.define | <style> in document.head; strings frozen at registration |

| Your plugin's settings page | ctx.registerSettingsPage({ title, mount(page) { page.update({ groups }) } }) (2026-11-18+; older hosts: registerSettingsView + ctx.ui.mountSettingsPage) | a settings page drawn with copied .settings-* CSS |

| Settings, chat box, Markdown editor, table, board | ctx.registerSetting / ctx.ui.mountSettingsPage, mountChatBox, mountMarkdownEditor, ctx.table.mount, ctx.ui.mountBoard | your own copy |

Signatures and details: references/host-ui-mounts.md, section "Host parts" and the one for each mount. The bundle template's counter view (samples/forsion-sample-bundle/main.js) uses the parts; copy from it.

Check it. node tools/check-plugin.mjs <plugin folder> --style lists, under "UI parts", what the plugin still draws itself where a part exists, and plugin_sandbox adds the same list to every status it returns. It reports, never blocks: fix what you can and keep the rest only on purpose. A plugin whose UI is a web page in an iframe is still allowed (host tokens and theme don't reach it); mark that page's CSS lines /* forsion-style: off */.

样式契约:能依赖的宿主类名与 token(2026-10-26 起)

宿主把插件可以依赖的类名和 CSS 变量发布在 tools/plugin-contract.json(每个带用途,随 apiVersion 升级)。清单外的宿主类名 / 变量

随时可能改名或删掉:不报错,只是某天界面塌了或变了色。

.ctx-separator、.ctx-shortcut、.ctx-head、.ctx-menu-scroll)、.empty-state / .empty-title。私有前缀 .amx-*(编辑器、数据库浮层、⌘P)、

.fc-*(内置日历)、.t2-* 别借;自己的类名用自己的前缀。

外加 --focus-ring。契约只列名字不列值:值跟着设计语言 / 主题色 / 背景色走。--ease-out、--ease-spring、--ease-apple、--dur-*、--radius-xl 已弃用。

菜单、浮层、普通卡 --radius-md;面板、对话框 --radius-lg;胶囊 --radius-pill,圆写 50%。和外框成对的内圆角写 calc(var(--radius-md) - 4px),

不另写数字。--radius-xl 换 --radius-lg(宿主留着别名,只为老插件不掉角)。

比你的 minAppVersion 新(契约的 since 表),兜底留给老宿主;--reading-* 两个本来就带兜底。

压在画面上的白字)写关键字 black / white,一看就知道是故意的;检查只认 #hex / rgb() / hsl()。

≥4px 的圆角、带色阴影。只报不拦,不改退出码。给另一份文档用的 CSS(iframe 里的页面、导出文件,那里没有宿主变量)在同一行写

/* forsion-style: off */ 跳过;打包把一个模块压成一行时,一个标记管整行。缺省只列前 300 条,数到清零要加 --all。

引擎插件(samples/forsion-sample-plugin)

三个常用贡献点:工具(sample_greet)、设置 schema(text/toggle,设置页通用渲染)、promptSection(启用时注入系统提示)。硬约束:

装本机:整夹拷到 ~/.forsion/plugins/<id>/ → 设置页重扫即生效,不用重启。同 id 覆盖升级也是重扫即热换代:单文件入口(esbuild 打成一个 bundle,推荐)直接换;多文件的纯 ESM 包("type": "module",入口相对 import 同包文件)在 Node ≥ 22.15 上也能整包换代。宿主证明不了整张模块图都会换代的,如实标「需重启」:包里有 CommonJS(.cjs、require('./x')、createRequire 造的函数)、原生 .node、任一层自带 node_modules、软链、import(变量)、引到插件目录外的文件,或运行时太旧。同一进程里热换代满 20 次后也一律「需重启」(旧模块卸不掉,省内存)。

主题(samples/forsion-sample-theme)

双轴模型:语言(结构:圆角/字体/阴影/布局)× 配色(颜色)× 明暗。磁盘主题装 ~/.forsion/themes/<id>/,目录名必须 == id。

line-height、段间距或 wb-view-enter 的时长写死 —— 写死了,用户拨那几个开关就没有反应。

动效主题(设置 → 外观,<html data-motion-theme> = genesis / droplet / stretch / glide,外加 data-motion-fade="on"「只淡入淡出」)归用户:theme.json 可写 "motionTheme": "<四者之一>" 建议一套,只在用户从没选过时生效;插件不读不写这两个属性,也别写死某一种效果 —— 用宿主的分段胶囊 / 开关 / ctx.ui 零件,自动跟着走。

Space(samples/forsion-sample-space)

space.json 声明视图布局配方(引用视图类型 id;插件视图用 plugin:<插件id>:<视图id> 并在 requires.views 声明)。纯数据,无代码。

For a Space bundled at spaces/<slug>/space.json, "autoDesktopShortcut": true asks the installed desktop host to create a shortcut once when it registers the enabled plugin’s Space. Deleting or moving it is respected across reloads, updates, and restarts. Users can create it again from the Space menu. Older hosts ignore this field.

图标:`icon` + `iconFile`(2026-10-04 起)

图标库只有 30 枚,几个 Space 一多就撞图标。给 Space 配一枚自己的图:

{ "icon": "video", "iconFile": "icon.png" }

所以 "iconFile": "icon.png" 而 Space 目录里不放图 = 直接用插件图标;想单独画一枚,就把图放进 spaces/<slug>/。

布局:原生 Panel 优先(2026-10-02 起规)

插件视图先摆进宿主的原生 Panel,别在一个 view 里自造侧栏、底栏、分栏 —— 原生 Panel 自带标签、拖宽、折叠、

mod+J、布局记忆和移动端抽屉,自造的一样都没有,还和别的 Space 长得不一样。按内容找位置:

| 内容 | 放哪 | 怎么写 |

|---|---|---|

| 可打开项的列表(工程、收藏、会话) | 左栏统一工作区 | registerListSource + layout.left: [{ "type": "workspace", "params": { "mode": "plugin:<id>:<列表源>" } }] |

| 主体(编辑器、播放器、详情) | 主区 | layout.main;要并排的另一份原生视图(笔记、聊天)用 split: "right" / "down" 分栏 |

| 这种主视图通常要的属性 / 检查器 / 对话 | 右栏 | 在 registerView 上写 rightCompanions(见下「右栏:主视图规则」);本 Space 的缺省组写 layout.right |

| 点了某一行 / 某个事件才出来的详情、表单 | 右栏临时 | Extend View(view.extendView.open({ side: 'right' })) |

| 横跨全片的时间线、日志、控制台、终端 | 底部面板 | layout.bottom(2026-10-02 起)或 ctx.openView(id, { location: 'bottom' }) |

视频工作室(左 = 工程列表;主区 = 舞台与走带;右 = 属性 Extend View;底部 = 时间线)。

拆不开的 DOM 可以整块搬进另一个 view 的 el(事件监听跟着走),样式随之注入。

靠 postMessage 驱动的预览要在帧每次报告就绪时把时间、播放状态补发回去,不能只听第一次(否则画面一直是黑的)。

会让只缺子任务的宿主连输入框位置也退回去)。选项层面、?. 看不出来的查能力清单:ctx.listCapabilities、

ctx.ui.chatBoxCapabilities、ctx.table.caps。

当主区打开,会把当前主视图导航走。查 ctx.viewLocations?.includes('bottom')(移动端没有底部面板,不含它)。

主视图让出内容的判据 = 配方传给它的参数(如 { "timeline": "bottom" })且 viewLocations 含 bottom;任一不满足就在 view 内自绘。

registerView 上声明 rightCompanions,它到前台时右栏就换成这组;没声明就用本 Space 的 layout.right。

```js

ctx.registerView({ id: 'session', title: 'Session', mount, rightCompanions: ['plugin:diting:chapters', 'chat-panel'] })

```

右栏收着只换暂存、不弹出来;新建标签页不算。用户自己开 / 拖进右栏的视图规则永远不关;配方里 "pinned": true 的右栏条目恒在。

回到你的主视图再回来。不想让位的条目写 "pinned": true。

amadeus-graph / calendar-side,或你自己的视图。主区实体(chat、amadeus-editor、amadeus-pdf…)会被滤掉;右栏要对话写

chat-panel(layout.right 里写 chat 的老配方,宿主按 chat-panel 开)。最多 4 项,建议 ≤ 3(侧栏标签只有图标,4 个就溢出)。

只对没写 mode 的老配方生效,新插件别用。

改了 layout 要抬 version,否则用过这个 Space 的人永远停在旧布局。

进这个 Space —— 从别的 Space 切进来、冷启动、人已在里面再点一次它的图标 —— 前台先是这个视图,不是上次离开时的前台;

别的标签照旧留着,只退到后台;主区里没有它就开一个。不写 = 缺省「还原上次离开时的样子」。通常和 "pinned": true 一起写:

不固定的话,命令里「先切过来再 openView」会把它就地换掉。旧宿主忽略该键。

底部收起;打开项目后左栏换成项目自己的内容(素材、对话),底部开出时间线 / 终端。换法:

ctx.replaceView?.('nav', 'media') —— 只换自己的视图,原地换(同一块面板、尺寸不变、不重建布局,所以主区

里的 iframe 不会重载);面板收着就只换暂存、保持收着;Space 的面板默认值跟着换。回到启动台反过来换,再

ctx.closeView?.('timeline') 收起底部(关掉底部最后一个视图 = 面板收起,与用户点 × 一样)。侧栏要收起就带

{ collapse: true }(2026-10-18 起):那一侧只剩这个视图时整侧收起、视图进暂存(用户展开或你下次 openView 时回来),

不留「空侧栏」占位;侧栏里还有别的视图就照常关。旧宿主忽略这个选项、照旧留占位。像蓬洲云概览那样「这一页不要右栏、

别的页出详情」就这么写。replaceView 返回 0 = 那个视图

哪儿都没开着(用户关了它,或布局已经是项目态):别拿 openView 兜底 —— 它会把用户收起的面板弹出来。

旧宿主没有这两个方法:左栏就一直是导航(视频工作室这么做:旧宿主上没有素材区,时间线仍画在编辑器里);

非要内容就 openView(id, { location: 'left' }) 多开一个标签,底部不动。

⚠️ 进出项目的布局跳转会让宿主重挂主区那一列(主区视图卸载再挂上;10-02 真 Electron 实测进、出各一次,⌘J 开合

不会)。两条后果:① 跨这一下要留的临时状态(新建页里填的想法、刚选的模板)放模块作用域,**等用户真正用掉

(发送 / 清空)才清** —— 别在第一次交给界面时就清,即将被卸掉的那一份可能先拿到;② 关项目时,新挂上的那份

会按「参数里的文件 → 模块里的当前项 → 存盘的上次打开」找项目:先把这三样清干净(存盘那步要 await)再拆界面、

换布局,否则它会把刚关的项目又打开。

范例:视频工作室(导航 ↔ 素材,底部时间线随项目开合;仪器 npm run verify:docked)。

Mini Panel 适配

A Space that should also open as a small floating window gets a mini block in space.json: read references/mini-panel.md before you add one.

智能体(samples/forsion-sample-agent)

文件夹式:config.toml(名字 name_zh / name_en、模型/工具/技能开关)+ SOUL.md(人设,英文写给模型)+ Library/(参考资料)+ 每-agent 记忆。装 ~/.forsion/agents/<slug>/。

捆绑包(samples/forsion-sample-bundle)—— 默认起点

新扩展默认从这个模板起步:除非明确只做主题或单个纯数据 Space/智能体,插件类工作一律用 bundle 布局(只填用得上的子目录即可,单一内容的 bundle 完全合法)。一个 Forsion 桌面插件目录内嵌引擎侧/跨域内容,装进 ~/.forsion/plugins/<id>/ 一处全就位。识别全靠标志文件,manifest 无新增字段;所有子目录可选,纯捆绑包连 main.js 都可省:

<id>/manifest.json                     ← bundle 标志(普通 Forsion 插件 manifest)
     main.js                           ← UI 部分(可省)
     tangu-plugins/<pid>/tangu-plugin.json   ← 内嵌引擎插件:引擎原地加载(优先级最低,顶不掉手装同 id)
     skills/<slug>/SKILL.md            ← 内嵌全局技能:引擎原地扫描(内置 < bundle < 用户)
     agents/<slug>/config.toml         ← 内嵌 Agent:人格面播种一次,其 skills/ 指纹自愈
     spaces/<slug>/space.json          ← 内嵌 Space:随插件启停显隐(图标见上文 `iconFile`)

多账号模式(一台机器上多个账号共用一个引擎进程):引擎只从 bundle 里取 agents/ 的人设和 skills/ 的技能(只读),tangu-plugins/ 引擎代码不加载、插件自带的 MCP 与 hooks 不启动。要在这种模式下可用,核心能力放进人设和技能,别依赖引擎插件。缺省单人模式照旧全部加载。

多账号模式下技能要跑脚本(2026-11-23 起):这种模式没有 run_bash,Agent 用 run_plugin_script({ skill, script, args }) 跑包里技能目录下的脚本(如 skills/<slug>/scripts/transcribe.py)。在 SKILL.md 里把两种调法都写上:有 run_plugin_script 用它,没有(单人模式)用 run_bash。规矩:

三种生命周期,发包前必须分清:

| | 谁 | 升级时 |

|---|---|---|

| 随包 | 引擎插件、Space | 父插件禁用即级联关闭/收起,卸载一并消失 |

| 播种一次 | Agent 的人格面(config.toml / SOUL.md / Library / MEMORY) | 首次发现拷入引擎成为活体,永不覆盖,卸载保留 |

| 指纹自愈 | Agent 的 skills/(2026-08-25 起) | 每次启动比指纹:用户没动过的跟着 bundle 更新;动过的(含无指纹老副本)保护不覆盖并在引擎日志报出来 |

上架商店后的安装目录与运行身份(2026-10-17 起):商店给每个条目一个不会变的 ID,新上架的条目装进 plugins/market-<ID>/(引擎插件是 ~/.tangu/plugins/market-<ID>/),和显示名无关,显示名可以重复。装在这种目录里的插件以目录名为运行身份:包里的引擎插件照常按这个目录名挂 scoped 路由,ctx.tangu.request 由宿主拼好,不用管;单独上架的引擎插件 ctx.paths.dataDir 在 plugin-data/market-<ID>/,注册的工具名会被宿主改写成 market_<原名前 16 位>_<哈希>(两份同 id 的插件互不顶替),所以提示词和文档里别让模型按字面工具名去调;sdk.runs.start 的 toolNames 与 sdk.automation.save 的 tool 照写原名,宿主自己换。别的插件在 requiresPlugins 里写你 manifest 的 id 照样认得到,前提是只装着一份。这种条目只有 2.13.4 之后的桌面版本装得了,旧桌面会收到「请先升级 Forsion」。更早上架的条目保留原来由显示名推出的目录名:其中带引擎插件的包在桌面 2.13.3 及更早的版本上,目录名和 manifest id 不一样时页面调不到包里的引擎插件(每次 404、不报错)。没有引擎插件的包不受影响。

包根 skills/(全局技能)是原地扫描、不落盘拷贝,不在上表内。因此 onboarding 里不要 recommends 自家已内嵌的 agent/skill(会引导去商店重复装)。真实范例:Forsion-Instrumentality-Project/bluebird/。

插件自带的 MCP server 与 hooks(2026-10-17 起;只收 stdio MCP、只开观察档 hooks)

A bundle can declare stdio MCP servers and observe-only hooks in its manifest: read references/bundle-mcp-hooks.md before you add either.

把动作搬进引擎侧:三档路由(通用纪律 5 的落地写法)

发现某个能力「只有点命令面板才能用」时,把它做成 bundle 的引擎侧资产(形态按纪律 5 选:默认包根 skills/,真需要专属人设/上下文预算/自动化入口才加 agents/<slug>/),然后在通用技能里写一张降级路由表(照抄 bluebird/skills/bluebird-link/SKILL.md)。只发全局技能时第 2 档不适用,直接写「自己做 / 指去工作台」两档即可:

  1. 我自己就有那份技能(即我就是那个专门 agent)→ use_skill 直接做。这一档必须排最前,否则专门 agent 会委派自己。
  2. 有 delegate 工具且当前是本地库 → delegate({ agentSlug: "<slug>", task }),task 里带真实库根路径并要求它自己落盘、回报路径;顺带如实说明「委派产物不进插件侧栏索引」。
  3. 都不行(没 delegate / 云端库 / 第 2 档失败)→ 让用户从命令面板打开工作台自己操作。

需要桌面主进程能力时(语音转写、系统面)引擎侧已有 MCP 桥工具,如 transcribe_audio(path, timestamps?) —— 它在没开桌面/云端 worker 上自动隐身。调用方明确说了「我自己接力转写」时,即使工具可见也不要调。子 agent 继承父会话的审批档位,不是它 config 里的 approval_mode。

发布到商店

上架的地方叫 Forsion 商店——界面里的名字就是「商店」(英文界面 Store),不叫「应用市场」「插件商店」或 Market。过审后,用户从桌面端功能区底部的「商店」入口进去,在对应分类(插件 / 技能 / 主题;Agent 与 Space 归在「插件」分类下)里一键安装。给用户指路时照这个名字说。

推成独立 GitHub 公开仓库(引擎插件记得含 dist/)→ 商店 → 投稿 选对应类型给仓库链接或传 zip(zip 内容放根或单层文件夹,两层路径装不了)。捆绑包(默认形态)按 amadeus-plugin 类投稿(桌面按包内 manifest 实测路由,自然落进 ~/.forsion/plugins/)。GitHub 来源会锁定过审时的 release tag,发新版需重新过审。

发新版 / 改信息(2026-10-24 起):在「投稿」里选中自己的条目。ZIP 拖进新包;GitHub / npm 先在原渠道发新 Release / 新版本,再点「检查新版本」(从没打过 Release 的仓库没有可锁的版本,先发一个 Release)。版本号只从包里 / 上游读,投稿页没有版本输入框:manifest 写 version,技能写 SKILL.md frontmatter 的 version 或 metadata.version(两处都认,桌面检查更新用同一条规则),新版要高于商店当前版本。提交前服务端先把包检查一遍(只读、不落库),列出读到的类型、版本、图标、README 和包体提醒,作者确认后才真提交。简介、标签、长描述、版本要求可以在「商店信息 → 编辑」里单独改,不用传包、不升版本。已上架条目的新版本和信息改动都要过审,审核通过前商店照旧发原来的;审核结果发到投稿账号的收件箱。升版号必写 CHANGELOG.md 一节(## x.y.z — YYYY-MM-DD),宿主会渲染成插件详情页的更新日志。

用户侧自动更新与回退(桌面 2.13.8 起):商店插件缺省自动更新(后台下好、下次启动换上;用户可全局或按插件关掉)。换版前旧版本留在本机(~/.forsion/.plugin-versions/<类型>/<目录名>/<版本>/,每个插件最近 2 份),用户能一键回退;回退或从「版本」页装旧版 = 固定在那一版,直到用户「恢复自动更新」。⚠️ 回退只换插件文件,数据不回退(工作文件夹、plugin-data、设置原样):改数据格式时让旧版读新数据也不出错(忽略不认识的字段、别把旧数据原地改成旧版读不了的形状),或新格式写新文件。核心插件(Extend / 日历 / Computer Use)跟桌面版本走,不参与。

商店来源:自己维护一份目录,不走投稿(2026-11-08 起)

不想每版都过审、或东西很多时,让插件在商店左栏「来源」里挂一份自己维护的 forsion-store.json(manifest storeSources,GitHub / npm / https / Forsion Git 私有仓)。来源只交目录,下载安装照常走商店。写之前读 references/store-sources.md。

投稿元数据、版本要求与评论(2026-10-17 起)

Android App 与 `isDesktopOnly`(2026-10-02 起)

Forsion Android App 也跑 Forsion 插件(同一份 pluginStore、同一个 ctx),只经市场装、只装 amadeus-plugin 类;插件住在 App 私有目录,ctx.loadData / ctx.saveData 照常可用。

Agent 自建 Space(2026-09-11 起;今天没有 agent 在用)

契约与 ctx.agent 在 references/agent-space.md。Muse 11-08 起改用下面的布局,不写 main.js。

Muse: Today's brief layout (from 2026-11-08, Muse only)

Muse's Space no longer loads main.js (it stays on disk; do not edit it): the desktop draws the "Today's brief" template from two local files. agents/muse/Space/space.json is Muse's part (the one-line message, ≤160 characters, may link [[Library path]]; up to 3 prepared Library files; proposed cards), written with the muse_space tool: read first, then update only what changes, with expectedRev. <tangu home>/ui/muse-space.json is the user's grid (order, hidden, placed cards, tombstones of rejected proposals): Muse cannot write it, move or remove cards, or re-propose a rejected key. At most one message change and one proposal per cycle; muse_space widget creates Muse's own native widget to propose. A broken space.json is shown from its last valid version and never repaired automatically.

Desktop plugin APIs: rules that hold everywhere (details moved to references/ on 2026-11-23)

The full API table and the per-topic contracts are in the reference files listed at the top; start from references/contribution-points.md for "which ctx entry does this" and references/host-data-sources.md for "where does this surface read its data". The rules below are the ones people break most; each links to its full text.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.