foliko 1.0.85 → 1.0.87

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 (178) hide show
  1. package/.agent/agents/code-assistant.json +14 -0
  2. package/.agent/agents/email-assistant.json +14 -0
  3. package/.agent/agents/file-assistant.json +15 -0
  4. package/.agent/agents/system-assistant.json +15 -0
  5. package/.agent/agents/web-assistant.json +12 -0
  6. package/.agent/data/ambient/goals.json +50 -0
  7. package/.agent/data/ambient/memories.json +7 -0
  8. package/.agent/data/default.json +21 -311
  9. package/.agent/data/plugins-state.json +162 -174
  10. package/.agent/data/scheduler/tasks.json +1 -0
  11. package/.agent/data/weixin.json +6 -0
  12. package/.agent/mcp_config.json +1 -0
  13. package/.agent/package.json +8 -0
  14. package/.agent/plugins/__pycache__/test_plugin.cpython-312.pyc +0 -0
  15. package/.agent/plugins/daytona/README.md +89 -0
  16. package/.agent/plugins/daytona/index.js +377 -0
  17. package/.agent/plugins/daytona/package.json +12 -0
  18. package/.agent/plugins/marknative/README.md +134 -0
  19. package/.agent/plugins/marknative/index.js +228 -0
  20. package/.agent/plugins/marknative/package.json +12 -0
  21. package/.agent/plugins/marknative/update-readme.js +134 -0
  22. package/.agent/plugins/system-info/index.js +387 -0
  23. package/.agent/plugins/system-info/package.json +4 -0
  24. package/.agent/plugins/system-info/test.js +40 -0
  25. package/.agent/plugins/temp-repo/LICENSE +201 -0
  26. package/.agent/plugins/test_plugin.py +304 -0
  27. package/.agent/plugins.json +14 -5
  28. package/.agent/python-scripts/test_sample.py +24 -0
  29. package/.agent/skills/agent-browser/SKILL.md +311 -0
  30. package/.agent/skills/agent-browser/TEST_PLAN.md +200 -0
  31. package/.agent/skills/sysinfo/SKILL.md +38 -0
  32. package/.agent/skills/sysinfo/system-info.sh +130 -0
  33. package/.agent/skills/workflow/SKILL.md +324 -0
  34. package/.agent/workflows/email-digest.json +50 -0
  35. package/.agent/workflows/file-backup.json +21 -0
  36. package/.agent/workflows/get-ip-notify.json +32 -0
  37. package/.agent/workflows/news-aggregator.json +93 -0
  38. package/.agent/workflows/news-dashboard-v2.json +94 -0
  39. package/.agent/workflows/notification-batch.json +32 -0
  40. package/.claude/settings.local.json +8 -7
  41. package/.env.example +56 -56
  42. package/README.md +441 -441
  43. package/examples/test-chat-debug.js +102 -0
  44. package/examples/test-chat-result.js +76 -0
  45. package/examples/test-chat-stream-diff.js +63 -0
  46. package/examples/test-concurrent-chat.js +60 -0
  47. package/examples/test-long-chat.js +77 -0
  48. package/examples/test-session-chat.js +93 -0
  49. package/package.json +2 -2
  50. package/plugins/ambient-agent/EventWatcher.js +4 -4
  51. package/plugins/extension-executor-plugin.js +44 -1
  52. package/plugins/file-system-plugin.js +44 -5
  53. package/plugins/session-plugin.js +21 -0
  54. package/plugins/weixin-plugin.js +278 -29
  55. package/skills/find-skills/AGENTS.md +162 -162
  56. package/skills/find-skills/SKILL.md +133 -133
  57. package/skills/foliko-dev/SKILL.md +67 -0
  58. package/skills/python-plugin-dev/SKILL.md +238 -238
  59. package/src/core/agent-chat.js +106 -58
  60. package/src/core/agent.js +3 -61
  61. package/src/utils/index.js +1 -1
  62. package/.agent/.shared/ui-ux-pro-max/data/charts.csv +0 -26
  63. package/.agent/.shared/ui-ux-pro-max/data/colors.csv +0 -97
  64. package/.agent/.shared/ui-ux-pro-max/data/icons.csv +0 -101
  65. package/.agent/.shared/ui-ux-pro-max/data/landing.csv +0 -31
  66. package/.agent/.shared/ui-ux-pro-max/data/products.csv +0 -97
  67. package/.agent/.shared/ui-ux-pro-max/data/prompts.csv +0 -24
  68. package/.agent/.shared/ui-ux-pro-max/data/react-performance.csv +0 -45
  69. package/.agent/.shared/ui-ux-pro-max/data/stacks/flutter.csv +0 -53
  70. package/.agent/.shared/ui-ux-pro-max/data/stacks/html-tailwind.csv +0 -56
  71. package/.agent/.shared/ui-ux-pro-max/data/stacks/jetpack-compose.csv +0 -53
  72. package/.agent/.shared/ui-ux-pro-max/data/stacks/nextjs.csv +0 -53
  73. package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxt-ui.csv +0 -51
  74. package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxtjs.csv +0 -59
  75. package/.agent/.shared/ui-ux-pro-max/data/stacks/react-native.csv +0 -52
  76. package/.agent/.shared/ui-ux-pro-max/data/stacks/react.csv +0 -54
  77. package/.agent/.shared/ui-ux-pro-max/data/stacks/shadcn.csv +0 -61
  78. package/.agent/.shared/ui-ux-pro-max/data/stacks/svelte.csv +0 -54
  79. package/.agent/.shared/ui-ux-pro-max/data/stacks/swiftui.csv +0 -51
  80. package/.agent/.shared/ui-ux-pro-max/data/stacks/vue.csv +0 -50
  81. package/.agent/.shared/ui-ux-pro-max/data/styles.csv +0 -59
  82. package/.agent/.shared/ui-ux-pro-max/data/typography.csv +0 -58
  83. package/.agent/.shared/ui-ux-pro-max/data/ui-reasoning.csv +0 -101
  84. package/.agent/.shared/ui-ux-pro-max/data/ux-guidelines.csv +0 -100
  85. package/.agent/.shared/ui-ux-pro-max/data/web-interface.csv +0 -31
  86. package/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/core.cpython-313.pyc +0 -0
  87. package/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-313.pyc +0 -0
  88. package/.agent/.shared/ui-ux-pro-max/scripts/core.py +0 -258
  89. package/.agent/.shared/ui-ux-pro-max/scripts/design_system.py +0 -1067
  90. package/.agent/.shared/ui-ux-pro-max/scripts/search.py +0 -106
  91. package/.agent/ARCHITECTURE.md +0 -288
  92. package/.agent/agents/ambient-agent.md +0 -57
  93. package/.agent/agents/debugger.md +0 -55
  94. package/.agent/agents/email-assistant.md +0 -49
  95. package/.agent/agents/file-manager.md +0 -42
  96. package/.agent/agents/python-developer.md +0 -60
  97. package/.agent/agents/scheduler.md +0 -59
  98. package/.agent/agents/web-developer.md +0 -45
  99. package/.agent/data/puppeteer-sessions/undefined.json +0 -6
  100. package/.agent/mcp_config_updated.json +0 -12
  101. package/.agent/rules/GEMINI.md +0 -273
  102. package/.agent/rules/allow-rule.md +0 -77
  103. package/.agent/rules/log-rule.md +0 -83
  104. package/.agent/rules/security-rule.md +0 -93
  105. package/.agent/scripts/auto_preview.py +0 -148
  106. package/.agent/scripts/checklist.py +0 -217
  107. package/.agent/scripts/session_manager.py +0 -120
  108. package/.agent/scripts/verify_all.py +0 -327
  109. package/.agent/skills/api-patterns/SKILL.md +0 -81
  110. package/.agent/skills/api-patterns/api-style.md +0 -42
  111. package/.agent/skills/api-patterns/auth.md +0 -24
  112. package/.agent/skills/api-patterns/documentation.md +0 -26
  113. package/.agent/skills/api-patterns/graphql.md +0 -41
  114. package/.agent/skills/api-patterns/rate-limiting.md +0 -31
  115. package/.agent/skills/api-patterns/response.md +0 -37
  116. package/.agent/skills/api-patterns/rest.md +0 -40
  117. package/.agent/skills/api-patterns/scripts/api_validator.py +0 -211
  118. package/.agent/skills/api-patterns/security-testing.md +0 -122
  119. package/.agent/skills/api-patterns/trpc.md +0 -41
  120. package/.agent/skills/api-patterns/versioning.md +0 -22
  121. package/.agent/skills/app-builder/SKILL.md +0 -75
  122. package/.agent/skills/app-builder/agent-coordination.md +0 -71
  123. package/.agent/skills/app-builder/feature-building.md +0 -53
  124. package/.agent/skills/app-builder/project-detection.md +0 -34
  125. package/.agent/skills/app-builder/scaffolding.md +0 -118
  126. package/.agent/skills/app-builder/tech-stack.md +0 -40
  127. package/.agent/skills/app-builder/templates/SKILL.md +0 -39
  128. package/.agent/skills/app-builder/templates/astro-static/TEMPLATE.md +0 -76
  129. package/.agent/skills/app-builder/templates/chrome-extension/TEMPLATE.md +0 -92
  130. package/.agent/skills/app-builder/templates/cli-tool/TEMPLATE.md +0 -88
  131. package/.agent/skills/app-builder/templates/electron-desktop/TEMPLATE.md +0 -88
  132. package/.agent/skills/app-builder/templates/express-api/TEMPLATE.md +0 -83
  133. package/.agent/skills/app-builder/templates/flutter-app/TEMPLATE.md +0 -90
  134. package/.agent/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +0 -90
  135. package/.agent/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +0 -122
  136. package/.agent/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +0 -122
  137. package/.agent/skills/app-builder/templates/nextjs-static/TEMPLATE.md +0 -169
  138. package/.agent/skills/app-builder/templates/nuxt-app/TEMPLATE.md +0 -134
  139. package/.agent/skills/app-builder/templates/python-fastapi/TEMPLATE.md +0 -83
  140. package/.agent/skills/app-builder/templates/react-native-app/TEMPLATE.md +0 -119
  141. package/.agent/skills/architecture/SKILL.md +0 -55
  142. package/.agent/skills/architecture/context-discovery.md +0 -43
  143. package/.agent/skills/architecture/examples.md +0 -94
  144. package/.agent/skills/architecture/pattern-selection.md +0 -68
  145. package/.agent/skills/architecture/patterns-reference.md +0 -50
  146. package/.agent/skills/architecture/trade-off-analysis.md +0 -77
  147. package/.agent/skills/clean-code/SKILL.md +0 -201
  148. package/.agent/skills/doc.md +0 -177
  149. package/.agent/skills/frontend-design/SKILL.md +0 -418
  150. package/.agent/skills/frontend-design/animation-guide.md +0 -331
  151. package/.agent/skills/frontend-design/color-system.md +0 -311
  152. package/.agent/skills/frontend-design/decision-trees.md +0 -418
  153. package/.agent/skills/frontend-design/motion-graphics.md +0 -306
  154. package/.agent/skills/frontend-design/scripts/accessibility_checker.py +0 -183
  155. package/.agent/skills/frontend-design/scripts/ux_audit.py +0 -722
  156. package/.agent/skills/frontend-design/typography-system.md +0 -345
  157. package/.agent/skills/frontend-design/ux-psychology.md +0 -1116
  158. package/.agent/skills/frontend-design/visual-effects.md +0 -383
  159. package/.agent/skills/i18n-localization/SKILL.md +0 -154
  160. package/.agent/skills/i18n-localization/scripts/i18n_checker.py +0 -241
  161. package/.agent/skills/mcp-builder/SKILL.md +0 -176
  162. package/.agent/skills/web-design-guidelines/SKILL.md +0 -57
  163. package/.agent/workflows/brainstorm.md +0 -113
  164. package/.agent/workflows/create.md +0 -59
  165. package/.agent/workflows/debug.md +0 -103
  166. package/.agent/workflows/deploy.md +0 -176
  167. package/.agent/workflows/enhance.md +0 -63
  168. package/.agent/workflows/orchestrate.md +0 -237
  169. package/.agent/workflows/plan.md +0 -89
  170. package/.agent/workflows/preview.md +0 -81
  171. package/.agent/workflows/simple-test.md +0 -42
  172. package/.agent/workflows/status.md +0 -86
  173. package/.agent/workflows/structured-orchestrate.md +0 -180
  174. package/.agent/workflows/test.md +0 -144
  175. package/.agent/workflows/ui-ux-pro-max.md +0 -296
  176. /package/.agent/plugins/{puppeteer-plugin → temp-repo/puppeteer-plugin}/README.md +0 -0
  177. /package/.agent/plugins/{puppeteer-plugin → temp-repo/puppeteer-plugin}/index.js +0 -0
  178. /package/.agent/plugins/{puppeteer-plugin → temp-repo/puppeteer-plugin}/package.json +0 -0
@@ -0,0 +1,200 @@
1
+ # Agent Browser 技能测试计划
2
+
3
+ **项目**: agent-browser skill
4
+ **版本**: v1.0.0
5
+ **日期**: 2024年
6
+ **测试环境**: Windows/macOS/Linux + Node.js 18+
7
+
8
+ ---
9
+
10
+ ## 1. 测试范围
11
+
12
+ ### 1.1 功能测试
13
+ - [ ] 安装与初始化
14
+ - [ ] 页面导航操作
15
+ - [ ] 元素定位与交互
16
+ - [ ] 信息获取
17
+ - [ ] 状态检查
18
+ - [ ] 截图功能
19
+ - [ ] 键盘鼠标操作
20
+ - [ ] 网络拦截
21
+ - [ ] 会话管理
22
+ - [ ] 认证管理
23
+
24
+ ### 1.2 集成测试
25
+ - [ ] 与 skill 工具集成
26
+ - [ ] 错误处理
27
+ - [ ] 超时机制
28
+
29
+ ---
30
+
31
+ ## 2. 前置条件
32
+
33
+ ```bash
34
+ # 1. 安装依赖
35
+ npm install -g agent-browser
36
+
37
+ # 2. 安装 Chrome
38
+ agent-browser install
39
+
40
+ # 3. 验证安装
41
+ agent-browser --version
42
+ ```
43
+
44
+ ---
45
+
46
+ ## 3. 测试用例
47
+
48
+ ### 3.1 安装测试
49
+
50
+ | ID | 测试项 | 命令 | 预期结果 |
51
+ |----|--------|------|----------|
52
+ | INST-01 | 全局安装 | `npm install -g agent-browser` | 无错误,安装成功 |
53
+ | INST-02 | Chrome 下载 | `agent-browser install` | Chrome 成功下载 |
54
+ | INST-03 | 版本验证 | `agent-browser --version` | 显示版本号 v0.23.4 |
55
+
56
+ ### 3.2 页面导航测试
57
+
58
+ | ID | 测试项 | 命令 | 预期结果 |
59
+ |----|--------|------|----------|
60
+ | NAV-01 | 打开网页 | `agent-browser open https://example.com` | 浏览器打开页面 |
61
+ | NAV-02 | 获取标题 | `agent-browser get title` | 返回 "Example Domain" |
62
+ | NAV-03 | 获取 URL | `agent-browser get url` | 返回完整 URL |
63
+ | NAV-04 | 刷新页面 | `agent-browser reload` | 页面刷新 |
64
+ | NAV-05 | 关闭浏览器 | `agent-browser close` | 浏览器关闭 |
65
+
66
+ ### 3.3 元素交互测试
67
+
68
+ | ID | 测试项 | 命令 | 预期结果 |
69
+ |----|--------|------|----------|
70
+ | INT-01 | 获取快照 | `agent-browser snapshot -i --json` | 返回可访问性树和引用 |
71
+ | INT-02 | 点击元素 | `agent-browser click @e1` | 元素被点击 |
72
+ | INT-03 | 填写表单 | `agent-browser fill @input "test@test.com"` | 输入框被填充 |
73
+ | INT-04 | 悬停元素 | `agent-browser hover @e2` | 鼠标悬停 |
74
+ | INT-05 | 滚动页面 | `agent-browser scroll down 500` | 页面滚动 |
75
+
76
+ ### 3.4 信息获取测试
77
+
78
+ | ID | 测试项 | 命令 | 预期结果 |
79
+ |----|--------|------|----------|
80
+ | GET-01 | 获取文本 | `agent-browser get text @e1` | 返回元素文本 |
81
+ | GET-02 | 获取 HTML | `agent-browser get html @e1` | 返回元素 HTML |
82
+ | GET-03 | 获取属性 | `agent-browser get attr @e1 href` | 返回属性值 |
83
+ | GET-04 | 元素计数 | `agent-browser get count "a"` | 返回链接数量 |
84
+
85
+ ### 3.5 状态检查测试
86
+
87
+ | ID | 测试项 | 命令 | 预期结果 |
88
+ |----|--------|------|----------|
89
+ | STA-01 | 可见性检查 | `agent-browser is visible @e1` | 返回 true/false |
90
+ | STA-02 | 可用性检查 | `agent-browser is enabled @e1` | 返回 true/false |
91
+
92
+ ### 3.6 截图功能测试
93
+
94
+ | ID | 测试项 | 命令 | 预期结果 |
95
+ |----|--------|------|----------|
96
+ | SCR-01 | 普通截图 | `agent-browser screenshot test.png` | 生成截图文件 |
97
+ | SCR-02 | 全页面截图 | `agent-browser screenshot --full full.png` | 生成全页面截图 |
98
+ | SCR-03 | 带标注截图 | `agent-browser screenshot --annotate anno.png` | 生成带编号标签的截图 |
99
+
100
+ ### 3.7 语义定位器测试
101
+
102
+ | ID | 测试项 | 命令 | 预期结果 |
103
+ |----|--------|------|----------|
104
+ | SEM-01 | 按角色查找 | `agent-browser find role button click` | 找到并点击按钮 |
105
+ | SEM-02 | 按文本查找 | `agent-browser find text "Submit" click` | 找到并点击 |
106
+ | SEM-03 | 按标签查找 | `agent-browser find label "Email" fill "test.com"` | 找到并填写 |
107
+ | SEM-04 | 位置选择 | `agent-browser find first "a" click` | 点击第一个链接 |
108
+
109
+ ### 3.8 等待机制测试
110
+
111
+ | ID | 测试项 | 命令 | 预期结果 |
112
+ |----|--------|------|----------|
113
+ | WAI-01 | 等待元素 | `agent-browser wait "#element"` | 元素出现后继续 |
114
+ | WAI-02 | 等待文本 | `agent-browser wait --text "Success"` | 文本出现后继续 |
115
+ | WAI-03 | 等待网络空闲 | `agent-browser wait --load networkidle` | 网络空闲后继续 |
116
+
117
+ ### 3.9 网络拦截测试
118
+
119
+ | ID | 测试项 | 命令 | 预期结果 |
120
+ |----|--------|------|----------|
121
+ | NET-01 | 阻止请求 | `agent-browser network route "*.js" --abort` | 资源被阻止 |
122
+ | NET-02 | Mock 响应 | `agent-browser network route "*/api/*" --body '{"ok":true}'` | 返回 Mock 数据 |
123
+ | NET-03 | 查看请求 | `agent-browser network requests` | 列出所有请求 |
124
+
125
+ ### 3.10 会话管理测试
126
+
127
+ | ID | 测试项 | 命令 | 预期结果 |
128
+ |----|--------|------|----------|
129
+ | SES-01 | 隔离会话 | `agent-browser --session s1 open a.com` | 独立会话打开 |
130
+ | SES-02 | 会话隔离验证 | `agent-browser --session s2 open b.com` | 不同会话状态隔离 |
131
+
132
+ ### 3.11 键盘鼠标操作测试
133
+
134
+ | ID | 测试项 | 命令 | 预期结果 |
135
+ |----|--------|------|----------|
136
+ | KEY-01 | 键盘输入 | `agent-browser keyboard type "Hello"` | 文本被输入 |
137
+ | KEY-02 | 按键操作 | `agent-browser press Enter` | 按下 Enter 键 |
138
+ | MOU-01 | 移动鼠标 | `agent-browser mouse move 100 200` | 鼠标移动 |
139
+ | MOU-02 | 滚轮滚动 | `agent-browser mouse wheel 100` | 页面滚动 |
140
+
141
+ ---
142
+
143
+ ## 4. 自动化测试脚本
144
+
145
+ ```bash
146
+ # test_basic.sh - 基础功能测试
147
+ #!/bin/bash
148
+
149
+ echo "=== Agent Browser 基础测试 ==="
150
+
151
+ # 测试打开网页
152
+ echo "[TEST] 打开网页..."
153
+ agent-browser open https://example.com
154
+ sleep 2
155
+
156
+ # 测试获取快照
157
+ echo "[TEST] 获取快照..."
158
+ agent-browser snapshot -i --json > snapshot.json
159
+ cat snapshot.json
160
+
161
+ # 测试截图
162
+ echo "[TEST] 截图..."
163
+ agent-browser screenshot output.png
164
+
165
+ # 关闭
166
+ echo "[TEST] 关闭浏览器..."
167
+ agent-browser close
168
+
169
+ echo "=== 测试完成 ==="
170
+ ```
171
+
172
+ ---
173
+
174
+ ## 5. 预期产出
175
+
176
+ | 类型 | 文件 | 说明 |
177
+ |------|------|------|
178
+ | 截图 | `*.png` | 测试截图输出 |
179
+ | 快照 | `snapshot.json` | 页面元素树 JSON |
180
+ | 日志 | `debug.log` | 调试模式日志 |
181
+
182
+ ---
183
+
184
+ ## 6. 风险评估
185
+
186
+ | 风险 | 影响 | 缓解措施 |
187
+ |------|------|----------|
188
+ | Chrome 未安装 | 无法运行 | 提供 `agent-browser install` 说明 |
189
+ | 网络超时 | 测试失败 | 增加 wait 等待时间 |
190
+ | 元素引用失效 | 交互失败 | 每次操作前重新 snapshot |
191
+ | 端口占用 | 启动失败 | 使用 `--port` 指定端口 |
192
+
193
+ ---
194
+
195
+ ## 7. 通过标准
196
+
197
+ - [ ] 所有 P0 测试用例通过
198
+ - [ ] 截图功能正常生成图片
199
+ - [ ] 元素交互命令无报错
200
+ - [ ] 会话隔离功能正常
@@ -0,0 +1,38 @@
1
+ ---
2
+ name: sysinfo
3
+ description: 使用 Bash 脚本查询系统信息(CPU、内存、磁盘、网络)
4
+ allowed-tools:
5
+ - get_cpu_info
6
+ - get_memory_info
7
+ - get_disk_info
8
+ - get_network_info
9
+ - get_full_system_info
10
+ ---
11
+
12
+ # 系统信息查询 (sysinfo)
13
+
14
+ 使用 Bash 脚本查询系统信息,支持模块化查询。
15
+
16
+ ## 使用方法
17
+
18
+ ### 完整系统信息
19
+ ```bash
20
+ bash .agent/skills/sysinfo/system-info.sh
21
+ ```
22
+
23
+ ### 分模块查询
24
+ ```bash
25
+ bash .agent/skills/sysinfo/system-info.sh cpu # CPU 信息
26
+ bash .agent/skills/sysinfo/system-info.sh memory # 内存信息
27
+ bash .agent/skills/sysinfo/system-info.sh disk # 磁盘信息
28
+ bash .agent/skills/sysinfo/system-info.sh network # 网络信息
29
+ bash .agent/skills/sysinfo/system-info.sh system # 系统基本信息
30
+ ```
31
+
32
+ ## 输出示例
33
+
34
+ - **CPU**: 型号、核心数、使用率
35
+ - **Memory**: 总内存、已用、可用、使用率
36
+ - **Disk**: 各分区容量和使用情况
37
+ - **Network**: IP 地址、网卡信息
38
+ - **System**: 主机名、操作系统、内核版本
@@ -0,0 +1,130 @@
1
+ #!/bin/bash
2
+ # 系统信息查询脚本(跨平台支持)
3
+ # 用法: system-info [option]
4
+ # 选项: all (默认), cpu, memory, disk, network, system
5
+
6
+ OPTION=${1:-all}
7
+
8
+ echo "=========================================="
9
+ echo " System Info Report - $(date '+%Y-%m-%d %H:%M:%S')"
10
+ echo "=========================================="
11
+ echo ""
12
+
13
+ # 系统基本信息
14
+ show_system() {
15
+ echo "[System Info]"
16
+ echo " Hostname: $(hostname)"
17
+ echo " OS: $(uname -s)"
18
+ echo " Kernel: $(uname -r)"
19
+ echo " Arch: $(uname -m)"
20
+ echo ""
21
+ }
22
+
23
+ # CPU 信息
24
+ show_cpu() {
25
+ echo "[CPU Info]"
26
+ if [ -f /proc/cpuinfo ]; then
27
+ echo " Model: $(grep 'model name' /proc/cpuinfo | head -1 | cut -d':' -f2 | xargs)"
28
+ echo " Cores: $(grep -c ^processor /proc/cpuinfo)"
29
+ elif command -v powershell &> /dev/null; then
30
+ cpu_info=$(powershell -NoProfile -Command "
31
+ \$cpu = Get-CimInstance Win32_Processor | Select-Object -First 1
32
+ \$cores = (Get-CimInstance Win32_Processor | Measure-Object -Property NumberOfCores -Sum).Sum
33
+ \$threads = (Get-CimInstance Win32_Processor | Measure-Object -Property NumberOfLogicalProcessors -Sum).Sum
34
+ Write-Output \"\$(\$cpu.Name)|\$cores|\$threads\"
35
+ ")
36
+ cpu_name=$(echo "$cpu_info" | cut -d'|' -f1)
37
+ cpu_cores=$(echo "$cpu_info" | cut -d'|' -f2)
38
+ cpu_threads=$(echo "$cpu_info" | cut -d'|' -f3)
39
+ echo " Model: $cpu_name"
40
+ echo " Cores: $cpu_cores"
41
+ echo " Threads: $cpu_threads"
42
+ else
43
+ echo " Model: $(sysctl -n machdep.cpu.brand_string 2>/dev/null || echo 'Unknown')"
44
+ fi
45
+ echo ""
46
+ }
47
+
48
+ # 内存信息
49
+ show_memory() {
50
+ echo "[Memory Info]"
51
+ if [ -f /proc/meminfo ]; then
52
+ mem_total=$(grep MemTotal /proc/meminfo | awk '{printf "%.2f GB", $2/1024/1024}')
53
+ mem_free=$(grep MemFree /proc/meminfo | awk '{printf "%.2f GB", $2/1024/1024}')
54
+ mem_avail=$(grep MemAvailable /proc/meminfo 2>/dev/null | awk '{printf "%.2f GB", $2/1024/1024}')
55
+ echo " Total: $mem_total"
56
+ echo " Free: $mem_free"
57
+ echo " Available: ${mem_avail:-N/A}"
58
+ elif command -v powershell &> /dev/null; then
59
+ mem_info=$(powershell -NoProfile -Command "
60
+ \$os = Get-CimInstance Win32_OperatingSystem
61
+ \$total = [math]::Round(\$os.TotalVisibleMemorySize / 1MB, 2)
62
+ \$free = [math]::Round(\$os.FreePhysicalMemory / 1MB, 2)
63
+ \$used = [math]::Round(\$total - \$free, 2)
64
+ \$pct = [math]::Round((\$used / \$total) * 100, 1)
65
+ Write-Output \"\$total|\$used|\$free|\$pct\"
66
+ ")
67
+ total=$(echo "$mem_info" | cut -d'|' -f1)
68
+ used=$(echo "$mem_info" | cut -d'|' -f2)
69
+ free=$(echo "$mem_info" | cut -d'|' -f3)
70
+ pct=$(echo "$mem_info" | cut -d'|' -f4)
71
+ echo " Total: ${total} GB"
72
+ echo " Used: ${used} GB (${pct}%)"
73
+ echo " Free: ${free} GB"
74
+ else
75
+ echo " Unable to get memory info"
76
+ fi
77
+ echo ""
78
+ }
79
+
80
+ # 磁盘信息
81
+ show_disk() {
82
+ echo "[Disk Info]"
83
+ if command -v powershell &> /dev/null; then
84
+ # Windows PowerShell - 使用 UTF8 编码输出
85
+ powershell -NoProfile -Command "[Console]::OutputEncoding = [System.Text.Encoding]::UTF8; Get-CimInstance Win32_LogicalDisk -Filter \"DriveType=3\" | Format-Table -AutoSize | Out-String"
86
+ elif [ -f /proc/mounts ] && command -v df &> /dev/null; then
87
+ df -h | grep -E '^/dev/' | awk '{
88
+ printf " %s: Total %s, Used %s (%s), Free %s\n", $1, $2, $3, $5, $4
89
+ }'
90
+ else
91
+ echo " Unable to get disk info"
92
+ fi
93
+ echo ""
94
+ }
95
+
96
+ # 网络信息
97
+ show_network() {
98
+ echo "[Network Info]"
99
+ echo " IP Addresses:"
100
+ if command -v ip &> /dev/null; then
101
+ ip addr show | grep inet | grep -v '127.0.0.1' | awk '{printf " %s\n", $2}'
102
+ elif command -v ifconfig &> /dev/null; then
103
+ ifconfig | grep 'inet ' | grep -v '127.0.0.1' | awk '{printf " %s\n", $2}'
104
+ elif command -v powershell &> /dev/null; then
105
+ powershell -NoProfile -Command "Get-NetIPAddress -AddressFamily IPv4 | Where-Object { \$_.IPAddress -ne '127.0.0.1' } | ForEach-Object { Write-Output \" \$(\$_.IPAddress)\" }"
106
+ fi
107
+ echo ""
108
+ }
109
+
110
+ # 执行选项
111
+ case $OPTION in
112
+ all)
113
+ show_system
114
+ show_cpu
115
+ show_memory
116
+ show_disk
117
+ show_network
118
+ ;;
119
+ cpu) show_cpu ;;
120
+ memory) show_memory ;;
121
+ disk) show_disk ;;
122
+ network) show_network ;;
123
+ system) show_system ;;
124
+ *)
125
+ echo "Usage: system-info [all|cpu|memory|disk|network|system]"
126
+ exit 1
127
+ ;;
128
+ esac
129
+
130
+ echo "=========================================="
@@ -0,0 +1,324 @@
1
+ ---
2
+ name: workflow
3
+ description: 工作流引擎 - 定义和执行结构化工作流,支持顺序、条件分支、循环、延迟、工具调用等步骤类型
4
+ allowed-tools: execute_workflow,reloadWorkflows
5
+ ---
6
+
7
+ # Workflow 工作流
8
+
9
+ 工作流引擎用于定义和执行结构化的工作流程,支持多种步骤类型,可以组合使用实现复杂逻辑。
10
+
11
+ ## 快速开始
12
+
13
+ ### 创建工作流文件
14
+
15
+ 工作流定义文件放在 `.agent/workflows/` 目录下,支持 `.json` 和 `.js` 格式:
16
+
17
+ ```json
18
+ {
19
+ "name": "example-workflow",
20
+ "description": "示例工作流",
21
+ "steps": [
22
+ { "type": "script", "name": "步骤1", "script": "return 'Hello';" },
23
+ { "type": "tool", "name": "发送通知", "tool": "notification_send", "args": { "title": "标题", "message": "内容" } }
24
+ ]
25
+ }
26
+ ```
27
+
28
+ ### 执行工作流
29
+
30
+ ```javascript
31
+ // 通过 execute_workflow 工具执行
32
+ await execute_workflow({
33
+ workflow: "get-ip-notify" // 工作流名称(自动从 .agent/workflows/ 加载)
34
+ })
35
+
36
+ // 或直接传入工作流定义
37
+ await execute_workflow({
38
+ workflow: {
39
+ steps: [
40
+ { "type": "script", "name": "Hello", "script": "return 'Hello World';" }
41
+ ]
42
+ }
43
+ })
44
+ ```
45
+
46
+ ### 重要注意事项
47
+
48
+ 1. **script 必须用 return 返回值**:`script` 是函数体,不是表达式
49
+ 2. **JSON 中不能使用多行字符串**:所有 script 内容写成单行,用分号分隔
50
+ 3. **JSON 中不能有注释**:注释会导致 JSON 解析失败
51
+
52
+ ## 步骤类型
53
+
54
+ ### 1. script - 脚本步骤
55
+
56
+ 执行 JavaScript 代码,**必须用 return 返回值**:
57
+
58
+ ```json
59
+ {
60
+ "type": "script",
61
+ "name": "计算",
62
+ "outputVariable": "result",
63
+ "script": "var a=10; var b=20; context.variables.sum=a+b; return a+b;"
64
+ }
65
+ ```
66
+
67
+ **正确写法**:
68
+ ```json
69
+ { "script": "return context.variables.value + 1;" }
70
+ ```
71
+
72
+ **错误写法**(缺少 return):
73
+ ```json
74
+ { "script": "context.variables.value + 1;" }
75
+ ```
76
+
77
+ **JSON 中 script 只能写单行**,不能换行。如果逻辑复杂,建议拆成多个 script 步骤。
78
+
79
+ **script 中的可用对象**:
80
+ - `context.input` - 工作流输入参数
81
+ - `context.variables` - 工作流变量(可读写),存储在 outputVariable 中的值
82
+ - `context.lastResult` - 上一步骤的返回值
83
+ - `context.variables.loopIndex` - 循环中的当前索引
84
+
85
+ ### 2. tool - 工具调用步骤
86
+
87
+ 在工作流中调用框架注册的工具:
88
+
89
+ ```json
90
+ {
91
+ "type": "tool",
92
+ "name": "发送通知",
93
+ "tool": "notification_send",
94
+ "args": {
95
+ "title": "标题",
96
+ "message": "内容"
97
+ },
98
+ "outputVariable": "result"
99
+ }
100
+ ```
101
+
102
+ **参数说明**:
103
+
104
+ | 字段 | 类型 | 必填 | 说明 |
105
+ |------|------|------|------|
106
+ | `tool` | string | 是 | 工具名称 |
107
+ | `args` | object | 否 | 工具参数 |
108
+ | `outputVariable` | string | 否 | 结果保存到的变量名,可通过 `context.variables.xxx` 访问 |
109
+
110
+ **args 中支持变量引用**:
111
+
112
+ 使用 `{{variableName}}` 语法引用 context.variables 中的变量:
113
+
114
+ ```json
115
+ {
116
+ "type": "tool",
117
+ "name": "发送通知",
118
+ "tool": "notification_send",
119
+ "args": {
120
+ "title": "IP 信息",
121
+ "message": "当前公网IP: {{currentIp}}"
122
+ }
123
+ }
124
+ ```
125
+
126
+ 变量引用规则:
127
+ - `{{currentIp}}` → 从 context.variables.currentIp 获取
128
+ - `{{emailResult.success}}` → 支持嵌套属性访问
129
+
130
+ **完整示例 - 获取IP并发送通知**:
131
+
132
+ ```json
133
+ {
134
+ "name": "get-ip-notify",
135
+ "description": "获取本机IP并发送通知",
136
+ "steps": [
137
+ {
138
+ "type": "tool",
139
+ "name": "获取IP信息",
140
+ "tool": "fetch",
141
+ "args": {
142
+ "url": "https://api.ipify.org?format=json",
143
+ "proxy": true
144
+ },
145
+ "outputVariable": "ipResult"
146
+ },
147
+ {
148
+ "type": "script",
149
+ "name": "提取IP",
150
+ "outputVariable": "currentIp",
151
+ "script": "var r=context.variables.ipResult; return (r&&r.success&&r.body)?(typeof r.body==='object'?r.body.ip:r.body.trim()):'获取失败';"
152
+ },
153
+ {
154
+ "type": "tool",
155
+ "name": "发送通知",
156
+ "tool": "notification_send",
157
+ "args": {
158
+ "title": "IP 信息",
159
+ "message": "当前公网IP: {{currentIp}}"
160
+ }
161
+ }
162
+ ]
163
+ }
164
+ ```
165
+
166
+ ### 3. condition - 条件分支
167
+
168
+ 根据条件选择执行分支:
169
+
170
+ ```json
171
+ {
172
+ "type": "condition",
173
+ "name": "判断",
174
+ "branches": [
175
+ {
176
+ "name": "大于10",
177
+ "condition": "context.variables.value > 10",
178
+ "steps": [
179
+ { "type": "script", "name": "处理大数", "script": "context.variables.status='big'; return true;" }
180
+ ]
181
+ },
182
+ {
183
+ "name": "小于等于10",
184
+ "condition": "context.variables.value <= 10",
185
+ "steps": [
186
+ { "type": "script", "name": "处理小数", "script": "context.variables.status='small'; return true;" }
187
+ ]
188
+ }
189
+ ]
190
+ }
191
+ ```
192
+
193
+ **condition 中的 condition 写法**:
194
+ - 比较运算符:`>`、`<`、`>=`、`<=`、`===`、`!==`
195
+ - 逻辑运算符:`&&`、`||`、`!`
196
+ - 必须返回 boolean 值
197
+
198
+ ### 4. loop - 循环步骤
199
+
200
+ 重复执行一组步骤:
201
+
202
+ ```json
203
+ {
204
+ "type": "loop",
205
+ "name": "循环3次",
206
+ "maxIterations": 3,
207
+ "loopVariable": "i",
208
+ "until": "context.variables.i >= 2",
209
+ "steps": [
210
+ { "type": "script", "name": "迭代", "script": "context.variables.count=context.variables.i+1; return context.variables.i;" }
211
+ ]
212
+ }
213
+ ```
214
+
215
+ ### 5. delay - 延迟步骤
216
+
217
+ 等待指定时间:
218
+
219
+ ```json
220
+ {
221
+ "type": "delay",
222
+ "name": "等待1秒",
223
+ "delayMs": 1000
224
+ }
225
+ ```
226
+
227
+ ### 6. sequential - 顺序步骤
228
+
229
+ 将多个步骤组合为顺序执行(可嵌套使用):
230
+
231
+ ```json
232
+ {
233
+ "type": "sequential",
234
+ "name": "顺序执行",
235
+ "steps": [
236
+ { "type": "script", "name": "步骤1", "script": "return 1;" },
237
+ { "type": "script", "name": "步骤2", "script": "return 2;" }
238
+ ]
239
+ }
240
+ ```
241
+
242
+ ## sessionId 传递
243
+
244
+ 工作流执行时会自动获取当前 sessionId,所有 tool 调用都会使用该 sessionId。
245
+
246
+ **调用流程**:
247
+ 1. `execute_workflow` 从执行上下文获取 sessionId
248
+ 2. sessionId 存入 `context.variables._sessionId`
249
+ 3. ToolStep 执行工具时使用该 sessionId
250
+
251
+ **这确保了通知会发送到当前会话**。
252
+
253
+ ## 工具
254
+
255
+ ### execute_workflow
256
+
257
+ 执行指定的工作流。
258
+
259
+ ```javascript
260
+ // 按名称执行(从 .agent/workflows/ 加载)
261
+ await execute_workflow({
262
+ workflow: "get-ip-notify"
263
+ })
264
+
265
+ // 传入工作流定义
266
+ await execute_workflow({
267
+ workflow: {
268
+ steps: [
269
+ { "type": "script", "script": "return 'test';" }
270
+ ]
271
+ }
272
+ })
273
+
274
+ // 带输入参数
275
+ await execute_workflow({
276
+ workflow: "my-workflow",
277
+ input: { key: "value" }
278
+ })
279
+ ```
280
+
281
+ ### reloadWorkflows
282
+
283
+ 重载所有工作流(当添加或修改工作流后调用)。
284
+
285
+ ```javascript
286
+ await reloadWorkflows()
287
+ ```
288
+
289
+ ## 最佳实践
290
+
291
+ 1. **script 必须 return**:`script` 是函数体,必须用 return 返回值
292
+ 2. **JSON 中 script 单行写**:用分号分隔多个语句,不要换行
293
+ 3. **拆分复杂逻辑**:复杂的 script 拆成多个简单步骤
294
+ 4. **使用 outputVariable**:需要跨步骤使用的值,存入 context.variables
295
+ 5. **条件判断加 else**:condition 分支要有兜底处理
296
+ 6. **合理设置循环次数**:loop 的 maxIterations 不要过大
297
+
298
+ **错误示例**:
299
+ ```json
300
+ // ❌ 错误 - script 没有 return
301
+ { "type": "script", "script": "context.variables.count + 1;" }
302
+
303
+ // ❌ 错误 - JSON 多行字符串
304
+ {
305
+ "script": "
306
+ const a = 10;
307
+ return a + 1;
308
+ "
309
+ }
310
+
311
+ // ❌ 错误 - JSON 中有注释
312
+ {
313
+ "script": "return 1; // 这是注释"
314
+ }
315
+ ```
316
+
317
+ **正确示例**:
318
+ ```json
319
+ // ✅ 正确
320
+ { "type": "script", "outputVariable": "count", "script": "return (context.variables.count||0) + 1;" }
321
+
322
+ // ✅ 正确 - 复杂逻辑拆成多步
323
+ { "type": "script", "script": "context.variables.a=10; context.variables.b=20; return context.variables.a+context.variables.b;" }
324
+ ```