@ai_mind/ade-plugin-sdk 0.1.1 → 0.2.1
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.
- package/README.md +69 -10
- package/index.d.ts +5 -1
- package/package.json +32 -8
- package/types/ade-types.d.ts +38 -176
- package/types/api.d.ts +1 -42
- package/types/plugins.d.ts +31 -0
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
| 开发条件 | 要求 |
|
|
20
20
|
| --- | --- |
|
|
21
|
-
| ADE | 0.
|
|
21
|
+
| ADE | 0.46.0 或更新的 0.x 版本;使用 SDK 0.2 的新增接口时需要此版本 |
|
|
22
22
|
| Node.js | 18 或更新版本;用于 npm 安装和构建 |
|
|
23
23
|
| 插件 API | `apiVersion: 1` |
|
|
24
24
|
| SDK | 安装 `@ai_mind/ade-plugin-sdk@0` |
|
|
@@ -36,7 +36,7 @@ SDK 与 ADE 的 **major 必须相同**。minor 和 patch 分别发布。
|
|
|
36
36
|
| `plugin.json.apiVersion` | 插件宿主 API 协议版本 | `1` |
|
|
37
37
|
| `plugin.json.version` | 你自己的插件版本 | `1.0.0` |
|
|
38
38
|
|
|
39
|
-
SDK major 相同不代表所有 ADE minor
|
|
39
|
+
SDK major 相同不代表所有 ADE minor 都提供相同能力。基础区域和 slot 从 ADE 0.45.0 起提供。SDK 0.2 增加的文件菜单、工作区操作和提示接口要求 ADE 0.46.0 或更新版本。使用以后增加的 API 时,先确认用户的 ADE 提供该 API。
|
|
40
40
|
|
|
41
41
|
builder 根据已安装 SDK 的 major 写入 `adeMajor`。如果 manifest 已声明不同 major,构建失败。手写 JavaScript 插件也应声明 `adeMajor`。
|
|
42
42
|
|
|
@@ -70,6 +70,9 @@ main 和 renderer 是两个独立实例。它们不共享变量、服务注册
|
|
|
70
70
|
| 文件工具按钮 | `editor.toolbar` slot | 统计文件、复制路径、运行检查 |
|
|
71
71
|
| 插件设置组件 | `settings` slot | 自定义配置表单、连接测试 |
|
|
72
72
|
| 自定义扩展位置 | SDK `Slot` 与 `registerSlot` | 允许其他插件扩展你的工具栏 |
|
|
73
|
+
| 文件树菜单 | renderer `registerFileMenu` | 为目录和文件增加操作 |
|
|
74
|
+
| 编辑器与文件树交互 | renderer `ctx.workspace` | 打开文件、刷新目录、检查未保存状态 |
|
|
75
|
+
| 操作提示 | renderer `ctx.ui.showToast` | 显示结果或带链接的提示 |
|
|
73
76
|
| 文件、项目与 worktree 操作 | renderer `ctx.api`;main 内置服务或 Node.js | 读取文件、创建文件、查询 worktree |
|
|
74
77
|
| 对话与 agent 接入 | main `registerAdapter`;renderer `ctx.api.chat` | agent CLI、模型 SDK、会话工具 |
|
|
75
78
|
| 配置与持久数据 | `getConfig/setConfig`;main `dataPath` | 用户选项、插件缓存 |
|
|
@@ -79,7 +82,7 @@ main 和 renderer 是两个独立实例。它们不共享变量、服务注册
|
|
|
79
82
|
### 2.3 当前边界
|
|
80
83
|
|
|
81
84
|
- 功能区域是 ADE 布局中的 React 区域。注册区域不会创建 Git worktree。
|
|
82
|
-
-
|
|
85
|
+
- 插件区域与核心区域使用同一布局。用户可以移动插件区域。`registerView` 不能替换核心编辑器或聊天组件。
|
|
83
86
|
- UI 上下文只提供项目、worktree 和当前文件的路径。它不提供编辑器实例、未保存正文或选区。
|
|
84
87
|
- 读取文件得到磁盘内容。统计未保存草稿需要以后提供的编辑器扩展 API。
|
|
85
88
|
- API 添加项目或创建 worktree,不会自动切换界面的当前选择。
|
|
@@ -414,14 +417,31 @@ renderer 和 main 都可以 `registerCommand`。main 上下文没有 `executeCom
|
|
|
414
417
|
| `title` | 中文区域标题 |
|
|
415
418
|
| `component` | React 组件,接收 `PluginComponentProps` |
|
|
416
419
|
| `defaultVisible` | 初始可见状态;用户之后可以修改 |
|
|
417
|
-
| `defaultSize` |
|
|
418
|
-
| `minSize` / `maxSize` |
|
|
419
|
-
| `order` |
|
|
420
|
+
| `defaultSize` | 首次放置时参考的相对大小;不会覆盖用户保存的大小 |
|
|
421
|
+
| `minSize` / `maxSize` | 旧单行布局的尺寸字段;继续接受,但 ADE 0.47 起不作为停靠布局的硬限制 |
|
|
422
|
+
| `order` | 首次新增插件区域时的排列顺序,数值越小越靠前;不会重排已有区域 |
|
|
420
423
|
|
|
421
|
-
宿主为区域 ID 加上插件命名空间。不同插件可以使用相同局部 ID
|
|
424
|
+
宿主为区域 ID 加上插件命名空间。不同插件可以使用相同局部 ID。请保持区域 `id` 不变。用户保存的位置与这个 ID 关联。
|
|
422
425
|
|
|
423
426
|
view 没有 `when` 字段。需要空状态时,在组件中检查上下文。用户通过「视图」菜单控制区域可见性。
|
|
424
427
|
|
|
428
|
+
**ADE 0.47 起的区域布局:**项目、worktree、目录、编辑、对话、Aone 看板和插件区域使用同一停靠布局。项目与 worktree 是两个独立区域。用户可以调整每个区域的位置、顺序和大小。插件无需增加布局接口。按 SDK 0.2 开发的区域可以直接使用这个布局。
|
|
429
|
+
|
|
430
|
+
| 用户操作 | 操作方法 |
|
|
431
|
+
| --- | --- |
|
|
432
|
+
| 移动并分屏 | 拖拽区域标签到目标区域的左侧、右侧、上方或下方,确认预览后松开 |
|
|
433
|
+
| 合并为标签页 | 拖拽区域标签到目标区域的中间或标签栏 |
|
|
434
|
+
| 调整标签顺序 | 在同一标签栏中拖拽标签到所需位置 |
|
|
435
|
+
| 调整大小 | 拖拽区域之间的分隔线 |
|
|
436
|
+
| 隐藏或显示区域 | 点击区域标签的隐藏按钮,或使用标题栏「视图」菜单 |
|
|
437
|
+
| 恢复默认布局 | 打开「视图 → 恢复默认布局」,恢复区域的位置、顺序和大小;保留显示开关 |
|
|
438
|
+
|
|
439
|
+
ADE 自动保存分屏结构、标签顺序和区域大小。重新打开 ADE 后恢复布局。布局在全 ADE 共用,切换项目或 worktree 不会切换布局。停用插件时,ADE 保留区域的位置记录。重新启用插件后,区域恢复到保存的位置。
|
|
440
|
+
|
|
441
|
+
`defaultSize` 和 `order` 只用于首次放置。更新配置、重新安装插件或修改这些声明,不会强制重排用户已有的区域。`minSize` 和 `maxSize` 保留给旧客户端使用。新停靠布局允许用户自由调整大小,不把这些旧百分比作为限制。当前不提供浮动区域或独立窗口。
|
|
442
|
+
|
|
443
|
+
不要假定插件区域始终在右侧。让组件适应不同的宽度和高度。内容过长时,在区域内提供滚动。区域移动、标签切换和最大化不应触发新的业务任务。用户隐藏区域或停用插件时,组件可能卸载。持久业务数据按第 7 节保存。资源按第 9 节清理。
|
|
444
|
+
|
|
425
445
|
### 6.2 注册内置 slot
|
|
426
446
|
|
|
427
447
|
`ctx.registerSlot(name, registration)` 在指定位置追加组件。
|
|
@@ -501,6 +521,37 @@ interface PluginCommandContext {
|
|
|
501
521
|
|
|
502
522
|
renderer 也可以 `ctx.addStyle(cssText)`。宿主在停用时移除样式。不要直接修改其他功能的 DOM。
|
|
503
523
|
|
|
524
|
+
### 6.6 文件树菜单
|
|
525
|
+
|
|
526
|
+
SDK 0.2 可以在 renderer `activate` 中注册文件菜单:
|
|
527
|
+
|
|
528
|
+
```ts
|
|
529
|
+
ctx.registerFileMenu({
|
|
530
|
+
id: 'open-local', label: '在 ADE 中打开', order: 10,
|
|
531
|
+
when: context => context.node.type === 'file',
|
|
532
|
+
onSelect: async context => {
|
|
533
|
+
await ctx.workspace.openFile(context.node.path)
|
|
534
|
+
}
|
|
535
|
+
})
|
|
536
|
+
```
|
|
537
|
+
|
|
538
|
+
菜单上下文包含 `projectPath`、`worktreePath`、`filePath`,以及 `node`、`isRoot` 和 `selection`。节点提供 `name`、`path`、`type`。`selection` 是打开菜单时的选中项。
|
|
539
|
+
|
|
540
|
+
`when` 控制是否显示。`enabled` 控制是否可用。宿主先关闭菜单,再执行 `onSelect`。执行前再次检查插件状态和条件。停用插件后,菜单注册自动撤销。
|
|
541
|
+
|
|
542
|
+
### 6.7 工作区操作与提示
|
|
543
|
+
|
|
544
|
+
这些接口在 renderer 中使用,不属于 preload IPC:
|
|
545
|
+
|
|
546
|
+
| 方法 | 结果与边界 |
|
|
547
|
+
| --- | --- |
|
|
548
|
+
| `await ctx.workspace.openFile(path)` | 在 ADE 打开真实存在的文件,返回 boolean。目录和缺失文件不会进入标签页;等待期间切换 worktree 或停用插件时,不打开旧结果 |
|
|
549
|
+
| `await ctx.workspace.refreshTree(directory?)` | 默认刷新当前 worktree。指定目录必须在当前 worktree 内;保留已展开缓存;忽略切换后的旧结果 |
|
|
550
|
+
| `ctx.workspace.isFileDirty(path)` | 返回文件当前是否有未保存修改。操作开始前读取;此方法不是 React hook |
|
|
551
|
+
| `ctx.ui.showToast(message, url?)` | 显示中文提示;可以附结果链接 |
|
|
552
|
+
|
|
553
|
+
这些接口不暴露编辑器草稿或选区。上传磁盘内容时,先检查 dirty;为 true 时提示用户保存。等待用户选择上传目标后,在真正上传前再次检查。
|
|
554
|
+
|
|
504
555
|
## 7. 配置与持久数据
|
|
505
556
|
|
|
506
557
|
### 7.1 声明配置表单
|
|
@@ -603,8 +654,8 @@ main 中已有以下内置服务:
|
|
|
603
654
|
| `files` | `readFile(path)`、`readDirTree(dir)`、`statFile(path)`、`writeFile(path, text)` | 这些方法同步返回 |
|
|
604
655
|
| `projects` | `listProjects()`、`addProject(path)`、`removeProject(path)` | 同步返回 |
|
|
605
656
|
| `worktrees` | `listWorktrees(project)`、`createWorktree(project, name)`、`removeWorktree(project, path)` | Promise |
|
|
606
|
-
| `settings` | `getSettings()`、`updateSettings(patch)`、`onSettingsChanged(listener)` |
|
|
607
|
-
| `app` | `getVersion()`、`openExternal(url)` |
|
|
657
|
+
| `settings` | `getSettings()`、`getSettingsFile()`、`updateSettings(patch)`、`onSettingsChanged(listener)`、`getLegacySettingsFile()` | 设置对象、完整设置文件、原始迁移备份或清理函数 |
|
|
658
|
+
| `app` | `getVersion()`、`getPath('userData' 或 'temp')`、`openExternal(url)` | 版本、应用目录字符串或 Promise |
|
|
608
659
|
| `chat` | `listAdapters()`、`listSessions()`、`listHistory()`、`sendMessage(id, prompt)`、`stop(id)` | 列表同步返回;发送和停止返回 Promise |
|
|
609
660
|
|
|
610
661
|
main `getService` 返回 `unknown`。先声明所需接口,再检查服务是否存在。下面的片段放在 main `activate` 内:
|
|
@@ -622,6 +673,10 @@ ctx.registerCommand('readSaved', (_args, context) => {
|
|
|
622
673
|
|
|
623
674
|
main 内置服务与 renderer preload API 的方法名不同。例如 main 用 `files.readFile(path)`,renderer 用 `await ctx.api.files.read(path)`。
|
|
624
675
|
|
|
676
|
+
`settings.getLegacySettingsFile()` 返回规范化前保存的原始设置副本。核心移出的字段可供插件以后安装时迁移。该备份只用于一次性迁移,不作为新的插件配置存储。插件应校验数据,并用自己的迁移标记避免覆盖用户后续配置。
|
|
677
|
+
|
|
678
|
+
`settings.getSettingsFile()` 同步返回当前 `AdeSettingsFile`,包含 `settings` 和 `state`。插件迁移旧区域时,可读取 `state.pluginAreasVisible`,先检查用户是否已设置对应区域,再决定是否写入迁移值。
|
|
679
|
+
|
|
625
680
|
main `files` 服务没有 renderer 的 `watch`、`trash`、`reveal` 或剪贴板方法。main 需要其他本地能力时,使用 Node.js。
|
|
626
681
|
|
|
627
682
|
### 8.2 renderer 调用 main 服务
|
|
@@ -1170,6 +1225,9 @@ export function activate(ctx) {
|
|
|
1170
1225
|
| `getContext` / `useContext` | 读取 UI 路径上下文 |
|
|
1171
1226
|
| `getConfig` / `useConfig` / `setConfig` / `onConfigChanged` | 读取、修改和订阅配置 |
|
|
1172
1227
|
| `registerView` / `registerSlot` | 注册区域与扩展组件 |
|
|
1228
|
+
| `registerFileMenu` | 注册文件树菜单,自动随插件清理 |
|
|
1229
|
+
| `workspace` | 打开文件、刷新文件树、读取 dirty 状态 |
|
|
1230
|
+
| `ui.showToast` | 操作提示与结果链接 |
|
|
1173
1231
|
| `registerCommand` / `executeCommand` | 注册与调用命令 |
|
|
1174
1232
|
| `provideService` / `getService` | 同进程服务 |
|
|
1175
1233
|
| `on` / `emit` | 同进程事件 |
|
|
@@ -1205,12 +1263,13 @@ main 没有 renderer 的 `api`、hook、区域或 slot 方法。
|
|
|
1205
1263
|
| `api.settings` | 读取与修改 ADE 设置、agent 列表、设置变化订阅 |
|
|
1206
1264
|
| `api.plugins` | 插件列表、配置、安装、启停、卸载与变更订阅;SDK 导出、main 命令和服务调用 |
|
|
1207
1265
|
| `api.daemon` | daemon 信息与 relay 配置 |
|
|
1208
|
-
| `api.dingtalk` | 钉钉文档、会议内容与文件上传下载;需要相应账号配置 |
|
|
1209
1266
|
| `api.aone` | Aone 看板与工作项操作;需要相应账号配置 |
|
|
1210
1267
|
| `api.logs` | 日志查询、scope 列表、清空、目录和摘要 |
|
|
1211
1268
|
|
|
1212
1269
|
调用写操作会产生实际效果。例如 `files.write` 修改磁盘,`chat.sendMessage` 发送消息。插件应在自己的交互中清楚表达操作目标。
|
|
1213
1270
|
|
|
1271
|
+
ADE 0.46 起,钉钉业务由独立插件提供,SDK 不再声明 `api.dingtalk`。业务插件通过自己的 main 服务与 React 区域接入;其他插件经 `api.plugins.invokeService` 调用其公开服务。
|
|
1272
|
+
|
|
1214
1273
|
下面的 renderer 回调片段读取当前已保存文件:
|
|
1215
1274
|
|
|
1216
1275
|
```ts
|
package/index.d.ts
CHANGED
|
@@ -3,7 +3,8 @@ import type * as ReactDOM from 'react-dom'
|
|
|
3
3
|
import type { AdeApi } from './types/api.js'
|
|
4
4
|
import type { PluginContext, SessionContext, ChatSession, ChatAdapter } from './types/adapter.js'
|
|
5
5
|
import type {
|
|
6
|
-
PluginCommandContext, PluginConfig, PluginDisposer,
|
|
6
|
+
PluginCommandContext, PluginConfig, PluginDisposer, PluginFileMenuRegistration,
|
|
7
|
+
PluginSlotName, PluginUiApi, PluginViewInfo, PluginWorkspaceApi
|
|
7
8
|
} from './types/plugins.js'
|
|
8
9
|
|
|
9
10
|
export type * from './types/plugins.js'
|
|
@@ -35,6 +36,8 @@ export interface RendererPluginContext {
|
|
|
35
36
|
React: typeof React
|
|
36
37
|
ReactDOM: typeof ReactDOM
|
|
37
38
|
api: AdeApi
|
|
39
|
+
workspace: PluginWorkspaceApi
|
|
40
|
+
ui: PluginUiApi
|
|
38
41
|
subscriptions: PluginDisposer[]
|
|
39
42
|
getContext(): PluginCommandContext
|
|
40
43
|
useContext(): PluginCommandContext
|
|
@@ -44,6 +47,7 @@ export interface RendererPluginContext {
|
|
|
44
47
|
onConfigChanged(listener: (config: PluginConfig) => void): PluginDisposer
|
|
45
48
|
registerView(view: PluginViewRegistration): PluginDisposer
|
|
46
49
|
registerSlot(name: PluginSlotName, contribution: PluginSlotRegistration): PluginDisposer
|
|
50
|
+
registerFileMenu(contribution: PluginFileMenuRegistration): PluginDisposer
|
|
47
51
|
registerCommand(id: string, handler: (args: unknown, context: PluginCommandContext) => unknown | Promise<unknown>): PluginDisposer
|
|
48
52
|
/** 优先执行本插件 renderer 命令,其次执行本插件 main 命令;跨插件使用 plugin:ID:command。 */
|
|
49
53
|
executeCommand(id: string, args?: unknown): Promise<unknown>
|
package/package.json
CHANGED
|
@@ -1,23 +1,47 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai_mind/ade-plugin-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "ADE 可信插件 SDK、类型与 React 插件构建工具",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "sepmini",
|
|
7
|
-
"engines": {
|
|
8
|
-
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=18"
|
|
9
|
+
},
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public",
|
|
12
|
+
"registry": "https://registry.npmjs.org/"
|
|
13
|
+
},
|
|
9
14
|
"type": "module",
|
|
10
15
|
"main": "./index.mjs",
|
|
11
16
|
"types": "./index.d.ts",
|
|
12
|
-
"exports": {
|
|
13
|
-
|
|
14
|
-
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./index.d.ts",
|
|
20
|
+
"default": "./index.mjs"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"bin": {
|
|
24
|
+
"ade-plugin-build": "./cli/build.mjs"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"index.mjs",
|
|
28
|
+
"index.d.ts",
|
|
29
|
+
"types",
|
|
30
|
+
"cli",
|
|
31
|
+
"README.md",
|
|
32
|
+
"LICENSE"
|
|
33
|
+
],
|
|
15
34
|
"scripts": {
|
|
16
35
|
"sync:types": "node scripts/sync-types.mjs",
|
|
17
36
|
"release:preflight": "node scripts/release-preflight.mjs",
|
|
18
37
|
"release:dry-run": "node scripts/release-preflight.mjs --dry-run",
|
|
19
38
|
"prepublishOnly": "node scripts/release-preflight.mjs"
|
|
20
39
|
},
|
|
21
|
-
"dependencies": {
|
|
22
|
-
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"esbuild": "^0.25.0"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"react": "^19.0.0",
|
|
45
|
+
"react-dom": "^19.0.0"
|
|
46
|
+
}
|
|
23
47
|
}
|
package/types/ade-types.d.ts
CHANGED
|
@@ -279,7 +279,7 @@ export interface WorktreeTabState {
|
|
|
279
279
|
/** 各文件在该 worktree 下的滚动位置(px),用于切回时恢复浏览位置 */
|
|
280
280
|
scrolls: Record<string, number>;
|
|
281
281
|
}
|
|
282
|
-
export type AreaKey = 'project' | 'worktree' | 'files' | 'editor' | 'chat' | '
|
|
282
|
+
export type AreaKey = 'project' | 'worktree' | 'files' | 'editor' | 'chat' | 'aone';
|
|
283
283
|
export type AoneCategory = 'req' | 'bug' | 'task';
|
|
284
284
|
/** a1 CLI 可用性与 BUC 登录状态。 */
|
|
285
285
|
export interface AoneStatus {
|
|
@@ -481,19 +481,45 @@ export interface AgentSettings {
|
|
|
481
481
|
*/
|
|
482
482
|
yolo: string[];
|
|
483
483
|
}
|
|
484
|
-
export interface DingTalkSettings {
|
|
485
|
-
cli: 'dws' | 'dwsx';
|
|
486
|
-
dwsxPath: string;
|
|
487
|
-
/** 留空使用 DWSX_DATA_DIR 或 ~/.local/share/dwsx,与终端共用登录态 */
|
|
488
|
-
dwsxDataDir?: string;
|
|
489
|
-
/** dws CLI 路径;留空时自动从 PATH 与常见目录探测 */
|
|
490
|
-
dwsPath: string;
|
|
491
|
-
}
|
|
492
484
|
export interface AppSettings {
|
|
493
485
|
appearance: AppearanceSettings;
|
|
494
486
|
editor: EditorSettings;
|
|
495
487
|
agents: AgentSettings;
|
|
496
|
-
|
|
488
|
+
}
|
|
489
|
+
/** 可持久化的区域布局;只保存位置、比例和标签,不保存插件业务参数。 */
|
|
490
|
+
export interface AdeDockPanel {
|
|
491
|
+
id: string;
|
|
492
|
+
contentComponent: 'area';
|
|
493
|
+
renderer: 'always';
|
|
494
|
+
title?: string;
|
|
495
|
+
}
|
|
496
|
+
export interface AdeDockGroup {
|
|
497
|
+
id: string;
|
|
498
|
+
views: string[];
|
|
499
|
+
activeView?: string;
|
|
500
|
+
}
|
|
501
|
+
export type AdeDockNode = {
|
|
502
|
+
type: 'leaf';
|
|
503
|
+
data: AdeDockGroup;
|
|
504
|
+
size?: number;
|
|
505
|
+
} | {
|
|
506
|
+
type: 'branch';
|
|
507
|
+
data: AdeDockNode[];
|
|
508
|
+
size?: number;
|
|
509
|
+
};
|
|
510
|
+
export interface AdeDockLayout {
|
|
511
|
+
grid: {
|
|
512
|
+
root: AdeDockNode;
|
|
513
|
+
width: number;
|
|
514
|
+
height: number;
|
|
515
|
+
orientation: 'HORIZONTAL' | 'VERTICAL';
|
|
516
|
+
};
|
|
517
|
+
panels: Record<string, AdeDockPanel>;
|
|
518
|
+
activeGroup?: string;
|
|
519
|
+
}
|
|
520
|
+
export interface AdeWorkspaceLayout {
|
|
521
|
+
version: 1;
|
|
522
|
+
dock: AdeDockLayout;
|
|
497
523
|
}
|
|
498
524
|
/** 应用状态(原 state.json + localStorage ade-areas 的统一归宿) */
|
|
499
525
|
export interface AdeState {
|
|
@@ -502,6 +528,8 @@ export interface AdeState {
|
|
|
502
528
|
worktreeTabs: Record<string, WorktreeTabState>;
|
|
503
529
|
/** 插件功能区域的显示状态,以插件 ID 和区域 ID 组合为 key。 */
|
|
504
530
|
pluginAreasVisible?: Record<string, boolean>;
|
|
531
|
+
/** 完整布局保留隐藏及暂不可用的区域;null 表示使用默认布局。 */
|
|
532
|
+
workspaceLayout?: AdeWorkspaceLayout | null;
|
|
505
533
|
}
|
|
506
534
|
/** ~/.ade/settings.json 的完整结构 */
|
|
507
535
|
export interface AdeSettingsFile {
|
|
@@ -515,7 +543,6 @@ export interface SettingsPatch {
|
|
|
515
543
|
appearance?: Partial<AppearanceSettings>;
|
|
516
544
|
editor?: Partial<EditorSettings>;
|
|
517
545
|
agents?: Partial<AgentSettings>;
|
|
518
|
-
dingtalk?: Partial<DingTalkSettings>;
|
|
519
546
|
};
|
|
520
547
|
state?: Partial<AdeState>;
|
|
521
548
|
}
|
|
@@ -523,155 +550,6 @@ export interface SettingsPatch {
|
|
|
523
550
|
export interface AgentSettingInfo extends ChatAdapterInfo {
|
|
524
551
|
hidden: boolean;
|
|
525
552
|
}
|
|
526
|
-
/** dws / 钉钉集成状态(设置页与钉钉面板共用) */
|
|
527
|
-
export interface DingTalkStatus {
|
|
528
|
-
cliKind?: 'dws' | 'dwsx';
|
|
529
|
-
dataDirectory?: string;
|
|
530
|
-
available: boolean;
|
|
531
|
-
authenticated: boolean;
|
|
532
|
-
version?: string;
|
|
533
|
-
/** dws 0.x 旧版接口线:上传走 doc create 而非 doc import */
|
|
534
|
-
legacy?: boolean;
|
|
535
|
-
message: string;
|
|
536
|
-
executable?: string;
|
|
537
|
-
}
|
|
538
|
-
/** 钉钉在线文档搜索结果条目 */
|
|
539
|
-
export interface DingTalkDocItem {
|
|
540
|
-
nodeId: string;
|
|
541
|
-
name: string;
|
|
542
|
-
docType?: string;
|
|
543
|
-
url?: string;
|
|
544
|
-
createTime?: number | string;
|
|
545
|
-
modifiedTime?: number | string;
|
|
546
|
-
creatorUid?: string;
|
|
547
|
-
creatorName?: string;
|
|
548
|
-
creatorNick?: string;
|
|
549
|
-
workspaceId?: string;
|
|
550
|
-
workspaceName?: string;
|
|
551
|
-
}
|
|
552
|
-
export type DingTalkDocDownloadFormat = 'dingdoc' | 'markdown';
|
|
553
|
-
/** 钉钉听记列表条目 */
|
|
554
|
-
export interface DingTalkMinutesItem {
|
|
555
|
-
taskUuid: string;
|
|
556
|
-
title: string;
|
|
557
|
-
url?: string;
|
|
558
|
-
startTime?: number | string;
|
|
559
|
-
status?: string;
|
|
560
|
-
creatorUid?: string;
|
|
561
|
-
creatorName?: string;
|
|
562
|
-
creatorNick?: string;
|
|
563
|
-
}
|
|
564
|
-
/** 下载到本地的结果 */
|
|
565
|
-
export interface DingTalkDownloadResult {
|
|
566
|
-
kind: 'doc' | 'minutes';
|
|
567
|
-
path: string;
|
|
568
|
-
title?: string;
|
|
569
|
-
url?: string;
|
|
570
|
-
taskUuid?: string;
|
|
571
|
-
/** dingdoc / dingmin 文件夹等场景下应打开的首选文件 */
|
|
572
|
-
entryPath?: string;
|
|
573
|
-
/** 钉钉文档/听记下载格式 */
|
|
574
|
-
format?: 'dingdoc' | 'dingmin' | 'markdown';
|
|
575
|
-
}
|
|
576
|
-
/** 可作为上传目标的钉钉知识库 / 个人空间 */
|
|
577
|
-
export interface DingTalkUploadWorkspace {
|
|
578
|
-
workspaceId: string;
|
|
579
|
-
name: string;
|
|
580
|
-
/** org = 组织知识库;mine = 「我的文档」个人空间 */
|
|
581
|
-
type: 'org' | 'mine';
|
|
582
|
-
}
|
|
583
|
-
/** 知识库内的文件夹节点(上传目标位置选择) */
|
|
584
|
-
export interface DingTalkUploadFolderNode {
|
|
585
|
-
nodeId: string;
|
|
586
|
-
name: string;
|
|
587
|
-
}
|
|
588
|
-
/** 粘贴钉钉链接后解析出的上传目标 */
|
|
589
|
-
export interface DingTalkUploadTarget {
|
|
590
|
-
/** 知识库 ID / URL */
|
|
591
|
-
workspace: string;
|
|
592
|
-
/** 文件夹 ID / URL */
|
|
593
|
-
folder: string;
|
|
594
|
-
/** 给人看的位置描述 */
|
|
595
|
-
label: string;
|
|
596
|
-
/** 链接指向文档本身时:可作为覆盖上传目标 */
|
|
597
|
-
document?: {
|
|
598
|
-
nodeId: string;
|
|
599
|
-
name: string;
|
|
600
|
-
};
|
|
601
|
-
}
|
|
602
|
-
/** 上传本地 Markdown 为钉钉文档的结果 */
|
|
603
|
-
export interface DingTalkUploadResult {
|
|
604
|
-
success: boolean;
|
|
605
|
-
documentUrl?: string;
|
|
606
|
-
nodeId?: string;
|
|
607
|
-
documentName?: string;
|
|
608
|
-
taskId?: string;
|
|
609
|
-
message?: string;
|
|
610
|
-
/** 随文档上传的本地图片(含 SVG)统计;无本地图片时不存在 */
|
|
611
|
-
images?: {
|
|
612
|
-
total: number;
|
|
613
|
-
inserted: number;
|
|
614
|
-
/** 上传失败的本地图片文件名 */
|
|
615
|
-
missing: string[];
|
|
616
|
-
/** 未能清理的占位块数量 */
|
|
617
|
-
leftoverPlaceholders: number;
|
|
618
|
-
};
|
|
619
|
-
}
|
|
620
|
-
/**
|
|
621
|
-
* dwsx JSONML 读取范围。不传 scope = 整篇 canonical body(root);
|
|
622
|
-
* outline 只取标题大纲(fragment,heading 带 uuid,可当块 ID)。
|
|
623
|
-
*/
|
|
624
|
-
export type DingTalkJsonmlScope = 'outline' | 'tags' | 'section' | 'range';
|
|
625
|
-
/** dwsx doc read --content-format jsonml 的读取选项 */
|
|
626
|
-
export interface DingTalkJsonmlReadOptions {
|
|
627
|
-
scope?: DingTalkJsonmlScope;
|
|
628
|
-
/** scope=tags:只取指定标签的块 */
|
|
629
|
-
tags?: string[];
|
|
630
|
-
/** scope=range:起始块 ID(可从块列表 / outline 的 uuid 取) */
|
|
631
|
-
startBlockId?: string;
|
|
632
|
-
/** scope=range:结束块 ID */
|
|
633
|
-
endBlockId?: string;
|
|
634
|
-
/** scope=section/outline:最大层级 */
|
|
635
|
-
maxDepth?: number;
|
|
636
|
-
/** 指定文档历史版本 */
|
|
637
|
-
version?: number | string;
|
|
638
|
-
/** 落盘路径;留空写入 ADE 钉钉缓存目录,读回文件即覆盖前的备份 */
|
|
639
|
-
outputPath?: string;
|
|
640
|
-
}
|
|
641
|
-
/** JSONML canonical body(["root"|"fragment", attrs, ...blocks])读取结果 */
|
|
642
|
-
export interface DingTalkJsonmlDocument {
|
|
643
|
-
nodeId: string;
|
|
644
|
-
jsonml: unknown[];
|
|
645
|
-
contentFormat: 'jsonml';
|
|
646
|
-
/** 落盘备份路径,可直接作为 overwriteDocJsonml 的 filePath 回写 */
|
|
647
|
-
savedPath?: string;
|
|
648
|
-
bytes?: number;
|
|
649
|
-
revision?: string;
|
|
650
|
-
scope?: DingTalkJsonmlScope;
|
|
651
|
-
}
|
|
652
|
-
/**
|
|
653
|
-
* JSONML 覆盖输入:裸数组 / { jsonml: [...] } / { jsonml: "…" } / 读回落盘的信封。
|
|
654
|
-
* filePath 与对象形态都接受,ADE 与 dwsx 一样逐层解包。
|
|
655
|
-
*/
|
|
656
|
-
export type DingTalkJsonmlInput = unknown[] | {
|
|
657
|
-
jsonml: unknown;
|
|
658
|
-
} | {
|
|
659
|
-
filePath: string;
|
|
660
|
-
};
|
|
661
|
-
/** JSONML 整篇覆盖结果 */
|
|
662
|
-
export interface DingTalkJsonmlWriteResult {
|
|
663
|
-
success: boolean;
|
|
664
|
-
message?: string;
|
|
665
|
-
nodeId?: string;
|
|
666
|
-
documentUrl?: string;
|
|
667
|
-
documentName?: string;
|
|
668
|
-
chunksWritten?: number;
|
|
669
|
-
}
|
|
670
|
-
/** 块 element 写入结果(dwsx doc block update / insert) */
|
|
671
|
-
export interface DingTalkBlockWriteResult {
|
|
672
|
-
success: boolean;
|
|
673
|
-
message?: string;
|
|
674
|
-
}
|
|
675
553
|
/** 日志等级:error > warn > info > debug */
|
|
676
554
|
export type LogLevel = 'error' | 'warn' | 'info' | 'debug';
|
|
677
555
|
/** 单条日志 */
|
|
@@ -694,19 +572,3 @@ export interface LogFilter {
|
|
|
694
572
|
query?: string;
|
|
695
573
|
limit?: number;
|
|
696
574
|
}
|
|
697
|
-
/** 可恢复的钉钉上传任务,正文与图片分别记录完成状态。 */
|
|
698
|
-
export interface DingTalkUploadJob {
|
|
699
|
-
filePath: string;
|
|
700
|
-
title?: string;
|
|
701
|
-
folder?: string;
|
|
702
|
-
workspace?: string;
|
|
703
|
-
nodeId?: string;
|
|
704
|
-
status: 'running' | 'failed' | 'completed';
|
|
705
|
-
step: string;
|
|
706
|
-
error?: string;
|
|
707
|
-
result?: DingTalkUploadResult;
|
|
708
|
-
steps: {
|
|
709
|
-
label: string;
|
|
710
|
-
status: 'running' | 'completed' | 'failed';
|
|
711
|
-
}[];
|
|
712
|
-
}
|
package/types/api.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// 由 sdk/scripts/sync-types.mjs 从 ADE 宿主生成,请勿手工修改。
|
|
2
2
|
import type { PluginCommandContext, PluginConfig, PluginInstallRequest } from './plugins.js';
|
|
3
|
-
import type { AdeSettingsFile, AgentSettingInfo, AoneBoardData, AoneBoardRequest, AoneCreateField, AoneCreateRequest, AoneStatus, AoneUpdateRequest, AoneWorkItem, AoneWorkItemDetail, ChatApprovalResponse, ChatAdapterInfo, ChatAttachment, ChatAttachmentKind, ChatSessionInfo, ChatSessionRecord, CliModelOption, CliOption, CopiedEntry,
|
|
3
|
+
import type { AdeSettingsFile, AgentSettingInfo, AoneBoardData, AoneBoardRequest, AoneCreateField, AoneCreateRequest, AoneStatus, AoneUpdateRequest, AoneWorkItem, AoneWorkItemDetail, ChatApprovalResponse, ChatAdapterInfo, ChatAttachment, ChatAttachmentKind, ChatSessionInfo, ChatSessionRecord, CliModelOption, CliOption, CopiedEntry, FileNode, FileStat, LogEntry, LogFilter, PluginInfo, Project, SettingsPatch, StructuredEvent, Worktree } from './ade-types.js';
|
|
4
4
|
export interface ChatEvent {
|
|
5
5
|
id: string;
|
|
6
6
|
data?: string;
|
|
@@ -140,47 +140,6 @@ declare const api: {
|
|
|
140
140
|
listAgents: () => Promise<AgentSettingInfo[]>;
|
|
141
141
|
onChanged: (cb: (file: AdeSettingsFile) => void) => (() => void);
|
|
142
142
|
};
|
|
143
|
-
dingtalk: {
|
|
144
|
-
getUploadJob: (filePath: string) => Promise<DingTalkUploadJob | null>;
|
|
145
|
-
runUploadJob: (request: {
|
|
146
|
-
filePath: string;
|
|
147
|
-
title?: string;
|
|
148
|
-
folder?: string;
|
|
149
|
-
workspace?: string;
|
|
150
|
-
nodeId?: string;
|
|
151
|
-
}, retry?: boolean) => Promise<DingTalkUploadJob>;
|
|
152
|
-
getStatus: () => Promise<DingTalkStatus>;
|
|
153
|
-
login: () => Promise<{
|
|
154
|
-
started: boolean;
|
|
155
|
-
}>;
|
|
156
|
-
restartWukong: () => Promise<{
|
|
157
|
-
restarted: boolean;
|
|
158
|
-
message: string;
|
|
159
|
-
}>;
|
|
160
|
-
searchDocs: (query: string, source?: "recent" | "mine") => Promise<DingTalkDocItem[]>;
|
|
161
|
-
listMinutes: (query: string) => Promise<DingTalkMinutesItem[]>;
|
|
162
|
-
previewDoc: (node: string, preferredName?: string) => Promise<DingTalkDownloadResult>;
|
|
163
|
-
downloadDoc: (node: string, targetDir: string, format?: DingTalkDocDownloadFormat, preferredName?: string) => Promise<DingTalkDownloadResult>;
|
|
164
|
-
downloadMinutes: (taskUuid: string, targetDir: string, outputName?: string, format?: "dingmin" | "markdown") => Promise<DingTalkDownloadResult>;
|
|
165
|
-
uploadMarkdown: (filePath: string, title: string, folder: string, workspace: string) => Promise<DingTalkUploadResult>;
|
|
166
|
-
listUploadWorkspaces: () => Promise<DingTalkUploadWorkspace[]>;
|
|
167
|
-
listUploadFolders: (workspaceId: string, parentNodeId?: string) => Promise<DingTalkUploadFolderNode[]>;
|
|
168
|
-
resolveUploadTarget: (input: string) => Promise<DingTalkUploadTarget>;
|
|
169
|
-
listUploadDocs: (workspaceId: string, parentNodeId?: string) => Promise<DingTalkUploadFolderNode[]>;
|
|
170
|
-
overwriteDoc: (nodeId: string, filePath: string) => Promise<DingTalkUploadResult>;
|
|
171
|
-
readDocJsonml: (nodeId: string, options?: DingTalkJsonmlReadOptions) => Promise<DingTalkJsonmlDocument>;
|
|
172
|
-
overwriteDocJsonml: (nodeId: string, input: DingTalkJsonmlInput) => Promise<DingTalkJsonmlWriteResult>;
|
|
173
|
-
createDocWithJsonml: (name: string, input: DingTalkJsonmlInput, location?: {
|
|
174
|
-
folder?: string;
|
|
175
|
-
workspace?: string;
|
|
176
|
-
}) => Promise<DingTalkJsonmlWriteResult>;
|
|
177
|
-
listDocBlockElements: (nodeId: string, options?: {
|
|
178
|
-
startIndex?: number;
|
|
179
|
-
contentFormat?: "element" | "jsonml";
|
|
180
|
-
}) => Promise<unknown[]>;
|
|
181
|
-
updateDocBlock: (nodeId: string, blockId: string, element: unknown) => Promise<DingTalkBlockWriteResult>;
|
|
182
|
-
insertDocBlock: (nodeId: string, index: number, element: unknown) => Promise<DingTalkBlockWriteResult>;
|
|
183
|
-
};
|
|
184
143
|
aone: {
|
|
185
144
|
getStatus: () => Promise<AoneStatus>;
|
|
186
145
|
loadBoard: (request: AoneBoardRequest) => Promise<AoneBoardData>;
|
package/types/plugins.d.ts
CHANGED
|
@@ -69,6 +69,37 @@ export interface PluginCommandContext {
|
|
|
69
69
|
filePath: string | null
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
+
/** 文件树菜单捕获的节点与选择;不暴露宿主 store 或 DOM。 */
|
|
73
|
+
export interface PluginFileMenuNode {
|
|
74
|
+
name: string
|
|
75
|
+
path: string
|
|
76
|
+
type: 'file' | 'dir'
|
|
77
|
+
}
|
|
78
|
+
export interface PluginFileMenuContext extends PluginCommandContext {
|
|
79
|
+
node: PluginFileMenuNode
|
|
80
|
+
isRoot: boolean
|
|
81
|
+
selection: PluginFileMenuNode[]
|
|
82
|
+
}
|
|
83
|
+
export interface PluginFileMenuRegistration {
|
|
84
|
+
id: string
|
|
85
|
+
label: string
|
|
86
|
+
order?: number
|
|
87
|
+
when?: (context: PluginFileMenuContext) => boolean
|
|
88
|
+
enabled?: (context: PluginFileMenuContext) => boolean
|
|
89
|
+
onSelect(context: PluginFileMenuContext): void | Promise<void>
|
|
90
|
+
}
|
|
91
|
+
export interface PluginWorkspaceApi {
|
|
92
|
+
/** 仅打开真实普通文件;不存在、目录或过期操作返回 false。 */
|
|
93
|
+
openFile(path: string): Promise<boolean>
|
|
94
|
+
/** 刷新当前 worktree 的目录;其他路径及过期结果不改动文件树。 */
|
|
95
|
+
refreshTree(directory?: string): Promise<void>
|
|
96
|
+
/** 查询当前未保存标记,不包含编辑器正文。 */
|
|
97
|
+
isFileDirty(path: string): boolean
|
|
98
|
+
}
|
|
99
|
+
export interface PluginUiApi {
|
|
100
|
+
showToast(message: string, url?: string): void
|
|
101
|
+
}
|
|
102
|
+
|
|
72
103
|
export interface PluginViewInfo {
|
|
73
104
|
id: string
|
|
74
105
|
title: string
|