@mybricks/plugin-ai 0.0.1 → 0.0.2
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/package.json +7 -2
- package/src/agents/app.ts +188 -60
- package/src/agents/common.ts +428 -68
- package/src/agents/custom.ts +14 -0
- package/src/agents/index.ts +31 -1
- package/src/agents/knowledges/README.md +614 -0
- package/src/agents/knowledges/SUMMARY.md +527 -0
- package/src/agents/knowledges/index.ts +8 -0
- package/src/agents/knowledges/knowledge-base.ts +565 -0
- package/src/agents/knowledges/knowledge-node.ts +266 -0
- package/src/agents/knowledges/types.ts +208 -0
- package/src/agents/utils/config.ts +427 -0
- package/src/agents/workspace/coding-manager.ts +31 -0
- package/src/agents/workspace/components-manager.ts +124 -0
- package/src/agents/workspace/outline-focus.ts +188 -0
- package/src/agents/workspace/outline-info.ts +520 -0
- package/src/agents/workspace/page-tree-generator.ts +83 -0
- package/src/agents/workspace/workspace.ts +319 -0
- package/src/agents/workspace-by-knowledges/MIGRATION.md +568 -0
- package/src/agents/workspace-by-knowledges/README.md +521 -0
- package/src/agents/workspace-by-knowledges/index.ts +11 -0
- package/src/agents/workspace-by-knowledges/providers/component-docs-provider.ts +92 -0
- package/src/agents/workspace-by-knowledges/providers/focus-info-provider.ts +131 -0
- package/src/agents/workspace-by-knowledges/providers/index.ts +8 -0
- package/src/agents/workspace-by-knowledges/providers/project-info-provider.ts +151 -0
- package/src/agents/workspace-by-knowledges/test.ts +240 -0
- package/src/agents/workspace-by-knowledges/types.ts +56 -0
- package/src/agents/workspace-by-knowledges/utils/components-manager.ts +145 -0
- package/src/agents/workspace-by-knowledges/utils/index.ts +8 -0
- package/src/agents/workspace-by-knowledges/utils/outline-focus.ts +178 -0
- package/src/agents/workspace-by-knowledges/utils/outline-info.ts +521 -0
- package/src/agents/workspace-by-knowledges/workspace.ts +166 -0
- package/src/api/cloud-components.ts +129 -0
- package/src/api-record-replay/README.md +187 -0
- package/src/api-record-replay/index.ts +11 -0
- package/src/api-record-replay/manager.ts +168 -0
- package/src/api-record-replay/recorder.ts +117 -0
- package/src/api-record-replay/replayer.ts +148 -0
- package/src/components/attachments/index.less +117 -0
- package/src/components/attachments/index.tsx +136 -0
- package/src/components/icons/index.tsx +21 -1
- package/src/components/index.less +34 -0
- package/src/components/mention/index.less +23 -0
- package/src/components/mention/index.tsx +19 -0
- package/src/components/messages/index.less +444 -237
- package/src/components/messages/index.tsx +371 -88
- package/src/components/sender/index.less +203 -0
- package/src/components/sender/index.tsx +298 -0
- package/src/components/types.ts +31 -0
- package/src/constants/index.ts +8 -0
- package/src/context/RequestStatusTracker.ts +50 -0
- package/src/context/index.ts +68 -6
- package/src/{types.d.ts → global.d.ts} +40 -5
- package/src/index.tsx +212 -32
- package/src/preset/agents.ts +380 -0
- package/src/preset/createTemplates.ts +25 -0
- package/src/preset/index.ts +12 -0
- package/src/preset/prompts.ts +235 -0
- package/src/preset/requestAsStream.ts +246 -0
- package/src/preset/user.ts +6 -0
- package/src/startView/components/header/header.less +17 -0
- package/src/startView/components/header/header.tsx +15 -0
- package/src/startView/components/index.ts +1 -0
- package/src/startView/index.less +22 -204
- package/src/startView/index.tsx +35 -203
- package/src/tools/analyze-and-expand-prd.ts +192 -86
- package/src/tools/analyze-requirement-and-components.ts +589 -0
- package/src/tools/answer.ts +59 -0
- package/src/tools/build-process.ts +1174 -0
- package/src/tools/coding-subagent-as-tool.ts +119 -0
- package/src/tools/generate-ui-content.ts +1083 -0
- package/src/tools/index.ts +22 -19
- package/src/tools/open-dsl.ts +69 -0
- package/src/tools/refactor-ui-content.ts +801 -0
- package/src/tools/utils.ts +880 -28
- package/src/types/index.ts +4 -0
- package/src/view/components/header/header.less +36 -2
- package/src/view/components/header/header.tsx +47 -2
- package/src/view/components/index.ts +0 -2
- package/src/view/index.tsx +158 -8
- package/src/tools/answer-user.ts +0 -35
- package/src/tools/focus-element.ts +0 -47
- package/src/tools/generate-page.ts +0 -750
- package/src/tools/get-component-info-by-ids.ts +0 -166
- package/src/tools/get-component-info.ts +0 -53
- package/src/tools/get-components-doc-and-prd.ts +0 -137
- package/src/tools/get-focus-mybricks-dsl.ts +0 -26
- package/src/tools/get-mybricks-dsl.ts +0 -73
- package/src/tools/modify-component.ts +0 -385
- package/src/view/components/messages/messages.less +0 -228
- package/src/view/components/messages/messages.tsx +0 -172
- package/src/view/components/sender/sender.less +0 -44
- package/src/view/components/sender/sender.tsx +0 -62
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
interface PageInfo {
|
|
2
|
+
id: string;
|
|
3
|
+
title: string;
|
|
4
|
+
type: string;
|
|
5
|
+
componentType?: string;
|
|
6
|
+
children?: PageInfo[];
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface PagesData {
|
|
10
|
+
pageAry: PageInfo[];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 页面树生成器
|
|
16
|
+
*/
|
|
17
|
+
export class PageTreeGenerator {
|
|
18
|
+
static generate(pagesInfo: PagesData | PagesData[], options: { pageId?: string } = {}): string {
|
|
19
|
+
const { pageId: focusedPageId } = options;
|
|
20
|
+
|
|
21
|
+
const processedPages = this.processRawData(pagesInfo);
|
|
22
|
+
return this.generateTreeText(processedPages, focusedPageId);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
private static processRawData(rawData: PagesData | PagesData[]): PageInfo[] {
|
|
26
|
+
// 如果 rawData 是数组
|
|
27
|
+
if (Array.isArray(rawData)) {
|
|
28
|
+
const allPages: PageInfo[] = [];
|
|
29
|
+
rawData.forEach((canvas: any) => {
|
|
30
|
+
if (canvas.pageAry && Array.isArray(canvas.pageAry)) { // 多画布
|
|
31
|
+
allPages.push(...canvas.pageAry.map((page: any) => ({
|
|
32
|
+
id: page.id,
|
|
33
|
+
title: page.title,
|
|
34
|
+
type: page.type,
|
|
35
|
+
componentType: page.componentType || undefined,
|
|
36
|
+
children: page.children || []
|
|
37
|
+
})));
|
|
38
|
+
} else if (canvas.id) {
|
|
39
|
+
allPages.push({ ...canvas })
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
return allPages;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// 如果不是数组
|
|
46
|
+
if (!rawData?.pageAry) {
|
|
47
|
+
return [];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return rawData.pageAry.map((page: PageInfo) => ({
|
|
51
|
+
id: page.id,
|
|
52
|
+
title: page.title,
|
|
53
|
+
type: page.type,
|
|
54
|
+
componentType: page.componentType || undefined,
|
|
55
|
+
children: page.children || []
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
private static generateTreeText(pages: PageInfo[], focusedPageId?: string, level = 0): string {
|
|
60
|
+
let result = '';
|
|
61
|
+
const indent = ' '.repeat(level);
|
|
62
|
+
|
|
63
|
+
pages.forEach(page => {
|
|
64
|
+
let line = `${indent}- ${page.title}[id=${page.id}]`;
|
|
65
|
+
|
|
66
|
+
if (page.componentType) {
|
|
67
|
+
line += `(${page.componentType})`;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (focusedPageId && page.id === focusedPageId) {
|
|
71
|
+
line += ' 【当前聚焦】';
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
result += line + '\n';
|
|
75
|
+
|
|
76
|
+
if (page.children && page.children.length > 0) {
|
|
77
|
+
result += this.generateTreeText(page.children, focusedPageId, level + 1);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
return result;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
import { OutlineNode } from './outline-info'
|
|
2
|
+
import { FocusOutlineInfoManager, FocusInfo } from './outline-focus'
|
|
3
|
+
import { ComponentsManager } from './components-manager'
|
|
4
|
+
import { PageTreeGenerator } from './page-tree-generator';
|
|
5
|
+
|
|
6
|
+
// 类型定义
|
|
7
|
+
interface DocumentInfo {
|
|
8
|
+
id: string;
|
|
9
|
+
type: string;
|
|
10
|
+
title: string;
|
|
11
|
+
desc: string;
|
|
12
|
+
content: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface PageInfo {
|
|
16
|
+
id: string;
|
|
17
|
+
title: string;
|
|
18
|
+
type: string;
|
|
19
|
+
componentType?: string;
|
|
20
|
+
children?: PageInfo[];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface PagesData {
|
|
24
|
+
pageAry: PageInfo[];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface WorkSpaceConfig {
|
|
28
|
+
currentFocus: FocusInfo;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
interface WorkSpaceAPI {
|
|
32
|
+
getAllPageInfo(): PagesData | PagesData[];
|
|
33
|
+
getComponentDoc(ns: string): string
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
class WorkSpace {
|
|
37
|
+
private openedDocuments: DocumentInfo[] = [];
|
|
38
|
+
|
|
39
|
+
private api: WorkSpaceAPI;
|
|
40
|
+
private focusInfo: FocusInfo;
|
|
41
|
+
private outlineInfoManager: FocusOutlineInfoManager;
|
|
42
|
+
private openedComponentDocs: string[] = []
|
|
43
|
+
|
|
44
|
+
/** 当前聚焦页面的大纲 */
|
|
45
|
+
focusPageOutlineInfo: OutlineNode
|
|
46
|
+
|
|
47
|
+
constructor(config: WorkSpaceConfig, api: WorkSpaceAPI, outlineInfo: FocusOutlineInfoManager) {
|
|
48
|
+
this.api = api;
|
|
49
|
+
this.focusInfo = { ...(config.currentFocus ?? {}) };
|
|
50
|
+
this.outlineInfoManager = outlineInfo;
|
|
51
|
+
|
|
52
|
+
this.focusPageOutlineInfo = this.outlineInfoManager.getFocusPageOutline();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* 获取所有页面信息
|
|
58
|
+
*/
|
|
59
|
+
private getAllPageInfo(): PagesData | PagesData[] {
|
|
60
|
+
return this.api.getAllPageInfo();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* 根据ID查找页面信息
|
|
65
|
+
*/
|
|
66
|
+
private findPageById(id: string): PageInfo | null {
|
|
67
|
+
const allPageInfo = this.getAllPageInfo();
|
|
68
|
+
let pages: PageInfo[] = [];
|
|
69
|
+
|
|
70
|
+
// 兼容两种返回类型
|
|
71
|
+
if (Array.isArray(allPageInfo)) {
|
|
72
|
+
// 如果是 PagesData[] 类型
|
|
73
|
+
allPageInfo.forEach(pagesData => {
|
|
74
|
+
if (pagesData.pageAry && Array.isArray(pagesData.pageAry)) { // 多画布
|
|
75
|
+
pages.push(...pagesData.pageAry);
|
|
76
|
+
} else {
|
|
77
|
+
pages.push({ ...pagesData } as any as PageInfo) // 单画布
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
} else {
|
|
81
|
+
// 如果是 PagesData 类型
|
|
82
|
+
pages = allPageInfo.pageAry || [];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return this.searchPageInArray(id, pages);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* 在页面数组中递归查找页面
|
|
90
|
+
*/
|
|
91
|
+
private searchPageInArray(id: string, pages: PageInfo[]): PageInfo | null {
|
|
92
|
+
for (const page of pages) {
|
|
93
|
+
if (page.id === id) {
|
|
94
|
+
return page;
|
|
95
|
+
}
|
|
96
|
+
if (page.children) {
|
|
97
|
+
const found = this.searchPageInArray(id, page.children);
|
|
98
|
+
if (found) return found;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
getJsxById = (id: string): string => {
|
|
105
|
+
const isPage = this.focusInfo.pageId === id || !!this.findPageById(id);
|
|
106
|
+
if (isPage) {
|
|
107
|
+
return this.outlineInfoManager.generateJSXByPageId(id)?.jsx ?? '';
|
|
108
|
+
} else {
|
|
109
|
+
return this.outlineInfoManager.generateJSXByOutline(this.focusPageOutlineInfo, [id])?.jsx ?? '';
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* 打开文档
|
|
115
|
+
*/
|
|
116
|
+
openDocument(id: string): void {
|
|
117
|
+
|
|
118
|
+
// 检查是否已经打开
|
|
119
|
+
if (this.openedDocuments.some(doc => doc.id === id)) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const isPage = this.focusInfo.pageId === id || !!this.findPageById(id);
|
|
124
|
+
const typeDesc = isPage ? '画布' : '组件'
|
|
125
|
+
|
|
126
|
+
let outlineInfo: OutlineNode;
|
|
127
|
+
let targetComponentIds: string[] = [];
|
|
128
|
+
|
|
129
|
+
if (isPage) {
|
|
130
|
+
// 如果是页面,直接获取页面信息
|
|
131
|
+
outlineInfo = this.outlineInfoManager.getPageOutline(id);
|
|
132
|
+
targetComponentIds = [];
|
|
133
|
+
} else {
|
|
134
|
+
// 如果是组件,需要获取包含该组件的页面信息
|
|
135
|
+
outlineInfo = this.focusPageOutlineInfo;
|
|
136
|
+
|
|
137
|
+
// 获取所有已打开的组件ID(排除页面ID)
|
|
138
|
+
const openedComponentIds = this.openedDocuments
|
|
139
|
+
.filter(doc => doc.type === '组件')
|
|
140
|
+
.map(doc => doc.id);
|
|
141
|
+
|
|
142
|
+
// 添加当前要打开的组件ID
|
|
143
|
+
targetComponentIds = [...openedComponentIds, id];
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const componentsInfo = this.outlineInfoManager.generateJSXByOutline(outlineInfo, targetComponentIds);
|
|
147
|
+
|
|
148
|
+
// 将已经打开文档的组件配置文档拿出来
|
|
149
|
+
componentsInfo.namespaces.forEach(ns => this.openComponentDoc(ns));
|
|
150
|
+
|
|
151
|
+
if (isPage) {
|
|
152
|
+
// 页面类型:直接添加新文档
|
|
153
|
+
this.openedDocuments.push({
|
|
154
|
+
id,
|
|
155
|
+
type: typeDesc,
|
|
156
|
+
title: '',
|
|
157
|
+
desc: '',
|
|
158
|
+
content: componentsInfo.jsx
|
|
159
|
+
});
|
|
160
|
+
} else {
|
|
161
|
+
// 组件类型:检查是否需要更新现有文档或创建新文档
|
|
162
|
+
const existingComponentDocs = this.openedDocuments.filter(doc => doc.type === '组件');
|
|
163
|
+
|
|
164
|
+
if (existingComponentDocs.length > 0) {
|
|
165
|
+
// 如果已经有组件文档,更新第一个组件文档的内容
|
|
166
|
+
existingComponentDocs[0].content = componentsInfo.jsx;
|
|
167
|
+
existingComponentDocs[0].id = componentsInfo.id;
|
|
168
|
+
// 可以选择更新ID为组合ID,比如:
|
|
169
|
+
// existingComponentDocs[0].id = targetComponentIds.join(',');
|
|
170
|
+
} else {
|
|
171
|
+
// 如果没有组件文档,创建新的
|
|
172
|
+
this.openedDocuments.push({
|
|
173
|
+
id: componentsInfo.id,
|
|
174
|
+
type: typeDesc,
|
|
175
|
+
title: '',
|
|
176
|
+
desc: '',
|
|
177
|
+
content: componentsInfo.jsx
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* 关闭文档
|
|
185
|
+
*/
|
|
186
|
+
closeDocument(id: string): void {
|
|
187
|
+
this.openedDocuments = this.openedDocuments.filter(doc => doc.id !== id);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* 检查文档状态
|
|
192
|
+
*/
|
|
193
|
+
checkDocumentStatus(id: string) {
|
|
194
|
+
if (this.openedDocuments.some(doc => doc.id === id)) {
|
|
195
|
+
return true;
|
|
196
|
+
}
|
|
197
|
+
return false;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* 获取项目结构描述
|
|
202
|
+
*/
|
|
203
|
+
getProjectStruct(): string {
|
|
204
|
+
const pageTree = PageTreeGenerator.generate(this.getAllPageInfo(), {
|
|
205
|
+
pageId: this.focusInfo.pageId
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
const focusDescription = this.outlineInfoManager.generateFocusDescription();
|
|
209
|
+
|
|
210
|
+
const contentHierarchy = this.outlineInfoManager.generateFocusHierarchy();
|
|
211
|
+
|
|
212
|
+
const openedDocumentsList = this.generateOpenedDocumentsList();
|
|
213
|
+
|
|
214
|
+
return `# 工作空间(Workspace)
|
|
215
|
+
工作空间包含整个项目的「画布索引」「聚焦信息」「已打开的文档」,提供的始终都是最新的项目信息。
|
|
216
|
+
|
|
217
|
+
WARNING: 如果「历史记录」的信息和工作空间冲突,始终以工作空间的信息为准,因为「历史记录」的操作很有可能没保存,且不是最新的。
|
|
218
|
+
|
|
219
|
+
## 画布索引
|
|
220
|
+
${pageTree}
|
|
221
|
+
|
|
222
|
+
## 聚焦信息
|
|
223
|
+
以下是当前聚焦组件的简略树结构,展示了聚焦元素的父级、兄弟、子级元素的关系。
|
|
224
|
+
注意:此树结构并不完整,折叠了无关元素信息,如需详细信息请打开DSL文档获取。
|
|
225
|
+
|
|
226
|
+
${contentHierarchy}
|
|
227
|
+
|
|
228
|
+
${focusDescription}
|
|
229
|
+
|
|
230
|
+
## 已打开的文档
|
|
231
|
+
${openedDocumentsList}
|
|
232
|
+
`;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
openComponentDoc(namespace: string) {
|
|
236
|
+
// 校验,保证传入的是完整namespace
|
|
237
|
+
const fullNamespace = ComponentsManager.getFullNamespace(namespace)
|
|
238
|
+
|
|
239
|
+
// 检查是否已经打开
|
|
240
|
+
if (this.openedComponentDocs.some(ns => ns === fullNamespace)) {
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
this.openedComponentDocs.push(fullNamespace)
|
|
245
|
+
|
|
246
|
+
// 加载依赖
|
|
247
|
+
const requires = ComponentsManager.getRequireComponents(fullNamespace)
|
|
248
|
+
if (Array.isArray(requires) && requires.length) {
|
|
249
|
+
requires.forEach(ns => this.openComponentDoc(ns))
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
closeComponentDoc(namespace: string) {
|
|
254
|
+
// 校验,保证传入的是完整namespace
|
|
255
|
+
const fullNamespace = ComponentsManager.getFullNamespace(namespace)
|
|
256
|
+
this.openedComponentDocs = this.openedComponentDocs.filter(ns => ns !== fullNamespace)
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
hasComponentsDocs(): boolean {
|
|
260
|
+
return this.openedComponentDocs.length > 0
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* 获取组件文档
|
|
265
|
+
*/
|
|
266
|
+
getComponentsDocs(): string {
|
|
267
|
+
const layoutComponentsNs = ComponentsManager.getLayoutComponentsAbbreviationNs()
|
|
268
|
+
return `# 组件使用文档
|
|
269
|
+
${layoutComponentsNs.length ? `在以下所有组件中,特别的,${layoutComponentsNs.map(ns => ns).join('、')} 是用于基础布局的组件,辅助标记也仅可以用于这些组件` : ''}
|
|
270
|
+
|
|
271
|
+
${this.openedComponentDocs.map(namespace => {
|
|
272
|
+
// 校验,保证传入的是完整namespace
|
|
273
|
+
const fullNamespace = ComponentsManager.getFullNamespace(namespace)
|
|
274
|
+
|
|
275
|
+
const abbreviationNs = ComponentsManager.getAbbreviation(fullNamespace);
|
|
276
|
+
const componentInfo = ComponentsManager.getAiComponent(fullNamespace)
|
|
277
|
+
const componentAll = componentInfo?.all ?? {}
|
|
278
|
+
const inputs = componentAll?.inputs?.reduce?.((pre: string, { id, title, schema }: any) => {
|
|
279
|
+
let schemaStr = "";
|
|
280
|
+
try {
|
|
281
|
+
schemaStr = ` - schema: ${JSON.stringify(schema)}\n`
|
|
282
|
+
} catch {}
|
|
283
|
+
return pre + ` - ${title} → inputId: \`${id}\`\n` +
|
|
284
|
+
schemaStr
|
|
285
|
+
}, "")
|
|
286
|
+
const isUI = !componentAll.rtType;
|
|
287
|
+
const slots = componentAll?.slots?.reduce?.((pre: string, { id, title, type, description, inputs }: any) => {
|
|
288
|
+
const isScope = type === "scope" && inputs?.length;
|
|
289
|
+
return pre + ` - ${id}(${title}${description ? ` - ${description}` : ""})${type === "scope" ? "- 作用域插槽" : ""}\n` +
|
|
290
|
+
(isScope ? inputs.reduce((pre: string, { id, title, desc }: any) => {
|
|
291
|
+
return pre + ` - ${id}(${title})${desc ? ` - ${desc}` : ""}\n`
|
|
292
|
+
}, ""): "")
|
|
293
|
+
}, "")
|
|
294
|
+
|
|
295
|
+
return this.api.getComponentDoc(fullNamespace)
|
|
296
|
+
.replace("</type>", '</type>' + (isUI ? `\n<slots>
|
|
297
|
+
${slots || "无\n"}</slots>\n\n` : ""))
|
|
298
|
+
.replace("</type>", '</type>' + (isUI ? `\n<inputs>
|
|
299
|
+
${inputs || "无\n"}</inputs>\n\n` : ""))
|
|
300
|
+
.replace('<component>', `<${abbreviationNs}文档>`).replace('</component>', `</${abbreviationNs}文档>`).replace(new RegExp(`${fullNamespace}`, 'g'), abbreviationNs)
|
|
301
|
+
}).join('')}
|
|
302
|
+
`
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* 生成已打开文档列表
|
|
307
|
+
*/
|
|
308
|
+
private generateOpenedDocumentsList(): string {
|
|
309
|
+
if (this.openedDocuments.length === 0) {
|
|
310
|
+
return '暂无打开的文档';
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
return this.openedDocuments.map(doc =>
|
|
314
|
+
`- ${doc.title}[id=${doc.id}](${doc.type})\n 描述:${doc.desc}\n 内容:${doc.content}`
|
|
315
|
+
).join('\n\n');
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
export { WorkSpace, type WorkSpaceConfig, type WorkSpaceAPI };
|