foliko 1.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 (54) hide show
  1. package/.claude/settings.local.json +30 -0
  2. package/22.txt +10 -0
  3. package/README.md +218 -0
  4. package/SPEC.md +452 -0
  5. package/cli/bin/foliko.js +12 -0
  6. package/cli/src/commands/chat.js +75 -0
  7. package/cli/src/index.js +64 -0
  8. package/cli/src/ui/chat-ui.js +272 -0
  9. package/cli/src/utils/ansi.js +40 -0
  10. package/cli/src/utils/markdown.js +296 -0
  11. package/docs/quick-reference.md +131 -0
  12. package/docs/user-manual.md +1205 -0
  13. package/examples/basic.js +110 -0
  14. package/examples/bootstrap.js +93 -0
  15. package/examples/mcp-example.js +53 -0
  16. package/examples/skill-example.js +49 -0
  17. package/examples/workflow.js +158 -0
  18. package/package.json +36 -0
  19. package/plugins/ai-plugin.js +89 -0
  20. package/plugins/audit-plugin.js +187 -0
  21. package/plugins/default-plugins.js +412 -0
  22. package/plugins/file-system-plugin.js +344 -0
  23. package/plugins/install-plugin.js +93 -0
  24. package/plugins/python-executor-plugin.js +331 -0
  25. package/plugins/rules-plugin.js +292 -0
  26. package/plugins/scheduler-plugin.js +426 -0
  27. package/plugins/session-plugin.js +343 -0
  28. package/plugins/shell-executor-plugin.js +196 -0
  29. package/plugins/storage-plugin.js +237 -0
  30. package/plugins/subagent-plugin.js +395 -0
  31. package/plugins/think-plugin.js +329 -0
  32. package/plugins/tools-plugin.js +114 -0
  33. package/skills/mcp-usage/SKILL.md +198 -0
  34. package/skills/vb-agent-dev/AGENTS.md +162 -0
  35. package/skills/vb-agent-dev/SKILL.md +370 -0
  36. package/src/capabilities/index.js +11 -0
  37. package/src/capabilities/skill-manager.js +319 -0
  38. package/src/capabilities/workflow-engine.js +401 -0
  39. package/src/core/agent-chat.js +311 -0
  40. package/src/core/agent.js +573 -0
  41. package/src/core/framework.js +255 -0
  42. package/src/core/index.js +19 -0
  43. package/src/core/plugin-base.js +205 -0
  44. package/src/core/plugin-manager.js +392 -0
  45. package/src/core/provider.js +108 -0
  46. package/src/core/tool-registry.js +134 -0
  47. package/src/core/tool-router.js +216 -0
  48. package/src/executors/executor-base.js +58 -0
  49. package/src/executors/mcp-executor.js +728 -0
  50. package/src/index.js +37 -0
  51. package/src/utils/event-emitter.js +97 -0
  52. package/test-chat.js +129 -0
  53. package/test-mcp.js +79 -0
  54. package/test-reload.js +61 -0
@@ -0,0 +1,131 @@
1
+ # VB-Agent 快速参考
2
+
3
+ ## 启动框架
4
+ ```javascript
5
+ const framework = new Framework({ debug: false })
6
+ await framework.bootstrap({
7
+ agentDir: './.agent',
8
+ aiConfig: { provider: 'deepseek', model: 'deepseek-chat', apiKey: '...' }
9
+ })
10
+ ```
11
+
12
+ ## 创建 Agent
13
+ ```javascript
14
+ const agent = framework.createAgent({
15
+ name: 'MyAgent',
16
+ systemPrompt: '你是一个有帮助的助手。'
17
+ })
18
+ ```
19
+
20
+ ## 发送消息
21
+ ```javascript
22
+ // 流式
23
+ for await (const chunk of agent.chatStream('你好')) {
24
+ if (chunk.type === 'text') process.stdout.write(chunk.text)
25
+ }
26
+
27
+ // 非流式
28
+ const result = await agent.chat('你好')
29
+ ```
30
+
31
+ ## 常用工具
32
+
33
+ | 工具 | 用途 |
34
+ |------|------|
35
+ | `list_tools` | 列出所有工具 |
36
+ | `loadSkill` | 加载技能 |
37
+ | `reload_plugins` | 重载插件 |
38
+ | `read_file` | 读取文件 |
39
+ | `write_file` | 写入文件 |
40
+ | `execute_command` | 执行命令 |
41
+ | `schedule_once` | 定时任务 |
42
+ | `think_now` | 主动思考 |
43
+
44
+ ## 插件位置
45
+
46
+ - 内置插件:`plugins/`
47
+ - 用户插件:`.agent/plugins/`
48
+
49
+ ## 重启插件
50
+
51
+ ```javascript
52
+ // 调用工具
53
+ await framework.executeTool('reload_plugins', {})
54
+ // 或
55
+ await framework.reloadAllPlugins()
56
+ ```
57
+
58
+ ## 事件监听
59
+
60
+ ```javascript
61
+ // Framework 事件
62
+ framework.on('framework:ready', (fw) => {})
63
+ framework.on('plugin:loaded', (plugin) => {})
64
+ framework.on('tool:registered', (tool) => {})
65
+
66
+ // Agent 事件
67
+ agent.on('status', ({ status }) => {}) // idle/busy/error
68
+ agent.on('chunk', (chunk) => {}) // 流式输出
69
+ agent.on('tool-call', ({ name, args }) => {})
70
+ agent.on('tool-result', ({ name, result }) => {})
71
+
72
+ // 子 Agent 事件
73
+ agent.on('subagent:chat:start', (data) => {})
74
+ agent.on('subagent:chat:end', (data) => {})
75
+ agent.on('subagent:error', (data) => {})
76
+ ```
77
+
78
+ ## 子 Agent 注册
79
+
80
+ ```javascript
81
+ const { tool } = require('ai')
82
+ const { z } = require('zod')
83
+
84
+ // 方式1:配置 agents 数组自动注册
85
+ class MyPlugin extends Plugin {
86
+ agents = [
87
+ {
88
+ name: 'code-agent',
89
+ role: '代码专家',
90
+ tools: {
91
+ compile: tool({
92
+ description: '编译',
93
+ parameters: z.object({ language: z.string(), code: z.string() }),
94
+ execute: async (args) => ({ success: true })
95
+ })
96
+ },
97
+ parentTools: ['read_file', 'write_file']
98
+ }
99
+ ]
100
+ }
101
+
102
+ // 方式2:手动调用
103
+ this.registerSubAgent({ name: 'code-agent', role: '代码专家', tools: {...}, parentTools: [...] })
104
+ ```
105
+
106
+ ## 系统提示中的部分
107
+
108
+ ```
109
+ 【可用工具】
110
+ - tool1: 描述
111
+ - tool2: 描述
112
+
113
+ 【可用技能】
114
+ - skill1: 描述
115
+ - skill2: 描述
116
+
117
+ 【子 Agent 分配规则】
118
+ - code-agent: 代码专家
119
+
120
+ 【系统能力】
121
+ - ai: AI 对话能力
122
+ - storage: 存储
123
+ ```
124
+
125
+ ## 状态管理
126
+
127
+ ```javascript
128
+ agent.getStatus() // 'idle' | 'busy' | 'error'
129
+ agent.resetStatus() // 重置状态
130
+ agent.clearHistory() // 清空历史
131
+ ```