@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.
Files changed (93) hide show
  1. package/package.json +7 -2
  2. package/src/agents/app.ts +188 -60
  3. package/src/agents/common.ts +428 -68
  4. package/src/agents/custom.ts +14 -0
  5. package/src/agents/index.ts +31 -1
  6. package/src/agents/knowledges/README.md +614 -0
  7. package/src/agents/knowledges/SUMMARY.md +527 -0
  8. package/src/agents/knowledges/index.ts +8 -0
  9. package/src/agents/knowledges/knowledge-base.ts +565 -0
  10. package/src/agents/knowledges/knowledge-node.ts +266 -0
  11. package/src/agents/knowledges/types.ts +208 -0
  12. package/src/agents/utils/config.ts +427 -0
  13. package/src/agents/workspace/coding-manager.ts +31 -0
  14. package/src/agents/workspace/components-manager.ts +124 -0
  15. package/src/agents/workspace/outline-focus.ts +188 -0
  16. package/src/agents/workspace/outline-info.ts +520 -0
  17. package/src/agents/workspace/page-tree-generator.ts +83 -0
  18. package/src/agents/workspace/workspace.ts +319 -0
  19. package/src/agents/workspace-by-knowledges/MIGRATION.md +568 -0
  20. package/src/agents/workspace-by-knowledges/README.md +521 -0
  21. package/src/agents/workspace-by-knowledges/index.ts +11 -0
  22. package/src/agents/workspace-by-knowledges/providers/component-docs-provider.ts +92 -0
  23. package/src/agents/workspace-by-knowledges/providers/focus-info-provider.ts +131 -0
  24. package/src/agents/workspace-by-knowledges/providers/index.ts +8 -0
  25. package/src/agents/workspace-by-knowledges/providers/project-info-provider.ts +151 -0
  26. package/src/agents/workspace-by-knowledges/test.ts +240 -0
  27. package/src/agents/workspace-by-knowledges/types.ts +56 -0
  28. package/src/agents/workspace-by-knowledges/utils/components-manager.ts +145 -0
  29. package/src/agents/workspace-by-knowledges/utils/index.ts +8 -0
  30. package/src/agents/workspace-by-knowledges/utils/outline-focus.ts +178 -0
  31. package/src/agents/workspace-by-knowledges/utils/outline-info.ts +521 -0
  32. package/src/agents/workspace-by-knowledges/workspace.ts +166 -0
  33. package/src/api/cloud-components.ts +129 -0
  34. package/src/api-record-replay/README.md +187 -0
  35. package/src/api-record-replay/index.ts +11 -0
  36. package/src/api-record-replay/manager.ts +168 -0
  37. package/src/api-record-replay/recorder.ts +117 -0
  38. package/src/api-record-replay/replayer.ts +148 -0
  39. package/src/components/attachments/index.less +117 -0
  40. package/src/components/attachments/index.tsx +136 -0
  41. package/src/components/icons/index.tsx +21 -1
  42. package/src/components/index.less +34 -0
  43. package/src/components/mention/index.less +23 -0
  44. package/src/components/mention/index.tsx +19 -0
  45. package/src/components/messages/index.less +444 -237
  46. package/src/components/messages/index.tsx +371 -88
  47. package/src/components/sender/index.less +203 -0
  48. package/src/components/sender/index.tsx +298 -0
  49. package/src/components/types.ts +31 -0
  50. package/src/constants/index.ts +8 -0
  51. package/src/context/RequestStatusTracker.ts +50 -0
  52. package/src/context/index.ts +68 -6
  53. package/src/{types.d.ts → global.d.ts} +40 -5
  54. package/src/index.tsx +212 -32
  55. package/src/preset/agents.ts +380 -0
  56. package/src/preset/createTemplates.ts +25 -0
  57. package/src/preset/index.ts +12 -0
  58. package/src/preset/prompts.ts +235 -0
  59. package/src/preset/requestAsStream.ts +246 -0
  60. package/src/preset/user.ts +6 -0
  61. package/src/startView/components/header/header.less +17 -0
  62. package/src/startView/components/header/header.tsx +15 -0
  63. package/src/startView/components/index.ts +1 -0
  64. package/src/startView/index.less +22 -204
  65. package/src/startView/index.tsx +35 -203
  66. package/src/tools/analyze-and-expand-prd.ts +192 -86
  67. package/src/tools/analyze-requirement-and-components.ts +589 -0
  68. package/src/tools/answer.ts +59 -0
  69. package/src/tools/build-process.ts +1174 -0
  70. package/src/tools/coding-subagent-as-tool.ts +119 -0
  71. package/src/tools/generate-ui-content.ts +1083 -0
  72. package/src/tools/index.ts +22 -19
  73. package/src/tools/open-dsl.ts +69 -0
  74. package/src/tools/refactor-ui-content.ts +801 -0
  75. package/src/tools/utils.ts +880 -28
  76. package/src/types/index.ts +4 -0
  77. package/src/view/components/header/header.less +36 -2
  78. package/src/view/components/header/header.tsx +47 -2
  79. package/src/view/components/index.ts +0 -2
  80. package/src/view/index.tsx +158 -8
  81. package/src/tools/answer-user.ts +0 -35
  82. package/src/tools/focus-element.ts +0 -47
  83. package/src/tools/generate-page.ts +0 -750
  84. package/src/tools/get-component-info-by-ids.ts +0 -166
  85. package/src/tools/get-component-info.ts +0 -53
  86. package/src/tools/get-components-doc-and-prd.ts +0 -137
  87. package/src/tools/get-focus-mybricks-dsl.ts +0 -26
  88. package/src/tools/get-mybricks-dsl.ts +0 -73
  89. package/src/tools/modify-component.ts +0 -385
  90. package/src/view/components/messages/messages.less +0 -228
  91. package/src/view/components/messages/messages.tsx +0 -172
  92. package/src/view/components/sender/sender.less +0 -44
  93. package/src/view/components/sender/sender.tsx +0 -62
@@ -1,25 +1,28 @@
1
- import GeneratePage from './generate-page';
2
- import GetComponentsDocAndPrd from './get-components-doc-and-prd';
3
- import ModifyComponent from './modify-component'
4
- import GetMybricksDSL from './get-mybricks-dsl';
5
- import GetFocusMybricksDSL from './get-focus-mybricks-dsl';
6
- import FocusElement from './focus-element'
7
- import GetComponentInfo from './get-component-info'
8
- import GetComponentsInfoByIds from './get-component-info-by-ids';
9
- import AnswerUser from './answer-user';
1
+ import GenerateUiContent, { GenerateUiContent as GenerateUiContentParamsTool } from './generate-ui-content';
2
+ import AnalyzeRequirementAndComponents, { AnalyzeRequirementAndComponents as AnalyzeRequirementAndComponentsParamsTool } from './analyze-requirement-and-components';
3
+ import RefactorUiContent, { RefactorUiContent as RefactorUiContentParamsTool } from './refactor-ui-content'
10
4
  import AnalyzeAndExpandPrd from './analyze-and-expand-prd';
5
+ import OpenDsl from './open-dsl';
6
+ import Answer from './answer';
7
+ import BuildProcess, { BuildProcess as BuildProcessParamsTool } from "./build-process";
8
+ import CodingSubagentAsTool from './coding-subagent-as-tool';
11
9
 
12
10
  export const MYBRICKS_TOOLS = {
13
- GeneratePage,
14
- GetComponentsDocAndPrd,
15
- ModifyComponent,
16
- // GetMybricksDSL,
17
- GetFocusMybricksDSL,
18
- GetComponentInfo,
19
- GetComponentsInfoByIds,
11
+ GenerateUiContent,
12
+ AnalyzeRequirementAndComponents,
13
+ RefactorUiContent,
20
14
  AnalyzeAndExpandPrd,
21
- // AnswerUser
22
- // FocusElement
15
+ OpenDsl,
16
+ Answer,
17
+ BuildProcess,
18
+ CodingSubagentAsTool
23
19
  }
24
20
 
25
- export { MyBricksHelper } from './utils'
21
+ export const MyBricksParamsTools = {
22
+ GenerateUiContent: GenerateUiContentParamsTool,
23
+ AnalyzeRequirementAndComponents: AnalyzeRequirementAndComponentsParamsTool,
24
+ RefactorUiContent: RefactorUiContentParamsTool,
25
+ BuildProcess: BuildProcessParamsTool,
26
+ }
27
+
28
+ export * from './utils'
@@ -0,0 +1,69 @@
1
+ import { fileFormat, RxaiError } from '@mybricks/rxai'
2
+
3
+ interface ToolParams {
4
+ onOpen?: (id: string) => void
5
+ }
6
+
7
+ const NAME = 'open-dsl-document'
8
+ openDsl.toolName = NAME
9
+
10
+ export default function openDsl(config: ToolParams, ): any {
11
+ return {
12
+ name: NAME,
13
+ displayName: "读取上下文",
14
+ description: `打开并获取工作空间中需求所关联的DSL文档(包含当前画布/组件DSL及其所有子组件DSL),用于后续完成需求使用。
15
+ 参数(ids):画布ID/组件ID列表,支持批量,批量ID用英文逗号分隔;
16
+ 工具分类:信息获取类
17
+ 何时使用:任何时候和搭建有关的提问,都应该先获取DSL文档看看,有可能需要参考画布级DSL(比如页面DSL)来理解当前需求。
18
+
19
+ DSL定义:将搭建信息总结成可视化的类JSX树状结构,包含当前组件及其子组件的尺寸、位置、样式、标题、组件配置等信息。
20
+
21
+ 聚焦信息里给出了简略的文档信息,如果没发现建议搜索更上层的范围去查找。
22
+
23
+ **DSL 文档选取策略:**
24
+ 1. 优先获取最近共同祖先 DSL(关键原则):由于包含所有子组件DSL,所以获取共同祖先是最简单的方式,比如
25
+ 1.1 需求是“参考组件 A 修改组件 B”,则应获取 A 与 B 的最近共同祖先 DSL;
26
+ 1.2 当传入多个组件 ID 时,应优先查找并返回它们最近的最近共同祖先 DSL 文档;
27
+ 2. 避免重复加载:若已加载某画布的完整 DSL,则无需再单独加载该画布内的组件 DSL;
28
+ 3. 完整包含:要修改的目标可能不在聚焦的组件内,也需要获取其DSL;
29
+
30
+ **重要说明:**
31
+ - 避免过度加载无关层级或冗余内容。
32
+ - 所有通过本操作打开的 DSL 文件仅在当前轮次有效。
33
+ - 若需使用历史对话中曾打开过的文件,必须在本轮重新调用打开操作。
34
+
35
+ > ⚠️ 注意:在调用任何工具前,必须先执行本指令以确保获取正确的上下文 DSL。
36
+ `,
37
+ execute({ params }) {
38
+ let ids = params.ids
39
+
40
+ // 兼容key使用错误的情况
41
+ if (!ids && Object.keys(params).length) {
42
+ ids = params[Object.keys(params)[0]]
43
+ }
44
+
45
+ if (ids && ids.split(',')) {
46
+ const idsAry = ids.split(',')
47
+
48
+ if (idsAry.length === 0) {
49
+ throw new RxaiError(`工具 ${NAME} 的调用缺少 ids 参数,请重新规划`, "retry", '没有要读取的上下文,请重试')
50
+ }
51
+
52
+ idsAry.forEach(id => {
53
+ try {
54
+ config.onOpen?.(id)
55
+ } catch (error) {
56
+ console.warn(error)
57
+ throw new RxaiError(`工具 ${NAME} 的调用失败,读取${id}的文档失败,错误信息为${error?.message},请重新规划`, "retry", `读取上下文${id}的信息失败,请重试`)
58
+ }
59
+ })
60
+ } else {
61
+ throw new RxaiError(`工具 ${NAME} 的调用缺少 ids 参数,请重新规划`, "retry", '读取上下文失败,请重试')
62
+ }
63
+ return {
64
+ llmContent: "已打开",
65
+ displayContent: "已成功读取上下文"
66
+ }
67
+ },
68
+ }
69
+ }