foliko 1.0.80 → 1.0.82

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 (154) 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 +15 -31894
  9. package/.agent/data/plugins-state.json +146 -181
  10. package/.agent/data/scheduler/tasks.json +1 -0
  11. package/.agent/mcp_config.json +1 -0
  12. package/.agent/package.json +8 -0
  13. package/.agent/plugins/__pycache__/test_plugin.cpython-312.pyc +0 -0
  14. package/.agent/plugins/system-info/index.js +387 -0
  15. package/.agent/plugins/system-info/package.json +4 -0
  16. package/.agent/plugins/system-info/test.js +40 -0
  17. package/.agent/plugins/test_plugin.py +304 -0
  18. package/.agent/plugins.json +14 -5
  19. package/.agent/python-scripts/test_sample.py +24 -0
  20. package/.agent/skills/sysinfo/SKILL.md +38 -0
  21. package/.agent/skills/sysinfo/system-info.sh +130 -0
  22. package/.agent/skills/workflow/SKILL.md +324 -0
  23. package/.agent/workflows/email-digest.json +50 -0
  24. package/.agent/workflows/file-backup.json +21 -0
  25. package/.agent/workflows/get-ip-notify.json +32 -0
  26. package/.agent/workflows/news-aggregator.json +93 -0
  27. package/.agent/workflows/news-dashboard-v2.json +94 -0
  28. package/.agent/workflows/notification-batch.json +32 -0
  29. package/.claude/settings.local.json +171 -171
  30. package/.env.example +56 -56
  31. package/cli/src/ui/chat-ui.js +8 -8
  32. package/package.json +1 -1
  33. package/plugins/feishu-plugin.js +6 -6
  34. package/plugins/file-system-plugin.js +54 -11
  35. package/plugins/telegram-plugin.js +6 -6
  36. package/plugins/weixin-plugin.js +6 -6
  37. package/skills/find-skills/AGENTS.md +162 -162
  38. package/skills/find-skills/SKILL.md +133 -133
  39. package/skills/foliko-dev/SKILL.md +563 -583
  40. package/skills/python-plugin-dev/SKILL.md +238 -238
  41. package/src/core/agent-chat.js +141 -134
  42. package/.agent/.shared/ui-ux-pro-max/data/charts.csv +0 -26
  43. package/.agent/.shared/ui-ux-pro-max/data/colors.csv +0 -97
  44. package/.agent/.shared/ui-ux-pro-max/data/icons.csv +0 -101
  45. package/.agent/.shared/ui-ux-pro-max/data/landing.csv +0 -31
  46. package/.agent/.shared/ui-ux-pro-max/data/products.csv +0 -97
  47. package/.agent/.shared/ui-ux-pro-max/data/prompts.csv +0 -24
  48. package/.agent/.shared/ui-ux-pro-max/data/react-performance.csv +0 -45
  49. package/.agent/.shared/ui-ux-pro-max/data/stacks/flutter.csv +0 -53
  50. package/.agent/.shared/ui-ux-pro-max/data/stacks/html-tailwind.csv +0 -56
  51. package/.agent/.shared/ui-ux-pro-max/data/stacks/jetpack-compose.csv +0 -53
  52. package/.agent/.shared/ui-ux-pro-max/data/stacks/nextjs.csv +0 -53
  53. package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxt-ui.csv +0 -51
  54. package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxtjs.csv +0 -59
  55. package/.agent/.shared/ui-ux-pro-max/data/stacks/react-native.csv +0 -52
  56. package/.agent/.shared/ui-ux-pro-max/data/stacks/react.csv +0 -54
  57. package/.agent/.shared/ui-ux-pro-max/data/stacks/shadcn.csv +0 -61
  58. package/.agent/.shared/ui-ux-pro-max/data/stacks/svelte.csv +0 -54
  59. package/.agent/.shared/ui-ux-pro-max/data/stacks/swiftui.csv +0 -51
  60. package/.agent/.shared/ui-ux-pro-max/data/stacks/vue.csv +0 -50
  61. package/.agent/.shared/ui-ux-pro-max/data/styles.csv +0 -59
  62. package/.agent/.shared/ui-ux-pro-max/data/typography.csv +0 -58
  63. package/.agent/.shared/ui-ux-pro-max/data/ui-reasoning.csv +0 -101
  64. package/.agent/.shared/ui-ux-pro-max/data/ux-guidelines.csv +0 -100
  65. package/.agent/.shared/ui-ux-pro-max/data/web-interface.csv +0 -31
  66. package/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/core.cpython-313.pyc +0 -0
  67. package/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-313.pyc +0 -0
  68. package/.agent/.shared/ui-ux-pro-max/scripts/core.py +0 -258
  69. package/.agent/.shared/ui-ux-pro-max/scripts/design_system.py +0 -1067
  70. package/.agent/.shared/ui-ux-pro-max/scripts/search.py +0 -106
  71. package/.agent/ARCHITECTURE.md +0 -288
  72. package/.agent/agents/ambient-agent.md +0 -57
  73. package/.agent/agents/debugger.md +0 -55
  74. package/.agent/agents/email-assistant.md +0 -49
  75. package/.agent/agents/file-manager.md +0 -42
  76. package/.agent/agents/python-developer.md +0 -60
  77. package/.agent/agents/scheduler.md +0 -59
  78. package/.agent/agents/web-developer.md +0 -45
  79. package/.agent/mcp_config_updated.json +0 -12
  80. package/.agent/rules/GEMINI.md +0 -273
  81. package/.agent/rules/allow-rule.md +0 -77
  82. package/.agent/rules/log-rule.md +0 -83
  83. package/.agent/rules/security-rule.md +0 -93
  84. package/.agent/scripts/auto_preview.py +0 -148
  85. package/.agent/scripts/checklist.py +0 -217
  86. package/.agent/scripts/session_manager.py +0 -120
  87. package/.agent/scripts/verify_all.py +0 -327
  88. package/.agent/skills/api-patterns/SKILL.md +0 -81
  89. package/.agent/skills/api-patterns/api-style.md +0 -42
  90. package/.agent/skills/api-patterns/auth.md +0 -24
  91. package/.agent/skills/api-patterns/documentation.md +0 -26
  92. package/.agent/skills/api-patterns/graphql.md +0 -41
  93. package/.agent/skills/api-patterns/rate-limiting.md +0 -31
  94. package/.agent/skills/api-patterns/response.md +0 -37
  95. package/.agent/skills/api-patterns/rest.md +0 -40
  96. package/.agent/skills/api-patterns/scripts/api_validator.py +0 -211
  97. package/.agent/skills/api-patterns/security-testing.md +0 -122
  98. package/.agent/skills/api-patterns/trpc.md +0 -41
  99. package/.agent/skills/api-patterns/versioning.md +0 -22
  100. package/.agent/skills/app-builder/SKILL.md +0 -75
  101. package/.agent/skills/app-builder/agent-coordination.md +0 -71
  102. package/.agent/skills/app-builder/feature-building.md +0 -53
  103. package/.agent/skills/app-builder/project-detection.md +0 -34
  104. package/.agent/skills/app-builder/scaffolding.md +0 -118
  105. package/.agent/skills/app-builder/tech-stack.md +0 -40
  106. package/.agent/skills/app-builder/templates/SKILL.md +0 -39
  107. package/.agent/skills/app-builder/templates/astro-static/TEMPLATE.md +0 -76
  108. package/.agent/skills/app-builder/templates/chrome-extension/TEMPLATE.md +0 -92
  109. package/.agent/skills/app-builder/templates/cli-tool/TEMPLATE.md +0 -88
  110. package/.agent/skills/app-builder/templates/electron-desktop/TEMPLATE.md +0 -88
  111. package/.agent/skills/app-builder/templates/express-api/TEMPLATE.md +0 -83
  112. package/.agent/skills/app-builder/templates/flutter-app/TEMPLATE.md +0 -90
  113. package/.agent/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +0 -90
  114. package/.agent/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +0 -122
  115. package/.agent/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +0 -122
  116. package/.agent/skills/app-builder/templates/nextjs-static/TEMPLATE.md +0 -169
  117. package/.agent/skills/app-builder/templates/nuxt-app/TEMPLATE.md +0 -134
  118. package/.agent/skills/app-builder/templates/python-fastapi/TEMPLATE.md +0 -83
  119. package/.agent/skills/app-builder/templates/react-native-app/TEMPLATE.md +0 -119
  120. package/.agent/skills/architecture/SKILL.md +0 -55
  121. package/.agent/skills/architecture/context-discovery.md +0 -43
  122. package/.agent/skills/architecture/examples.md +0 -94
  123. package/.agent/skills/architecture/pattern-selection.md +0 -68
  124. package/.agent/skills/architecture/patterns-reference.md +0 -50
  125. package/.agent/skills/architecture/trade-off-analysis.md +0 -77
  126. package/.agent/skills/clean-code/SKILL.md +0 -201
  127. package/.agent/skills/doc.md +0 -177
  128. package/.agent/skills/frontend-design/SKILL.md +0 -418
  129. package/.agent/skills/frontend-design/animation-guide.md +0 -331
  130. package/.agent/skills/frontend-design/color-system.md +0 -311
  131. package/.agent/skills/frontend-design/decision-trees.md +0 -418
  132. package/.agent/skills/frontend-design/motion-graphics.md +0 -306
  133. package/.agent/skills/frontend-design/scripts/accessibility_checker.py +0 -183
  134. package/.agent/skills/frontend-design/scripts/ux_audit.py +0 -722
  135. package/.agent/skills/frontend-design/typography-system.md +0 -345
  136. package/.agent/skills/frontend-design/ux-psychology.md +0 -1116
  137. package/.agent/skills/frontend-design/visual-effects.md +0 -383
  138. package/.agent/skills/i18n-localization/SKILL.md +0 -154
  139. package/.agent/skills/i18n-localization/scripts/i18n_checker.py +0 -241
  140. package/.agent/skills/mcp-builder/SKILL.md +0 -176
  141. package/.agent/skills/web-design-guidelines/SKILL.md +0 -57
  142. package/.agent/workflows/brainstorm.md +0 -113
  143. package/.agent/workflows/create.md +0 -59
  144. package/.agent/workflows/debug.md +0 -103
  145. package/.agent/workflows/deploy.md +0 -176
  146. package/.agent/workflows/enhance.md +0 -63
  147. package/.agent/workflows/orchestrate.md +0 -237
  148. package/.agent/workflows/plan.md +0 -89
  149. package/.agent/workflows/preview.md +0 -81
  150. package/.agent/workflows/simple-test.md +0 -42
  151. package/.agent/workflows/status.md +0 -86
  152. package/.agent/workflows/structured-orchestrate.md +0 -180
  153. package/.agent/workflows/test.md +0 -144
  154. package/.agent/workflows/ui-ux-pro-max.md +0 -296
@@ -0,0 +1,387 @@
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
@@ -0,0 +1,4 @@
1
+ {
2
+ "name": "system-info",
3
+ "main": "index.js"
4
+ }
@@ -0,0 +1,40 @@
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!');