cladogram 0.5.5-beta.5 → 0.5.5-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,135 +0,0 @@
1
- # Clado 本地插件实验入口
2
-
3
- 从源码启动当前工作区。开启开关即启用该工作区下通过校验的插件,并授予它们清单中声明的权限。只在你信任的项目里开启。
4
-
5
- ```sh
6
- node bin/clado.js serve /path/to/project --experimental-plugins
7
- ```
8
-
9
- 在「插件管理」选择「安装插件」,选中包含 `clado-plugin.json` 的构建目录,核对清单权限后确认。Clado 校验清单、入口和兼容性,将包保存到 `.clado/plugins/<插件 ID>/`。也可以预先将构建好的目录放在 `.clado/plugins/`,服务启动时读取。启动时跳过包的原因会输出到终端。
10
-
11
- ```text
12
- .clado/plugins/review/
13
- ├── clado-plugin.json
14
- └── ui/
15
- ├── index.html
16
- └── main.js
17
- ```
18
-
19
- 例如,一个读取当前文档和选区的侧栏挂载可以声明以下清单。
20
-
21
- ```json
22
- {
23
- "manifestVersion": 1,
24
- "id": "example.review",
25
- "name": "Review",
26
- "version": "0.1.0",
27
- "engines": { "clado": "^0.5.3" },
28
- "protocols": ["1.0"],
29
- "entrypoints": { "ui": { "path": "ui/index.html" } },
30
- "permissions": ["ui.mount:sidebar", "canvas.document.read", "canvas.selection.read"],
31
- "contributes": { "mounts": [{ "id": "review", "slot": "sidebar" }] }
32
- }
33
- ```
34
-
35
- 每项本地挂载启动独立的 iframe。支持 `top-left`、`top-right`、`bottom-left`、`bottom-right`、`topbar`、`bottombar`、`sidebar` 和 `canvas-overlay`。`topbar` 是顶部中间的悬浮插槽。UI 使用 `ui/` 下的本地脚本、样式和素材,样式写在独立的 CSS 文件中。通过以下脚本标签加载宿主 SDK。
36
-
37
- ```html
38
- <script src="/clado-plugin-sdk.js"></script>
39
- <script type="module" src="./main.js"></script>
40
- ```
41
-
42
- ```js
43
- const plugin = await CladoPlugin.ready;
44
- const context = await plugin.getContext(['document', 'selection']);
45
- ```
46
-
47
- SDK 通过消息端口完成 `clado.hello` 和 `clado.register`,并将 `getContext` 映射到 `clado.call`。每次读取取得当前页面的快照。文档切换期间可以重读,挂载实例在工作区页面存活期间持续使用。
48
-
49
- | 字段 | 所需权限 | 结果 |
50
- | --- | --- | --- |
51
- | `document` | `canvas.document.read` | 当前文档的相对路径、标题、版本、视图和主题 |
52
- | `selection` | `canvas.selection.read` | 按点选顺序排列的标题路径、正文和各自的子节点 |
53
- | `graph` | `canvas.graph.read` | 节点、父子关系和同文档的引用边。返回 `items`、`revision`、`nextOffset` |
54
- | `viewport` | `canvas.viewport.read` | 当前视口的 CSS 像素宽高和缩放比例 |
55
-
56
- 读取图的后续页时调用 `getContext(['graph'], { offset: nextOffset, revision })`,沿用上一页 `graph.revision`,它与 `document.revision` 用途不同。切换文档或版本变化时从第一页开始。当前没有可读画布时,选区返回空数组,其他字段返回 `null`。
57
-
58
- ## 注册与调用能力
59
-
60
- 能力声明写在清单的 `contributes.capabilities` 数组中。每项含 `id`、承载它的挂载 `mount`、版本 `version`、用途 `description`,以及 JSON Schema Draft 7 的 `inputSchema` 和 `outputSchema`。输入和输出的顶层都是对象,服务在发出调用前和返回结果前分别校验。一个插件内的能力名与主版本组合必须唯一。改变必填参数、返回结构或行为含义时增加主版本,消费者在 `major` 中指定自己支持的版本。
61
-
62
- ```json
63
- {
64
- "id": "review.describe",
65
- "mount": "review",
66
- "version": "1.0.0",
67
- "description": "根据文件路径返回评审标题。",
68
- "inputSchema": {
69
- "type": "object",
70
- "properties": { "file": { "type": "string" } },
71
- "required": ["file"],
72
- "additionalProperties": false
73
- },
74
- "outputSchema": {
75
- "type": "object",
76
- "properties": { "title": { "type": "string" } },
77
- "required": ["title"],
78
- "additionalProperties": false
79
- }
80
- }
81
- ```
82
-
83
- 挂载初始化结束后传入该挂载声明的全部处理函数,键使用 `能力名@主版本`。服务登记完成后,能力才出现在查询里。
84
-
85
- ```js
86
- const plugin = await CladoPlugin.ready;
87
- await plugin.provide({
88
- 'review.describe@1'({ file }, { from, to, scope }) {
89
- // from.kind 为 plugin 或 agent。插件来源还含 pluginId 和 mountId。
90
- return { title: '评审 ' + file };
91
- },
92
- });
93
- ```
94
-
95
- 另一个插件先在自己的 `permissions` 中声明 `capability.call:clado.directory/directory.open`,再查询和调用。同一插件可查找自己的能力。调用来源由宿主补齐,目标使用 `pluginId`、`capability` 和 `major`,作用范围由 SDK 绑定到当前工作区和标签页。处理函数内部也可以调用别的能力。
96
-
97
- ```js
98
- const [open] = await plugin.listCapabilities({ pluginId: 'clado.directory', capability: 'directory.open', major: 1 });
99
- if (open) {
100
- const { output } = await plugin.call(
101
- { pluginId: open.pluginId, capability: open.capability, major: open.major },
102
- { file: 'design/checkout.mdc' },
103
- );
104
- console.log(output.file, output.title, output.mode);
105
- }
106
- ```
107
-
108
- 能力设置 `exposeToAgent: true` 后才向 MCP 开放。模型使用 `clado_capabilities` 的 `list` 获取在线标签页、能力和契约,再用 `call` 传 `workspace`、`to` 和 `input`。存在多个在线标签页时,调用必须传 `viewId`。Clado 的「灵感」面板会随每轮指令附上它自己的 `viewId`。服务将请求实时推送给目标标签页,并等待插件回执。标签页断开时注册随之失效。
109
-
110
- MCP 的 `tools/list` 提供固定入口。每次调用 `clado_capabilities` 的 `list` 都查询当前注册表,新注册的能力可当场发现和调用。原生截图能力 `clado.host/canvas.capture` v1 同时提供 `clado_screenshot` 快捷入口。两种调用都返回 MCP 图片内容和结构化的文件、版本、视图与尺寸。默认截图保留画布的展开和聚焦状态,`scope:"full"` 展开完整调用链,`mode` 指定截图视图,`source:"latest"` 读取本标签页最近一次成功生成的 PNG。
111
-
112
- 默认目录插件提供 `clado.directory/directory.open` v1。输入 `{ "file": "design/checkout.mdc" }` 为相对文档目录的路径。成功返回 `{ file, title, mode }`,此时目标画布已加载。文件未收录、标签页断开、版本不匹配、参数不符合契约或等待超时会返回错误。插件调用可读 `error.data.kind`,MCP 可读 `error.code`。调用超时后由调用方判断结果,再决定是否重试。
113
-
114
- 产品自带的插件在源码根目录的 [`plugins/`](../plugins/) 下。每个插件有自己的 `index.js` 和 `style.css`。
115
-
116
- | 目录 | 功能 |
117
- | --- | --- |
118
- | `plugins/brand/` | 左上角 Logo、字标、外观设置和截图 |
119
- | `plugins/view-controls/` | 右上角视图切换和状态控件 |
120
- | `plugins/directory/` | 左下角文档目录、搜索和文件名 |
121
- | `plugins/agent/` | 右下角的「灵感」ACP 对话面板 |
122
-
123
- 这些插件随 Clado 一起分发,在宿主内运行,能力契约放在各自目录的 `capabilities.json`,运行时通过宿主注册。工作区里的 UI 插件从 `.clado/plugins/` 加载,运行在隔离的 iframe 内。在线工作区提供能力通信。共享的样式见 [Clado 插件界面设计规范](plugin-ui.md)。
124
-
125
- 左上角 Clado 菜单里的「插件管理」列出内置插件和当前服务加载的工作区插件。「应用并刷新」保存当前浏览器的工作区偏好。停用的扩展不会挂载 iframe,也不会注册当前标签页的能力。Clado 设置始终可用。
126
-
127
- 每张插件卡片的「设置」打开 JSON 编辑器。配置按插件 ID 保存到项目的 `.clado/plugin-settings.json`。当前优先级为插件默认值 → 工作区字段覆盖。保存时校验字段和类型,再刷新页面使配置生效。插件的启停仍是当前浏览器的工作区偏好。
128
-
129
- 第三方插件可在清单声明 `configuration: { "schema": { "type": "object", … }, "defaults": { … } }`。`schema` 使用 JSON Schema Draft 7,`defaults` 可省略。iframe 通过 `(await CladoPlugin.ready).settings` 读取自身合并后的配置。插件设置由工作区保存,适用于项目内可共享的选项。
130
-
131
- ## 接入其他 ACP Agent
132
-
133
- ACP 规定客户端怎样与 Agent 建立会话、发送请求和接收流式更新。默认配置为 ZCode 的社区适配器 `zcode-acp-server`。在「灵感」设置中填写其他实现的 `command`、`args` 和 `env`,开启新对话即可换用。启动命令须以 stdio 提供 ACP,支持 HTTP MCP 的 Agent 还可直接操作画布。配置示例见 [ZCode ACP](https://github.com/william0wang/zcode-acp)。
134
-
135
- 在 Clado 内接入新 Agent 时,为服务端添加可选的 Agent 配置,明确指定其启动命令、参数、会话能力和权限处理,复用聊天面板及流式输出。工作区 UI 插件通过 iframe SDK 使用画布上下文和能力,Agent 进程从服务端连接。[ACP SDK](https://github.com/agentclientprotocol/agent-client-protocol/blob/main/docs/libraries/typescript.mdx) · [ACP 会话规范](https://github.com/agentclientprotocol/agent-client-protocol/blob/main/docs/protocol/v1/session-setup.mdx)
package/docs/plugin-ui.md DELETED
@@ -1,43 +0,0 @@
1
- # Clado 插件界面设计规范
2
-
3
- 画布始终铺到视口边缘。入口贴近它所作用的区域,默认保持小而安静。Clado 内置的品牌、视图控制和文档目录分别用 `clado.brand`、`clado.view-controls` 和 `clado.directory` 挂载,是这一套规范的实现参考。
4
-
5
- ## 挂载位置
6
-
7
- | 插槽 | 适合放什么 |
8
- | --- | --- |
9
- | `top-left` | 产品标识、全局设置入口 |
10
- | `top-right` | 三视图切换和作用于当前画布的操作 |
11
- | `bottom-left` | 工作区导航、文档树和当前文件名 |
12
- | `topbar` / `bottombar` | 居中的紧凑工具组,宽度随内容收缩 |
13
- | `sidebar` | 需要持续查看的面板 |
14
- | `canvas-overlay` | 短时提示或跟当前画布内容有关的操作 |
15
-
16
- 默认边距为 16px,插件间距为 8px。浮层收起时只保留触发控件,画布能接收其周围的点击、拖动和滚轮。小屏优先保留操作和辨识度,路径可以截断,完整名称保留在提示中。短标签适合工具组,详细信息放进展开的面板。
17
-
18
- ## 色彩、玻璃与状态
19
-
20
- | 项目 | 可用样式 |
21
- | --- | --- |
22
- | 文本和辅助信息 | `--clado-ui-text`、`--clado-ui-muted` |
23
- | 交互强调 | `--clado-ui-accent`、`--clado-ui-active` |
24
- | 控件和面板表面 | `--clado-ui-surface`、`--clado-ui-panel-surface`、`--clado-ui-solid`、`--clado-ui-well` |
25
- | 边界和反光 | `--clado-ui-edge`、`--clado-ui-highlight`、`--clado-ui-rim` |
26
- | 层次 | `--clado-ui-radius`、`--clado-ui-shadow`、`--clado-ui-gap` |
27
-
28
- 轻量控件用 `clado-ui-glass`,依靠柔和的反光和投影轮廓与背景分离。文档树和对话面板再加 `clado-ui-glass-panel`,用独立的填充和模糊参数兼顾透光和文字清晰度。模糊覆盖玻璃表面并在外缘柔和过渡,让背后的画布只透出色块和轮廓。表单内层可以使用半透明的 `--clado-ui-well`,源文预览使用统一实色。浏览器不支持模糊或用户要求减少透明度时,玻璃外壳使用实色。[Apple 材质规范](https://developer.apple.com/design/human-interface-guidelines/materials) · [网页效果参考](https://lite.ego.app/zh-cn)
29
-
30
- 紧凑控件采用 13px 系统字体,桌面工具栏按钮至少 32px 高,外层工具组约 44px 高。按钮统一使用 `clado-ui-button`,保留圆角矩形和细边框,用半透明的浅色底表达悬停和选中,主操作再加 `clado-ui-button-primary`。为图标按钮设置名称,用 `aria-pressed` 标示视图选择、用 `aria-expanded` 标示面板开合、用 `aria-current="page"` 标示当前文档,并保留可见键盘焦点。错误状态同时用文字表达。轮询取得的新状态和当前显示相同,保留原来的 DOM。
31
-
32
- ## 在隔离插件里使用
33
-
34
- 插件可加载宿主的共享 CSS,然后加载本包样式做针对性补充。SDK 会在启动和主题切换时更新插件根元素的 `data-theme`,插件可以直接使用上表的属性。宿主为隔离 iframe 提供玻璃外壳。插件页面把 `html` 和 `body` 设为透明时,能透出宿主模糊后的画布。
35
-
36
- ```html
37
- <link rel="stylesheet" href="/plugin-ui.css">
38
- <link rel="stylesheet" href="./panel.css">
39
- <button class="clado-ui-glass clado-ui-button" aria-pressed="false">查看选区</button>
40
- <script src="/clado-plugin-sdk.js"></script>
41
- ```
42
-
43
- 左上角的品牌图标和字标打开设置菜单,可以切换日间与夜间模式,勾号标记当前外观。「截取当前画布」沿用画布的展开和聚焦状态。右上角三视图切换使用共享的玻璃外壳,半透明滑块标记当前视图。