foliko 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.local.json +3 -1
- package/cli/src/ui/chat-ui.js +27 -2
- package/install.ps1 +179 -0
- package/package.json +2 -2
- package/plugins/default-plugins.js +9 -0
- package/plugins/python-executor-plugin.js +3 -3
- package/plugins/python-plugin-loader.js +478 -0
- package/skills/python-plugin-dev/SKILL.md +265 -0
- package/website/docs/api.html +159 -0
- package/website/docs/configuration.html +119 -0
- package/website/docs/plugin-development.html +155 -0
- package/website/docs/project-structure.html +142 -0
- package/website/docs/skill-development.html +85 -0
- package/website/index.html +197 -0
- package/website/script.js +77 -0
- package/website/styles.css +306 -0
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: python-plugin-dev
|
|
3
|
+
description: Python 插件开发指南。当用户说"创建 Python 插件"、"用 Python 写插件"时立即调用此 skill。
|
|
4
|
+
allowed-tools: Read, Write, Edit, Glob, Grep, Bash, python_plugin
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Python 插件开发
|
|
8
|
+
|
|
9
|
+
## 概述
|
|
10
|
+
|
|
11
|
+
Python 插件允许用 Python 语言开发工具,插件代码运行在 Python 环境中,可以调用所有 Python 库。
|
|
12
|
+
|
|
13
|
+
## 插件存放位置
|
|
14
|
+
|
|
15
|
+
`.agent/plugins/*.py`
|
|
16
|
+
|
|
17
|
+
## 插件结构
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
# .agent/plugins/my-plugin.py
|
|
21
|
+
|
|
22
|
+
plugin_info = {
|
|
23
|
+
"name": "my-plugin",
|
|
24
|
+
"version": "1.0.0",
|
|
25
|
+
"description": "我的 Python 插件",
|
|
26
|
+
"tools": [
|
|
27
|
+
{
|
|
28
|
+
"name": "hello",
|
|
29
|
+
"description": "问候工具",
|
|
30
|
+
"params": {"name": "string"}
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"name": "calc",
|
|
34
|
+
"description": "计算器工具",
|
|
35
|
+
"params": {"a": "number", "b": "number", "op": "string"}
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
def execute_tool(tool_name, params):
|
|
41
|
+
"""
|
|
42
|
+
执行工具 - 框架调用入口
|
|
43
|
+
tool_name: 工具名称
|
|
44
|
+
params: 参数字典
|
|
45
|
+
"""
|
|
46
|
+
if tool_name == "hello":
|
|
47
|
+
return hello_tool(params)
|
|
48
|
+
elif tool_name == "calc":
|
|
49
|
+
return calc_tool(params)
|
|
50
|
+
else:
|
|
51
|
+
return {"success": False, "error": f"Unknown tool: {tool_name}"}
|
|
52
|
+
|
|
53
|
+
# === 工具实现 ===
|
|
54
|
+
|
|
55
|
+
def hello_tool(params):
|
|
56
|
+
"""简单问候工具"""
|
|
57
|
+
name = params.get("name", "World")
|
|
58
|
+
return {
|
|
59
|
+
"success": True,
|
|
60
|
+
"result": f"Hello, {name}!"
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
def calc_tool(params):
|
|
64
|
+
"""计算器工具"""
|
|
65
|
+
a = params.get("a", 0)
|
|
66
|
+
b = params.get("b", 0)
|
|
67
|
+
op = params.get("op", "add")
|
|
68
|
+
|
|
69
|
+
if op == "add":
|
|
70
|
+
result = a + b
|
|
71
|
+
elif op == "sub":
|
|
72
|
+
result = a - b
|
|
73
|
+
elif op == "mul":
|
|
74
|
+
result = a * b
|
|
75
|
+
elif op == "div":
|
|
76
|
+
if b == 0:
|
|
77
|
+
return {"success": False, "error": "Division by zero"}
|
|
78
|
+
result = a / b
|
|
79
|
+
else:
|
|
80
|
+
return {"success": False, "error": f"Unknown operation: {op}"}
|
|
81
|
+
|
|
82
|
+
return {"success": True, "result": result}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
**重要**:`tools` 字段定义了插件提供的所有工具。框架会自动:
|
|
86
|
+
1. 将这些工具注册到系统中
|
|
87
|
+
2. 附加到系统提示词,LLM 可以直接调用
|
|
88
|
+
|
|
89
|
+
## 工具函数规范
|
|
90
|
+
|
|
91
|
+
| 规范 | 说明 |
|
|
92
|
+
|------|------|
|
|
93
|
+
| 返回 dict | 必须是 Python 字典 |
|
|
94
|
+
| success 字段 | `true` 或 `false` |
|
|
95
|
+
| result 字段 | 成功时返回的结果 |
|
|
96
|
+
| error 字段 | 失败时返回的错误信息 |
|
|
97
|
+
|
|
98
|
+
## 返回值格式
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
# 成功
|
|
102
|
+
{"success": True, "result": "返回值"}
|
|
103
|
+
|
|
104
|
+
# 失败
|
|
105
|
+
{"success": False, "error": "错误信息"}
|
|
106
|
+
|
|
107
|
+
# 返回复杂数据
|
|
108
|
+
{"success": True, "result": {"key": "value", "list": [1, 2, 3]}}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## 使用方式
|
|
112
|
+
|
|
113
|
+
创建插件后,使用 `python_plugin` 工具调用:
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
python_plugin({
|
|
117
|
+
plugin: "my-plugin", # 插件名称(不含 .py)
|
|
118
|
+
tool: "hello", # 工具名称
|
|
119
|
+
params: { name: "Foliko" } # 工具参数
|
|
120
|
+
})
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## 示例:天气查询插件
|
|
124
|
+
|
|
125
|
+
```python
|
|
126
|
+
# .agent/plugins/weather.py
|
|
127
|
+
|
|
128
|
+
plugin_info = {
|
|
129
|
+
"name": "weather",
|
|
130
|
+
"version": "1.0.0",
|
|
131
|
+
"description": "天气查询插件"
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
def execute_tool(tool_name, params):
|
|
135
|
+
if tool_name == "get_weather":
|
|
136
|
+
return get_weather(params)
|
|
137
|
+
else:
|
|
138
|
+
return {"success": False, "error": f"Unknown tool: {tool_name}"}
|
|
139
|
+
|
|
140
|
+
def get_weather(params):
|
|
141
|
+
import requests
|
|
142
|
+
|
|
143
|
+
city = params.get("city", "北京")
|
|
144
|
+
|
|
145
|
+
try:
|
|
146
|
+
# 这里使用免费的天气 API
|
|
147
|
+
response = requests.get(
|
|
148
|
+
f"https://wttr.in/{city}?format=j1",
|
|
149
|
+
timeout=5
|
|
150
|
+
)
|
|
151
|
+
data = response.json()
|
|
152
|
+
|
|
153
|
+
return {
|
|
154
|
+
"success": True,
|
|
155
|
+
"result": {
|
|
156
|
+
"city": city,
|
|
157
|
+
"temperature": data["current_condition"][0]["temp_C"],
|
|
158
|
+
"weather": data["current_condition"][0]["weatherDesc"][0]["value"]
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
except Exception as e:
|
|
162
|
+
return {"success": False, "error": str(e)}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## 示例:文件处理插件
|
|
166
|
+
|
|
167
|
+
```python
|
|
168
|
+
# .agent/plugins/file_processor.py
|
|
169
|
+
|
|
170
|
+
plugin_info = {
|
|
171
|
+
"name": "file_processor",
|
|
172
|
+
"version": "1.0.0",
|
|
173
|
+
"description": "文件处理插件"
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
def execute_tool(tool_name, params):
|
|
177
|
+
if tool_name == "read_file":
|
|
178
|
+
return read_file_tool(params)
|
|
179
|
+
elif tool_name == "write_file":
|
|
180
|
+
return write_file_tool(params)
|
|
181
|
+
else:
|
|
182
|
+
return {"success": False, "error": f"Unknown tool: {tool_name}"}
|
|
183
|
+
|
|
184
|
+
def read_file_tool(params):
|
|
185
|
+
import os
|
|
186
|
+
|
|
187
|
+
filepath = params.get("path")
|
|
188
|
+
if not filepath:
|
|
189
|
+
return {"success": False, "error": "path is required"}
|
|
190
|
+
|
|
191
|
+
try:
|
|
192
|
+
with open(filepath, "r", encoding="utf-8") as f:
|
|
193
|
+
content = f.read()
|
|
194
|
+
return {"success": True, "result": content}
|
|
195
|
+
except Exception as e:
|
|
196
|
+
return {"success": False, "error": str(e)}
|
|
197
|
+
|
|
198
|
+
def write_file_tool(params):
|
|
199
|
+
filepath = params.get("path")
|
|
200
|
+
content = params.get("content", "")
|
|
201
|
+
|
|
202
|
+
if not filepath:
|
|
203
|
+
return {"success": False, "error": "path is required"}
|
|
204
|
+
|
|
205
|
+
try:
|
|
206
|
+
os.makedirs(os.path.dirname(filepath), exist_ok=True)
|
|
207
|
+
with open(filepath, "w", encoding="utf-8") as f:
|
|
208
|
+
f.write(content)
|
|
209
|
+
return {"success": True, "result": f"Written to {filepath}"}
|
|
210
|
+
except Exception as e:
|
|
211
|
+
return {"success": False, "error": str(e)}
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
## 依赖管理
|
|
215
|
+
|
|
216
|
+
如果需要第三方库,可以在插件中用 `pip` 安装:
|
|
217
|
+
|
|
218
|
+
```python
|
|
219
|
+
def execute_tool(tool_name, params):
|
|
220
|
+
if tool_name == "install_package":
|
|
221
|
+
return install_package(params)
|
|
222
|
+
...
|
|
223
|
+
|
|
224
|
+
def install_package(params):
|
|
225
|
+
import subprocess
|
|
226
|
+
import sys
|
|
227
|
+
|
|
228
|
+
package = params.get("package")
|
|
229
|
+
if not package:
|
|
230
|
+
return {"success": False, "error": "package name is required"}
|
|
231
|
+
|
|
232
|
+
try:
|
|
233
|
+
subprocess.check_call([sys.executable, "-m", "pip", "install", package])
|
|
234
|
+
return {"success": True, "result": f"Installed {package}"}
|
|
235
|
+
except Exception as e:
|
|
236
|
+
return {"success": False, "error": str(e)}
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
## 注意事项
|
|
240
|
+
|
|
241
|
+
1. **不要创建目录** - 必须是单个 `.py` 文件
|
|
242
|
+
2. **必须定义 `execute_tool`** - 这是框架调用的入口
|
|
243
|
+
3. **必须定义 `plugin_info`** - 插件元信息
|
|
244
|
+
4. **异常处理** - 所有可能出错的地方都要 try-except
|
|
245
|
+
5. **编码** - 文件使用 UTF-8 编码
|
|
246
|
+
|
|
247
|
+
## 开发流程
|
|
248
|
+
|
|
249
|
+
1. **编写插件代码** - 在 `.agent/plugins/` 下创建 `.py` 文件
|
|
250
|
+
2. **调用工具** - 使用 `python_plugin` 工具执行
|
|
251
|
+
3. **调试** - 查看返回的 `success` 和 `error` 信息
|
|
252
|
+
|
|
253
|
+
## 常用 Python 库
|
|
254
|
+
|
|
255
|
+
插件中可以使用的常用库:
|
|
256
|
+
|
|
257
|
+
| 库 | 用途 | 导入方式 |
|
|
258
|
+
|-----|------|---------|
|
|
259
|
+
| requests | HTTP 请求 | `import requests` |
|
|
260
|
+
| json | JSON 处理 | `import json` |
|
|
261
|
+
| os | 系统操作 | `import os` |
|
|
262
|
+
| pathlib | 路径处理 | `from pathlib import Path` |
|
|
263
|
+
| datetime | 日期时间 | `from datetime import datetime` |
|
|
264
|
+
| re | 正则表达式 | `import re` |
|
|
265
|
+
| csv | CSV 处理 | `import csv` |
|
|
@@ -0,0 +1,159 @@
|
|
|
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="stylesheet" href="../styles.css">
|
|
8
|
+
<style>
|
|
9
|
+
.sidebar { position: fixed; left: 0; top: 60px; width: 250px; height: calc(100vh - 60px); background: var(--bg-card); border-right: 1px solid var(--border); padding: 2rem 1rem; overflow-y: auto; }
|
|
10
|
+
.sidebar ul { list-style: none; }
|
|
11
|
+
.sidebar li { margin-bottom: 0.5rem; }
|
|
12
|
+
.sidebar a { color: var(--text-secondary); text-decoration: none; display: block; padding: 0.5rem; border-radius: 4px; }
|
|
13
|
+
.sidebar a:hover, .sidebar a.active { background: rgba(99, 102, 241, 0.2); color: var(--primary); }
|
|
14
|
+
.main-content { margin-left: 250px; padding: 2rem; max-width: 900px; }
|
|
15
|
+
.main-content h1 { font-size: 2rem; margin-bottom: 1rem; }
|
|
16
|
+
.main-content h2 { font-size: 1.5rem; margin: 2rem 0 1rem; color: var(--secondary); }
|
|
17
|
+
.main-content p { margin-bottom: 1rem; color: var(--text-secondary); }
|
|
18
|
+
.main-content pre { background: var(--bg-card); padding: 1rem; border-radius: 8px; overflow-x: auto; margin-bottom: 1rem; }
|
|
19
|
+
.main-content code { font-family: 'Fira Code', monospace; background: var(--bg-dark); padding: 0.2rem 0.4rem; border-radius: 4px; }
|
|
20
|
+
.tool-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 1.5rem; margin-bottom: 1rem; }
|
|
21
|
+
.tool-name { font-size: 1.2rem; color: var(--primary); font-weight: 600; }
|
|
22
|
+
.tool-desc { color: var(--text-secondary); margin: 0.5rem 0; }
|
|
23
|
+
.tool-params { font-size: 0.9rem; color: var(--text-secondary); }
|
|
24
|
+
@media (max-width: 768px) { .sidebar { display: none; } .main-content { margin-left: 0; } }
|
|
25
|
+
</style>
|
|
26
|
+
</head>
|
|
27
|
+
<body>
|
|
28
|
+
<header>
|
|
29
|
+
<nav>
|
|
30
|
+
<div class="logo">Foliko</div>
|
|
31
|
+
<ul class="nav-links">
|
|
32
|
+
<li><a href="../index.html">首页</a></li>
|
|
33
|
+
<li><a href="../index.html#features">特性</a></li>
|
|
34
|
+
<li><a href="../index.html#quickstart">快速开始</a></li>
|
|
35
|
+
<li><a href="../index.html#docs">文档</a></li>
|
|
36
|
+
</ul>
|
|
37
|
+
</nav>
|
|
38
|
+
</header>
|
|
39
|
+
|
|
40
|
+
<div class="sidebar">
|
|
41
|
+
<ul>
|
|
42
|
+
<li><a href="project-structure.html">项目结构</a></li>
|
|
43
|
+
<li><a href="configuration.html">配置指南</a></li>
|
|
44
|
+
<li><a href="plugin-development.html">插件开发</a></li>
|
|
45
|
+
<li><a href="skill-development.html">技能开发</a></li>
|
|
46
|
+
<li><a href="api.html" class="active">API 参考</a></li>
|
|
47
|
+
</ul>
|
|
48
|
+
</div>
|
|
49
|
+
|
|
50
|
+
<div class="main-content">
|
|
51
|
+
<h1>API 参考</h1>
|
|
52
|
+
|
|
53
|
+
<h2>内置工具</h2>
|
|
54
|
+
|
|
55
|
+
<div class="tool-card">
|
|
56
|
+
<div class="tool-name">install</div>
|
|
57
|
+
<div class="tool-desc">安装 npm 包到 .agent 目录</div>
|
|
58
|
+
<div class="tool-params">
|
|
59
|
+
<code>package</code>: string - 包名(如 zod 或 lodash@4.17.21)
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
|
|
63
|
+
<div class="tool-card">
|
|
64
|
+
<div class="tool-name">loadSkill</div>
|
|
65
|
+
<div class="tool-desc">加载指定技能</div>
|
|
66
|
+
<div class="tool-params">
|
|
67
|
+
<code>skill</code>: string - 技能名称
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
|
|
71
|
+
<div class="tool-card">
|
|
72
|
+
<div class="tool-name">shell_execute</div>
|
|
73
|
+
<div class="tool-desc">执行 Shell 命令</div>
|
|
74
|
+
<div class="tool-params">
|
|
75
|
+
<code>command</code>: string - 要执行的命令
|
|
76
|
+
</div>
|
|
77
|
+
</div>
|
|
78
|
+
|
|
79
|
+
<div class="tool-card">
|
|
80
|
+
<div class="tool-name">python_execute</div>
|
|
81
|
+
<div class="tool-desc">执行 Python 代码</div>
|
|
82
|
+
<div class="tool-params">
|
|
83
|
+
<code>code</code>: string - Python 代码
|
|
84
|
+
</div>
|
|
85
|
+
</div>
|
|
86
|
+
|
|
87
|
+
<div class="tool-card">
|
|
88
|
+
<div class="tool-name">mcp_execute</div>
|
|
89
|
+
<div class="tool-desc">执行 MCP 工具</div>
|
|
90
|
+
<div class="tool-params">
|
|
91
|
+
<code>server</code>: string - 服务器名称<br>
|
|
92
|
+
<code>tool</code>: string - 工具名称<br>
|
|
93
|
+
<code>arguments</code>: object - 工具参数
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|
|
96
|
+
|
|
97
|
+
<div class="tool-card">
|
|
98
|
+
<div class="tool-name">mcp_reload</div>
|
|
99
|
+
<div class="tool-desc">重载 MCP 服务器</div>
|
|
100
|
+
</div>
|
|
101
|
+
|
|
102
|
+
<div class="tool-card">
|
|
103
|
+
<div class="tool-name">session_*</div>
|
|
104
|
+
<div class="tool-desc">会话管理相关工具</div>
|
|
105
|
+
<div class="tool-params">
|
|
106
|
+
session_create, session_list, session_load, session_delete 等
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
109
|
+
|
|
110
|
+
<div class="tool-card">
|
|
111
|
+
<div class="tool-name">audit_query</div>
|
|
112
|
+
<div class="tool-desc">查询审计日志</div>
|
|
113
|
+
<div class="tool-params">
|
|
114
|
+
<code>query</code>: string - 查询条件
|
|
115
|
+
</div>
|
|
116
|
+
</div>
|
|
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
|
+
|
|
127
|
+
<h2>框架 API</h2>
|
|
128
|
+
<pre><code>// 创建 Agent
|
|
129
|
+
const agent = framework.createAgent({
|
|
130
|
+
name: 'MyAgent',
|
|
131
|
+
systemPrompt: '你是一个助手',
|
|
132
|
+
sharedPrompt: '工作目录: {{WORK_DIR}}',
|
|
133
|
+
metadata: {
|
|
134
|
+
key: 'value'
|
|
135
|
+
}
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
// 发送消息
|
|
139
|
+
const response = await agent.chat('你好')
|
|
140
|
+
|
|
141
|
+
// 流式发送
|
|
142
|
+
for await (const chunk of agent.chatStream('你好')) {
|
|
143
|
+
console.log(chunk)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// 注册工具
|
|
147
|
+
framework.registerTool({
|
|
148
|
+
name: 'my_tool',
|
|
149
|
+
description: '...',
|
|
150
|
+
inputSchema: z.object({...}),
|
|
151
|
+
execute: async (args) => {...}
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
// 重载插件
|
|
155
|
+
await framework.reloadPlugin('plugin-name')
|
|
156
|
+
await framework.reloadAllPlugins()</code></pre>
|
|
157
|
+
</div>
|
|
158
|
+
</body>
|
|
159
|
+
</html>
|
|
@@ -0,0 +1,119 @@
|
|
|
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="stylesheet" href="../styles.css">
|
|
8
|
+
<style>
|
|
9
|
+
.sidebar { position: fixed; left: 0; top: 60px; width: 250px; height: calc(100vh - 60px); background: var(--bg-card); border-right: 1px solid var(--border); padding: 2rem 1rem; overflow-y: auto; }
|
|
10
|
+
.sidebar ul { list-style: none; }
|
|
11
|
+
.sidebar li { margin-bottom: 0.5rem; }
|
|
12
|
+
.sidebar a { color: var(--text-secondary); text-decoration: none; display: block; padding: 0.5rem; border-radius: 4px; }
|
|
13
|
+
.sidebar a:hover, .sidebar a.active { background: rgba(99, 102, 241, 0.2); color: var(--primary); }
|
|
14
|
+
.main-content { margin-left: 250px; padding: 2rem; max-width: 900px; }
|
|
15
|
+
.main-content h1 { font-size: 2rem; margin-bottom: 1rem; }
|
|
16
|
+
.main-content h2 { font-size: 1.5rem; margin: 2rem 0 1rem; color: var(--secondary); }
|
|
17
|
+
.main-content p { margin-bottom: 1rem; color: var(--text-secondary); }
|
|
18
|
+
.main-content pre { background: var(--bg-card); padding: 1rem; border-radius: 8px; overflow-x: auto; margin-bottom: 1rem; }
|
|
19
|
+
.main-content code { font-family: 'Fira Code', monospace; background: var(--bg-dark); padding: 0.2rem 0.4rem; border-radius: 4px; }
|
|
20
|
+
table { width: 100%; border-collapse: collapse; margin-bottom: 1rem; }
|
|
21
|
+
th, td { padding: 0.75rem; text-align: left; border: 1px solid var(--border); }
|
|
22
|
+
th { background: var(--bg-card); color: var(--secondary); }
|
|
23
|
+
@media (max-width: 768px) { .sidebar { display: none; } .main-content { margin-left: 0; } }
|
|
24
|
+
</style>
|
|
25
|
+
</head>
|
|
26
|
+
<body>
|
|
27
|
+
<header>
|
|
28
|
+
<nav>
|
|
29
|
+
<div class="logo">Foliko</div>
|
|
30
|
+
<ul class="nav-links">
|
|
31
|
+
<li><a href="../index.html">首页</a></li>
|
|
32
|
+
<li><a href="../index.html#features">特性</a></li>
|
|
33
|
+
<li><a href="../index.html#quickstart">快速开始</a></li>
|
|
34
|
+
<li><a href="../index.html#docs">文档</a></li>
|
|
35
|
+
</ul>
|
|
36
|
+
</nav>
|
|
37
|
+
</header>
|
|
38
|
+
|
|
39
|
+
<div class="sidebar">
|
|
40
|
+
<ul>
|
|
41
|
+
<li><a href="project-structure.html">项目结构</a></li>
|
|
42
|
+
<li><a href="configuration.html" class="active">配置指南</a></li>
|
|
43
|
+
<li><a href="plugin-development.html">插件开发</a></li>
|
|
44
|
+
<li><a href="skill-development.html">技能开发</a></li>
|
|
45
|
+
<li><a href="api.html">API 参考</a></li>
|
|
46
|
+
</ul>
|
|
47
|
+
</div>
|
|
48
|
+
|
|
49
|
+
<div class="main-content">
|
|
50
|
+
<h1>配置指南</h1>
|
|
51
|
+
|
|
52
|
+
<h2>目录结构</h2>
|
|
53
|
+
<p>在项目根目录创建 <code>.agent</code> 目录:</p>
|
|
54
|
+
<pre><code>项目目录/
|
|
55
|
+
└── .agent/
|
|
56
|
+
├── config # 配置文件
|
|
57
|
+
├── ai.json # AI 配置
|
|
58
|
+
├── mcp_config.json # MCP 服务器配置
|
|
59
|
+
├── plugins/ # 用户插件
|
|
60
|
+
├── skills/ # 用户技能
|
|
61
|
+
└── data/ # 数据目录</code></pre>
|
|
62
|
+
|
|
63
|
+
<h2>config 文件</h2>
|
|
64
|
+
<p>简单的 key=value 格式配置:</p>
|
|
65
|
+
<pre><code>ai_key: your-api-key
|
|
66
|
+
ai_model: MiniMax-M2.7
|
|
67
|
+
ai_provider: minimax
|
|
68
|
+
ai_base_url: https://api.minimaxi.com/v1</code></pre>
|
|
69
|
+
|
|
70
|
+
<h2>ai.json</h2>
|
|
71
|
+
<p>JSON 格式的 AI 配置:</p>
|
|
72
|
+
<pre><code>{
|
|
73
|
+
"provider": "minimax",
|
|
74
|
+
"model": "MiniMax-M2.7",
|
|
75
|
+
"apiKey": "your-api-key",
|
|
76
|
+
"baseURL": "https://api.minimaxi.com/v1"
|
|
77
|
+
}</code></pre>
|
|
78
|
+
|
|
79
|
+
<h2>mcp_config.json</h2>
|
|
80
|
+
<p>MCP 服务器配置:</p>
|
|
81
|
+
<pre><code>{
|
|
82
|
+
"mcpServers": {
|
|
83
|
+
"fetch": {
|
|
84
|
+
"command": "npx",
|
|
85
|
+
"args": ["-y", "@modelcontextprotocol/server-fetch"]
|
|
86
|
+
},
|
|
87
|
+
"filesystem": {
|
|
88
|
+
"command": "npx",
|
|
89
|
+
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/dir"]
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}</code></pre>
|
|
93
|
+
|
|
94
|
+
<h2>CLI 参数</h2>
|
|
95
|
+
<table>
|
|
96
|
+
<tr>
|
|
97
|
+
<th>参数</th>
|
|
98
|
+
<th>说明</th>
|
|
99
|
+
</tr>
|
|
100
|
+
<tr>
|
|
101
|
+
<td><code>--model</code></td>
|
|
102
|
+
<td>指定 AI 模型</td>
|
|
103
|
+
</tr>
|
|
104
|
+
<tr>
|
|
105
|
+
<td><code>--provider</code></td>
|
|
106
|
+
<td>指定 AI 提供商</td>
|
|
107
|
+
</tr>
|
|
108
|
+
<tr>
|
|
109
|
+
<td><code>--api-key</code></td>
|
|
110
|
+
<td>指定 API 密钥</td>
|
|
111
|
+
</tr>
|
|
112
|
+
<tr>
|
|
113
|
+
<td><code>--base-url</code></td>
|
|
114
|
+
<td>指定 API 地址</td>
|
|
115
|
+
</tr>
|
|
116
|
+
</table>
|
|
117
|
+
</div>
|
|
118
|
+
</body>
|
|
119
|
+
</html>
|