@ai_mind/ade-plugin-sdk 0.1.0 → 0.2.0
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 +1240 -17
- package/index.d.ts +5 -1
- package/package.json +1 -1
- package/types/ade-types.d.ts +1 -176
- package/types/api.d.ts +1 -42
- package/types/plugins.d.ts +31 -0
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
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,10 @@ 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
|
-
dingtalk: DingTalkSettings;
|
|
497
488
|
}
|
|
498
489
|
/** 应用状态(原 state.json + localStorage ade-areas 的统一归宿) */
|
|
499
490
|
export interface AdeState {
|
|
@@ -515,7 +506,6 @@ export interface SettingsPatch {
|
|
|
515
506
|
appearance?: Partial<AppearanceSettings>;
|
|
516
507
|
editor?: Partial<EditorSettings>;
|
|
517
508
|
agents?: Partial<AgentSettings>;
|
|
518
|
-
dingtalk?: Partial<DingTalkSettings>;
|
|
519
509
|
};
|
|
520
510
|
state?: Partial<AdeState>;
|
|
521
511
|
}
|
|
@@ -523,155 +513,6 @@ export interface SettingsPatch {
|
|
|
523
513
|
export interface AgentSettingInfo extends ChatAdapterInfo {
|
|
524
514
|
hidden: boolean;
|
|
525
515
|
}
|
|
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
516
|
/** 日志等级:error > warn > info > debug */
|
|
676
517
|
export type LogLevel = 'error' | 'warn' | 'info' | 'debug';
|
|
677
518
|
/** 单条日志 */
|
|
@@ -694,19 +535,3 @@ export interface LogFilter {
|
|
|
694
535
|
query?: string;
|
|
695
536
|
limit?: number;
|
|
696
537
|
}
|
|
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
|