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.
- package/.agent/.shared/ui-ux-pro-max/data/charts.csv +26 -0
- package/.agent/.shared/ui-ux-pro-max/data/colors.csv +97 -0
- package/.agent/.shared/ui-ux-pro-max/data/icons.csv +101 -0
- package/.agent/.shared/ui-ux-pro-max/data/landing.csv +31 -0
- package/.agent/.shared/ui-ux-pro-max/data/products.csv +97 -0
- package/.agent/.shared/ui-ux-pro-max/data/prompts.csv +24 -0
- package/.agent/.shared/ui-ux-pro-max/data/react-performance.csv +45 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/react.csv +54 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/vue.csv +50 -0
- package/.agent/.shared/ui-ux-pro-max/data/styles.csv +59 -0
- package/.agent/.shared/ui-ux-pro-max/data/typography.csv +58 -0
- package/.agent/.shared/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
- package/.agent/.shared/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
- package/.agent/.shared/ui-ux-pro-max/data/web-interface.csv +31 -0
- package/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/core.cpython-313.pyc +0 -0
- package/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-313.pyc +0 -0
- package/.agent/.shared/ui-ux-pro-max/scripts/core.py +258 -0
- package/.agent/.shared/ui-ux-pro-max/scripts/design_system.py +1067 -0
- package/.agent/.shared/ui-ux-pro-max/scripts/search.py +106 -0
- package/.agent/ARCHITECTURE.md +288 -0
- package/.agent/agents/ambient-agent.md +57 -0
- package/.agent/agents/debugger.md +55 -0
- package/.agent/agents/email-assistant.md +49 -0
- package/.agent/agents/file-manager.md +42 -0
- package/.agent/agents/python-developer.md +60 -0
- package/.agent/agents/scheduler.md +59 -0
- package/.agent/agents/web-developer.md +45 -0
- package/.agent/data/default.json +29 -0
- package/.agent/data/plugins-state.json +255 -0
- package/.agent/mcp_config.json +4 -0
- package/.agent/mcp_config_updated.json +12 -0
- package/.agent/plugins.json +5 -0
- package/.agent/rules/GEMINI.md +273 -0
- package/.agent/rules/allow-rule.md +77 -0
- package/.agent/rules/log-rule.md +83 -0
- package/.agent/rules/security-rule.md +93 -0
- package/.agent/scripts/auto_preview.py +148 -0
- package/.agent/scripts/checklist.py +217 -0
- package/.agent/scripts/session_manager.py +120 -0
- package/.agent/scripts/verify_all.py +327 -0
- package/.agent/skills/api-patterns/SKILL.md +81 -0
- package/.agent/skills/api-patterns/api-style.md +42 -0
- package/.agent/skills/api-patterns/auth.md +24 -0
- package/.agent/skills/api-patterns/documentation.md +26 -0
- package/.agent/skills/api-patterns/graphql.md +41 -0
- package/.agent/skills/api-patterns/rate-limiting.md +31 -0
- package/.agent/skills/api-patterns/response.md +37 -0
- package/.agent/skills/api-patterns/rest.md +40 -0
- package/.agent/skills/api-patterns/scripts/api_validator.py +211 -0
- package/.agent/skills/api-patterns/security-testing.md +122 -0
- package/.agent/skills/api-patterns/trpc.md +41 -0
- package/.agent/skills/api-patterns/versioning.md +22 -0
- package/.agent/skills/app-builder/SKILL.md +75 -0
- package/.agent/skills/app-builder/agent-coordination.md +71 -0
- package/.agent/skills/app-builder/feature-building.md +53 -0
- package/.agent/skills/app-builder/project-detection.md +34 -0
- package/.agent/skills/app-builder/scaffolding.md +118 -0
- package/.agent/skills/app-builder/tech-stack.md +40 -0
- package/.agent/skills/app-builder/templates/SKILL.md +39 -0
- package/.agent/skills/app-builder/templates/astro-static/TEMPLATE.md +76 -0
- package/.agent/skills/app-builder/templates/chrome-extension/TEMPLATE.md +92 -0
- package/.agent/skills/app-builder/templates/cli-tool/TEMPLATE.md +88 -0
- package/.agent/skills/app-builder/templates/electron-desktop/TEMPLATE.md +88 -0
- package/.agent/skills/app-builder/templates/express-api/TEMPLATE.md +83 -0
- package/.agent/skills/app-builder/templates/flutter-app/TEMPLATE.md +90 -0
- package/.agent/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +90 -0
- package/.agent/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +122 -0
- package/.agent/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +122 -0
- package/.agent/skills/app-builder/templates/nextjs-static/TEMPLATE.md +169 -0
- package/.agent/skills/app-builder/templates/nuxt-app/TEMPLATE.md +134 -0
- package/.agent/skills/app-builder/templates/python-fastapi/TEMPLATE.md +83 -0
- package/.agent/skills/app-builder/templates/react-native-app/TEMPLATE.md +119 -0
- package/.agent/skills/architecture/SKILL.md +55 -0
- package/.agent/skills/architecture/context-discovery.md +43 -0
- package/.agent/skills/architecture/examples.md +94 -0
- package/.agent/skills/architecture/pattern-selection.md +68 -0
- package/.agent/skills/architecture/patterns-reference.md +50 -0
- package/.agent/skills/architecture/trade-off-analysis.md +77 -0
- package/.agent/skills/clean-code/SKILL.md +201 -0
- package/.agent/skills/doc.md +177 -0
- package/.agent/skills/frontend-design/SKILL.md +418 -0
- package/.agent/skills/frontend-design/animation-guide.md +331 -0
- package/.agent/skills/frontend-design/color-system.md +311 -0
- package/.agent/skills/frontend-design/decision-trees.md +418 -0
- package/.agent/skills/frontend-design/motion-graphics.md +306 -0
- package/.agent/skills/frontend-design/scripts/accessibility_checker.py +183 -0
- package/.agent/skills/frontend-design/scripts/ux_audit.py +722 -0
- package/.agent/skills/frontend-design/typography-system.md +345 -0
- package/.agent/skills/frontend-design/ux-psychology.md +1116 -0
- package/.agent/skills/frontend-design/visual-effects.md +383 -0
- package/.agent/skills/i18n-localization/SKILL.md +154 -0
- package/.agent/skills/i18n-localization/scripts/i18n_checker.py +241 -0
- package/.agent/skills/mcp-builder/SKILL.md +176 -0
- package/.agent/skills/web-design-guidelines/SKILL.md +57 -0
- package/.agent/workflows/brainstorm.md +113 -0
- package/.agent/workflows/create.md +59 -0
- package/.agent/workflows/debug.md +103 -0
- package/.agent/workflows/deploy.md +176 -0
- package/.agent/workflows/enhance.md +63 -0
- package/.agent/workflows/orchestrate.md +237 -0
- package/.agent/workflows/plan.md +89 -0
- package/.agent/workflows/preview.md +81 -0
- package/.agent/workflows/simple-test.md +42 -0
- package/.agent/workflows/status.md +86 -0
- package/.agent/workflows/structured-orchestrate.md +180 -0
- package/.agent/workflows/test.md +144 -0
- package/.agent/workflows/ui-ux-pro-max.md +296 -0
- package/.claude/settings.local.json +157 -149
- package/.editorconfig +56 -0
- package/.husky/pre-commit +4 -0
- package/.lintstagedrc +7 -0
- package/.prettierignore +29 -0
- package/.prettierrc +11 -0
- package/CLAUDE.md +2 -0
- package/README.md +64 -55
- package/SPEC.md +102 -61
- package/cli/bin/foliko.js +4 -4
- package/cli/src/commands/chat.js +53 -51
- package/cli/src/commands/list.js +40 -37
- package/cli/src/index.js +18 -18
- package/cli/src/ui/chat-ui.js +78 -76
- package/cli/src/utils/ansi.js +15 -15
- package/cli/src/utils/markdown.js +112 -116
- package/docker-compose.yml +1 -1
- package/docs/ai-sdk-optimization.md +655 -636
- package/docs/features.md +80 -80
- package/docs/quick-reference.md +49 -46
- package/docs/user-manual.md +411 -380
- package/examples/ambient-example.js +95 -97
- package/examples/basic.js +115 -110
- package/examples/bootstrap.js +52 -43
- package/examples/mcp-example.js +56 -53
- package/examples/skill-example.js +49 -49
- package/examples/test-chat.js +60 -58
- package/examples/test-mcp.js +49 -43
- package/examples/test-reload.js +38 -40
- package/examples/test-telegram.js +3 -3
- package/examples/test-tg-bot.js +7 -4
- package/examples/test-tg-simple.js +4 -3
- package/examples/test-tg.js +3 -3
- package/examples/test-think.js +13 -7
- package/examples/test-web-plugin.js +61 -56
- package/examples/test-weixin-feishu.js +40 -37
- package/examples/workflow.js +49 -49
- package/foliko-1.0.75.tgz +0 -0
- package/package.json +37 -3
- package/plugins/ai-plugin.js +7 -5
- package/plugins/ambient-agent/EventWatcher.js +113 -0
- package/plugins/ambient-agent/ExplorerLoop.js +640 -0
- package/plugins/ambient-agent/GoalManager.js +197 -0
- package/plugins/ambient-agent/Reflector.js +95 -0
- package/plugins/ambient-agent/StateStore.js +90 -0
- package/plugins/ambient-agent/constants.js +101 -0
- package/plugins/ambient-agent/index.js +579 -0
- package/plugins/default-plugins.js +62 -49
- package/plugins/email/constants.js +64 -0
- package/plugins/email/handlers.js +461 -0
- package/plugins/email/index.js +278 -0
- package/plugins/email/monitor.js +269 -0
- package/plugins/email/parser.js +138 -0
- package/plugins/email/reply.js +151 -0
- package/plugins/email/utils.js +124 -0
- package/plugins/feishu-plugin.js +23 -19
- package/plugins/file-system-plugin.js +469 -120
- package/plugins/install-plugin.js +6 -4
- package/plugins/python-executor-plugin.js +3 -1
- package/plugins/python-plugin-loader.js +10 -8
- package/plugins/rules-plugin.js +5 -3
- package/plugins/scheduler-plugin.js +18 -16
- package/plugins/session-plugin.js +3 -1
- package/plugins/storage-plugin.js +5 -3
- package/plugins/subagent-plugin.js +152 -92
- package/plugins/telegram-plugin.js +26 -19
- package/plugins/think-plugin.js +4 -2
- package/plugins/tools-plugin.js +3 -1
- package/plugins/web-plugin.js +15 -13
- package/plugins/weixin-plugin.js +43 -36
- package/reports/system-health-report-20260401.md +79 -0
- package/skills/ambient-agent/SKILL.md +49 -39
- package/skills/foliko-dev/AGENTS.md +64 -61
- package/skills/foliko-dev/SKILL.md +125 -119
- package/skills/mcp-usage/SKILL.md +19 -17
- package/skills/python-plugin-dev/SKILL.md +16 -15
- package/skills/skill-guide/SKILL.md +12 -12
- package/skills/subagent-guide/SKILL.md +237 -0
- package/skills/workflow-guide/SKILL.md +90 -45
- package/skills/workflow-troubleshooting/DEBUGGING.md +36 -21
- package/skills/workflow-troubleshooting/SKILL.md +156 -79
- package/src/capabilities/index.js +4 -4
- package/src/capabilities/skill-manager.js +211 -197
- package/src/capabilities/workflow-engine.js +461 -547
- package/src/core/agent-chat.js +426 -279
- package/src/core/agent.js +453 -248
- package/src/core/framework.js +183 -149
- package/src/core/index.js +8 -8
- package/src/core/plugin-base.js +52 -52
- package/src/core/plugin-manager.js +377 -281
- package/src/core/provider.js +35 -32
- package/src/core/sub-agent-config.js +264 -0
- package/src/core/system-prompt-builder.js +120 -0
- package/src/core/tool-registry.js +416 -33
- package/src/core/tool-router.js +149 -68
- package/src/executors/executor-base.js +58 -58
- package/src/executors/mcp-executor.js +269 -257
- package/src/index.js +5 -17
- package/src/utils/circuit-breaker.js +301 -0
- package/src/utils/error-boundary.js +363 -0
- package/src/utils/error.js +374 -0
- package/src/utils/event-emitter.js +20 -20
- package/src/utils/id.js +133 -0
- package/src/utils/index.js +217 -3
- package/src/utils/logger.js +181 -0
- package/src/utils/plugin-helpers.js +90 -0
- package/src/utils/retry.js +122 -0
- package/src/utils/sandbox.js +292 -0
- package/test/tool-registry-validation.test.js +218 -0
- package/test_report.md +70 -0
- package/website/docs/api.html +169 -107
- package/website/docs/configuration.html +296 -144
- package/website/docs/plugin-development.html +154 -85
- package/website/docs/project-structure.html +110 -109
- package/website/docs/skill-development.html +117 -61
- package/website/index.html +209 -205
- package/website/script.js +20 -17
- package/website/styles.css +1 -1
- package/plugins/ambient-agent-plugin.js +0 -1565
- 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:
|
|
181
|
+
install({ package: 'zod' });
|
|
179
182
|
|
|
180
183
|
// 安装到指定目录(用于文件夹插件)
|
|
181
|
-
install({ package:
|
|
184
|
+
install({ package: 'axios', path: '.agent/plugins/my-plugin' });
|
|
182
185
|
|
|
183
186
|
// 从 package.json 安装所有依赖到默认位置
|
|
184
|
-
install({ file:
|
|
187
|
+
install({ file: './package.json' });
|
|
185
188
|
|
|
186
189
|
// 从 package.json 安装所有依赖到指定目录
|
|
187
|
-
install({ file:
|
|
190
|
+
install({ file: './my-plugin/package.json', path: '.agent/plugins/my-plugin' });
|
|
188
191
|
|
|
189
192
|
// 仅指定路径,安装该目录下的 package.json 依赖
|
|
190
|
-
install({ path:
|
|
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 =
|
|
301
|
+
module.exports = MyPlugin;
|
|
298
302
|
```
|
|
299
303
|
|
|
300
304
|
---
|
|
301
305
|
|
|
302
306
|
## 插件属性
|
|
303
307
|
|
|
304
|
-
| 属性
|
|
305
|
-
|
|
306
|
-
| `name`
|
|
307
|
-
| `version`
|
|
308
|
-
| `description` | string | ❌
|
|
309
|
-
| `priority`
|
|
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**
|
|
351
|
-
| **必须用 zod 定义参数**
|
|
352
|
-
| **install 必须返回 this** | 确保链式调用
|
|
353
|
-
| **文件夹与文件重名时**
|
|
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`
|
|
491
|
-
| `role`
|
|
492
|
-
| `description` | string | 详细描述
|
|
493
|
-
| `tools`
|
|
494
|
-
| `parentTools` | array
|
|
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:
|
|
90
|
-
tool:
|
|
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:
|
|
101
|
-
tool:
|
|
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
|
-
| 查询参数结构
|
|
193
|
-
| 调用工具
|
|
194
|
-
| 重载配置
|
|
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
|
|
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 请求
|
|
260
|
-
| json
|
|
261
|
-
| os
|
|
262
|
-
| pathlib
|
|
263
|
-
| datetime | 日期时间
|
|
264
|
-
| re
|
|
265
|
-
| 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`
|
|
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
|
- 最佳实践
|