foliko 1.1.92 → 2.0.0

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 (212) hide show
  1. package/.claude/settings.local.json +2 -1
  2. package/CLAUDE.md +56 -30
  3. package/REFACTORING_PLAN.md +645 -0
  4. package/docs/architecture.md +131 -0
  5. package/docs/migration.md +57 -0
  6. package/docs/public-api.md +138 -0
  7. package/docs/usage.md +385 -0
  8. package/examples/ambient-example.js +20 -137
  9. package/examples/basic.js +21 -48
  10. package/examples/bootstrap.js +16 -74
  11. package/examples/mcp-example.js +6 -29
  12. package/examples/skill-example.js +6 -19
  13. package/examples/workflow.js +8 -56
  14. package/package.json +8 -4
  15. package/plugins/README.md +49 -0
  16. package/plugins/{ambient-agent → ambient}/EventWatcher.js +1 -1
  17. package/plugins/{ambient-agent → ambient}/ExplorerLoop.js +3 -3
  18. package/plugins/{ambient-agent → ambient}/GoalManager.js +2 -2
  19. package/plugins/ambient/README.md +14 -0
  20. package/plugins/{ambient-agent → ambient}/Reflector.js +1 -1
  21. package/plugins/{ambient-agent → ambient}/StateStore.js +1 -1
  22. package/plugins/{ambient-agent → ambient}/index.js +2 -2
  23. package/plugins/{ai-plugin.js → core/ai/index.js} +14 -30
  24. package/plugins/{audit-plugin.js → core/audit/index.js} +3 -30
  25. package/plugins/{coordinator-plugin.js → core/coordinator/index.js} +3 -35
  26. package/plugins/core/default/bootstrap.js +202 -0
  27. package/plugins/core/default/config.js +220 -0
  28. package/plugins/core/default/index.js +58 -0
  29. package/plugins/core/mcp/index.js +1 -0
  30. package/plugins/{python-plugin-loader.js → core/python-loader/index.js} +7 -187
  31. package/plugins/{rules-plugin.js → core/rules/index.js} +121 -64
  32. package/plugins/{scheduler-plugin.js → core/scheduler/index.js} +12 -114
  33. package/plugins/{session-plugin.js → core/session/index.js} +9 -73
  34. package/{src/capabilities/skill-manager.js → plugins/core/skill-manager/index.js} +64 -18
  35. package/plugins/{storage-plugin.js → core/storage/index.js} +5 -29
  36. package/plugins/{subagent-plugin.js → core/sub-agent/index.js} +10 -171
  37. package/plugins/{think-plugin.js → core/think/index.js} +24 -91
  38. package/{src/capabilities/workflow-engine.js → plugins/core/workflow/index.js} +87 -85
  39. package/plugins/default-plugins.js +6 -720
  40. package/plugins/{data-splitter-plugin.js → executors/data-splitter/index.js} +9 -83
  41. package/plugins/{extension-executor-plugin.js → executors/extension/index.js} +13 -97
  42. package/plugins/{python-executor-plugin.js → executors/python/index.js} +6 -31
  43. package/plugins/{shell-executor-plugin.js → executors/shell/index.js} +2 -5
  44. package/plugins/install/README.md +9 -0
  45. package/plugins/{install-plugin.js → install/index.js} +3 -3
  46. package/plugins/{file-system-plugin.js → io/file-system/index.js} +34 -236
  47. package/plugins/{web-plugin.js → io/web/index.js} +11 -113
  48. package/plugins/memory/README.md +13 -0
  49. package/plugins/{memory-plugin.js → memory/index.js} +4 -18
  50. package/plugins/messaging/email/README.md +19 -0
  51. package/plugins/{email → messaging/email}/index.js +2 -2
  52. package/plugins/{feishu-plugin.js → messaging/feishu/index.js} +3 -3
  53. package/plugins/{qq-plugin.js → messaging/qq/index.js} +5 -16
  54. package/plugins/{telegram-plugin.js → messaging/telegram/index.js} +3 -3
  55. package/plugins/{weixin-plugin.js → messaging/weixin/index.js} +15 -15
  56. package/plugins/{plugin-manager-plugin.js → plugin-manager/index.js} +36 -180
  57. package/plugins/{tools-plugin.js → tools/index.js} +68 -116
  58. package/plugins/trading/README.md +15 -0
  59. package/plugins/{gate-trading.js → trading/index.js} +8 -8
  60. package/{examples → sandbox}/test-concurrent-chat.js +2 -2
  61. package/{examples → sandbox}/test-long-chat.js +2 -2
  62. package/{examples → sandbox}/test-session-chat.js +2 -2
  63. package/{examples → sandbox}/test-web-plugin.js +1 -1
  64. package/{examples → sandbox}/test-weixin-feishu.js +2 -2
  65. package/src/agent/base.js +56 -0
  66. package/src/{core/agent-chat.js → agent/chat.js} +11 -11
  67. package/src/{core/coordinator-manager.js → agent/coordinator.js} +3 -3
  68. package/src/agent/index.js +111 -0
  69. package/src/agent/main.js +337 -0
  70. package/src/agent/prompt.js +78 -0
  71. package/src/agent/sub.js +198 -0
  72. package/src/agent/worker.js +104 -0
  73. package/{cli/bin/foliko.js → src/cli/bin.js} +1 -1
  74. package/{cli/src → src/cli}/commands/chat.js +25 -21
  75. package/{cli/src → src/cli}/index.js +1 -0
  76. package/{cli/src → src/cli}/ui/chat-ui-old.js +40 -178
  77. package/{cli/src → src/cli}/ui/chat-ui.js +3 -3
  78. package/{cli/src → src/cli}/ui/components/footer-bar.js +1 -1
  79. package/src/{core → common}/constants.js +3 -0
  80. package/src/common/errors.js +402 -0
  81. package/src/{utils → common}/logger.js +33 -0
  82. package/src/{utils/chat-queue.js → common/queue.js} +2 -2
  83. package/src/config/plugin-config.js +50 -0
  84. package/src/context/agent.js +32 -0
  85. package/src/context/compaction-prompts.js +170 -0
  86. package/src/context/compaction-utils.js +191 -0
  87. package/src/context/compressor.js +413 -0
  88. package/src/context/index.js +9 -0
  89. package/src/{core/context-manager.js → context/manager.js} +1 -1
  90. package/src/context/request.js +50 -0
  91. package/src/context/session.js +33 -0
  92. package/src/context/storage.js +30 -0
  93. package/src/executors/mcp-client.js +153 -0
  94. package/src/executors/mcp-desc.js +236 -0
  95. package/src/executors/mcp-executor.js +91 -956
  96. package/src/{core → framework}/command-registry.js +1 -1
  97. package/src/framework/framework.js +300 -0
  98. package/src/framework/index.js +18 -0
  99. package/src/framework/lifecycle.js +203 -0
  100. package/src/framework/loader.js +78 -0
  101. package/src/framework/registry.js +86 -0
  102. package/src/{core/ui-extension-context.js → framework/ui-extension.js} +1 -1
  103. package/src/index.js +130 -15
  104. package/src/llm/index.js +26 -0
  105. package/src/llm/provider.js +212 -0
  106. package/src/llm/registry.js +11 -0
  107. package/src/{core/token-counter.js → llm/tokens.js} +4 -37
  108. package/src/{core/plugin-base.js → plugin/base.js} +10 -136
  109. package/src/plugin/index.js +14 -0
  110. package/src/plugin/loader.js +101 -0
  111. package/src/plugin/manager.js +261 -0
  112. package/src/{core → session}/branch-summary-auto.js +2 -2
  113. package/src/{core/chat-session.js → session/chat.js} +2 -2
  114. package/src/session/index.js +7 -0
  115. package/src/{core/session-manager.js → session/session.js} +2 -2
  116. package/src/session/ttl.js +92 -0
  117. package/src/{core/jsonl-storage.js → storage/jsonl.js} +1 -1
  118. package/src/tool/executor.js +85 -0
  119. package/src/tool/index.js +15 -0
  120. package/src/tool/registry.js +143 -0
  121. package/src/{core/tool-router.js → tool/router.js} +17 -124
  122. package/src/tool/schema.js +108 -0
  123. package/src/utils/data-splitter.js +1 -1
  124. package/src/utils/download.js +1 -1
  125. package/src/utils/index.js +6 -6
  126. package/src/utils/message-validator.js +1 -1
  127. package/tests/core/context-storage.test.js +46 -0
  128. package/tests/core/llm.test.js +54 -0
  129. package/tests/core/plugin.test.js +42 -0
  130. package/tests/core/tool.test.js +60 -0
  131. package/tests/setup.js +10 -0
  132. package/tests/smoke.test.js +58 -0
  133. package/vitest.config.js +9 -0
  134. package/cli/src/daemon.js +0 -149
  135. package/docs/CONTEXT_DESIGN.md +0 -1596
  136. package/docs/ai-sdk-optimization.md +0 -655
  137. package/docs/features.md +0 -120
  138. package/docs/qq-bot.md +0 -976
  139. package/docs/quick-reference.md +0 -160
  140. package/docs/user-manual.md +0 -1391
  141. package/images/geometric_shapes.jpg +0 -0
  142. package/images/sunset_mountain_lake.jpg +0 -0
  143. package/skills/poster-guide/SKILL.md +0 -792
  144. package/src/capabilities/index.js +0 -11
  145. package/src/core/agent.js +0 -808
  146. package/src/core/context-compressor.js +0 -959
  147. package/src/core/enhanced-context-compressor.js +0 -210
  148. package/src/core/framework.js +0 -1422
  149. package/src/core/index.js +0 -30
  150. package/src/core/plugin-manager.js +0 -961
  151. package/src/core/provider-registry.js +0 -159
  152. package/src/core/provider.js +0 -156
  153. package/src/core/request-context.js +0 -98
  154. package/src/core/subagent.js +0 -442
  155. package/src/core/system-prompt-builder.js +0 -120
  156. package/src/core/tool-executor.js +0 -202
  157. package/src/core/tool-registry.js +0 -517
  158. package/src/core/worker-agent.js +0 -192
  159. package/src/executors/executor-base.js +0 -58
  160. package/src/utils/error-boundary.js +0 -363
  161. package/src/utils/error.js +0 -374
  162. package/system.md +0 -1645
  163. package/website_v2/README.md +0 -57
  164. package/website_v2/SPEC.md +0 -1
  165. package/website_v2/docs/api.html +0 -128
  166. package/website_v2/docs/configuration.html +0 -147
  167. package/website_v2/docs/plugin-development.html +0 -129
  168. package/website_v2/docs/project-structure.html +0 -89
  169. package/website_v2/docs/skill-development.html +0 -85
  170. package/website_v2/index.html +0 -489
  171. package/website_v2/scripts/main.js +0 -93
  172. package/website_v2/styles/animations.css +0 -8
  173. package/website_v2/styles/docs.css +0 -83
  174. package/website_v2/styles/main.css +0 -417
  175. package/xhs_auth.json +0 -268
  176. package//346/265/267/346/212/245/346/217/222/344/273/266.md +0 -621
  177. /package/plugins/{ambient-agent → ambient}/constants.js +0 -0
  178. /package/plugins/{email → messaging/email}/constants.js +0 -0
  179. /package/plugins/{email → messaging/email}/handlers.js +0 -0
  180. /package/plugins/{email → messaging/email}/monitor.js +0 -0
  181. /package/plugins/{email → messaging/email}/parser.js +0 -0
  182. /package/plugins/{email → messaging/email}/reply.js +0 -0
  183. /package/plugins/{email → messaging/email}/utils.js +0 -0
  184. /package/{examples → sandbox}/test-chat.js +0 -0
  185. /package/{examples → sandbox}/test-mcp.js +0 -0
  186. /package/{examples → sandbox}/test-reload.js +0 -0
  187. /package/{examples → sandbox}/test-telegram.js +0 -0
  188. /package/{examples → sandbox}/test-tg-bot.js +0 -0
  189. /package/{examples → sandbox}/test-tg-simple.js +0 -0
  190. /package/{examples → sandbox}/test-tg.js +0 -0
  191. /package/{examples → sandbox}/test-think.js +0 -0
  192. /package/src/{core/sub-agent-config.js → agent/sub-config.js} +0 -0
  193. /package/{cli/src → src/cli}/commands/daemon.js +0 -0
  194. /package/{cli/src → src/cli}/commands/list.js +0 -0
  195. /package/{cli/src → src/cli}/commands/plugin.js +0 -0
  196. /package/{cli/src → src/cli}/ui/components/agent-mention-provider.js +0 -0
  197. /package/{cli/src → src/cli}/ui/components/chained-autocomplete-provider.js +0 -0
  198. /package/{cli/src → src/cli}/ui/components/message-bubble.js +0 -0
  199. /package/{cli/src → src/cli}/ui/components/status-bar.js +0 -0
  200. /package/{cli/src → src/cli}/utils/ansi.js +0 -0
  201. /package/{cli/src → src/cli}/utils/config.js +0 -0
  202. /package/{cli/src → src/cli}/utils/markdown.js +0 -0
  203. /package/{cli/src → src/cli}/utils/plugin-config.js +0 -0
  204. /package/{cli/src → src/cli}/utils/render-diff.js +0 -0
  205. /package/src/{utils/circuit-breaker.js → common/circuit.js} +0 -0
  206. /package/src/{utils/edit-diff.js → common/diff.js} +0 -0
  207. /package/src/{utils/event-emitter.js → common/events.js} +0 -0
  208. /package/src/{utils → common}/id.js +0 -0
  209. /package/src/{utils → common}/retry.js +0 -0
  210. /package/src/{core/notification-manager.js → notification/manager.js} +0 -0
  211. /package/src/{core/session-entry.js → session/entry.js} +0 -0
  212. /package/src/{core/storage-manager.js → storage/manager.js} +0 -0
@@ -1,57 +0,0 @@
1
- # Foliko 官网
2
-
3
- ## 安装与运行
4
-
5
- ### 本地开发
6
-
7
- ```bash
8
- cd website_v2
9
- # 启动简易 HTTP 服务器
10
- python -m http.server 8080
11
- # 或使用 npx
12
- npx serve .
13
- ```
14
-
15
- 然后访问 http://localhost:8080
16
-
17
- ### 部署
18
-
19
- 静态文件在 `website_v2/` 目录下,可部署到任意静态托管服务(Vercel、Netlify、Nginx 等)
20
-
21
- ## 项目结构
22
-
23
- ```
24
- website_v2/
25
- ├── index.html # 主页面
26
- ├── docs/ # 文档页面
27
- │ ├── api.html # API 参考
28
- │ ├── configuration.html # 配置指南
29
- │ ├── plugin-development.html # 插件开发
30
- │ ├── project-structure.html # 项目结构
31
- │ └── skill-development.html # 技能开发
32
- ├── styles/
33
- │ ├── main.css # 主样式文件
34
- │ ├── animations.css # 动画样式
35
- │ └── docs.css # 文档样式
36
- ├── scripts/
37
- │ └── main.js # 主脚本文件
38
- └── images/ # 图片资源
39
- ```
40
-
41
- ## 设计风格
42
-
43
- - **主题**:明亮主题
44
- - **Primary**: #6366F1
45
- - **Accent**: #8B5CF6
46
- - **Background**: #FFFFFF
47
- - **Surface**: #F8FAFC
48
- - **字体**: DM Sans (display/body), JetBrains Mono (code)
49
-
50
- ## 技术特点
51
-
52
- - 纯 HTML + CSS + JS,无框架依赖
53
- - 响应式设计,支持桌面,平板、手机
54
- - 渐变色彩与柔和阴影
55
- - 平滑滚动与交互动画
56
- - 安装命令一键复制
57
- - 完整的文档页面
@@ -1 +0,0 @@
1
- # Foliko 官网 v2 设计规范\n\n## 设计风格\n融合 Linear 极简美学 + AI Native 科技感:深色沉浸式体验、精致微交互、霓虹光晕点缀\n\n## 色彩系统\n- Primary: #6366F1\n- Accent: #8B5CF6 \n- Background: #0A0A0F\n- Surface: #1A1A24\n- Text: #FFFFFF / #A1A1AA\n\n## 技术实现\n纯 HTML/CSS/JS 单页应用,Google Fonts + Lucide Icons
@@ -1,128 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="zh-CN">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>API 参考 - Foliko</title>
7
- <link rel="preconnect" href="https://fonts.googleapis.com">
8
- <link href="https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
9
- <link rel="stylesheet" href="../styles/docs.css">
10
- <link rel="icon" type="image/svg+xml" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><defs><linearGradient id='g' x1='0%25' y1='0%25' x2='100%25' y2='100%25'><stop offset='0%25' stop-color='%236366F1'/><stop offset='100%25' stop-color='%238B5CF6'/></linearGradient></defs><circle cx='50' cy='50' r='45' fill='url(%23g)'/><path d='M30 50 L45 65 L70 35' stroke='white' stroke-width='8' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>">
11
- </head>
12
- <body>
13
- <nav class="nav">
14
- <div class="nav-inner">
15
- <a href="../index.html" class="nav-logo">
16
- <svg viewBox="0 0 100 100" width="32" height="32" fill="none">
17
- <defs><linearGradient id="logoGrad" x1="0%" y1="0%" x2="100%" y2="100%"><stop offset="0%" stop-color="#6366F1"/><stop offset="100%" stop-color="#8B5CF6"/></linearGradient></defs>
18
- <circle cx="50" cy="50" r="45" fill="url(#logoGrad)"/>
19
- <path d="M30 50 L45 65 L70 35" stroke="white" stroke-width="8" fill="none" stroke-linecap="round" stroke-linejoin="round"/>
20
- </svg>
21
- Foliko
22
- </a>
23
- <div class="nav-links">
24
- <a href="../index.html#features" class="nav-link">核心特性</a>
25
- <a href="../index.html#architecture" class="nav-link">架构设计</a>
26
- <a href="../index.html#plugins" class="nav-link">插件生态</a>
27
- <a href="../index.html#quickstart" class="nav-link">快速开始</a>
28
- <a href="configuration.html" class="nav-link">文档</a>
29
- </div>
30
- <div class="nav-actions">
31
- <a href="../index.html#quickstart" class="btn btn-primary" style="display: inline-flex; align-items: center; gap: 8px; padding: 10px 20px; background: linear-gradient(135deg, #6366F1, #8B5CF6); color: white; border-radius: 8px; font-weight: 500; font-size: 0.9rem;">立即开始</a>
32
- </div>
33
- </div>
34
- </nav>
35
-
36
- <aside class="sidebar">
37
- <ul>
38
- <li><a href="project-structure.html">项目结构</a></li>
39
- <li><a href="configuration.html">配置指南</a></li>
40
- <li><a href="plugin-development.html">插件开发</a></li>
41
- <li><a href="skill-development.html">技能开发</a></li>
42
- <li><a href="api.html" class="active">API 参考</a></li>
43
- </ul>
44
- </aside>
45
-
46
- <main class="main-content">
47
- <h1>API 参考</h1>
48
-
49
- <h2>内置工具</h2>
50
-
51
- <div class="tool-card">
52
- <div class="tool-name">install</div>
53
- <div class="tool-desc">安装 npm 包到 .foliko 目录</div>
54
- <div class="tool-params"><code>package</code>: string - 包名(如 zod 或 lodash@4.17.21)</div>
55
- </div>
56
-
57
- <div class="tool-card">
58
- <div class="tool-name">loadSkill</div>
59
- <div class="tool-desc">加载指定技能</div>
60
- <div class="tool-params"><code>skill</code>: string - 技能名称</div>
61
- </div>
62
-
63
- <div class="tool-card">
64
- <div class="tool-name">shell</div>
65
- <div class="tool-desc">执行 Shell 命令</div>
66
- <div class="tool-params"><code>command</code>: string - 要执行的命令</div>
67
- </div>
68
-
69
- <div class="tool-card">
70
- <div class="tool-name">python-execute</div>
71
- <div class="tool-desc">执行 Python 代码</div>
72
- <div class="tool-params"><code>code</code>: string - Python 代码</div>
73
- </div>
74
-
75
- <div class="tool-card">
76
- <div class="tool-name">session_*
77
- <div class="tool-desc">会话管理相关工具</div>
78
- <div class="tool-params">session_create, session_list, session_load, session_delete 等</div>
79
- </div>
80
-
81
- <div class="tool-card">
82
- <div class="tool-name">schedule_task</div>
83
- <div class="tool-desc">创建定时任务</div>
84
- <div class="tool-params"><code>name</code>: 任务名称<br><code>scheduleTime</code>: 执行时间<br><code>message</code>: 提醒消息</div>
85
- </div>
86
-
87
- <div class="tool-card">
88
- <div class="tool-name">ambient_goals</div>
89
- <div class="tool-desc">管理 Ambient Agent 目标</div>
90
- <div class="tool-params"><code>action</code>: list/create/update/delete/activate<br><code>goalId</code>: 目标ID</div>
91
- </div>
92
-
93
- <h2>框架 API</h2>
94
- <pre><code>// 创建 Agent
95
- const { Framework } = require('foliko')
96
- const framework = new Framework()
97
- framework.loadPlugin('ai')
98
-
99
- const agent = framework.createAgent({
100
- name: 'MyAgent',
101
- systemPrompt: '你是一个助手'
102
- })
103
-
104
- // 发送消息
105
- const response = await agent.chat('你好')
106
-
107
- // 注册工具
108
- framework.registerTool({
109
- name: 'my_tool',
110
- description: '...',
111
- inputSchema: z.object({...}),
112
- execute: async (args) => {...}
113
- })
114
-
115
- // 热重载插件
116
- await framework.reloadPlugin('plugin-name')</code></pre>
117
-
118
- <h2>占位符</h2>
119
- <p>在 sharedPrompt 中使用:</p>
120
- <pre><code>{{WORK_DIR}} # 工作目录
121
- {{HOME_DIR}} # 主目录
122
- {{HOST_NAME}} # 主机名
123
- {{PLATFORM}} # 平台
124
- {{TIME}} # 当前时间
125
- {{DATE}} # 当前日期</code></pre>
126
- </main>
127
- </body>
128
- </html>
@@ -1,147 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="zh-CN">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>配置指南 - Foliko</title>
7
- <link rel="preconnect" href="https://fonts.googleapis.com">
8
- <link href="https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
9
- <link rel="stylesheet" href="../styles/docs.css">
10
- <link rel="icon" type="image/svg+xml" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><defs><linearGradient id='g' x1='0%25' y1='0%25' x2='100%25' y2='100%25'><stop offset='0%25' stop-color='%236366F1'/><stop offset='100%25' stop-color='%238B5CF6'/></linearGradient></defs><circle cx='50' cy='50' r='45' fill='url(%23g)'/><path d='M30 50 L45 65 L70 35' stroke='white' stroke-width='8' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>">
11
- </head>
12
- <body>
13
- <!-- Navigation -->
14
- <nav class="nav">
15
- <div class="nav-inner">
16
- <a href="../index.html" class="nav-logo">
17
- <svg viewBox="0 0 100 100" width="32" height="32" fill="none">
18
- <defs><linearGradient id="logoGrad" x1="0%" y1="0%" x2="100%" y2="100%"><stop offset="0%" stop-color="#6366F1"/><stop offset="100%" stop-color="#8B5CF6"/></linearGradient></defs>
19
- <circle cx="50" cy="50" r="45" fill="url(#logoGrad)"/>
20
- <path d="M30 50 L45 65 L70 35" stroke="white" stroke-width="8" fill="none" stroke-linecap="round" stroke-linejoin="round"/>
21
- </svg>
22
- Foliko
23
- </a>
24
- <div class="nav-links">
25
- <a href="../index.html#features" class="nav-link">核心特性</a>
26
- <a href="../index.html#architecture" class="nav-link">架构设计</a>
27
- <a href="../index.html#plugins" class="nav-link">插件生态</a>
28
- <a href="../index.html#quickstart" class="nav-link">快速开始</a>
29
- <a href="configuration.html" class="nav-link">文档</a>
30
- </div>
31
- <div class="nav-actions">
32
- <a href="../index.html#quickstart" class="btn btn-primary" style="display: inline-flex; align-items: center; gap: 8px; padding: 10px 20px; background: linear-gradient(135deg, #6366F1, #8B5CF6); color: white; border-radius: 8px; font-weight: 500;">立即开始</a>
33
- </div>
34
- </div>
35
- </nav>
36
-
37
- <!-- Sidebar -->
38
- <aside class="sidebar">
39
- <ul>
40
- <li><a href="project-structure.html">项目结构</a></li>
41
- <li><a href="configuration.html" class="active">配置指南</a></li>
42
- <li><a href="plugin-development.html">插件开发</a></li>
43
- <li><a href="skill-development.html">技能开发</a></li>
44
- <li><a href="api.html">API 参考</a></li>
45
- </ul>
46
- </aside>
47
-
48
- <!-- Main Content -->
49
- <main class="main-content">
50
- <h1>配置指南</h1>
51
-
52
- <h2>环境变量配置 (.env)</h2>
53
- <p>在项目根目录创建 <code>.env</code> 文件:</p>
54
- <pre><code># AI Provider: minimax, deepseek, openai, anthropic 等
55
- FOLIKO_PROVIDER=minimax
56
-
57
- # AI Model(可选,不填则使用 provider 默认值)
58
- FOLIKO_MODEL=MiniMax-M2.7
59
-
60
- # API Base URL(可选)
61
- FOLIKO_BASE_URL=https://api.minimaxi.com/v1
62
-
63
- # API Key(通用)
64
- FOLIKO_API_KEY=sk-your-api-key
65
-
66
- # Provider 专用 API Key
67
- DEEPSEEK_API_KEY=sk-your-deepseek-api-key
68
- MINIMAX_API_KEY=sk-your-minimax-api-key</code></pre>
69
- <p><strong>配置优先级</strong>:命令行参数 &gt; .env配置 &gt; provider默认值</p>
70
-
71
- <h2>目录结构</h2>
72
- <p>在项目根目录创建 <code>.foliko</code> 目录:</p>
73
- <pre><code>项目目录/
74
- └── .foliko/
75
- ├── config # 配置文件
76
- ├── ai.json # AI 配置
77
- ├── mcp_config.json # MCP 服务器配置
78
- ├── plugins/ # 用户插件
79
- ├── skills/ # 用户技能
80
- └── data/ # 数据目录</code></pre>
81
-
82
- <h2>config 文件</h2>
83
- <p>简单的 key=value 格式配置:</p>
84
- <pre><code>ai_key: your-api-key
85
- ai_model: MiniMax-M2.7
86
- ai_provider: minimax
87
- ai_base_url: https://api.minimaxi.com/v1</code></pre>
88
-
89
- <h2>ai.json</h2>
90
- <p>JSON 格式的 AI 配置:</p>
91
- <pre><code>{
92
- "provider": "minimax",
93
- "model": "MiniMax-M2.7",
94
- "apiKey": "your-api-key",
95
- "baseURL": "https://api.minimaxi.com/v1"
96
- }</code></pre>
97
-
98
- <h2>mcp_config.json</h2>
99
- <p>MCP 服务器配置:</p>
100
- <pre><code>{
101
- "mcpServers": {
102
- "fetch": {
103
- "command": "npx",
104
- "args": ["-y", "@modelcontextprotocol/server-fetch"]
105
- }
106
- }
107
- }</code></pre>
108
-
109
- <h2>插件配置</h2>
110
-
111
- <h3>Telegram 插件</h3>
112
- <pre><code>{
113
- "telegram": {
114
- "botToken": "your-bot-token",
115
- "allowedChats": ["123456789"],
116
- "groupMode": false,
117
- "prefix": "/"
118
- }
119
- }</code></pre>
120
-
121
- <h3>Session 插件</h3>
122
- <pre><code>{
123
- "session": {
124
- "sessionTTL": 1800000,
125
- "maxSessions": 100,
126
- "maxHistoryLength": 50,
127
- "autoCleanup": true,
128
- "cleanupInterval": 300000
129
- }
130
- }</code></pre>
131
-
132
- <h3>Email 插件</h3>
133
- <pre><code># SMTP 配置 (发送邮件)
134
- SMTP_HOST=smtp.gmail.com
135
- SMTP_PORT=587
136
- SMTP_SECURE=false
137
- SMTP_USER=your-email@gmail.com
138
- SMTP_PASS=your-app-password
139
-
140
- # IMAP 配置 (读取邮件)
141
- IMAP_HOST=imap.gmail.com
142
- IMAP_PORT=993
143
- IMAP_USER=your-email@gmail.com
144
- IMAP_PASS=your-app-password</code></pre>
145
- </main>
146
- </body>
147
- </html>
@@ -1,129 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="zh-CN">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>插件开发 - Foliko</title>
7
- <link rel="preconnect" href="https://fonts.googleapis.com">
8
- <link href="https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
9
- <link rel="stylesheet" href="../styles/docs.css">
10
- <link rel="icon" type="image/svg+xml" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><defs><linearGradient id='g' x1='0%25' y1='0%25' x2='100%25' y2='100%25'><stop offset='0%25' stop-color='%236366F1'/><stop offset='100%25' stop-color='%238B5CF6'/></linearGradient></defs><circle cx='50' cy='50' r='45' fill='url(%23g)'/><path d='M30 50 L45 65 L70 35' stroke='white' stroke-width='8' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>">
11
- </head>
12
- <body>
13
- <nav class="nav">
14
- <div class="nav-inner">
15
- <a href="../index.html" class="nav-logo">
16
- <svg viewBox="0 0 100 100" width="32" height="32" fill="none">
17
- <defs><linearGradient id="logoGrad" x1="0%" y1="0%" x2="100%" y2="100%"><stop offset="0%" stop-color="#6366F1"/><stop offset="100%" stop-color="#8B5CF6"/></linearGradient></defs>
18
- <circle cx="50" cy="50" r="45" fill="url(#logoGrad)"/>
19
- <path d="M30 50 L45 65 L70 35" stroke="white" stroke-width="8" fill="none" stroke-linecap="round" stroke-linejoin="round"/>
20
- </svg>
21
- Foliko
22
- </a>
23
- <div class="nav-links">
24
- <a href="../index.html#features" class="nav-link">核心特性</a>
25
- <a href="../index.html#architecture" class="nav-link">架构设计</a>
26
- <a href="../index.html#plugins" class="nav-link">插件生态</a>
27
- <a href="../index.html#quickstart" class="nav-link">快速开始</a>
28
- <a href="configuration.html" class="nav-link">文档</a>
29
- </div>
30
- <div class="nav-actions">
31
- <a href="../index.html#quickstart" class="btn btn-primary" style="display: inline-flex; align-items: center; gap: 8px; padding: 10px 20px; background: linear-gradient(135deg, #6366F1, #8B5CF6); color: white; border-radius: 8px; font-weight: 500; font-size: 0.9rem;">立即开始</a>
32
- </div>
33
- </div>
34
- </nav>
35
-
36
- <aside class="sidebar">
37
- <ul>
38
- <li><a href="project-structure.html">项目结构</a></li>
39
- <li><a href="configuration.html">配置指南</a></li>
40
- <li><a href="plugin-development.html" class="active">插件开发</a></li>
41
- <li><a href="skill-development.html">技能开发</a></li>
42
- <li><a href="api.html">API 参考</a></li>
43
- </ul>
44
- </aside>
45
-
46
- <main class="main-content">
47
- <h1>插件开发</h1>
48
-
49
- <h2>快速开始</h2>
50
- <p>在 <code>.foliko/plugins/</code> 目录下创建插件文件:</p>
51
- <pre><code>// .foliko/plugins/my-plugin.js
52
- module.exports = function(Plugin) {
53
- return class MyPlugin extends Plugin {
54
- constructor(config = {}) {
55
- super()
56
- this.name = 'my-plugin'
57
- this.version = '1.0.0'
58
- this.description = '我的工具插件'
59
- }
60
-
61
- install(framework) {
62
- framework.registerTool({
63
- name: 'my_tool',
64
- description: '我的工具',
65
- inputSchema: z.object({
66
- param: z.string().describe('参数描述')
67
- }),
68
- execute: async (args, framework) => {
69
- return { success: true, result: args.param }
70
- }
71
- })
72
- return this
73
- }
74
- }
75
- }</code></pre>
76
-
77
- <h2>插件结构</h2>
78
-
79
- <h3>必须属性</h3>
80
- <ul>
81
- <li><code>name</code> - 唯一名称</li>
82
- <li><code>version</code> - 版本号(可选,默认 1.0.0)</li>
83
- <li><code>description</code> - 描述(可选)</li>
84
- <li><code>priority</code> - 优先级(可选,默认 10)</li>
85
- </ul>
86
-
87
- <h3>生命周期</h3>
88
- <ul>
89
- <li><code>install(framework)</code> - 安装时调用,注册工具</li>
90
- <li><code>start(framework)</code> - 启动时调用</li>
91
- <li><code>reload(framework)</code> - 热重载时调用</li>
92
- <li><code>uninstall(framework)</code> - 卸载时调用</li>
93
- </ul>
94
-
95
- <h2>注册工具</h2>
96
- <pre><code>framework.registerTool({
97
- name: 'tool_name',
98
- description: '工具描述',
99
- inputSchema: z.object({
100
- param: z.string().describe('参数描述')
101
- }),
102
- execute: async (args, framework) => {
103
- return { success: true, result: '...' }
104
- }
105
- })</code></pre>
106
-
107
- <div class="tip">
108
- <strong>提示:</strong> 如果插件需要第三方库(如 zod),需要先调用 <code>install</code> 工具安装依赖。
109
- </div>
110
-
111
- <h2>Python 插件</h2>
112
- <p>创建 <code>.foliko/plugins/*.py</code> 文件:</p>
113
- <pre><code># .foliko/plugins/my-python-plugin.py
114
-
115
- plugin_info = {
116
- "name": "my-python-plugin",
117
- "version": "1.0.0",
118
- "description": "我的 Python 插件"
119
- }
120
-
121
- def execute_tool(tool_name, params):
122
- if tool_name == "hello":
123
- return {"success": True, "result": f"Hello, {params.get('name', 'World')}!"}
124
- return {"success": False, "error": "Unknown tool"}</code></pre>
125
-
126
- <div class="tip"><strong>提示:</strong> Python 插件会自动加载并注册到框架中。</div>
127
- </main>
128
- </body>
129
- </html>
@@ -1,89 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="zh-CN">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>项目结构 - Foliko</title>
7
- <link rel="preconnect" href="https://fonts.googleapis.com">
8
- <link href="https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
9
- <link rel="stylesheet" href="../styles/docs.css">
10
- <link rel="icon" type="image/svg+xml" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><defs><linearGradient id='g' x1='0%25' y1='0%25' x2='100%25' y2='100%25'><stop offset='0%25' stop-color='%236366F1'/><stop offset='100%25' stop-color='%238B5CF6'/></linearGradient></defs><circle cx='50' cy='50' r='45' fill='url(%23g)'/><path d='M30 50 L45 65 L70 35' stroke='white' stroke-width='8' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>">
11
- </head>
12
- <body>
13
- <nav class="nav">
14
- <div class="nav-inner">
15
- <a href="../index.html" class="nav-logo">
16
- <svg viewBox="0 0 100 100" width="32" height="32" fill="none">
17
- <defs><linearGradient id="logoGrad" x1="0%" y1="0%" x2="100%" y2="100%"><stop offset="0%" stop-color="#6366F1"/><stop offset="100%" stop-color="#8B5CF6"/></linearGradient></defs>
18
- <circle cx="50" cy="50" r="45" fill="url(#logoGrad)"/>
19
- <path d="M30 50 L45 65 L70 35" stroke="white" stroke-width="8" fill="none" stroke-linecap="round" stroke-linejoin="round"/>
20
- </svg>
21
- Foliko
22
- </a>
23
- <div class="nav-links">
24
- <a href="../index.html#features" class="nav-link">核心特性</a>
25
- <a href="../index.html#architecture" class="nav-link">架构设计</a>
26
- <a href="../index.html#plugins" class="nav-link">插件生态</a>
27
- <a href="../index.html#quickstart" class="nav-link">快速开始</a>
28
- <a href="configuration.html" class="nav-link">文档</a>
29
- </div>
30
- <div class="nav-actions">
31
- <a href="../index.html#quickstart" class="btn btn-primary" style="display: inline-flex; align-items: center; gap: 8px; padding: 10px 20px; background: linear-gradient(135deg, #6366F1, #8B5CF6); color: white; border-radius: 8px; font-weight: 500; font-size: 0.9rem;">立即开始</a>
32
- </div>
33
- </div>
34
- </nav>
35
-
36
- <aside class="sidebar">
37
- <ul>
38
- <li><a href="project-structure.html" class="active">项目结构</a></li>
39
- <li><a href="configuration.html">配置指南</a></li>
40
- <li><a href="plugin-development.html">插件开发</a></li>
41
- <li><a href="skill-development.html">技能开发</a></li>
42
- <li><a href="api.html">API 参考</a></li>
43
- </ul>
44
- </aside>
45
-
46
- <main class="main-content">
47
- <h1>项目结构</h1>
48
-
49
- <h2>目录结构</h2>
50
- <pre><code>foliko/
51
- ├── cli/ # 命令行入口
52
- │ └── bin/foliko.js # CLI 入口脚本
53
- ├── src/ # 核心框架
54
- │ ├── core/ # 核心组件
55
- │ ├── capabilities/ # 能力插件
56
- │ └── executors/ # 执行器
57
- ├── plugins/ # 内置插件
58
- ├── skills/ # 技能目录
59
- ├── examples/ # 示例
60
- └── docs/ # 文档</code></pre>
61
-
62
- <h2>核心目录</h2>
63
- <h3>cli/</h3>
64
- <p>命令行界面相关代码,包含聊天模式、命令解析等。</p>
65
-
66
- <h3>src/core/</h3>
67
- <p>框架核心组件,包括:</p>
68
- <ul>
69
- <li><code>agent.js</code> - Agent 类</li>
70
- <li><code>framework.js</code> - 框架容器</li>
71
- <li><code>plugin-manager.js</code> - 插件管理器</li>
72
- <li><code>tool-registry.js</code> - 工具注册表</li>
73
- </ul>
74
-
75
- <h3>plugins/</h3>
76
- <p>内置插件,提供核心功能:AI、存储、工具、工作流等。</p>
77
-
78
- <h2>.foliko/ 目录</h2>
79
- <p>用户配置目录(项目根目录下),包含:</p>
80
- <pre><code>.foliko/
81
- ├── config # 配置文件
82
- ├── ai.json # AI 配置
83
- ├── mcp_config.json # MCP 配置
84
- ├── plugins/ # 用户插件
85
- ├── skills/ # 用户技能
86
- └── data/ # 数据存储</code></pre>
87
- </main>
88
- </body>
89
- </html>
@@ -1,85 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="zh-CN">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>技能开发 - Foliko</title>
7
- <link rel="preconnect" href="https://fonts.googleapis.com">
8
- <link href="https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
9
- <link rel="stylesheet" href="../styles/docs.css">
10
- <link rel="icon" type="image/svg+xml" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><defs><linearGradient id='g' x1='0%25' y1='0%25' x2='100%25' y2='100%25'><stop offset='0%25' stop-color='%236366F1'/><stop offset='100%25' stop-color='%238B5CF6'/></linearGradient></defs><circle cx='50' cy='50' r='45' fill='url(%23g)'/><path d='M30 50 L45 65 L70 35' stroke='white' stroke-width='8' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>">
11
- </head>
12
- <body>
13
- <nav class="nav">
14
- <div class="nav-inner">
15
- <a href="../index.html" class="nav-logo">
16
- <svg viewBox="0 0 100 100" width="32" height="32" fill="none">
17
- <defs><linearGradient id="logoGrad" x1="0%" y1="0%" x2="100%" y2="100%"><stop offset="0%" stop-color="#6366F1"/><stop offset="100%" stop-color="#8B5CF6"/></linearGradient></defs>
18
- <circle cx="50" cy="50" r="45" fill="url(#logoGrad)"/>
19
- <path d="M30 50 L45 65 L70 35" stroke="white" stroke-width="8" fill="none" stroke-linecap="round" stroke-linejoin="round"/>
20
- </svg>
21
- Foliko
22
- </a>
23
- <div class="nav-links">
24
- <a href="../index.html#features" class="nav-link">核心特性</a>
25
- <a href="../index.html#architecture" class="nav-link">架构设计</a>
26
- <a href="../index.html#plugins" class="nav-link">插件生态</a>
27
- <a href="../index.html#quickstart" class="nav-link">快速开始</a>
28
- <a href="configuration.html" class="nav-link">文档</a>
29
- </div>
30
- <div class="nav-actions">
31
- <a href="../index.html#quickstart" class="btn btn-primary" style="display: inline-flex; align-items: center; gap: 8px; padding: 10px 20px; background: linear-gradient(135deg, #6366F1, #8B5CF6); color: white; border-radius: 8px; font-weight: 500; font-size: 0.9rem;">立即开始</a>
32
- </div>
33
- </div>
34
- </nav>
35
-
36
- <aside class="sidebar">
37
- <ul>
38
- <li><a href="project-structure.html">项目结构</a></li>
39
- <li><a href="configuration.html">配置指南</a></li>
40
- <li><a href="plugin-development.html">插件开发</a></li>
41
- <li><a href="skill-development.html" class="active">技能开发</a></li>
42
- <li><a href="api.html">API 参考</a></li>
43
- </ul>
44
- </aside>
45
-
46
- <main class="main-content">
47
- <h1>技能开发</h1>
48
-
49
- <h2>目录结构</h2>
50
- <p>在 <code>.foliko/skills/</code> 目录下创建技能:</p>
51
- <pre><code>.foliko/skills/
52
- └── my-skill/
53
- └── SKILL.md</code></pre>
54
-
55
- <h2>SKILL.md 格式</h2>
56
- <pre><code>---
57
- name: my-skill
58
- description: 技能描述
59
- allowed-tools: tool1, tool2
60
- ---
61
-
62
- # 技能名称
63
-
64
- 这里是技能的详细说明和使用指南...
65
-
66
- ## 使用示例
67
-
68
- \`\`\`
69
- 示例代码或用法说明
70
- \`\`\`</code></pre>
71
-
72
- <h2>Frontmatter 字段</h2>
73
- <ul>
74
- <li><code>name</code> - 技能名称</li>
75
- <li><code>description</code> - 技能描述</li>
76
- <li><code>allowed-tools</code> - 允许使用的工具列表(逗号分隔)</li>
77
- </ul>
78
-
79
- <h2>加载技能</h2>
80
- <p>Agent 启动时自动加载技能目录下的所有技能。</p>
81
- <p>使用 <code>loadSkill</code> 工具加载特定技能:</p>
82
- <pre><code>loadSkill { skill: "my-skill" }</code></pre>
83
- </main>
84
- </body>
85
- </html>