foliko 1.1.0 → 1.1.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.
Files changed (214) hide show
  1. package/.agent/.shared/ui-ux-pro-max/data/charts.csv +26 -0
  2. package/.agent/.shared/ui-ux-pro-max/data/colors.csv +97 -0
  3. package/.agent/.shared/ui-ux-pro-max/data/icons.csv +101 -0
  4. package/.agent/.shared/ui-ux-pro-max/data/landing.csv +31 -0
  5. package/.agent/.shared/ui-ux-pro-max/data/products.csv +97 -0
  6. package/.agent/.shared/ui-ux-pro-max/data/prompts.csv +24 -0
  7. package/.agent/.shared/ui-ux-pro-max/data/react-performance.csv +45 -0
  8. package/.agent/.shared/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
  9. package/.agent/.shared/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
  10. package/.agent/.shared/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
  11. package/.agent/.shared/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
  12. package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
  13. package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
  14. package/.agent/.shared/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
  15. package/.agent/.shared/ui-ux-pro-max/data/stacks/react.csv +54 -0
  16. package/.agent/.shared/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
  17. package/.agent/.shared/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
  18. package/.agent/.shared/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
  19. package/.agent/.shared/ui-ux-pro-max/data/stacks/vue.csv +50 -0
  20. package/.agent/.shared/ui-ux-pro-max/data/styles.csv +59 -0
  21. package/.agent/.shared/ui-ux-pro-max/data/typography.csv +58 -0
  22. package/.agent/.shared/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
  23. package/.agent/.shared/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
  24. package/.agent/.shared/ui-ux-pro-max/data/web-interface.csv +31 -0
  25. package/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/core.cpython-313.pyc +0 -0
  26. package/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-313.pyc +0 -0
  27. package/.agent/.shared/ui-ux-pro-max/scripts/core.py +258 -0
  28. package/.agent/.shared/ui-ux-pro-max/scripts/design_system.py +1067 -0
  29. package/.agent/.shared/ui-ux-pro-max/scripts/search.py +106 -0
  30. package/.agent/ARCHITECTURE.md +288 -0
  31. package/.agent/agents/ambient-agent.md +57 -0
  32. package/.agent/agents/debugger.md +55 -0
  33. package/.agent/agents/email-assistant.md +49 -0
  34. package/.agent/agents/file-manager.md +42 -0
  35. package/.agent/agents/python-developer.md +60 -0
  36. package/.agent/agents/scheduler.md +59 -0
  37. package/.agent/agents/web-developer.md +45 -0
  38. package/.agent/data/default.json +412 -3
  39. package/.agent/data/plugins-state.json +173 -174
  40. package/.agent/data/puppeteer-sessions/undefined.json +6 -0
  41. package/.agent/data/weixin-media/2026-04-08/img_1775618677512.jpg +0 -0
  42. package/.agent/data/weixin-media/2026-04-08/img_1775619073340.jpg +0 -0
  43. package/.agent/data/weixin-media/2026-04-08/img_1775619097536.jpg +0 -0
  44. package/.agent/data/weixin-media/2026-04-08/img_1775619209388.jpg +0 -0
  45. package/.agent/mcp_config_updated.json +12 -0
  46. package/.agent/plugins/poster-plugin/fonts/NotoColorEmoji-Regular.ttf +0 -0
  47. package/.agent/plugins/poster-plugin/package.json +2 -1
  48. package/.agent/plugins/poster-plugin/src/canvas.js +70 -7
  49. package/.agent/plugins/poster-plugin/src/components/barcode.js +120 -0
  50. package/.agent/plugins/poster-plugin/src/components/bubble.js +153 -0
  51. package/.agent/plugins/poster-plugin/src/components/button.js +124 -0
  52. package/.agent/plugins/poster-plugin/src/components/cta.js +26 -24
  53. package/.agent/plugins/poster-plugin/src/components/featureGrid.js +22 -17
  54. package/.agent/plugins/poster-plugin/src/components/frame.js +230 -0
  55. package/.agent/plugins/poster-plugin/src/components/highlightText.js +144 -0
  56. package/.agent/plugins/poster-plugin/src/components/icon.js +94 -0
  57. package/.agent/plugins/poster-plugin/src/components/index.js +19 -0
  58. package/.agent/plugins/poster-plugin/src/components/listItem.js +6 -5
  59. package/.agent/plugins/poster-plugin/src/components/qrcode.js +74 -0
  60. package/.agent/plugins/poster-plugin/src/components/ribbon.js +193 -0
  61. package/.agent/plugins/poster-plugin/src/components/seal.js +146 -0
  62. package/.agent/plugins/poster-plugin/src/components/table.js +17 -9
  63. package/.agent/plugins/poster-plugin/src/components/tagCloud.js +24 -17
  64. package/.agent/plugins/poster-plugin/src/components/timeline.js +24 -12
  65. package/.agent/plugins/poster-plugin/src/composer.js +392 -150
  66. package/.agent/plugins/poster-plugin/src/elements/background.js +36 -4
  67. package/.agent/plugins/poster-plugin/src/elements/image.js +4 -47
  68. package/.agent/plugins/poster-plugin/src/elements/index.js +2 -0
  69. package/.agent/plugins/poster-plugin/src/elements/polygon.js +37 -6
  70. package/.agent/plugins/poster-plugin/src/elements/richText.js +230 -0
  71. package/.agent/plugins/poster-plugin/src/elements/svg.js +35 -19
  72. package/.agent/plugins/poster-plugin/src/elements/text.js +71 -2
  73. package/.agent/plugins/poster-plugin/src/fonts.js +123 -8
  74. package/.agent/plugins/poster-plugin/src/index.js +445 -23
  75. package/.agent/plugins/poster-plugin/src/utils/imageLoader.js +84 -0
  76. package/.agent/plugins/poster-plugin/test-background.svg +1 -0
  77. package/.agent/plugins/poster-plugin/test-full-poster.svg +2 -0
  78. package/.agent/plugins/poster-plugin/test-image.png +0 -0
  79. package/.agent/plugins/puppeteer-plugin/README.md +147 -0
  80. package/.agent/plugins/puppeteer-plugin/index.js +1418 -0
  81. package/.agent/plugins/puppeteer-plugin/package.json +9 -0
  82. package/.agent/plugins.json +5 -11
  83. package/.agent/rules/GEMINI.md +273 -0
  84. package/.agent/rules/allow-rule.md +77 -0
  85. package/.agent/rules/log-rule.md +83 -0
  86. package/.agent/rules/security-rule.md +93 -0
  87. package/.agent/scripts/auto_preview.py +148 -0
  88. package/.agent/scripts/checklist.py +217 -0
  89. package/.agent/scripts/session_manager.py +120 -0
  90. package/.agent/scripts/verify_all.py +327 -0
  91. package/.agent/sessions/cli_default.json +678 -23580
  92. package/.agent/sessions/weixin_o9cq80zgZqKPA2-s59PN43GdDy1w@im.wechat.json +11097 -0
  93. package/.agent/skills/api-patterns/SKILL.md +81 -0
  94. package/.agent/skills/api-patterns/api-style.md +42 -0
  95. package/.agent/skills/api-patterns/auth.md +24 -0
  96. package/.agent/skills/api-patterns/documentation.md +26 -0
  97. package/.agent/skills/api-patterns/graphql.md +41 -0
  98. package/.agent/skills/api-patterns/rate-limiting.md +31 -0
  99. package/.agent/skills/api-patterns/response.md +37 -0
  100. package/.agent/skills/api-patterns/rest.md +40 -0
  101. package/.agent/skills/api-patterns/scripts/api_validator.py +211 -0
  102. package/.agent/skills/api-patterns/security-testing.md +122 -0
  103. package/.agent/skills/api-patterns/trpc.md +41 -0
  104. package/.agent/skills/api-patterns/versioning.md +22 -0
  105. package/.agent/skills/app-builder/SKILL.md +75 -0
  106. package/.agent/skills/app-builder/agent-coordination.md +71 -0
  107. package/.agent/skills/app-builder/feature-building.md +53 -0
  108. package/.agent/skills/app-builder/project-detection.md +34 -0
  109. package/.agent/skills/app-builder/scaffolding.md +118 -0
  110. package/.agent/skills/app-builder/tech-stack.md +40 -0
  111. package/.agent/skills/app-builder/templates/SKILL.md +39 -0
  112. package/.agent/skills/app-builder/templates/astro-static/TEMPLATE.md +76 -0
  113. package/.agent/skills/app-builder/templates/chrome-extension/TEMPLATE.md +92 -0
  114. package/.agent/skills/app-builder/templates/cli-tool/TEMPLATE.md +88 -0
  115. package/.agent/skills/app-builder/templates/electron-desktop/TEMPLATE.md +88 -0
  116. package/.agent/skills/app-builder/templates/express-api/TEMPLATE.md +83 -0
  117. package/.agent/skills/app-builder/templates/flutter-app/TEMPLATE.md +90 -0
  118. package/.agent/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +90 -0
  119. package/.agent/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +122 -0
  120. package/.agent/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +122 -0
  121. package/.agent/skills/app-builder/templates/nextjs-static/TEMPLATE.md +169 -0
  122. package/.agent/skills/app-builder/templates/nuxt-app/TEMPLATE.md +134 -0
  123. package/.agent/skills/app-builder/templates/python-fastapi/TEMPLATE.md +83 -0
  124. package/.agent/skills/app-builder/templates/react-native-app/TEMPLATE.md +119 -0
  125. package/.agent/skills/architecture/SKILL.md +55 -0
  126. package/.agent/skills/architecture/context-discovery.md +43 -0
  127. package/.agent/skills/architecture/examples.md +94 -0
  128. package/.agent/skills/architecture/pattern-selection.md +68 -0
  129. package/.agent/skills/architecture/patterns-reference.md +50 -0
  130. package/.agent/skills/architecture/trade-off-analysis.md +77 -0
  131. package/.agent/skills/clean-code/SKILL.md +201 -0
  132. package/.agent/skills/doc.md +177 -0
  133. package/.agent/skills/frontend-design/SKILL.md +418 -0
  134. package/.agent/skills/frontend-design/animation-guide.md +331 -0
  135. package/.agent/skills/frontend-design/color-system.md +311 -0
  136. package/.agent/skills/frontend-design/decision-trees.md +418 -0
  137. package/.agent/skills/frontend-design/motion-graphics.md +306 -0
  138. package/.agent/skills/frontend-design/scripts/accessibility_checker.py +183 -0
  139. package/.agent/skills/frontend-design/scripts/ux_audit.py +722 -0
  140. package/.agent/skills/frontend-design/typography-system.md +345 -0
  141. package/.agent/skills/frontend-design/ux-psychology.md +1116 -0
  142. package/.agent/skills/frontend-design/visual-effects.md +383 -0
  143. package/.agent/skills/i18n-localization/SKILL.md +154 -0
  144. package/.agent/skills/i18n-localization/scripts/i18n_checker.py +241 -0
  145. package/.agent/skills/mcp-builder/SKILL.md +176 -0
  146. package/.agent/skills/web-design-guidelines/SKILL.md +57 -0
  147. package/.agent/workflows/brainstorm.md +113 -0
  148. package/.agent/workflows/create.md +59 -0
  149. package/.agent/workflows/debug.md +103 -0
  150. package/.agent/workflows/deploy.md +176 -0
  151. package/.agent/workflows/enhance.md +63 -0
  152. package/.agent/workflows/orchestrate.md +237 -0
  153. package/.agent/workflows/plan.md +89 -0
  154. package/.agent/workflows/preview.md +81 -0
  155. package/.agent/workflows/simple-test.md +42 -0
  156. package/.agent/workflows/status.md +86 -0
  157. package/.agent/workflows/structured-orchestrate.md +180 -0
  158. package/.agent/workflows/test.md +144 -0
  159. package/.agent/workflows/ui-ux-pro-max.md +296 -0
  160. package/.claude/settings.local.json +21 -1
  161. package/.env.example +56 -56
  162. package/README.md +441 -441
  163. package/cli/src/commands/chat.js +2 -1
  164. package/output/international-news-daily.png +0 -0
  165. package/package.json +2 -1
  166. package/plugins/extension-executor-plugin.js +91 -12
  167. package/plugins/file-system-plugin.js +4 -19
  168. package/plugins/subagent-plugin.js +37 -14
  169. package/plugins/weixin-plugin.js +168 -40
  170. package/poster-test-2.png +0 -0
  171. package/skills/find-skills/AGENTS.md +162 -162
  172. package/skills/find-skills/SKILL.md +133 -133
  173. package/skills/poster-guide/SKILL.md +1435 -627
  174. package/src/core/agent-chat.js +223 -11
  175. package/src/core/agent.js +6 -3
  176. package/.agent/agents/code-assistant.json +0 -14
  177. package/.agent/agents/email-assistant.json +0 -14
  178. package/.agent/agents/file-assistant.json +0 -15
  179. package/.agent/agents/system-assistant.json +0 -15
  180. package/.agent/agents/web-assistant.json +0 -12
  181. package/.agent/data/ambient/goals.json +0 -50
  182. package/.agent/data/ambient/memories.json +0 -7
  183. package/.agent/data/scheduler/tasks.json +0 -1
  184. package/.agent/memory/core.md +0 -1
  185. package/.agent/memory/project/mnn93ogy-ypjn27.md +0 -9
  186. package/.agent/memory/project/mnn98fqy-5nhc1u.md +0 -25
  187. package/.agent/memory/user/mnm67t9m-x8rekk.md +0 -9
  188. package/.agent/memory/user/mnn5mmqh-w6aktx.md +0 -11
  189. package/.agent/memory/user/mnnbfhhn-dk1bd1.md +0 -22
  190. package/.agent/package.json +0 -8
  191. package/.agent/plugins/__pycache__/file_writer.cpython-312.pyc +0 -0
  192. package/.agent/plugins/daytona/README.md +0 -89
  193. package/.agent/plugins/daytona/index.js +0 -377
  194. package/.agent/plugins/daytona/package.json +0 -12
  195. package/.agent/plugins/marknative/README.md +0 -134
  196. package/.agent/plugins/marknative/index.js +0 -228
  197. package/.agent/plugins/marknative/package.json +0 -12
  198. package/.agent/plugins/marknative/update-readme.js +0 -134
  199. package/.agent/plugins/system-info/index.js +0 -387
  200. package/.agent/plugins/system-info/package.json +0 -4
  201. package/.agent/plugins/system-info/test.js +0 -40
  202. package/.agent/python-scripts/test_sample.py +0 -24
  203. package/.agent/skills/agent-browser/SKILL.md +0 -311
  204. package/.agent/skills/agent-browser/TEST_PLAN.md +0 -200
  205. package/.agent/skills/sysinfo/SKILL.md +0 -38
  206. package/.agent/skills/sysinfo/system-info.sh +0 -130
  207. package/.agent/skills/workflow/SKILL.md +0 -324
  208. package/.agent/weixin.json +0 -6
  209. package/.agent/workflows/email-digest.json +0 -50
  210. package/.agent/workflows/file-backup.json +0 -21
  211. package/.agent/workflows/get-ip-notify.json +0 -32
  212. package/.agent/workflows/news-aggregator.json +0 -93
  213. package/.agent/workflows/news-dashboard-v2.json +0 -94
  214. package/.agent/workflows/notification-batch.json +0 -32
@@ -1,387 +0,0 @@
1
- /**
2
- * System Info Plugin - 获取系统信息插件
3
- * 提供 CPU、内存、操作系统、磁盘、网络等系统信息查询功能
4
- */
5
-
6
- const { Plugin } = require('../../../src/core/plugin-base')
7
- const { z } = require('zod')
8
- const os = require('os')
9
- const { execSync } = require('child_process')
10
-
11
- class SystemInfoPlugin extends Plugin {
12
- constructor(config = {}) {
13
- super()
14
- this.name = 'system-info'
15
- this.version = '1.0.0'
16
- this.description = '获取系统信息插件 - 提供 CPU、内存、操作系统、磁盘、网络等系统信息查询功能'
17
- this.priority = 10
18
- }
19
-
20
- install(framework) {
21
- super.install(framework)
22
- this._registerTools()
23
- return this
24
- }
25
-
26
- _registerTools() {
27
- const framework = this._framework
28
-
29
- // 获取简略系统信息
30
- framework.registerTool({
31
- name: 'get_basic_info',
32
- description: '获取简略系统信息,包括主机名、操作系统、平台、架构、运行时间等基本信息',
33
- inputSchema: z.object({}),
34
- execute: async (args, framework) => {
35
- const uptime = os.uptime()
36
- const uptimeStr = this.formatUptime(uptime)
37
-
38
- return {
39
- success: true,
40
- data: {
41
- hostname: os.hostname(),
42
- platform: os.platform(),
43
- osType: os.type(),
44
- osRelease: os.release(),
45
- arch: os.arch(),
46
- nodeVersion: process.version,
47
- processUptime: uptimeStr,
48
- totalMemory: this.formatBytes(os.totalmem()),
49
- cpuCount: os.cpus().length,
50
- cpuModel: os.cpus()[0]?.model || 'Unknown'
51
- }
52
- }
53
- }
54
- })
55
-
56
- // 获取 CPU 详细信息
57
- framework.registerTool({
58
- name: 'get_cpu_info',
59
- description: '获取 CPU 详细信息,包括每个核心的频率、使用率等',
60
- inputSchema: z.object({}),
61
- execute: async (args, framework) => {
62
- const cpus = os.cpus()
63
- const cpuInfo = cpus.map((cpu, index) => ({
64
- core: index,
65
- model: cpu.model,
66
- speed: `${cpu.speed} MHz`,
67
- times: {
68
- user: this.formatMs(cpu.times.user),
69
- nice: this.formatMs(cpu.times.nice),
70
- sys: this.formatMs(cpu.times.sys),
71
- idle: this.formatMs(cpu.times.idle),
72
- irq: this.formatMs(cpu.times.irq)
73
- }
74
- }))
75
-
76
- // 计算平均 CPU 使用率
77
- const avgUsage = this.calculateCpuUsage(cpus)
78
-
79
- return {
80
- success: true,
81
- data: {
82
- cpuCount: cpus.length,
83
- totalCores: cpus.length,
84
- averageUsage: avgUsage,
85
- cores: cpuInfo
86
- }
87
- }
88
- }
89
- })
90
-
91
- // 获取内存信息
92
- framework.registerTool({
93
- name: 'get_memory_info',
94
- description: '获取内存使用信息,包括总内存、已用内存、可用内存、使用率等',
95
- inputSchema: z.object({}),
96
- execute: async (args, framework) => {
97
- const totalMem = os.totalmem()
98
- const freeMem = os.freemem()
99
- const usedMem = totalMem - freeMem
100
- const usagePercent = ((usedMem / totalMem) * 100).toFixed(2)
101
-
102
- return {
103
- success: true,
104
- data: {
105
- total: this.formatBytes(totalMem),
106
- free: this.formatBytes(freeMem),
107
- used: this.formatBytes(usedMem),
108
- usagePercent: `${usagePercent}%`,
109
- details: {
110
- totalBytes: totalMem,
111
- freeBytes: freeMem,
112
- usedBytes: usedMem
113
- }
114
- }
115
- }
116
- }
117
- })
118
-
119
- // 获取网络接口信息
120
- framework.registerTool({
121
- name: 'get_network_info',
122
- description: '获取网络接口信息,包括 IP 地址、MAC 地址、网络类型等',
123
- inputSchema: z.object({}),
124
- execute: async (args, framework) => {
125
- const interfaces = os.networkInterfaces()
126
- const networkInfo = {}
127
-
128
- for (const [name, addrs] of Object.entries(interfaces)) {
129
- const addrList = addrs.map(addr => ({
130
- address: addr.address,
131
- family: addr.family,
132
- mac: addr.mac,
133
- internal: addr.internal,
134
- netmask: addr.netmask
135
- }))
136
- networkInfo[name] = addrList
137
- }
138
-
139
- return {
140
- success: true,
141
- data: {
142
- interfaces: networkInfo,
143
- hostname: os.hostname()
144
- }
145
- }
146
- }
147
- })
148
-
149
- // 获取磁盘信息
150
- framework.registerTool({
151
- name: 'get_disk_info',
152
- description: '获取磁盘使用信息,包括各磁盘的总容量、已用空间、可用空间、使用率',
153
- inputSchema: z.object({
154
- platform: z.enum(['windows', 'linux', 'darwin', 'auto']).optional().describe('操作系统平台,auto 为自动检测')
155
- }),
156
- execute: async (args, framework) => {
157
- const diskInfo = []
158
- const currentPlatform = args.platform === 'auto' ? os.platform() : (args.platform || os.platform())
159
-
160
- try {
161
- if (currentPlatform === 'win32') {
162
- // Windows 系统
163
- const output = execSync('wmic logicaldisk get size,freespace,caption', { encoding: 'utf8', timeout: 5000 })
164
- const lines = output.trim().split('\n').slice(1)
165
-
166
- for (const line of lines) {
167
- const parts = line.trim().split(/\s+/)
168
- if (parts.length >= 3) {
169
- const caption = parts[0]
170
- const freeSpace = parseInt(parts[1]) || 0
171
- const size = parseInt(parts[2]) || 0
172
- const used = size - freeSpace
173
- const usagePercent = size > 0 ? ((used / size) * 100).toFixed(2) : 0
174
-
175
- diskInfo.push({
176
- filesystem: caption,
177
- total: this.formatBytes(size),
178
- used: this.formatBytes(used),
179
- free: this.formatBytes(freeSpace),
180
- usagePercent: `${usagePercent}%`,
181
- details: {
182
- totalBytes: size,
183
- usedBytes: used,
184
- freeBytes: freeSpace
185
- }
186
- })
187
- }
188
- }
189
- } else if (currentPlatform === 'linux') {
190
- // Linux 系统
191
- const output = execSync('df -B1 --output=source,size,used,avail -x tmpfs -x devtmpfs -x squashfs 2>/dev/null || df -B1', { encoding: 'utf8', timeout: 5000 })
192
- const lines = output.trim().split('\n').slice(1)
193
-
194
- for (const line of lines) {
195
- const parts = line.trim().split(/\s+/)
196
- if (parts.length >= 4) {
197
- const filesystem = parts[0]
198
- const size = parseInt(parts[1]) || 0
199
- const used = parseInt(parts[2]) || 0
200
- const free = parseInt(parts[3]) || 0
201
- const usagePercent = size > 0 ? ((used / size) * 100).toFixed(2) : 0
202
-
203
- // 过滤掉虚拟文件系统
204
- if (!filesystem.startsWith('/dev') && !filesystem.startsWith('/sys') && !filesystem.startsWith('/proc')) {
205
- continue
206
- }
207
-
208
- diskInfo.push({
209
- filesystem,
210
- total: this.formatBytes(size),
211
- used: this.formatBytes(used),
212
- free: this.formatBytes(free),
213
- usagePercent: `${usagePercent}%`,
214
- details: {
215
- totalBytes: size,
216
- usedBytes: used,
217
- freeBytes: free
218
- }
219
- })
220
- }
221
- }
222
- } else if (currentPlatform === 'darwin') {
223
- // macOS 系统
224
- const output = execSync('df -B1', { encoding: 'utf8', timeout: 5000 })
225
- const lines = output.trim().split('\n').slice(1)
226
-
227
- for (const line of lines) {
228
- const parts = line.trim().split(/\s+/)
229
- if (parts.length >= 6) {
230
- const filesystem = parts[0]
231
- const size = parseInt(parts[1]) || 0
232
- const used = parseInt(parts[2]) || 0
233
- const free = parseInt(parts[3]) || 0
234
- const usagePercent = size > 0 ? ((used / size) * 100).toFixed(2) : 0
235
-
236
- diskInfo.push({
237
- filesystem,
238
- total: this.formatBytes(size),
239
- used: this.formatBytes(used),
240
- free: this.formatBytes(free),
241
- usagePercent: `${usagePercent}%`,
242
- details: {
243
- totalBytes: size,
244
- usedBytes: used,
245
- freeBytes: free
246
- }
247
- })
248
- }
249
- }
250
- }
251
- } catch (error) {
252
- return {
253
- success: false,
254
- error: `获取磁盘信息失败: ${error.message}`,
255
- data: []
256
- }
257
- }
258
-
259
- return {
260
- success: true,
261
- platform: currentPlatform,
262
- data: diskInfo
263
- }
264
- }
265
- })
266
-
267
- // 获取完整系统信息(综合)
268
- framework.registerTool({
269
- name: 'get_full_system_info',
270
- description: '获取完整的系统信息,包括 CPU、内存、磁盘、网络等所有信息',
271
- inputSchema: z.object({}),
272
- execute: async (args, framework) => {
273
- const uptime = os.uptime()
274
-
275
- // CPU 信息
276
- const cpus = os.cpus()
277
- const avgUsage = this.calculateCpuUsage(cpus)
278
-
279
- // 内存信息
280
- const totalMem = os.totalmem()
281
- const freeMem = os.freemem()
282
- const usedMem = totalMem - freeMem
283
- const memUsagePercent = ((usedMem / totalMem) * 100).toFixed(2)
284
-
285
- // 网络信息
286
- const networkInterfaces = os.networkInterfaces()
287
-
288
- // 磁盘信息
289
- let diskInfo = []
290
- try {
291
- const diskResult = await framework.callTool('get_disk_info', {})
292
- diskInfo = diskResult.data || []
293
- } catch (e) {
294
- diskInfo = []
295
- }
296
-
297
- return {
298
- success: true,
299
- data: {
300
- system: {
301
- hostname: os.hostname(),
302
- platform: os.platform(),
303
- osType: os.type(),
304
- osRelease: os.release(),
305
- arch: os.arch(),
306
- nodeVersion: process.version,
307
- uptime: this.formatUptime(uptime)
308
- },
309
- cpu: {
310
- count: cpus.length,
311
- model: cpus[0]?.model || 'Unknown',
312
- averageUsage: avgUsage,
313
- speed: `${cpus[0]?.speed || 'N/A'} MHz`
314
- },
315
- memory: {
316
- total: this.formatBytes(totalMem),
317
- free: this.formatBytes(freeMem),
318
- used: this.formatBytes(usedMem),
319
- usagePercent: `${memUsagePercent}%`
320
- },
321
- disk: diskInfo,
322
- network: {
323
- interfacesCount: Object.keys(networkInterfaces).length,
324
- interfaces: Object.keys(networkInterfaces)
325
- }
326
- }
327
- }
328
- }
329
- })
330
- }
331
-
332
- // 格式化字节数
333
- formatBytes(bytes) {
334
- if (bytes === 0) return '0 Bytes'
335
- const k = 1024
336
- const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB']
337
- const i = Math.floor(Math.log(bytes) / Math.log(k))
338
- return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i]
339
- }
340
-
341
- // 格式化毫秒
342
- formatMs(ms) {
343
- return `${(ms / 1000).toFixed(2)}s`
344
- }
345
-
346
- // 格式化运行时间
347
- formatUptime(seconds) {
348
- const days = Math.floor(seconds / 86400)
349
- const hours = Math.floor((seconds % 86400) / 3600)
350
- const minutes = Math.floor((seconds % 3600) / 60)
351
- const secs = Math.floor(seconds % 60)
352
-
353
- const parts = []
354
- if (days > 0) parts.push(`${days} 天`)
355
- if (hours > 0) parts.push(`${hours} 小时`)
356
- if (minutes > 0) parts.push(`${minutes} 分钟`)
357
- if (secs > 0 || parts.length === 0) parts.push(`${secs} 秒`)
358
-
359
- return parts.join(' ')
360
- }
361
-
362
- // 计算 CPU 使用率
363
- calculateCpuUsage(cpus) {
364
- let totalIdle = 0
365
- let totalTick = 0
366
-
367
- cpus.forEach(cpu => {
368
- for (const type in cpu.times) {
369
- totalTick += cpu.times[type]
370
- }
371
- totalIdle += cpu.times.idle
372
- })
373
-
374
- const idle = totalIdle / cpus.length
375
- const total = totalTick / cpus.length
376
- const usage = ((total - idle) / total * 100).toFixed(2)
377
-
378
- return `${usage}%`
379
- }
380
-
381
- uninstall(framework) {
382
- // 清理资源
383
- this._framework = null
384
- }
385
- }
386
-
387
- module.exports =SystemInfoPlugin
@@ -1,4 +0,0 @@
1
- {
2
- "name": "system-info",
3
- "main": "index.js"
4
- }
@@ -1,40 +0,0 @@
1
- // 测试系统信息插件
2
- const os = require('os');
3
-
4
- // 模拟插件安装
5
- const plugin = require('./index.js');
6
- const mockPlugin = plugin({});
7
- const registeredTools = [];
8
-
9
- const mockFramework = {
10
- registerTool: (tool) => {
11
- registeredTools.push(tool.name);
12
- console.log('✓ Registered tool:', tool.name);
13
- },
14
- callTool: async (name, args) => {
15
- if (name === 'get_disk_info') {
16
- // 模拟磁盘信息获取
17
- return { success: true, data: [] };
18
- }
19
- }
20
- };
21
-
22
- console.log('\n=== Testing System Info Plugin ===\n');
23
- mockPlugin.install(mockFramework);
24
-
25
- console.log('\n✓ Plugin name:', mockPlugin.name);
26
- console.log('✓ Plugin version:', mockPlugin.version);
27
- console.log('✓ Plugin description:', mockPlugin.description);
28
-
29
- console.log('\n✓ Total tools registered:', registeredTools.length);
30
- console.log('✓ Tools:', registeredTools.join(', '));
31
-
32
- console.log('\n=== System Information Preview ===\n');
33
- console.log('Hostname:', os.hostname());
34
- console.log('Platform:', os.platform());
35
- console.log('OS Type:', os.type());
36
- console.log('CPU Count:', os.cpus().length);
37
- console.log('Total Memory:', (os.totalmem() / 1024 / 1024 / 1024).toFixed(2), 'GB');
38
- console.log('Node Version:', process.version);
39
-
40
- console.log('\n✓ All tests passed!');
@@ -1,24 +0,0 @@
1
- """
2
- 测试模块 - 2026-04-02 02:52:12
3
- """
4
-
5
- import unittest
6
-
7
-
8
-
9
- class TestMath(unittest.TestCase):
10
- """TestMath 测试类"""
11
-
12
- def test_add(self):
13
- """测试用例: test_add"""
14
- # TODO: 实现测试逻辑
15
- self.assertTrue(True)
16
-
17
- def test_subtract(self):
18
- """测试用例: test_subtract"""
19
- # TODO: 实现测试逻辑
20
- self.assertTrue(True)
21
-
22
-
23
- if __name__ == "__main__":
24
- unittest.main()