foliko 1.0.40 → 1.0.43

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.
@@ -82,7 +82,41 @@
82
82
  "Bash(node -c plugins/feishu-plugin.js 2>&1)",
83
83
  "Bash(node debug-skills.js)",
84
84
  "Bash(node -c src/capabilities/workflow-engine.js 2>&1)",
85
- "Bash(node -c skills/workflow-guide/SKILL.md 2>&1 || head -10 skills/workflow-guide/SKILL.md)"
85
+ "Bash(node -c skills/workflow-guide/SKILL.md 2>&1 || head -10 skills/workflow-guide/SKILL.md)",
86
+ "Bash(ls plugins/*.js 2>&1)",
87
+ "Bash(node -c plugins/web-plugin.js 2>&1)",
88
+ "Bash(cd D:/code/vb-agent && node -e \"require\\('./plugins/web-plugin.js'\\)\" 2>&1)",
89
+ "Bash(cd D:/code/vb-agent && node -e \"\nconst { WebPlugin } = require\\('./plugins/web-plugin.js'\\);\nconst p = new WebPlugin\\(\\);\nconsole.log\\('Plugin created:', p.name, p.version\\);\n\" 2>&1)",
90
+ "Bash(cd D:/code/vb-agent && mkdir -p test-static && echo '<html><body>Hello Static</body></html>' > test-static/index.html)",
91
+ "mcp__plugin_context7_context7__resolve-library-id",
92
+ "mcp__plugin_context7_context7__query-docs",
93
+ "Bash(cd D:/code/vb-agent && rm test-hono.js)",
94
+ "Bash(curl -s http://localhost:3000/test 2>&1 || echo \"连接失败\")",
95
+ "Bash(cd D:/code/vb-agent && timeout 15 node examples/test-web-plugin.js 2>&1)",
96
+ "Bash(cd D:/code/vb-agent && timeout 60 node examples/test-chat.js 2>&1 | head -100)",
97
+ "Bash(cd D:/code/vb-agent && timeout 120 node examples/test-chat.js 2>&1 | tail -80)",
98
+ "Bash(cd D:/code/vb-agent && timeout 120 node examples/bootstrap.js 2>&1 | tail -100)",
99
+ "Bash(cd D:/code/vb-agent && timeout 10 node examples/test-web-plugin.js 2>&1)",
100
+ "Bash(curl -s -X POST http://localhost:3000/test-webhook \\\\\n -H \"Content-Type: application/json\" \\\\\n -d '{\"message\":\"test from curl\",\"sessionId\":\"web_test\"}')",
101
+ "Bash(curl -s http://localhost:3000/test 2>&1 || echo \"Connection failed\")",
102
+ "Bash(curl -s -X POST http://localhost:3000/webhook/test-webhook \\\\\n -H \"Content-Type: application/json\" \\\\\n -d '{\"message\":\"test from curl\",\"sessionId\":\"web_test\"}')",
103
+ "Bash(curl -s http://localhost:3000/webui/status)",
104
+ "Bash(curl -s http://localhost:3000/test)",
105
+ "Bash(curl -s -v -X POST http://localhost:3000/test-webhook \\\\\n -H \"Content-Type: application/json\" \\\\\n -d '{\"message\":\"test\"}' 2>&1 | head -30)",
106
+ "Bash(curl -s -X POST \"http://localhost:3000/webhook/test-webhook\" \\\\\n -H \"Content-Type: application/json\" \\\\\n -d '{\"message\":\"test\"}' 2>&1)",
107
+ "Bash(curl -s http://localhost:3000/webui/ 2>&1)",
108
+ "Bash(curl -s -X POST http://localhost:3000/webui/list-routes \\\\\n -H \"Content-Type: application/json\" \\\\\n -d '{}' 2>&1 || echo \"Endpoint not found\")",
109
+ "Bash(curl -s http://localhost:3000/ 2>&1)",
110
+ "Bash(curl -s -X POST \"http://localhost:3000/webhook/test-webhook\" \\\\\n -H \"Content-Type: application/json\" \\\\\n -d '{\"message\":\"test with prefix\"}')",
111
+ "Bash(netstat -ano | grep :3000 | head -5)",
112
+ "Bash(netstat -ano | grep :3000 | grep LISTENING)",
113
+ "Bash(curl -s -X POST http://localhost:3000/test-webhook \\\\\n -H \"Content-Type: application/json\" \\\\\n -d '{\"message\":\"test\",\"sessionId\":\"web_test\"}')",
114
+ "Bash(taskkill /F /IM node.exe 2>/dev/null; sleep 1; echo \"Node processes killed\")",
115
+ "Bash(netstat -ano | grep :3000)",
116
+ "Bash(taskkill //F //PID 19848)",
117
+ "Bash(curl -s -X POST \"http://localhost:3000/webhook/075s5s2umn4smn4f\" \\\\\n -H \"Content-Type: application/json\" \\\\\n -d '{\"test\":\"data\"}' 2>&1)",
118
+ "Bash(curl -s http://localhost:3000/api/hello 2>&1)",
119
+ "Bash(curl -v -X POST \"http://localhost:3000/webhook/075s5s2umn4smn4f\" \\\\\n -H \"Content-Type: application/json\" \\\\\n -d '{\"test\":\"data\"}' 2>&1 | head -30)"
86
120
  ]
87
121
  }
88
122
  }
@@ -101,11 +101,11 @@ async function chatCommand(args) {
101
101
  const agent = framework.createAgent({
102
102
  name: 'FolikoAgent',
103
103
  systemPrompt: `你是一个有帮助的助手,擅长回答问题和执行任务。
104
- **注意事项:**
105
- 1、遇到npx skills add,npx skills remove, npx skills list 命令时:
106
- --添加"-a openclaw","-y"参数
107
- --不要加-g 参数
108
- `,
104
+
105
+ **命令执行规范:**
106
+ - 执行 npx skills add / npx skills remove / npx skills list 命令时,必须自动添加参数:-a openclaw -y
107
+ - 禁止添加 -g 参数
108
+ - 例如:npx skills add xxx 应该执行为 npx skills add xxx -a openclaw -y`,
109
109
  sharedPrompt: `工作目录: {{WORK_DIR}}`,
110
110
  metadata: {
111
111
  WORK_DIR: process.cwd() // 覆盖内置的 WORK_DIR
@@ -149,7 +149,11 @@ class ChatUI {
149
149
  console.log(colored('● ', GREEN))
150
150
  console.log()
151
151
 
152
- for await (const chunk of this.agent.chatStream(message, { sessionId: this.sessionId })) {
152
+ const runWithContext = this.agent.framework?.runWithContext.bind(this.agent.framework)
153
+ const { sessionId } = this
154
+
155
+ await runWithContext({ sessionId }, async () => {
156
+ for await (const chunk of this.agent.chatStream(message, { sessionId })) {
153
157
  if (interrupted) break
154
158
 
155
159
  if (chunk.type === 'text') {
@@ -171,7 +175,8 @@ class ChatUI {
171
175
  } else if (chunk.type === 'error') {
172
176
  console.error(`\n${colored('[错误]', RED)} ${chunk.error}`)
173
177
  }
174
- }
178
+ }
179
+ })
175
180
 
176
181
  if (lineBuffer.trim() && !interrupted) {
177
182
  console.log(renderLine(lineBuffer, renderState))
@@ -0,0 +1,120 @@
1
+ # Foliko 功能点清单
2
+
3
+ ## 1. AI 对话
4
+
5
+ | 功能 | 说明 |
6
+ |------|------|
7
+ | 流式输出 | 实时流式响应 |
8
+ | 多 Provider | minimax / deepseek / openai / anthropic |
9
+ | 模型配置 | 支持自定义 model、baseURL、apiKey |
10
+ | 系统提示词 | 支持 sharedPrompt 模板变量 |
11
+ | 思考过程 | 可选的 think 插件显示推理 |
12
+
13
+ ## 2. 工具系统
14
+
15
+ | 功能 | 说明 |
16
+ |------|------|
17
+ | `Bash` | 执行 Shell/Bash 命令 |
18
+ | `Read` | 读取文件内容 |
19
+ | `Write` | 写入文件 |
20
+ | `Edit` | 编辑文件(diff 替换) |
21
+ | `Glob` | 按模式搜索文件 |
22
+ | `Grep` | 文件内容搜索 |
23
+ | `python` | 执行 Python 代码 |
24
+ | `execute_workflow` | 执行工作流 |
25
+ | `loadSkill/reloadSkills` | 技能加载与重载 |
26
+ | `reloadWorkflows` | 工作流重载 |
27
+ | MCP 工具 | Model Context Protocol 集成 |
28
+
29
+ ## 3. 插件系统
30
+
31
+ | 功能 | 说明 |
32
+ |------|------|
33
+ | 插件目录 | `.agent/plugins/` 自动加载 |
34
+ | 插件生命周期 | install / start / reload / uninstall |
35
+ | 工具注册 | 插件可注册工具到 Agent |
36
+ | 事件系统 | 插件间通过事件通信 |
37
+ | 状态持久化 | 插件配置保存到 JSON |
38
+ | 优先级控制 | priority 决定加载顺序 |
39
+
40
+ ## 4. 工作流引擎
41
+
42
+ | 功能 | 说明 |
43
+ |------|------|
44
+ | `script` | JavaScript 脚本执行 |
45
+ | `loop` | 循环(maxIterations) |
46
+ | `condition` | 条件分支 |
47
+ | `delay` | 延时等待 |
48
+ | `parallel` | 并行执行 |
49
+ | 上下文共享 | variables / input / stepResults |
50
+ | 目录加载 | `.agent/workflows/` 自动注册 |
51
+
52
+ ## 5. 技能系统
53
+
54
+ | 功能 | 说明 |
55
+ |------|------|
56
+ | 技能目录 | `skills/` + `.agent/skills/` |
57
+ | SKILL.md | frontmatter 元数据格式 |
58
+ | 自动发现 | 递归扫描子目录 |
59
+ | 工具过滤 | allowed-tools 限制可用工具 |
60
+ | 重载支持 | reloadSkills 动态加载 |
61
+
62
+ ## 6. 会话管理
63
+
64
+ | 功能 | 说明 |
65
+ |------|------|
66
+ | SessionPlugin | 统一会话历史管理 |
67
+ | 多会话 | 按 sessionId 隔离 |
68
+ | 消息持久化 | JSON 文件存储 |
69
+ | 元数据 | 支持 platform / userId 等 |
70
+ | 会话事件 | session:created / deleted |
71
+
72
+ ## 7. 子 Agent
73
+
74
+ | 功能 | 说明 |
75
+ |------|------|
76
+ | 子Agent配置 | `.agent/agents/*.json/*.md` |
77
+ | 角色定义 | role / description |
78
+ | 工具继承 | parentTools 指定可用工具 |
79
+ | 工具路由 | 自动匹配最合适 Agent |
80
+ | 协作执行 | 支持多 Agent 分工 |
81
+
82
+ ## 8. 通讯插件
83
+
84
+ | 功能 | 说明 |
85
+ |------|------|
86
+ | Telegram | Bot Token / 群组模式 / 命令前缀 |
87
+ | 微信 | WebSocket 登录 / 二维码 |
88
+ | 飞书 | WS 长连接 / 事件订阅 |
89
+ | 邮件 | IMAP 读取 / SMTP 发送 / 163 兼容 |
90
+
91
+ ## 9. 执行器
92
+
93
+ | 功能 | 说明 |
94
+ |------|------|
95
+ | ShellExecutor | system 命令执行 |
96
+ | PythonExecutor | Python 3 代码执行 |
97
+ | 超时控制 | 可配置 maxDuration |
98
+ | 结果返回 | stdout/stderr/exitCode |
99
+
100
+ ## 10. Web 服务
101
+
102
+ | 功能 | 说明 |
103
+ |------|------|
104
+ | `web_start` | 启动 HTTP 服务器 |
105
+ | `web_stop` | 停止 HTTP 服务器 |
106
+ | `web_register_route` | 注册 HTTP 路由 |
107
+ | `web_register_webhook` | 注册 Webhook(数据交给 LLM 处理) |
108
+ | `web_list_routes` | 列出所有路由和 Webhook |
109
+ | 路由参数 | 支持 `/user/:id` 路径参数 |
110
+ | Webhook LLM | 接收数据后转发给 LLM 处理 |
111
+
112
+ ## 11. 其他内置插件
113
+
114
+ | 功能 | 说明 |
115
+ |------|------|
116
+ | `scheduler` | 定时任务 / 循环调度 |
117
+ | `rules` | 规则引擎 / 条件触发 |
118
+ | `storage` | 键值存储 |
119
+ | `audit` | 操作审计日志 |
120
+ | `install` | 插件安装工具 |
package/examples/basic.js CHANGED
@@ -1,110 +1,110 @@
1
- /**
2
- * 基础示例
3
- * 展示如何使用 Framework 和 Agent
4
- */
5
-
6
- const { Framework } = require('../src')
7
- const { AIPlugin } = require('../plugins/ai-plugin')
8
- const { z } = require('zod')
9
-
10
- async function main() {
11
- // 创建框架实例
12
- const framework = new Framework({ debug: true })
13
-
14
- // 加载 AI 插件
15
- await framework.loadPlugin(new AIPlugin({
16
- provider: 'deepseek',
17
- model: 'deepseek-chat',
18
- apiKey: process.env.DEEPSEEK_API_KEY || 'your-api-key'
19
- }))
20
-
21
- // 注册自定义工具(使用 inputSchema 格式)
22
- framework.registerTool({
23
- name: 'hello',
24
- description: '打招呼工具',
25
- inputSchema: z.object({
26
- name: z.string().optional().describe('姓名')
27
- }),
28
- execute: async (args) => {
29
- return `Hello, ${args.name || 'World'}!`
30
- }
31
- })
32
-
33
- // 注册计算器工具
34
- framework.registerTool({
35
- name: 'calculate',
36
- description: '简单的计算器',
37
- inputSchema: z.object({
38
- expression: z.string().describe('数学表达式,如 2+3*4')
39
- }),
40
- execute: async (args) => {
41
- try {
42
- // 安全计算(仅支持基本运算)
43
- const result = Function(`"use strict"; return (${args.expression})`)()
44
- return { result }
45
- } catch (e) {
46
- return { error: e.message }
47
- }
48
- }
49
- })
50
-
51
- console.log('[Framework] Ready!')
52
- console.log('[Tools]', framework.getTools().map(t => t.name))
53
-
54
- // 创建 Agent
55
- const agent = framework.createAgent({
56
- name: 'MyAgent',
57
- systemPrompt: '你是一个有帮助的助手。当需要计算时,使用 calculate 工具。'
58
- })
59
-
60
- // 监听事件
61
- agent.on('tool-call', (tool) => {
62
- console.log('[Agent] Tool call:', tool.name, tool.args)
63
- })
64
-
65
- agent.on('tool-result', (result) => {
66
- console.log('[Agent] Tool result:', result.name, result.result)
67
- })
68
-
69
- // AI 对话示例
70
- console.log('\n=== AI Chat Example ===')
71
- try {
72
- const response = await agent.chat('你好!')
73
- console.log('[Agent] Response:', response.message)
74
- } catch (err) {
75
- console.error('[Agent] Error:', err.message)
76
- }
77
-
78
- // 使用工具的对话示例
79
- console.log('\n=== AI Chat with Tool Call ===')
80
- try {
81
- const response = await agent.chat('请帮我计算 (15 + 25) * 2 等于多少?')
82
- console.log('[Agent] Response:', response.message)
83
- } catch (err) {
84
- console.error('[Agent] Error:', err.message)
85
- }
86
-
87
- // 流式对话示例
88
- console.log('\n=== Streaming Chat ===')
89
- try {
90
- for await (const chunk of agent.chatStream('请用中文介绍一下你自己')) {
91
- if (chunk.type === 'text') {
92
- process.stdout.write(chunk.text)
93
- }
94
- }
95
- console.log('\n')
96
- } catch (err) {
97
- console.error('[Agent] Stream Error:', err.message)
98
- }
99
-
100
- // 热重载示例
101
- console.log('\n=== Hot Reload ===')
102
- await framework.reloadPlugin('ai')
103
- console.log('AI plugin reloaded!')
104
-
105
- // 清理
106
- await framework.destroy()
107
- console.log('\n[Done]')
108
- }
109
-
110
- main().catch(console.error)
1
+ /**
2
+ * 基础示例
3
+ * 展示如何使用 Framework 和 Agent
4
+ */
5
+
6
+ const { Framework } = require('../src')
7
+ const { AIPlugin } = require('../plugins/ai-plugin')
8
+ const { z } = require('zod')
9
+
10
+ async function main() {
11
+ // 创建框架实例
12
+ const framework = new Framework({ debug: true })
13
+
14
+ // 加载 AI 插件
15
+ await framework.loadPlugin(new AIPlugin({
16
+ provider: 'deepseek',
17
+ model: 'deepseek-chat',
18
+ apiKey: process.env.DEEPSEEK_API_KEY || 'your-api-key'
19
+ }))
20
+
21
+ // 注册自定义工具(使用 inputSchema 格式)
22
+ framework.registerTool({
23
+ name: 'hello',
24
+ description: '打招呼工具',
25
+ inputSchema: z.object({
26
+ name: z.string().optional().describe('姓名')
27
+ }),
28
+ execute: async (args) => {
29
+ return `Hello, ${args.name || 'World'}!`
30
+ }
31
+ })
32
+
33
+ // 注册计算器工具
34
+ framework.registerTool({
35
+ name: 'calculate',
36
+ description: '简单的计算器',
37
+ inputSchema: z.object({
38
+ expression: z.string().describe('数学表达式,如 2+3*4')
39
+ }),
40
+ execute: async (args) => {
41
+ try {
42
+ // 安全计算(仅支持基本运算)
43
+ const result = Function(`"use strict"; return (${args.expression})`)()
44
+ return { result }
45
+ } catch (e) {
46
+ return { error: e.message }
47
+ }
48
+ }
49
+ })
50
+
51
+ console.log('[Framework] Ready!')
52
+ console.log('[Tools]', framework.getTools().map(t => t.name))
53
+
54
+ // 创建 Agent
55
+ const agent = framework.createAgent({
56
+ name: 'MyAgent',
57
+ systemPrompt: '你是一个有帮助的助手。当需要计算时,使用 calculate 工具。'
58
+ })
59
+
60
+ // 监听事件
61
+ agent.on('tool-call', (tool) => {
62
+ console.log('[Agent] Tool call:', tool.name, tool.args)
63
+ })
64
+
65
+ agent.on('tool-result', (result) => {
66
+ console.log('[Agent] Tool result:', result.name, result.result)
67
+ })
68
+
69
+ // AI 对话示例
70
+ console.log('\n=== AI Chat Example ===')
71
+ try {
72
+ const response = await agent.chat('你好!')
73
+ console.log('[Agent] Response:', response.message)
74
+ } catch (err) {
75
+ console.error('[Agent] Error:', err.message)
76
+ }
77
+
78
+ // 使用工具的对话示例
79
+ console.log('\n=== AI Chat with Tool Call ===')
80
+ try {
81
+ const response = await agent.chat('请帮我计算 (15 + 25) * 2 等于多少?')
82
+ console.log('[Agent] Response:', response.message)
83
+ } catch (err) {
84
+ console.error('[Agent] Error:', err.message)
85
+ }
86
+
87
+ // 流式对话示例
88
+ console.log('\n=== Streaming Chat ===')
89
+ try {
90
+ for await (const chunk of agent.chatStream('请用中文介绍一下你自己')) {
91
+ if (chunk.type === 'text') {
92
+ process.stdout.write(chunk.text)
93
+ }
94
+ }
95
+ console.log('\n')
96
+ } catch (err) {
97
+ console.error('[Agent] Stream Error:', err.message)
98
+ }
99
+
100
+ // 热重载示例
101
+ console.log('\n=== Hot Reload ===')
102
+ await framework.reloadPlugin('ai')
103
+ console.log('AI plugin reloaded!')
104
+
105
+ // 清理
106
+ await framework.destroy()
107
+ console.log('\n[Done]')
108
+ }
109
+
110
+ main().catch(console.error)
@@ -85,6 +85,25 @@ async function main() {
85
85
  const listResult = await framework.executeTool('list_plugins', {})
86
86
  console.log('list_plugins:', listResult)
87
87
 
88
+ // 测试 Web 插件 - 让 LLM 注册路由并测试
89
+ console.log('\n--- Web Plugin Test ---')
90
+ console.log('指示 LLM 注册一个 GET /test 路由...\n')
91
+
92
+ try {
93
+ for await (const chunk of agent.chatStream('请帮我注册一个 GET 路由 /test,handler 写:return "1232432"。只调用工具不要解释。')) {
94
+ if (chunk.type === 'text') {
95
+ process.stdout.write(chunk.text)
96
+ } else if (chunk?.type === 'tool-call') {
97
+ console.log(`\n[工具调用: ${chunk.toolName}]`)
98
+ } else if (chunk?.type === 'tool-result') {
99
+ console.log(`\n[工具结果] ${JSON.stringify(chunk.result).substring(0, 200)}...`)
100
+ }
101
+ }
102
+ console.log('\n')
103
+ } catch (err) {
104
+ console.error('[Agent] Web Plugin Test Error:', err.message)
105
+ }
106
+
88
107
  // 清理
89
108
  await framework.destroy()
90
109
  console.log('\n[Done]')
@@ -1,53 +1,53 @@
1
- /**
2
- * MCP 执行器示例
3
- * 展示如何连接 MCP 服务器
4
- */
5
-
6
- const { Framework } = require('../src')
7
- const { MCPExecutorPlugin } = require('../src/executors/mcp-executor')
8
-
9
- async function main() {
10
- console.log('=== MCP Executor Example ===\n')
11
-
12
- // 创建框架
13
- const framework = new Framework({ debug: true })
14
-
15
- // 创建 MCP 执行器插件
16
- const mcpPlugin = new MCPExecutorPlugin({
17
- servers: [
18
- // 示例:添加一个 MCP 服务器
19
- // {
20
- // name: 'example',
21
- // command: 'uvx',
22
- // args: ['example-mcp-server'],
23
- // env: {}
24
- // }
25
- ]
26
- })
27
-
28
- // 加载插件
29
- await framework.loadPlugin(mcpPlugin)
30
-
31
- // 列出服务器
32
- console.log('\n--- MCP Servers ---')
33
- const servers = mcpPlugin.getServers()
34
- console.log('Servers:', servers)
35
-
36
- // 列出所有 MCP 工具
37
- console.log('\n--- MCP Tools ---')
38
- const tools = framework.getTools().filter(t => t.name.startsWith('mcp_'))
39
- console.log('MCP tools:', tools.map(t => t.name))
40
-
41
- // 如果有配置的服务器,可以这样调用:
42
- // const result = await framework.executeTool('mcp_call', {
43
- // server: 'example',
44
- // tool: 'tool_name',
45
- // args: { /* tool arguments */ }
46
- // })
47
-
48
- // 清理
49
- await framework.destroy()
50
- console.log('\n[Done]')
51
- }
52
-
53
- main().catch(console.error)
1
+ /**
2
+ * MCP 执行器示例
3
+ * 展示如何连接 MCP 服务器
4
+ */
5
+
6
+ const { Framework } = require('../src')
7
+ const { MCPExecutorPlugin } = require('../src/executors/mcp-executor')
8
+
9
+ async function main() {
10
+ console.log('=== MCP Executor Example ===\n')
11
+
12
+ // 创建框架
13
+ const framework = new Framework({ debug: true })
14
+
15
+ // 创建 MCP 执行器插件
16
+ const mcpPlugin = new MCPExecutorPlugin({
17
+ servers: [
18
+ // 示例:添加一个 MCP 服务器
19
+ // {
20
+ // name: 'example',
21
+ // command: 'uvx',
22
+ // args: ['example-mcp-server'],
23
+ // env: {}
24
+ // }
25
+ ]
26
+ })
27
+
28
+ // 加载插件
29
+ await framework.loadPlugin(mcpPlugin)
30
+
31
+ // 列出服务器
32
+ console.log('\n--- MCP Servers ---')
33
+ const servers = mcpPlugin.getServers()
34
+ console.log('Servers:', servers)
35
+
36
+ // 列出所有 MCP 工具
37
+ console.log('\n--- MCP Tools ---')
38
+ const tools = framework.getTools().filter(t => t.name.startsWith('mcp_'))
39
+ console.log('MCP tools:', tools.map(t => t.name))
40
+
41
+ // 如果有配置的服务器,可以这样调用:
42
+ // const result = await framework.executeTool('mcp_call', {
43
+ // server: 'example',
44
+ // tool: 'tool_name',
45
+ // args: { /* tool arguments */ }
46
+ // })
47
+
48
+ // 清理
49
+ await framework.destroy()
50
+ console.log('\n[Done]')
51
+ }
52
+
53
+ main().catch(console.error)
@@ -1,49 +1,49 @@
1
- /**
2
- * Skill 管理器示例
3
- * 展示如何加载和使用 Skill
4
- */
5
-
6
- const { Framework } = require('../src')
7
- const { SkillManagerPlugin } = require('../src/capabilities/skill-manager')
8
-
9
- async function main() {
10
- console.log('=== Skill Manager Example ===\n')
11
-
12
- // 创建框架
13
- const framework = new Framework({ debug: true })
14
-
15
- // 创建 skills 目录(如果没有)
16
- const fs = require('fs')
17
- const skillsDir = './skills'
18
- if (!fs.existsSync(skillsDir)) {
19
- fs.mkdirSync(skillsDir, { recursive: true })
20
- }
21
-
22
- // 加载 Skill 管理器插件
23
- const skillPlugin = new SkillManagerPlugin({
24
- skillsDir: skillsDir
25
- })
26
-
27
- await framework.loadPlugin(skillPlugin)
28
-
29
- // 列出所有加载的 skills
30
- console.log('\n--- Loaded Skills ---')
31
- const skills = skillPlugin.getAllSkills()
32
- console.log(`Found ${skills.length} skills:`)
33
- for (const skill of skills) {
34
- console.log(` - ${skill.name}: ${skill.metadata.description}`)
35
- }
36
-
37
- // 获取单个 skill
38
- if (skillPlugin.hasSkill('hello-skill')) {
39
- console.log('\n--- Hello Skill ---')
40
- const helloSkill = skillPlugin.getSkill('hello-skill')
41
- console.log('Content preview:', helloSkill.content.substring(0, 100) + '...')
42
- }
43
-
44
- // 清理
45
- await framework.destroy()
46
- console.log('\n[Done]')
47
- }
48
-
49
- main().catch(console.error)
1
+ /**
2
+ * Skill 管理器示例
3
+ * 展示如何加载和使用 Skill
4
+ */
5
+
6
+ const { Framework } = require('../src')
7
+ const { SkillManagerPlugin } = require('../src/capabilities/skill-manager')
8
+
9
+ async function main() {
10
+ console.log('=== Skill Manager Example ===\n')
11
+
12
+ // 创建框架
13
+ const framework = new Framework({ debug: true })
14
+
15
+ // 创建 skills 目录(如果没有)
16
+ const fs = require('fs')
17
+ const skillsDir = './skills'
18
+ if (!fs.existsSync(skillsDir)) {
19
+ fs.mkdirSync(skillsDir, { recursive: true })
20
+ }
21
+
22
+ // 加载 Skill 管理器插件
23
+ const skillPlugin = new SkillManagerPlugin({
24
+ skillsDir: skillsDir
25
+ })
26
+
27
+ await framework.loadPlugin(skillPlugin)
28
+
29
+ // 列出所有加载的 skills
30
+ console.log('\n--- Loaded Skills ---')
31
+ const skills = skillPlugin.getAllSkills()
32
+ console.log(`Found ${skills.length} skills:`)
33
+ for (const skill of skills) {
34
+ console.log(` - ${skill.name}: ${skill.metadata.description}`)
35
+ }
36
+
37
+ // 获取单个 skill
38
+ if (skillPlugin.hasSkill('hello-skill')) {
39
+ console.log('\n--- Hello Skill ---')
40
+ const helloSkill = skillPlugin.getSkill('hello-skill')
41
+ console.log('Content preview:', helloSkill.content.substring(0, 100) + '...')
42
+ }
43
+
44
+ // 清理
45
+ await framework.destroy()
46
+ console.log('\n[Done]')
47
+ }
48
+
49
+ main().catch(console.error)