foliko 1.0.74 → 1.0.76
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 +11 -1
- 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 +11 -11
- package/cli/src/commands/chat.js +143 -141
- package/cli/src/commands/list.js +93 -90
- package/cli/src/index.js +75 -75
- package/cli/src/ui/chat-ui.js +201 -199
- package/cli/src/utils/ansi.js +40 -40
- package/cli/src/utils/markdown.js +292 -296
- package/docker-compose.yml +1 -1
- package/docs/ai-sdk-optimization.md +655 -643
- 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 +194 -196
- package/examples/basic.js +50 -45
- package/examples/bootstrap.js +121 -112
- package/examples/mcp-example.js +19 -16
- package/examples/skill-example.js +20 -20
- package/examples/test-chat.js +137 -135
- package/examples/test-mcp.js +85 -79
- package/examples/test-reload.js +59 -61
- package/examples/test-telegram.js +50 -50
- package/examples/test-tg-bot.js +45 -42
- package/examples/test-tg-simple.js +47 -46
- package/examples/test-tg.js +62 -62
- package/examples/test-think.js +43 -37
- package/examples/test-web-plugin.js +103 -98
- package/examples/test-weixin-feishu.js +103 -100
- package/examples/workflow.js +158 -158
- package/package.json +37 -3
- package/plugins/ai-plugin.js +102 -100
- 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/audit-plugin.js +187 -187
- package/plugins/default-plugins.js +662 -649
- 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 +481 -477
- package/plugins/file-system-plugin.js +826 -476
- package/plugins/install-plugin.js +199 -197
- package/plugins/python-executor-plugin.js +367 -365
- package/plugins/python-plugin-loader.js +481 -479
- package/plugins/rules-plugin.js +294 -292
- package/plugins/scheduler-plugin.js +691 -689
- package/plugins/session-plugin.js +369 -367
- package/plugins/shell-executor-plugin.js +197 -197
- package/plugins/storage-plugin.js +240 -238
- package/plugins/subagent-plugin.js +845 -785
- package/plugins/telegram-plugin.js +482 -475
- package/plugins/think-plugin.js +345 -343
- package/plugins/tools-plugin.js +196 -194
- package/plugins/web-plugin.js +606 -604
- package/plugins/weixin-plugin.js +545 -538
- 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 +11 -11
- package/src/capabilities/skill-manager.js +609 -595
- package/src/capabilities/workflow-engine.js +1109 -1195
- package/src/core/agent-chat.js +882 -735
- package/src/core/agent.js +892 -688
- package/src/core/framework.js +465 -431
- package/src/core/index.js +19 -19
- package/src/core/plugin-base.js +219 -219
- package/src/core/plugin-manager.js +863 -767
- package/src/core/provider.js +114 -111
- package/src/core/sub-agent-config.js +264 -0
- package/src/core/system-prompt-builder.js +120 -0
- package/src/core/tool-registry.js +517 -134
- package/src/core/tool-router.js +297 -216
- package/src/executors/executor-base.js +12 -12
- package/src/executors/mcp-executor.js +741 -729
- package/src/index.js +25 -37
- 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 +97 -97
- 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 +136 -133
- package/website/styles.css +1 -1
- package/plugins/ambient-agent-plugin.js +0 -1565
- package/plugins/email.js +0 -1142
package/SPEC.md
CHANGED
|
@@ -49,8 +49,8 @@ class Framework {
|
|
|
49
49
|
```javascript
|
|
50
50
|
// 创建 Agent
|
|
51
51
|
const agent = framework.createAgent({
|
|
52
|
-
name: 'MyAgent',
|
|
53
|
-
systemPrompt: '你是一个助手',
|
|
52
|
+
name: 'MyAgent', // Agent 名称
|
|
53
|
+
systemPrompt: '你是一个助手', // 系统提示
|
|
54
54
|
|
|
55
55
|
// 共享提示模板 (支持 {{VAR}} 占位符)
|
|
56
56
|
sharedPrompt: `工作目录: {{WORK_DIR}}`,
|
|
@@ -58,16 +58,16 @@ const agent = framework.createAgent({
|
|
|
58
58
|
// 元数据 (供 sharedPrompt 和自身使用)
|
|
59
59
|
metadata: {
|
|
60
60
|
projectName: 'MyProject',
|
|
61
|
-
version: '1.0.0'
|
|
62
|
-
}
|
|
63
|
-
})
|
|
61
|
+
version: '1.0.0',
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
64
|
|
|
65
65
|
// 运行时元数据操作
|
|
66
|
-
agent.setMetadata('task', '数据分析')
|
|
67
|
-
agent.setMetadata({ key: 'value' })
|
|
68
|
-
agent.getMetadata('task')
|
|
69
|
-
agent.deleteMetadata('task')
|
|
70
|
-
agent.clearMetadata()
|
|
66
|
+
agent.setMetadata('task', '数据分析'); // 设置单个
|
|
67
|
+
agent.setMetadata({ key: 'value' }); // 批量设置
|
|
68
|
+
agent.getMetadata('task'); // 获取
|
|
69
|
+
agent.deleteMetadata('task'); // 删除
|
|
70
|
+
agent.clearMetadata(); // 清空
|
|
71
71
|
```
|
|
72
72
|
|
|
73
73
|
**内置占位符:**
|
|
@@ -81,6 +81,7 @@ agent.clearMetadata() // 清空
|
|
|
81
81
|
| `{{DATE}}` | 当前日期 |
|
|
82
82
|
|
|
83
83
|
**Agent 方法:**
|
|
84
|
+
|
|
84
85
|
```javascript
|
|
85
86
|
class Agent {
|
|
86
87
|
constructor(framework, config) // 创建 Agent
|
|
@@ -102,6 +103,7 @@ class Agent {
|
|
|
102
103
|
```
|
|
103
104
|
|
|
104
105
|
**生成的 System Prompt 示例:**
|
|
106
|
+
|
|
105
107
|
```
|
|
106
108
|
你是一个助手。
|
|
107
109
|
|
|
@@ -120,14 +122,14 @@ class Agent {
|
|
|
120
122
|
|
|
121
123
|
```javascript
|
|
122
124
|
class Plugin {
|
|
123
|
-
name
|
|
124
|
-
version = '1.0.0'
|
|
125
|
-
description
|
|
126
|
-
|
|
127
|
-
install(framework) {
|
|
128
|
-
start(framework) {
|
|
129
|
-
reload(framework) {
|
|
130
|
-
uninstall(framework) {
|
|
125
|
+
name; // 插件名称 (必填)
|
|
126
|
+
version = '1.0.0';
|
|
127
|
+
description; // 插件描述
|
|
128
|
+
|
|
129
|
+
install(framework) {} // 安装时调用
|
|
130
|
+
start(framework) {} // 启动时调用
|
|
131
|
+
reload(framework) {} // 热重载时调用
|
|
132
|
+
uninstall(framework) {} // 卸载时调用
|
|
131
133
|
}
|
|
132
134
|
```
|
|
133
135
|
|
|
@@ -190,14 +192,15 @@ D:\code\foliko\
|
|
|
190
192
|
|
|
191
193
|
```javascript
|
|
192
194
|
// 更新插件配置
|
|
193
|
-
framework.updatePluginConfig('telegram', { allowedChats: ['123'] })
|
|
195
|
+
framework.updatePluginConfig('telegram', { allowedChats: ['123'] });
|
|
194
196
|
|
|
195
197
|
// 启用/禁用插件
|
|
196
|
-
framework.enablePlugin('telegram')
|
|
197
|
-
framework.disablePlugin('telegram')
|
|
198
|
+
framework.enablePlugin('telegram');
|
|
199
|
+
framework.disablePlugin('telegram');
|
|
198
200
|
```
|
|
199
201
|
|
|
200
202
|
**保存的内容:**
|
|
203
|
+
|
|
201
204
|
- `enabled` - 插件启用状态
|
|
202
205
|
- `config` - 插件配置对象
|
|
203
206
|
|
|
@@ -206,12 +209,14 @@ framework.disablePlugin('telegram')
|
|
|
206
209
|
### 4.1 Framework (src/core/framework.js)
|
|
207
210
|
|
|
208
211
|
**职责**:
|
|
212
|
+
|
|
209
213
|
- 管理插件生命周期
|
|
210
214
|
- 提供工具注册表
|
|
211
215
|
- 事件总线
|
|
212
216
|
- 初始化协调
|
|
213
217
|
|
|
214
218
|
**API**:
|
|
219
|
+
|
|
215
220
|
```javascript
|
|
216
221
|
const framework = new Framework({
|
|
217
222
|
debug: false
|
|
@@ -242,11 +247,13 @@ await framework.ready()
|
|
|
242
247
|
### 4.2 Agent (src/core/agent.js)
|
|
243
248
|
|
|
244
249
|
**职责**:
|
|
250
|
+
|
|
245
251
|
- 维护对话上下文
|
|
246
252
|
- 调用 AI 进行对话
|
|
247
253
|
- 管理工具调用循环
|
|
248
254
|
|
|
249
255
|
**API**:
|
|
256
|
+
|
|
250
257
|
```javascript
|
|
251
258
|
const agent = framework.createAgent({
|
|
252
259
|
systemPrompt: '你是一个有帮助的助手',
|
|
@@ -263,11 +270,13 @@ const response = await agent.chat('你好')
|
|
|
263
270
|
### 4.3 PluginManager (src/core/plugin-manager.js)
|
|
264
271
|
|
|
265
272
|
**职责**:
|
|
273
|
+
|
|
266
274
|
- 维护已加载插件列表
|
|
267
275
|
- 按优先级排序加载
|
|
268
276
|
- 协调插件生命周期
|
|
269
277
|
|
|
270
278
|
**生命周期**:
|
|
279
|
+
|
|
271
280
|
1. `install()` - 注册工具/事件
|
|
272
281
|
2. `start()` - 初始化完成,开始工作
|
|
273
282
|
3. `reload()` - 热重载
|
|
@@ -276,11 +285,13 @@ const response = await agent.chat('你好')
|
|
|
276
285
|
### 4.4 ToolRegistry (src/core/tool-registry.js)
|
|
277
286
|
|
|
278
287
|
**职责**:
|
|
288
|
+
|
|
279
289
|
- 注册工具
|
|
280
290
|
- 调用工具
|
|
281
291
|
- 工具描述管理
|
|
282
292
|
|
|
283
293
|
**工具格式**:
|
|
294
|
+
|
|
284
295
|
```javascript
|
|
285
296
|
{
|
|
286
297
|
name: 'tool_name',
|
|
@@ -294,21 +305,21 @@ const response = await agent.chat('你好')
|
|
|
294
305
|
|
|
295
306
|
```javascript
|
|
296
307
|
// 事件列表
|
|
297
|
-
'framework:ready'
|
|
298
|
-
'plugin:install'
|
|
299
|
-
'plugin:start'
|
|
300
|
-
'plugin:reload'
|
|
301
|
-
'plugin:uninstall'
|
|
302
|
-
'plugin:enabled'
|
|
303
|
-
'plugin:disabled'
|
|
304
|
-
'agent:message'
|
|
305
|
-
'agent:tool-call'
|
|
306
|
-
'agent:tool-result'
|
|
307
|
-
'notification'
|
|
308
|
-
'scheduler:reminder'
|
|
309
|
-
'think:thought_completed'
|
|
310
|
-
'email:received'
|
|
311
|
-
'webhook:received'
|
|
308
|
+
'framework:ready'; // 框架就绪
|
|
309
|
+
'plugin:install'; // 插件安装
|
|
310
|
+
'plugin:start'; // 插件启动
|
|
311
|
+
'plugin:reload'; // 插件重载
|
|
312
|
+
'plugin:uninstall'; // 插件卸载
|
|
313
|
+
'plugin:enabled'; // 插件启用
|
|
314
|
+
'plugin:disabled'; // 插件禁用
|
|
315
|
+
'agent:message'; // Agent消息
|
|
316
|
+
'agent:tool-call'; // Agent调用工具
|
|
317
|
+
'agent:tool-result'; // 工具执行结果
|
|
318
|
+
'notification'; // 统一通知事件(推送用户)
|
|
319
|
+
'scheduler:reminder'; // 定时提醒触发(业务事件)
|
|
320
|
+
'think:thought_completed'; // 思考完成
|
|
321
|
+
'email:received'; // 收到新邮件
|
|
322
|
+
'webhook:received'; // 收到Webhook请求
|
|
312
323
|
```
|
|
313
324
|
|
|
314
325
|
### 通知事件 (notification)
|
|
@@ -330,36 +341,39 @@ const response = await agent.chat('你好')
|
|
|
330
341
|
|
|
331
342
|
业务事件用于触发 Ambient Agent 的目标,不直接通知用户。
|
|
332
343
|
|
|
333
|
-
| 事件
|
|
334
|
-
|
|
335
|
-
| `scheduler:reminder`
|
|
336
|
-
| `think:thought_completed` | `thought`
|
|
337
|
-
| `email:received`
|
|
338
|
-
| `webhook:received`
|
|
339
|
-
| `tool:result`
|
|
340
|
-
| `agent:message`
|
|
344
|
+
| 事件 | 数据 | 说明 |
|
|
345
|
+
| ------------------------- | ----------------------------------------------- | ----------------- |
|
|
346
|
+
| `scheduler:reminder` | `{ taskId, taskName, message, sessionId, llm }` | 定时提醒触发时 |
|
|
347
|
+
| `think:thought_completed` | `thought` | 思考完成时 |
|
|
348
|
+
| `email:received` | `email` | 收到新邮件时 |
|
|
349
|
+
| `webhook:received` | `{ webhook, data, response, sessionId }` | 收到Webhook请求时 |
|
|
350
|
+
| `tool:result` | `{ name, args, result }` | 工具执行结果 |
|
|
351
|
+
| `agent:message` | `{ content }` | Agent发送消息时 |
|
|
341
352
|
|
|
342
353
|
## 六、热重载机制
|
|
343
354
|
|
|
344
355
|
### 设计原则
|
|
356
|
+
|
|
345
357
|
- **不监测文件变化** - 避免复杂性和性能开销
|
|
346
358
|
- **手动调用重载** - 通过 API 触发
|
|
347
359
|
- **插件自管理** - 插件提供 reload() 方法
|
|
348
360
|
|
|
349
361
|
### API
|
|
362
|
+
|
|
350
363
|
```javascript
|
|
351
364
|
// 重载单个插件
|
|
352
|
-
await framework.reloadPlugin('my-plugin')
|
|
365
|
+
await framework.reloadPlugin('my-plugin');
|
|
353
366
|
|
|
354
367
|
// 重载所有插件
|
|
355
|
-
await framework.reloadAllPlugins()
|
|
368
|
+
await framework.reloadAllPlugins();
|
|
356
369
|
|
|
357
370
|
// 在 Agent 中调用
|
|
358
|
-
agent.chat('请重载 my-plugin 插件')
|
|
371
|
+
agent.chat('请重载 my-plugin 插件');
|
|
359
372
|
// 需要插件提供 reload_plugins 工具
|
|
360
373
|
```
|
|
361
374
|
|
|
362
375
|
### 重载流程
|
|
376
|
+
|
|
363
377
|
1. 调用 `plugin.reload(framework)`
|
|
364
378
|
2. 插件清理旧资源
|
|
365
379
|
3. 插件重新初始化
|
|
@@ -370,10 +384,12 @@ agent.chat('请重载 my-plugin 插件')
|
|
|
370
384
|
### 7.1 AI Plugin (plugins/ai-plugin.js)
|
|
371
385
|
|
|
372
386
|
**功能**:
|
|
387
|
+
|
|
373
388
|
- AI 对话能力
|
|
374
389
|
- 工具调用循环
|
|
375
390
|
|
|
376
391
|
**配置**:
|
|
392
|
+
|
|
377
393
|
```javascript
|
|
378
394
|
{
|
|
379
395
|
type: 'ai-plugin',
|
|
@@ -387,10 +403,12 @@ agent.chat('请重载 my-plugin 插件')
|
|
|
387
403
|
### 7.2 Tools Plugin (plugins/tools-plugin.js)
|
|
388
404
|
|
|
389
405
|
**功能**:
|
|
406
|
+
|
|
390
407
|
- 内置工具注册
|
|
391
408
|
- 工具调用执行
|
|
392
409
|
|
|
393
410
|
**内置工具**:
|
|
411
|
+
|
|
394
412
|
- `reload_plugins` - 热重载插件
|
|
395
413
|
- `list_plugins` - 列出已加载插件
|
|
396
414
|
- `enable_plugin` - 启用插件
|
|
@@ -401,10 +419,12 @@ agent.chat('请重载 my-plugin 插件')
|
|
|
401
419
|
### 7.3 Email Plugin (plugins/email-plugin.js)
|
|
402
420
|
|
|
403
421
|
**功能**:
|
|
422
|
+
|
|
404
423
|
- SMTP 发送邮件
|
|
405
424
|
- IMAP 读取邮件
|
|
406
425
|
|
|
407
426
|
**工具**:
|
|
427
|
+
|
|
408
428
|
- `email_send` - 发送邮件
|
|
409
429
|
- `email_read` - 读取邮件
|
|
410
430
|
- `email_unread_count` - 未读数量
|
|
@@ -413,6 +433,7 @@ agent.chat('请重载 my-plugin 插件')
|
|
|
413
433
|
### 7.4 Telegram Plugin (plugins/telegram-plugin.js)
|
|
414
434
|
|
|
415
435
|
**功能**:
|
|
436
|
+
|
|
416
437
|
- Telegram Bot 对话
|
|
417
438
|
- 绑定主 Agent 持续对话
|
|
418
439
|
- 支持 MarkdownV2
|
|
@@ -420,9 +441,11 @@ agent.chat('请重载 my-plugin 插件')
|
|
|
420
441
|
- 监听 `scheduler:reminder` 事件发送定时提醒
|
|
421
442
|
|
|
422
443
|
**监听事件**:
|
|
444
|
+
|
|
423
445
|
- `scheduler:reminder` - 接收定时任务提醒并发送到 Telegram
|
|
424
446
|
|
|
425
447
|
**配置**:
|
|
448
|
+
|
|
426
449
|
```javascript
|
|
427
450
|
{
|
|
428
451
|
botToken: '...',
|
|
@@ -435,18 +458,21 @@ agent.chat('请重载 my-plugin 插件')
|
|
|
435
458
|
### 7.5 Scheduler Plugin (plugins/scheduler-plugin.js)
|
|
436
459
|
|
|
437
460
|
**功能**:
|
|
461
|
+
|
|
438
462
|
- 定时任务调度(Cron 表达式、相对时间、绝对时间)
|
|
439
463
|
- 支持 LLM 自动检测(简单提醒直接显示,需要处理的任务启用 LLM)
|
|
440
464
|
- 会话自动检测(自动发送到最近活跃的会话)
|
|
441
465
|
- 事件系统(供其他插件监听和响应)
|
|
442
466
|
|
|
443
467
|
**工具**:
|
|
468
|
+
|
|
444
469
|
- `schedule_task` - 创建定时任务
|
|
445
470
|
- `schedule_list` - 列出所有任务
|
|
446
471
|
- `schedule_cancel` - 取消任务
|
|
447
472
|
- `cron_examples` - Cron 表达式示例
|
|
448
473
|
|
|
449
474
|
**schedule_task 参数**:
|
|
475
|
+
|
|
450
476
|
```javascript
|
|
451
477
|
{
|
|
452
478
|
name: '任务名称', // 可选
|
|
@@ -467,14 +493,17 @@ agent.chat('请重载 my-plugin 插件')
|
|
|
467
493
|
| Cron | `*/5 * * * *`, `0 9 * * *` | Cron 表达式 |
|
|
468
494
|
|
|
469
495
|
**自动 LLM 检测**:
|
|
496
|
+
|
|
470
497
|
- 简单提醒(喝水、吃饭)→ 直接显示
|
|
471
498
|
- 查询/分析任务(查看列表、分析数据)→ 启用 LLM
|
|
472
499
|
|
|
473
500
|
**持久化**:
|
|
501
|
+
|
|
474
502
|
- 任务自动保存到 `.agent/data/scheduler/tasks.json`
|
|
475
503
|
- 重启后自动恢复 Cron 任务和未执行的一次性任务
|
|
476
504
|
|
|
477
505
|
**通知**:
|
|
506
|
+
|
|
478
507
|
- 任务完成/失败/取消时发送 `notification` 事件
|
|
479
508
|
- 消息插件(微信、飞书)自动推送给用户
|
|
480
509
|
|
|
@@ -483,12 +512,14 @@ agent.chat('请重载 my-plugin 插件')
|
|
|
483
512
|
### 8.1 Ambient Agent (plugins/ambient-agent-plugin.js)
|
|
484
513
|
|
|
485
514
|
**功能**:
|
|
515
|
+
|
|
486
516
|
- 持续后台运行的智能代理
|
|
487
517
|
- 监控事件并主动执行操作
|
|
488
518
|
- 目标(Goal)管理系统
|
|
489
519
|
- 持久化记忆
|
|
490
520
|
|
|
491
521
|
**支持的事件**:
|
|
522
|
+
|
|
492
523
|
- `tool:result` - 工具执行结果
|
|
493
524
|
- `scheduler:reminder` - 定时提醒
|
|
494
525
|
- `agent:message` - 代理消息
|
|
@@ -497,6 +528,7 @@ agent.chat('请重载 my-plugin 插件')
|
|
|
497
528
|
- `webhook:received` - 收到Webhook
|
|
498
529
|
|
|
499
530
|
**工具**:
|
|
531
|
+
|
|
500
532
|
- `ambient_goals` - 管理目标(列出/创建/更新/删除/激活)
|
|
501
533
|
- `ambient_status` - 获取状态
|
|
502
534
|
- `ambient_think` - 触发主动思考
|
|
@@ -504,6 +536,7 @@ agent.chat('请重载 my-plugin 插件')
|
|
|
504
536
|
- `ambient_control` - 控制循环(暂停/恢复/调整)
|
|
505
537
|
|
|
506
538
|
**目标结构**:
|
|
539
|
+
|
|
507
540
|
```javascript
|
|
508
541
|
{
|
|
509
542
|
title: '目标标题',
|
|
@@ -522,6 +555,7 @@ agent.chat('请重载 my-plugin 插件')
|
|
|
522
555
|
```
|
|
523
556
|
|
|
524
557
|
**通知**:
|
|
558
|
+
|
|
525
559
|
- 目标完成时发送 `notification` 事件(level: 'success')
|
|
526
560
|
- 目标失败时发送 `notification` 事件(level: 'error')
|
|
527
561
|
|
|
@@ -530,9 +564,9 @@ agent.chat('请重载 my-plugin 插件')
|
|
|
530
564
|
### 9.1 基础用法
|
|
531
565
|
|
|
532
566
|
```javascript
|
|
533
|
-
const { Framework } = require('./src')
|
|
567
|
+
const { Framework } = require('./src');
|
|
534
568
|
|
|
535
|
-
const framework = new Framework({ debug: true })
|
|
569
|
+
const framework = new Framework({ debug: true });
|
|
536
570
|
|
|
537
571
|
// 注册插件
|
|
538
572
|
framework.registerPlugin({
|
|
@@ -541,49 +575,53 @@ framework.registerPlugin({
|
|
|
541
575
|
f.registerTool({
|
|
542
576
|
name: 'greet',
|
|
543
577
|
description: '打招呼',
|
|
544
|
-
execute: async (args) => `Hello, ${args.name}
|
|
545
|
-
})
|
|
546
|
-
}
|
|
547
|
-
})
|
|
578
|
+
execute: async (args) => `Hello, ${args.name}!`,
|
|
579
|
+
});
|
|
580
|
+
},
|
|
581
|
+
});
|
|
548
582
|
|
|
549
|
-
await framework.ready()
|
|
583
|
+
await framework.ready();
|
|
550
584
|
|
|
551
585
|
const agent = framework.createAgent({
|
|
552
586
|
systemPrompt: '你是一个助手',
|
|
553
587
|
model: 'deepseek-chat',
|
|
554
|
-
apiKey: process.env.API_KEY
|
|
555
|
-
})
|
|
588
|
+
apiKey: process.env.API_KEY,
|
|
589
|
+
});
|
|
556
590
|
|
|
557
|
-
const response = await agent.chat('你好')
|
|
558
|
-
console.log(response)
|
|
591
|
+
const response = await agent.chat('你好');
|
|
592
|
+
console.log(response);
|
|
559
593
|
```
|
|
560
594
|
|
|
561
595
|
### 9.2 热重载
|
|
562
596
|
|
|
563
597
|
```javascript
|
|
564
598
|
// 重载单个插件
|
|
565
|
-
await framework.reloadPlugin('my-plugin')
|
|
599
|
+
await framework.reloadPlugin('my-plugin');
|
|
566
600
|
|
|
567
601
|
// 重载所有插件
|
|
568
|
-
await framework.reloadAllPlugins()
|
|
602
|
+
await framework.reloadAllPlugins();
|
|
569
603
|
```
|
|
570
604
|
|
|
571
605
|
## 九、代码规范
|
|
572
606
|
|
|
573
607
|
### 9.1 文件命名
|
|
608
|
+
|
|
574
609
|
- 类文件:`小写-连字符.js`,如 `plugin-base.js`
|
|
575
610
|
- 目录:`小写-连字符`,如 `src/core`
|
|
576
611
|
|
|
577
612
|
### 9.2 类命名
|
|
613
|
+
|
|
578
614
|
- 类名:`大写驼峰`,如 `Framework`, `Agent`
|
|
579
615
|
- 方法名:`小写驼峰`,如 `registerTool`, `loadPlugin`
|
|
580
616
|
|
|
581
617
|
### 9.3 变量命名
|
|
618
|
+
|
|
582
619
|
- 类属性:`小写驼峰`
|
|
583
620
|
- 常量:`全大写+下划线`,如 `DEFAULT_PRIORITY`
|
|
584
621
|
- 私有属性:`_下划线前缀`
|
|
585
622
|
|
|
586
623
|
### 9.4 注释
|
|
624
|
+
|
|
587
625
|
```javascript
|
|
588
626
|
/**
|
|
589
627
|
* 类描述
|
|
@@ -594,13 +632,14 @@ class Framework {
|
|
|
594
632
|
* @param {string} name - 参数描述
|
|
595
633
|
* @returns {Promise<void>}
|
|
596
634
|
*/
|
|
597
|
-
async loadPlugin(name) {
|
|
635
|
+
async loadPlugin(name) {}
|
|
598
636
|
}
|
|
599
637
|
```
|
|
600
638
|
|
|
601
639
|
## 十、已实现功能
|
|
602
640
|
|
|
603
641
|
### Phase 1 - 核心框架 ✓
|
|
642
|
+
|
|
604
643
|
- [x] Framework 核心类 (`src/core/framework.js`)
|
|
605
644
|
- [x] Agent 基础类 (`src/core/agent.js`)
|
|
606
645
|
- [x] 插件系统 (`src/core/plugin-manager.js`, `src/core/plugin-base.js`)
|
|
@@ -609,10 +648,12 @@ class Framework {
|
|
|
609
648
|
- [x] 热重载 API (`reloadPlugin()`, `reloadAllPlugins()`)
|
|
610
649
|
|
|
611
650
|
### Phase 2 - 内置插件 ✓
|
|
651
|
+
|
|
612
652
|
- [x] AI Plugin (`plugins/ai-plugin.js`) - 对接 Vercel AI SDK
|
|
613
653
|
- [x] 内置工具插件 (`plugins/tools-plugin.js`) - 热重载、列表工具
|
|
614
654
|
|
|
615
655
|
### Phase 3 - 高级功能 ✓
|
|
656
|
+
|
|
616
657
|
- [x] Skill 管理 (`src/capabilities/skill-manager.js`) - 加载和管理 Skill
|
|
617
658
|
- [x] 工作流引擎 (`src/capabilities/workflow-engine.js`) - 支持脚本、条件、循环等
|
|
618
659
|
- [x] MCP 执行器 (`src/executors/mcp-executor.js`) - 连接 MCP 服务器
|
package/cli/bin/foliko.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Foliko CLI 入口
|
|
4
|
-
* Usage: foliko <command> [options]
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
// 加载 dotenv
|
|
8
|
-
require('dotenv').config()
|
|
9
|
-
|
|
10
|
-
const { cli } = require('../src')
|
|
11
|
-
|
|
12
|
-
cli()
|
|
2
|
+
/**
|
|
3
|
+
* Foliko CLI 入口
|
|
4
|
+
* Usage: foliko <command> [options]
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// 加载 dotenv
|
|
8
|
+
require('dotenv').config();
|
|
9
|
+
|
|
10
|
+
const { cli } = require('../src');
|
|
11
|
+
|
|
12
|
+
cli();
|