foliko 1.0.73 → 1.0.75

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 (237) hide show
  1. package/.agent/.shared/ui-ux-pro-max/data/charts.csv +26 -0
  2. package/.agent/.shared/ui-ux-pro-max/data/colors.csv +97 -0
  3. package/.agent/.shared/ui-ux-pro-max/data/icons.csv +101 -0
  4. package/.agent/.shared/ui-ux-pro-max/data/landing.csv +31 -0
  5. package/.agent/.shared/ui-ux-pro-max/data/products.csv +97 -0
  6. package/.agent/.shared/ui-ux-pro-max/data/prompts.csv +24 -0
  7. package/.agent/.shared/ui-ux-pro-max/data/react-performance.csv +45 -0
  8. package/.agent/.shared/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
  9. package/.agent/.shared/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
  10. package/.agent/.shared/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
  11. package/.agent/.shared/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
  12. package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
  13. package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
  14. package/.agent/.shared/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
  15. package/.agent/.shared/ui-ux-pro-max/data/stacks/react.csv +54 -0
  16. package/.agent/.shared/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
  17. package/.agent/.shared/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
  18. package/.agent/.shared/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
  19. package/.agent/.shared/ui-ux-pro-max/data/stacks/vue.csv +50 -0
  20. package/.agent/.shared/ui-ux-pro-max/data/styles.csv +59 -0
  21. package/.agent/.shared/ui-ux-pro-max/data/typography.csv +58 -0
  22. package/.agent/.shared/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
  23. package/.agent/.shared/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
  24. package/.agent/.shared/ui-ux-pro-max/data/web-interface.csv +31 -0
  25. package/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/core.cpython-313.pyc +0 -0
  26. package/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-313.pyc +0 -0
  27. package/.agent/.shared/ui-ux-pro-max/scripts/core.py +258 -0
  28. package/.agent/.shared/ui-ux-pro-max/scripts/design_system.py +1067 -0
  29. package/.agent/.shared/ui-ux-pro-max/scripts/search.py +106 -0
  30. package/.agent/ARCHITECTURE.md +288 -0
  31. package/.agent/agents/ambient-agent.md +57 -0
  32. package/.agent/agents/debugger.md +55 -0
  33. package/.agent/agents/email-assistant.md +49 -0
  34. package/.agent/agents/file-manager.md +42 -0
  35. package/.agent/agents/python-developer.md +60 -0
  36. package/.agent/agents/scheduler.md +59 -0
  37. package/.agent/agents/web-developer.md +45 -0
  38. package/.agent/data/default.json +29 -0
  39. package/.agent/data/plugins-state.json +255 -0
  40. package/.agent/mcp_config.json +4 -0
  41. package/.agent/mcp_config_updated.json +12 -0
  42. package/.agent/plugins.json +5 -0
  43. package/.agent/rules/GEMINI.md +273 -0
  44. package/.agent/rules/allow-rule.md +77 -0
  45. package/.agent/rules/log-rule.md +83 -0
  46. package/.agent/rules/security-rule.md +93 -0
  47. package/.agent/scripts/auto_preview.py +148 -0
  48. package/.agent/scripts/checklist.py +217 -0
  49. package/.agent/scripts/session_manager.py +120 -0
  50. package/.agent/scripts/verify_all.py +327 -0
  51. package/.agent/skills/api-patterns/SKILL.md +81 -0
  52. package/.agent/skills/api-patterns/api-style.md +42 -0
  53. package/.agent/skills/api-patterns/auth.md +24 -0
  54. package/.agent/skills/api-patterns/documentation.md +26 -0
  55. package/.agent/skills/api-patterns/graphql.md +41 -0
  56. package/.agent/skills/api-patterns/rate-limiting.md +31 -0
  57. package/.agent/skills/api-patterns/response.md +37 -0
  58. package/.agent/skills/api-patterns/rest.md +40 -0
  59. package/.agent/skills/api-patterns/scripts/api_validator.py +211 -0
  60. package/.agent/skills/api-patterns/security-testing.md +122 -0
  61. package/.agent/skills/api-patterns/trpc.md +41 -0
  62. package/.agent/skills/api-patterns/versioning.md +22 -0
  63. package/.agent/skills/app-builder/SKILL.md +75 -0
  64. package/.agent/skills/app-builder/agent-coordination.md +71 -0
  65. package/.agent/skills/app-builder/feature-building.md +53 -0
  66. package/.agent/skills/app-builder/project-detection.md +34 -0
  67. package/.agent/skills/app-builder/scaffolding.md +118 -0
  68. package/.agent/skills/app-builder/tech-stack.md +40 -0
  69. package/.agent/skills/app-builder/templates/SKILL.md +39 -0
  70. package/.agent/skills/app-builder/templates/astro-static/TEMPLATE.md +76 -0
  71. package/.agent/skills/app-builder/templates/chrome-extension/TEMPLATE.md +92 -0
  72. package/.agent/skills/app-builder/templates/cli-tool/TEMPLATE.md +88 -0
  73. package/.agent/skills/app-builder/templates/electron-desktop/TEMPLATE.md +88 -0
  74. package/.agent/skills/app-builder/templates/express-api/TEMPLATE.md +83 -0
  75. package/.agent/skills/app-builder/templates/flutter-app/TEMPLATE.md +90 -0
  76. package/.agent/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +90 -0
  77. package/.agent/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +122 -0
  78. package/.agent/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +122 -0
  79. package/.agent/skills/app-builder/templates/nextjs-static/TEMPLATE.md +169 -0
  80. package/.agent/skills/app-builder/templates/nuxt-app/TEMPLATE.md +134 -0
  81. package/.agent/skills/app-builder/templates/python-fastapi/TEMPLATE.md +83 -0
  82. package/.agent/skills/app-builder/templates/react-native-app/TEMPLATE.md +119 -0
  83. package/.agent/skills/architecture/SKILL.md +55 -0
  84. package/.agent/skills/architecture/context-discovery.md +43 -0
  85. package/.agent/skills/architecture/examples.md +94 -0
  86. package/.agent/skills/architecture/pattern-selection.md +68 -0
  87. package/.agent/skills/architecture/patterns-reference.md +50 -0
  88. package/.agent/skills/architecture/trade-off-analysis.md +77 -0
  89. package/.agent/skills/clean-code/SKILL.md +201 -0
  90. package/.agent/skills/doc.md +177 -0
  91. package/.agent/skills/frontend-design/SKILL.md +418 -0
  92. package/.agent/skills/frontend-design/animation-guide.md +331 -0
  93. package/.agent/skills/frontend-design/color-system.md +311 -0
  94. package/.agent/skills/frontend-design/decision-trees.md +418 -0
  95. package/.agent/skills/frontend-design/motion-graphics.md +306 -0
  96. package/.agent/skills/frontend-design/scripts/accessibility_checker.py +183 -0
  97. package/.agent/skills/frontend-design/scripts/ux_audit.py +722 -0
  98. package/.agent/skills/frontend-design/typography-system.md +345 -0
  99. package/.agent/skills/frontend-design/ux-psychology.md +1116 -0
  100. package/.agent/skills/frontend-design/visual-effects.md +383 -0
  101. package/.agent/skills/i18n-localization/SKILL.md +154 -0
  102. package/.agent/skills/i18n-localization/scripts/i18n_checker.py +241 -0
  103. package/.agent/skills/mcp-builder/SKILL.md +176 -0
  104. package/.agent/skills/web-design-guidelines/SKILL.md +57 -0
  105. package/.agent/workflows/brainstorm.md +113 -0
  106. package/.agent/workflows/create.md +59 -0
  107. package/.agent/workflows/debug.md +103 -0
  108. package/.agent/workflows/deploy.md +176 -0
  109. package/.agent/workflows/enhance.md +63 -0
  110. package/.agent/workflows/orchestrate.md +237 -0
  111. package/.agent/workflows/plan.md +89 -0
  112. package/.agent/workflows/preview.md +81 -0
  113. package/.agent/workflows/simple-test.md +42 -0
  114. package/.agent/workflows/status.md +86 -0
  115. package/.agent/workflows/structured-orchestrate.md +180 -0
  116. package/.agent/workflows/test.md +144 -0
  117. package/.agent/workflows/ui-ux-pro-max.md +296 -0
  118. package/.claude/settings.local.json +157 -149
  119. package/.editorconfig +56 -0
  120. package/.husky/pre-commit +4 -0
  121. package/.lintstagedrc +7 -0
  122. package/.prettierignore +29 -0
  123. package/.prettierrc +11 -0
  124. package/CLAUDE.md +2 -0
  125. package/README.md +64 -55
  126. package/SPEC.md +102 -61
  127. package/cli/bin/foliko.js +4 -4
  128. package/cli/src/commands/chat.js +53 -51
  129. package/cli/src/commands/list.js +40 -37
  130. package/cli/src/index.js +18 -18
  131. package/cli/src/ui/chat-ui.js +78 -76
  132. package/cli/src/utils/ansi.js +15 -15
  133. package/cli/src/utils/markdown.js +112 -116
  134. package/docker-compose.yml +1 -1
  135. package/docs/ai-sdk-optimization.md +655 -636
  136. package/docs/features.md +80 -80
  137. package/docs/quick-reference.md +49 -46
  138. package/docs/user-manual.md +411 -380
  139. package/examples/ambient-example.js +95 -97
  140. package/examples/basic.js +115 -110
  141. package/examples/bootstrap.js +52 -43
  142. package/examples/mcp-example.js +56 -53
  143. package/examples/skill-example.js +49 -49
  144. package/examples/test-chat.js +60 -58
  145. package/examples/test-mcp.js +49 -43
  146. package/examples/test-reload.js +38 -40
  147. package/examples/test-telegram.js +3 -3
  148. package/examples/test-tg-bot.js +7 -4
  149. package/examples/test-tg-simple.js +4 -3
  150. package/examples/test-tg.js +3 -3
  151. package/examples/test-think.js +13 -7
  152. package/examples/test-web-plugin.js +61 -56
  153. package/examples/test-weixin-feishu.js +40 -37
  154. package/examples/workflow.js +49 -49
  155. package/foliko-1.0.75.tgz +0 -0
  156. package/package.json +37 -3
  157. package/plugins/ai-plugin.js +7 -5
  158. package/plugins/ambient-agent/EventWatcher.js +113 -0
  159. package/plugins/ambient-agent/ExplorerLoop.js +640 -0
  160. package/plugins/ambient-agent/GoalManager.js +197 -0
  161. package/plugins/ambient-agent/Reflector.js +95 -0
  162. package/plugins/ambient-agent/StateStore.js +90 -0
  163. package/plugins/ambient-agent/constants.js +101 -0
  164. package/plugins/ambient-agent/index.js +579 -0
  165. package/plugins/default-plugins.js +62 -49
  166. package/plugins/email/constants.js +64 -0
  167. package/plugins/email/handlers.js +461 -0
  168. package/plugins/email/index.js +278 -0
  169. package/plugins/email/monitor.js +269 -0
  170. package/plugins/email/parser.js +138 -0
  171. package/plugins/email/reply.js +151 -0
  172. package/plugins/email/utils.js +124 -0
  173. package/plugins/feishu-plugin.js +23 -19
  174. package/plugins/file-system-plugin.js +469 -120
  175. package/plugins/install-plugin.js +6 -4
  176. package/plugins/python-executor-plugin.js +3 -1
  177. package/plugins/python-plugin-loader.js +10 -8
  178. package/plugins/rules-plugin.js +5 -3
  179. package/plugins/scheduler-plugin.js +18 -16
  180. package/plugins/session-plugin.js +3 -1
  181. package/plugins/storage-plugin.js +5 -3
  182. package/plugins/subagent-plugin.js +152 -92
  183. package/plugins/telegram-plugin.js +26 -19
  184. package/plugins/think-plugin.js +4 -2
  185. package/plugins/tools-plugin.js +3 -1
  186. package/plugins/web-plugin.js +15 -13
  187. package/plugins/weixin-plugin.js +43 -36
  188. package/reports/system-health-report-20260401.md +79 -0
  189. package/skills/ambient-agent/SKILL.md +49 -39
  190. package/skills/foliko-dev/AGENTS.md +64 -61
  191. package/skills/foliko-dev/SKILL.md +125 -119
  192. package/skills/mcp-usage/SKILL.md +19 -17
  193. package/skills/python-plugin-dev/SKILL.md +16 -15
  194. package/skills/skill-guide/SKILL.md +12 -12
  195. package/skills/subagent-guide/SKILL.md +237 -0
  196. package/skills/workflow-guide/SKILL.md +90 -45
  197. package/skills/workflow-troubleshooting/DEBUGGING.md +36 -21
  198. package/skills/workflow-troubleshooting/SKILL.md +156 -79
  199. package/src/capabilities/index.js +4 -4
  200. package/src/capabilities/skill-manager.js +211 -197
  201. package/src/capabilities/workflow-engine.js +461 -547
  202. package/src/core/agent-chat.js +426 -279
  203. package/src/core/agent.js +453 -248
  204. package/src/core/framework.js +183 -149
  205. package/src/core/index.js +8 -8
  206. package/src/core/plugin-base.js +52 -52
  207. package/src/core/plugin-manager.js +377 -281
  208. package/src/core/provider.js +35 -32
  209. package/src/core/sub-agent-config.js +264 -0
  210. package/src/core/system-prompt-builder.js +120 -0
  211. package/src/core/tool-registry.js +416 -33
  212. package/src/core/tool-router.js +149 -68
  213. package/src/executors/executor-base.js +58 -58
  214. package/src/executors/mcp-executor.js +269 -257
  215. package/src/index.js +5 -17
  216. package/src/utils/circuit-breaker.js +301 -0
  217. package/src/utils/error-boundary.js +363 -0
  218. package/src/utils/error.js +374 -0
  219. package/src/utils/event-emitter.js +20 -20
  220. package/src/utils/id.js +133 -0
  221. package/src/utils/index.js +217 -3
  222. package/src/utils/logger.js +181 -0
  223. package/src/utils/plugin-helpers.js +90 -0
  224. package/src/utils/retry.js +122 -0
  225. package/src/utils/sandbox.js +292 -0
  226. package/test/tool-registry-validation.test.js +218 -0
  227. package/test_report.md +70 -0
  228. package/website/docs/api.html +169 -107
  229. package/website/docs/configuration.html +296 -144
  230. package/website/docs/plugin-development.html +154 -85
  231. package/website/docs/project-structure.html +110 -109
  232. package/website/docs/skill-development.html +117 -61
  233. package/website/index.html +209 -205
  234. package/website/script.js +20 -17
  235. package/website/styles.css +1 -1
  236. package/plugins/ambient-agent-plugin.js +0 -1565
  237. package/plugins/email.js +0 -1142
@@ -34,6 +34,7 @@ Foliko 是一个基于插件的 Agent 框架,核心简单,通过插件扩展
34
34
  ```
35
35
 
36
36
  **文件夹结构的优势:**
37
+
37
38
  - 支持 `package.json` 的 `main` 字段自定义入口
38
39
  - 支持 `node_modules` 存放插件私有依赖
39
40
  - 更适合复杂插件的代码组织
@@ -66,85 +67,87 @@ Foliko 是一个基于插件的 Agent 框架,核心简单,通过插件扩展
66
67
 
67
68
  ```javascript
68
69
  // .agent/plugins/my-plugin/index.js
69
- module.exports = function(Plugin) {
70
+ module.exports = function (Plugin) {
70
71
  return class MyPlugin extends Plugin {
71
72
  constructor(config = {}) {
72
- super()
73
- this.name = 'my-plugin'
74
- this.version = '1.0.0'
75
- this.description = '我的工具插件'
76
- this.priority = 10
73
+ super();
74
+ this.name = 'my-plugin';
75
+ this.version = '1.0.0';
76
+ this.description = '我的工具插件';
77
+ this.priority = 10;
77
78
  }
78
79
 
79
80
  install(framework) {
80
- const { z } = require('zod')
81
+ const { z } = require('zod');
81
82
  framework.registerTool({
82
83
  name: 'my_tool',
83
84
  description: '我的工具',
84
85
  inputSchema: z.object({
85
- param: z.string().describe('参数描述')
86
+ param: z.string().describe('参数描述'),
86
87
  }),
87
88
  execute: async (args, framework) => {
88
- return { success: true, result: args.param }
89
- }
90
- })
91
- return this
89
+ return { success: true, result: args.param };
90
+ },
91
+ });
92
+ return this;
92
93
  }
93
94
 
94
95
  uninstall(framework) {
95
96
  // 清理资源
96
97
  }
97
- }
98
- }
98
+ };
99
+ };
99
100
  ```
100
101
 
101
102
  ### 单文件结构(仍支持)
102
103
 
103
104
  ```javascript
104
105
  // .agent/plugins/my-plugin.js
105
- module.exports = function(Plugin) {
106
+ module.exports = function (Plugin) {
106
107
  return class MyPlugin extends Plugin {
107
108
  // ... 与上面相同
108
- }
109
- }
109
+ };
110
+ };
110
111
  ```
111
112
 
112
113
  **注意**:如果文件夹和同名 `.js` 文件同时存在,**文件夹优先**。
113
114
 
114
115
  ```javascript
115
116
  // .agent/plugins/my-plugin.js
116
- module.exports = function(Plugin) {
117
+ module.exports = function (Plugin) {
117
118
  return class MyPlugin extends Plugin {
118
119
  constructor(config = {}) {
119
- super()
120
- this.name = 'my-plugin'
121
- this.version = '1.0.0'
122
- this.description = '我的工具插件'
123
- this.priority = 10
120
+ super();
121
+ this.name = 'my-plugin';
122
+ this.version = '1.0.0';
123
+ this.description = '我的工具插件';
124
+ this.priority = 10;
124
125
  }
125
126
 
126
127
  install(framework) {
127
- const { z } = require('zod')
128
+ const { z } = require('zod');
128
129
  framework.registerTool({
129
130
  name: 'my_tool',
130
131
  description: '我的工具',
131
132
  inputSchema: z.object({
132
- param: z.string().describe('参数描述')
133
+ param: z.string().describe('参数描述'),
133
134
  }),
134
135
  execute: async (args, framework) => {
135
- return { success: true, result: args.param }
136
- }
137
- })
138
- return this
136
+ return { success: true, result: args.param };
137
+ },
138
+ });
139
+ return this;
139
140
  }
140
141
 
141
142
  uninstall(framework) {
142
143
  // 清理资源
143
144
  }
144
- }
145
- }
145
+ };
146
+ };
146
147
  ```
148
+
147
149
  **插件开发流程:**
150
+
148
151
  1. **创建插件**(优先使用文件夹结构)
149
152
  2. **安装依赖**:
150
153
  - 文件夹插件:`install { package: "包名", path: ".agent/plugins/插件名" }`
@@ -152,8 +155,8 @@ module.exports = function(Plugin) {
152
155
  3. **热重载**:`reload_plugins`
153
156
  4. **检查加载状态**
154
157
 
155
-
156
158
  **关键点:**
159
+
157
160
  - `Plugin` 基类由系统自动传入(无需 require)
158
161
  - 函数直接返回插件类
159
162
  - 在 `install(framework)` 中通过 `framework` 注册工具
@@ -164,10 +167,10 @@ module.exports = function(Plugin) {
164
167
 
165
168
  当插件需要使用第三方 npm 包(如 `zod`、`axios` 等)时,根据插件类型选择安装位置:
166
169
 
167
- | 插件类型 | 安装位置 | 说明 |
168
- |----------|----------|------|
170
+ | 插件类型 | 安装位置 | 说明 |
171
+ | -------------- | ------------------------------------- | ---------------------- |
169
172
  | **文件夹插件** | `.agent/plugins/插件名/node_modules/` | 插件自包含,可独立迁移 |
170
- | **单文件插件** | `.agent/node_modules/` | 共享依赖 |
173
+ | **单文件插件** | `.agent/node_modules/` | 共享依赖 |
171
174
 
172
175
  ### 自动安装工具
173
176
 
@@ -175,30 +178,30 @@ module.exports = function(Plugin) {
175
178
 
176
179
  ```javascript
177
180
  // 安装到默认位置 .agent/node_modules
178
- install({ package: "zod" })
181
+ install({ package: 'zod' });
179
182
 
180
183
  // 安装到指定目录(用于文件夹插件)
181
- install({ package: "axios", path: ".agent/plugins/my-plugin" })
184
+ install({ package: 'axios', path: '.agent/plugins/my-plugin' });
182
185
 
183
186
  // 从 package.json 安装所有依赖到默认位置
184
- install({ file: "./package.json" })
187
+ install({ file: './package.json' });
185
188
 
186
189
  // 从 package.json 安装所有依赖到指定目录
187
- install({ file: "./my-plugin/package.json", path: ".agent/plugins/my-plugin" })
190
+ install({ file: './my-plugin/package.json', path: '.agent/plugins/my-plugin' });
188
191
 
189
192
  // 仅指定路径,安装该目录下的 package.json 依赖
190
- install({ path: ".agent/plugins/my-plugin" })
193
+ install({ path: '.agent/plugins/my-plugin' });
191
194
  ```
192
195
 
193
196
  ### 文件夹插件的依赖安装示例
194
197
 
195
198
  ```javascript
196
199
  // .agent/plugins/my-plugin/index.js
197
- module.exports = function(Plugin) {
200
+ module.exports = function (Plugin) {
198
201
  return class MyPlugin extends Plugin {
199
202
  constructor(config = {}) {
200
- super()
201
- this.name = 'my-plugin'
203
+ super();
204
+ this.name = 'my-plugin';
202
205
  }
203
206
 
204
207
  install(framework) {
@@ -206,26 +209,26 @@ module.exports = function(Plugin) {
206
209
  name: 'fetch_data',
207
210
  description: '获取远程数据',
208
211
  inputSchema: z.object({
209
- url: z.string().describe('API URL')
212
+ url: z.string().describe('API URL'),
210
213
  }),
211
214
  execute: async (args, framework) => {
212
215
  // 安装到插件自己的目录
213
- const pluginDir = '.agent/plugins/my-plugin'
216
+ const pluginDir = '.agent/plugins/my-plugin';
214
217
  await framework.callTool('install', {
215
218
  package: 'axios',
216
- path: pluginDir
217
- })
219
+ path: pluginDir,
220
+ });
218
221
 
219
222
  // 引入插件目录下的 node_modules
220
- const axios = require(`${pluginDir}/node_modules/axios`)
221
- const response = await axios.get(args.url)
222
- return { success: true, data: response.data }
223
- }
224
- })
225
- return this
223
+ const axios = require(`${pluginDir}/node_modules/axios`);
224
+ const response = await axios.get(args.url);
225
+ return { success: true, data: response.data };
226
+ },
227
+ });
228
+ return this;
226
229
  }
227
- }
228
- }
230
+ };
231
+ };
229
232
  ```
230
233
 
231
234
  ### 安装步骤
@@ -238,6 +241,7 @@ module.exports = function(Plugin) {
238
241
  4. **返回状态** 给用户
239
242
 
240
243
  示例流程(文件夹插件):
244
+
241
245
  ```
242
246
  错误: Cannot find module 'axios'
243
247
 
@@ -265,16 +269,16 @@ module.exports = function(Plugin) {
265
269
 
266
270
  ```javascript
267
271
  // plugins/my-plugin.js
268
- const { Plugin } = require('../src/core/plugin-base')
269
- const { z } = require('zod')
272
+ const { Plugin } = require('../src/core/plugin-base');
273
+ const { z } = require('zod');
270
274
 
271
275
  class MyPlugin extends Plugin {
272
276
  constructor(config = {}) {
273
- super()
274
- this.name = 'my-plugin'
275
- this.version = '1.0.0'
276
- this.description = '我的工具插件'
277
- this.priority = 10
277
+ super();
278
+ this.name = 'my-plugin';
279
+ this.version = '1.0.0';
280
+ this.description = '我的工具插件';
281
+ this.priority = 10;
278
282
  }
279
283
 
280
284
  install(framework) {
@@ -282,42 +286,42 @@ class MyPlugin extends Plugin {
282
286
  name: 'my_tool',
283
287
  description: '我的工具',
284
288
  inputSchema: z.object({
285
- param: z.string().describe('参数描述')
289
+ param: z.string().describe('参数描述'),
286
290
  }),
287
291
  execute: async (args, framework) => {
288
- return { success: true, result: args.param }
289
- }
290
- })
291
- return this
292
+ return { success: true, result: args.param };
293
+ },
294
+ });
295
+ return this;
292
296
  }
293
297
 
294
- uninstall(framework) { }
298
+ uninstall(framework) {}
295
299
  }
296
300
 
297
- module.exports = { MyPlugin }
301
+ module.exports = MyPlugin;
298
302
  ```
299
303
 
300
304
  ---
301
305
 
302
306
  ## 插件属性
303
307
 
304
- | 属性 | 类型 | 必须 | 说明 |
305
- |------|------|------|------|
306
- | `name` | string | ✅ | 唯一名称 |
307
- | `version` | string | ❌ | 版本号,默认 '1.0.0' |
308
- | `description` | string | ❌ | 插件描述 |
309
- | `priority` | number | ❌ | 加载优先级,默认 10 |
308
+ | 属性 | 类型 | 必须 | 说明 |
309
+ | ------------- | ------ | ---- | -------------------- |
310
+ | `name` | string | ✅ | 唯一名称 |
311
+ | `version` | string | ❌ | 版本号,默认 '1.0.0' |
312
+ | `description` | string | ❌ | 插件描述 |
313
+ | `priority` | number | ❌ | 加载优先级,默认 10 |
310
314
 
311
315
  ---
312
316
 
313
317
  ## 生命周期
314
318
 
315
- | 方法 | 调用时机 | 必须实现 |
316
- |------|----------|---------|
317
- | `install(framework)` | 插件安装时 | ✅ |
318
- | `start(framework)` | 插件启动时 | 推荐 |
319
- | `reload(framework)` | 热重载时 | 可选 |
320
- | `uninstall(framework)` | 卸载时 | 推荐 |
319
+ | 方法 | 调用时机 | 必须实现 |
320
+ | ---------------------- | ---------- | -------- |
321
+ | `install(framework)` | 插件安装时 | ✅ |
322
+ | `start(framework)` | 插件启动时 | 推荐 |
323
+ | `reload(framework)` | 热重载时 | 可选 |
324
+ | `uninstall(framework)` | 卸载时 | 推荐 |
321
325
 
322
326
  ---
323
327
 
@@ -344,13 +348,13 @@ install(framework) {
344
348
 
345
349
  ## 核心规则
346
350
 
347
- | 规则 | 说明 |
348
- |------|------|
349
- | **优先使用文件夹结构** | 复杂插件推荐用文件夹,便于管理依赖和代码 |
350
- | **必须用 inputSchema** | `inputSchema: z.object({})`(不是 parameters!) |
351
- | **必须用 zod 定义参数** | `param: z.string().describe('描述')` |
352
- | **install 必须返回 this** | 确保链式调用 |
353
- | **文件夹与文件重名时** | 文件夹优先,同名 `.js` 文件会被忽略 |
351
+ | 规则 | 说明 |
352
+ | ------------------------- | ----------------------------------------------- |
353
+ | **优先使用文件夹结构** | 复杂插件推荐用文件夹,便于管理依赖和代码 |
354
+ | **必须用 inputSchema** | `inputSchema: z.object({})`(不是 parameters!) |
355
+ | **必须用 zod 定义参数** | `param: z.string().describe('描述')` |
356
+ | **install 必须返回 this** | 确保链式调用 |
357
+ | **文件夹与文件重名时** | 文件夹优先,同名 `.js` 文件会被忽略 |
354
358
 
355
359
  ## 开发完成后注意事项
356
360
 
@@ -366,6 +370,7 @@ install(framework) {
366
370
  4. **检查加载状态**
367
371
 
368
372
  示例:
373
+
369
374
  ```
370
375
  创建插件 my-plugin.js(需要 zod)
371
376
 
@@ -377,6 +382,7 @@ reload_plugins
377
382
  ```
378
383
 
379
384
  ### 其他注意事项
385
+
380
386
  --**开发完成重载成功后检测有没有加载新的插件,不需要进行过多测试步骤,直接告知用户状态即可**
381
387
 
382
388
  ---
@@ -385,14 +391,14 @@ reload_plugins
385
391
 
386
392
  Agent 支持 `sharedPrompt` 中的占位符替换:
387
393
 
388
- | 占位符 | 说明 |
389
- |--------|------|
390
- | `{{WORK_DIR}}` | 工作目录 |
391
- | `{{HOME_DIR}}` | 主目录 |
392
- | `{{HOST_NAME}}` | 主机名 |
393
- | `{{PLATFORM}}` | 平台 |
394
- | `{{TIME}}` | 当前时间 |
395
- | `{{DATE}}` | 当前日期 |
394
+ | 占位符 | 说明 |
395
+ | --------------- | -------- |
396
+ | `{{WORK_DIR}}` | 工作目录 |
397
+ | `{{HOME_DIR}}` | 主目录 |
398
+ | `{{HOST_NAME}}` | 主机名 |
399
+ | `{{PLATFORM}}` | 平台 |
400
+ | `{{TIME}}` | 当前时间 |
401
+ | `{{DATE}}` | 当前日期 |
396
402
 
397
403
  ---
398
404
 
@@ -405,9 +411,9 @@ const agent = framework.createAgent({
405
411
  sharedPrompt: '工作目录: {{WORK_DIR}}\n项目: {{projectName}}',
406
412
  metadata: {
407
413
  projectName: 'MyProject',
408
- version: '1.0.0'
409
- }
410
- })
414
+ version: '1.0.0',
415
+ },
416
+ });
411
417
  ```
412
418
 
413
419
  ---
@@ -416,10 +422,10 @@ const agent = framework.createAgent({
416
422
 
417
423
  ```javascript
418
424
  // 重载单个插件
419
- await framework.reloadPlugin('my-plugin')
425
+ await framework.reloadPlugin('my-plugin');
420
426
 
421
427
  // 重载所有插件
422
- await framework.reloadAllPlugins()
428
+ await framework.reloadAllPlugins();
423
429
  ```
424
430
 
425
431
  ---
@@ -432,14 +438,14 @@ await framework.reloadAllPlugins()
432
438
 
433
439
  ```javascript
434
440
  // plugins/my-plugin.js
435
- const { Plugin } = require('../src/core/plugin-base')
436
- const { tool } = require('ai')
437
- const { z } = require('zod')
441
+ const { Plugin } = require('../src/core/plugin-base');
442
+ const { tool } = require('ai');
443
+ const { z } = require('zod');
438
444
 
439
445
  class MyPlugin extends Plugin {
440
446
  constructor(config = {}) {
441
- super()
442
- this.name = 'my-plugin'
447
+ super();
448
+ this.name = 'my-plugin';
443
449
  }
444
450
 
445
451
  // 配置式注册子Agent,插件启动时自动创建
@@ -453,14 +459,14 @@ class MyPlugin extends Plugin {
453
459
  description: '编译代码',
454
460
  parameters: z.object({
455
461
  language: z.string(),
456
- code: z.string()
462
+ code: z.string(),
457
463
  }),
458
- execute: async (args) => ({ success: true })
459
- })
464
+ execute: async (args) => ({ success: true }),
465
+ }),
460
466
  },
461
- parentTools: ['read_file', 'write_file']
462
- }
463
- ]
467
+ parentTools: ['read_file', 'write_file'],
468
+ },
469
+ ];
464
470
  }
465
471
  ```
466
472
 
@@ -485,10 +491,10 @@ start(framework) {
485
491
 
486
492
  ### 子Agent配置说明
487
493
 
488
- | 字段 | 类型 | 说明 |
489
- |------|------|------|
490
- | `name` | string | 子Agent名称(唯一标识) |
491
- | `role` | string | 角色描述 |
492
- | `description` | string | 详细描述 |
493
- | `tools` | object | 自定义工具 `{ name: toolDef }`,只属于此子Agent |
494
- | `parentTools` | array | 从父Agent继承的工具名称列表 |
494
+ | 字段 | 类型 | 说明 |
495
+ | ------------- | ------ | ----------------------------------------------- |
496
+ | `name` | string | 子Agent名称(唯一标识) |
497
+ | `role` | string | 角色描述 |
498
+ | `description` | string | 详细描述 |
499
+ | `tools` | object | 自定义工具 `{ name: toolDef }`,只属于此子Agent |
500
+ | `parentTools` | array | 从父Agent继承的工具名称列表 |
@@ -21,12 +21,11 @@ mcp_list_servers()
21
21
  ```
22
22
 
23
23
  返回示例:
24
+
24
25
  ```json
25
26
  {
26
27
  "success": true,
27
- "servers": [
28
- { "name": "fetch", "tools": [{ "name": "fetch", "description": "..." }] }
29
- ]
28
+ "servers": [{ "name": "fetch", "tools": [{ "name": "fetch", "description": "..." }] }]
30
29
  }
31
30
  ```
32
31
 
@@ -39,6 +38,7 @@ mcp_tool_schema({ server: "服务器名", tool: "工具名" })
39
38
  ```
40
39
 
41
40
  返回示例:
41
+
42
42
  ```json
43
43
  {
44
44
  "success": true,
@@ -65,6 +65,7 @@ mcp_call({
65
65
  ```
66
66
 
67
67
  **重要**:
68
+
68
69
  - `args_json` 必须是有效的 JSON 字符串
69
70
  - 必填参数不能为空
70
71
  - 如果不知道参数结构,先用 `mcp_tool_schema` 查询
@@ -86,10 +87,10 @@ mcp_reload()
86
87
  ```javascript
87
88
  // 调用 fetch 工具获取网页
88
89
  mcp_call({
89
- server: "fetch",
90
- tool: "fetch",
91
- args_json: '{"url": "https://news.baidu.com"}'
92
- })
90
+ server: 'fetch',
91
+ tool: 'fetch',
92
+ args_json: '{"url": "https://news.baidu.com"}',
93
+ });
93
94
  ```
94
95
 
95
96
  ### 多个参数调用
@@ -97,10 +98,10 @@ mcp_call({
97
98
  ```javascript
98
99
  // 调用搜索工具
99
100
  mcp_call({
100
- server: "bing-cn-mcp-server",
101
- tool: "bing_search",
102
- args_json: '{"query": "关键词", "count": 10}'
103
- })
101
+ server: 'bing-cn-mcp-server',
102
+ tool: 'bing_search',
103
+ args_json: '{"query": "关键词", "count": 10}',
104
+ });
104
105
  ```
105
106
 
106
107
  ### 复杂参数调用
@@ -108,6 +109,7 @@ mcp_call({
108
109
  对于复杂参数(嵌套对象、数组等):
109
110
 
110
111
  1. 先查询参数结构:
112
+
111
113
  ```
112
114
  mcp_tool_schema({ server: "服务器", tool: "工具" })
113
115
  ```
@@ -186,12 +188,12 @@ MCP 服务器配置在 `.agent/mcp_config.json`:
186
188
 
187
189
  ## 6. Quick Reference
188
190
 
189
- | 场景 | 操作 |
190
- |------|------|
191
- | 查看可用服务器 | `mcp_list_servers()` |
192
- | 查询参数结构 | `mcp_tool_schema({ server: "x", tool: "y" })` |
193
- | 调用工具 | `mcp_call({ server: "x", tool: "y", args_json: '{}' })` |
194
- | 重载配置 | `mcp_reload()` |
191
+ | 场景 | 操作 |
192
+ | -------------- | ------------------------------------------------------- |
193
+ | 查看可用服务器 | `mcp_list_servers()` |
194
+ | 查询参数结构 | `mcp_tool_schema({ server: "x", tool: "y" })` |
195
+ | 调用工具 | `mcp_call({ server: "x", tool: "y", args_json: '{}' })` |
196
+ | 重载配置 | `mcp_reload()` |
195
197
 
196
198
  ---
197
199
 
@@ -83,17 +83,18 @@ def calc_tool(params):
83
83
  ```
84
84
 
85
85
  **重要**:`tools` 字段定义了插件提供的所有工具。框架会自动:
86
+
86
87
  1. 将这些工具注册到系统中
87
88
  2. 附加到系统提示词,LLM 可以直接调用
88
89
 
89
90
  ## 工具函数规范
90
91
 
91
- | 规范 | 说明 |
92
- |------|------|
93
- | 返回 dict | 必须是 Python 字典 |
94
- | success 字段 | `true` 或 `false` |
95
- | result 字段 | 成功时返回的结果 |
96
- | error 字段 | 失败时返回的错误信息 |
92
+ | 规范 | 说明 |
93
+ | ------------ | -------------------- |
94
+ | 返回 dict | 必须是 Python 字典 |
95
+ | success 字段 | `true` 或 `false` |
96
+ | result 字段 | 成功时返回的结果 |
97
+ | error 字段 | 失败时返回的错误信息 |
97
98
 
98
99
  ## 返回值格式
99
100
 
@@ -254,12 +255,12 @@ def install_package(params):
254
255
 
255
256
  插件中可以使用的常用库:
256
257
 
257
- | 库 | 用途 | 导入方式 |
258
- |-----|------|---------|
259
- | requests | HTTP 请求 | `import requests` |
260
- | json | JSON 处理 | `import json` |
261
- | os | 系统操作 | `import os` |
262
- | pathlib | 路径处理 | `from pathlib import Path` |
263
- | datetime | 日期时间 | `from datetime import datetime` |
264
- | re | 正则表达式 | `import re` |
265
- | csv | CSV 处理 | `import csv` |
258
+ | 库 | 用途 | 导入方式 |
259
+ | -------- | ---------- | ------------------------------- |
260
+ | requests | HTTP 请求 | `import requests` |
261
+ | json | JSON 处理 | `import json` |
262
+ | os | 系统操作 | `import os` |
263
+ | pathlib | 路径处理 | `from pathlib import Path` |
264
+ | datetime | 日期时间 | `from datetime import datetime` |
265
+ | re | 正则表达式 | `import re` |
266
+ | csv | CSV 处理 | `import csv` |
@@ -27,13 +27,12 @@ allowed-tools: Read, Write, Edit, Glob, Grep, Bash
27
27
 
28
28
  ```yaml
29
29
  ---
30
- name: my-skill # 技能名称(必需,唯一标识)
30
+ name: my-skill # 技能名称(必需,唯一标识)
31
31
  description: 这是一个自定义技能的描述。当用户说"..."时调用此技能。(必需)
32
- allowed-tools: Read, Write, Edit, Glob, Grep, Bash # 可选,允许使用的工具列表
33
- license: MIT # 可选,许可证
34
- compatibility: v1.0.0 # 可选,兼容版本
32
+ allowed-tools: Read, Write, Edit, Glob, Grep, Bash # 可选,允许使用的工具列表
33
+ license: MIT # 可选,许可证
34
+ compatibility: v1.0.0 # 可选,兼容版本
35
35
  ---
36
-
37
36
  # 技能标题
38
37
 
39
38
  这里是技能的详细说明内容,可以使用 Markdown 格式。
@@ -41,17 +40,18 @@ compatibility: v1.0.0 # 可选,兼容版本
41
40
 
42
41
  ### frontmatter 字段说明
43
42
 
44
- | 字段 | 必需 | 说明 |
45
- |------|------|------|
46
- | `name` | 是 | 技能唯一标识,字母、数字、下划线、横杠,1-64字符 |
47
- | `description` | 是 | 技能描述,当用户意图匹配时会被调用 |
48
- | `allowed-tools` | 否 | 允许使用的工具列表,逗号分隔 |
49
- | `license` | 否 | 许可证类型 |
50
- | `compatibility` | 否 | 兼容的框架版本 |
43
+ | 字段 | 必需 | 说明 |
44
+ | --------------- | ---- | ------------------------------------------------ |
45
+ | `name` | 是 | 技能唯一标识,字母、数字、下划线、横杠,1-64字符 |
46
+ | `description` | 是 | 技能描述,当用户意图匹配时会被调用 |
47
+ | `allowed-tools` | 否 | 允许使用的工具列表,逗号分隔 |
48
+ | `license` | 否 | 许可证类型 |
49
+ | `compatibility` | 否 | 兼容的框架版本 |
51
50
 
52
51
  ### 正文格式
53
52
 
54
53
  frontmatter 之后是技能的正文内容,支持 Markdown 格式,包含:
54
+
55
55
  - 详细的功能说明
56
56
  - 使用示例
57
57
  - 最佳实践