foliko 1.1.2 → 1.1.4
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.
- package/.agent/agents/code-assistant.json +14 -0
- package/.agent/agents/email-assistant.json +14 -0
- package/.agent/agents/file-assistant.json +15 -0
- package/.agent/agents/system-assistant.json +15 -0
- package/.agent/agents/web-assistant.json +12 -0
- package/.agent/data/ambient/goals.json +50 -0
- package/.agent/data/ambient/memories.json +7 -0
- package/.agent/data/default.json +3 -412
- package/.agent/data/plugins-state.json +174 -173
- package/.agent/data/scheduler/tasks.json +1 -0
- package/.agent/memory/core.md +1 -0
- package/.agent/memory/project/mnn93ogy-ypjn27.md +9 -0
- package/.agent/memory/project/mnn98fqy-5nhc1u.md +25 -0
- package/.agent/memory/reference/mnq3oenw-46haj6.md +63 -0
- package/.agent/memory/reference/mnq5qxm2-mjoooh.md +116 -0
- package/.agent/memory/user/mnm67t9m-x8rekk.md +9 -0
- package/.agent/memory/user/mnn5mmqh-w6aktx.md +11 -0
- package/.agent/memory/user/mnnbfhhn-dk1bd1.md +22 -0
- package/.agent/package.json +8 -0
- package/.agent/plugins/__pycache__/file_writer.cpython-312.pyc +0 -0
- package/.agent/plugins/daytona/README.md +89 -0
- package/.agent/plugins/daytona/index.js +377 -0
- package/.agent/plugins/daytona/package.json +12 -0
- package/.agent/plugins/marknative/README.md +134 -0
- package/.agent/plugins/marknative/fonts/SegoeUI Emoji.ttf +0 -0
- package/.agent/plugins/marknative/index.js +256 -0
- package/.agent/plugins/marknative/package.json +12 -0
- package/.agent/plugins/marknative/update-readme.js +134 -0
- package/.agent/plugins/poster-plugin/emojis/rocket.png +1 -0
- package/.agent/plugins/poster-plugin/fonts/SegoeUI Emoji.ttf +0 -0
- package/.agent/plugins/poster-plugin/src/elements/text.js +3 -1
- package/.agent/plugins/poster-plugin/src/fonts.js +10 -0
- package/.agent/plugins/poster-plugin/yarn.lock +1007 -0
- package/.agent/plugins/system-info/index.js +387 -0
- package/.agent/plugins/system-info/package.json +4 -0
- package/.agent/plugins/system-info/test.js +40 -0
- package/.agent/plugins.json +11 -5
- package/.agent/python-scripts/test_sample.py +24 -0
- package/.agent/sessions/cli_default.json +1869 -691
- package/.agent/skills/agent-browser/SKILL.md +311 -0
- package/.agent/skills/agent-browser/TEST_PLAN.md +200 -0
- package/.agent/skills/sysinfo/SKILL.md +38 -0
- package/.agent/skills/sysinfo/system-info.sh +130 -0
- package/.agent/skills/workflow/SKILL.md +324 -0
- package/.agent/weixin.json +6 -0
- package/.agent/workflows/email-digest.json +50 -0
- package/.agent/workflows/file-backup.json +21 -0
- package/.agent/workflows/get-ip-notify.json +32 -0
- package/.agent/workflows/news-aggregator.json +93 -0
- package/.agent/workflows/news-dashboard-v2.json +94 -0
- package/.agent/workflows/notification-batch.json +32 -0
- package/.claude/settings.local.json +1 -20
- package/.env.example +56 -56
- package/README.md +441 -441
- package/cli/src/commands/chat.js +22 -13
- package/cli/src/ui/chat-ui.js +50 -37
- package/output/emoji-segoe-test-v2.png +0 -0
- package/output/emoji-segoe-test.png +0 -0
- package/output/emoji-test.png +0 -0
- package/output/emoji-windows-test.png +0 -0
- package/output/foliko-emoji-poster.png +0 -0
- package/output/foliko-muji-poster-final.png +0 -0
- package/output/foliko-muji-poster-v2.png +0 -0
- package/output/foliko-muji-poster.png +0 -0
- package/output/foliko-share.png +0 -0
- package/output/progress-circle-test.png +0 -0
- package/output/vb-agent-poster.png +0 -0
- package/package.json +1 -2
- package/plugins/default-plugins.js +4 -3
- package/plugins/extension-executor-plugin.js +12 -91
- package/plugins/file-system-plugin.js +19 -4
- package/plugins/memory-plugin.js +33 -4
- package/plugins/subagent-plugin.js +14 -37
- package/plugins/weixin-plugin.js +40 -168
- package/skills/find-skills/AGENTS.md +162 -162
- package/skills/find-skills/SKILL.md +133 -133
- package/skills/poster-guide/SKILL.md +669 -1426
- package/src/core/agent-chat.js +439 -269
- package/src/core/agent.js +3 -6
- package/.agent/.shared/ui-ux-pro-max/data/charts.csv +0 -26
- package/.agent/.shared/ui-ux-pro-max/data/colors.csv +0 -97
- package/.agent/.shared/ui-ux-pro-max/data/icons.csv +0 -101
- package/.agent/.shared/ui-ux-pro-max/data/landing.csv +0 -31
- package/.agent/.shared/ui-ux-pro-max/data/products.csv +0 -97
- package/.agent/.shared/ui-ux-pro-max/data/prompts.csv +0 -24
- package/.agent/.shared/ui-ux-pro-max/data/react-performance.csv +0 -45
- package/.agent/.shared/ui-ux-pro-max/data/stacks/flutter.csv +0 -53
- package/.agent/.shared/ui-ux-pro-max/data/stacks/html-tailwind.csv +0 -56
- package/.agent/.shared/ui-ux-pro-max/data/stacks/jetpack-compose.csv +0 -53
- package/.agent/.shared/ui-ux-pro-max/data/stacks/nextjs.csv +0 -53
- package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxt-ui.csv +0 -51
- package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxtjs.csv +0 -59
- package/.agent/.shared/ui-ux-pro-max/data/stacks/react-native.csv +0 -52
- package/.agent/.shared/ui-ux-pro-max/data/stacks/react.csv +0 -54
- package/.agent/.shared/ui-ux-pro-max/data/stacks/shadcn.csv +0 -61
- package/.agent/.shared/ui-ux-pro-max/data/stacks/svelte.csv +0 -54
- package/.agent/.shared/ui-ux-pro-max/data/stacks/swiftui.csv +0 -51
- package/.agent/.shared/ui-ux-pro-max/data/stacks/vue.csv +0 -50
- package/.agent/.shared/ui-ux-pro-max/data/styles.csv +0 -59
- package/.agent/.shared/ui-ux-pro-max/data/typography.csv +0 -58
- package/.agent/.shared/ui-ux-pro-max/data/ui-reasoning.csv +0 -101
- package/.agent/.shared/ui-ux-pro-max/data/ux-guidelines.csv +0 -100
- package/.agent/.shared/ui-ux-pro-max/data/web-interface.csv +0 -31
- package/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/core.cpython-313.pyc +0 -0
- package/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-313.pyc +0 -0
- package/.agent/.shared/ui-ux-pro-max/scripts/core.py +0 -258
- package/.agent/.shared/ui-ux-pro-max/scripts/design_system.py +0 -1067
- package/.agent/.shared/ui-ux-pro-max/scripts/search.py +0 -106
- package/.agent/ARCHITECTURE.md +0 -288
- package/.agent/agents/ambient-agent.md +0 -57
- package/.agent/agents/debugger.md +0 -55
- package/.agent/agents/email-assistant.md +0 -49
- package/.agent/agents/file-manager.md +0 -42
- package/.agent/agents/python-developer.md +0 -60
- package/.agent/agents/scheduler.md +0 -59
- package/.agent/agents/web-developer.md +0 -45
- package/.agent/data/puppeteer-sessions/undefined.json +0 -6
- package/.agent/data/weixin-media/2026-04-08/img_1775618677512.jpg +0 -0
- package/.agent/data/weixin-media/2026-04-08/img_1775619073340.jpg +0 -0
- package/.agent/data/weixin-media/2026-04-08/img_1775619097536.jpg +0 -0
- package/.agent/data/weixin-media/2026-04-08/img_1775619209388.jpg +0 -0
- package/.agent/mcp_config_updated.json +0 -12
- package/.agent/plugins/poster-plugin/fonts/NotoColorEmoji-Regular.ttf +0 -0
- package/.agent/plugins/puppeteer-plugin/README.md +0 -147
- package/.agent/plugins/puppeteer-plugin/index.js +0 -1418
- package/.agent/plugins/puppeteer-plugin/package.json +0 -9
- package/.agent/rules/GEMINI.md +0 -273
- package/.agent/rules/allow-rule.md +0 -77
- package/.agent/rules/log-rule.md +0 -83
- package/.agent/rules/security-rule.md +0 -93
- package/.agent/scripts/auto_preview.py +0 -148
- package/.agent/scripts/checklist.py +0 -217
- package/.agent/scripts/session_manager.py +0 -120
- package/.agent/scripts/verify_all.py +0 -327
- package/.agent/sessions/weixin_o9cq80zgZqKPA2-s59PN43GdDy1w@im.wechat.json +0 -11097
- package/.agent/skills/api-patterns/SKILL.md +0 -81
- package/.agent/skills/api-patterns/api-style.md +0 -42
- package/.agent/skills/api-patterns/auth.md +0 -24
- package/.agent/skills/api-patterns/documentation.md +0 -26
- package/.agent/skills/api-patterns/graphql.md +0 -41
- package/.agent/skills/api-patterns/rate-limiting.md +0 -31
- package/.agent/skills/api-patterns/response.md +0 -37
- package/.agent/skills/api-patterns/rest.md +0 -40
- package/.agent/skills/api-patterns/scripts/api_validator.py +0 -211
- package/.agent/skills/api-patterns/security-testing.md +0 -122
- package/.agent/skills/api-patterns/trpc.md +0 -41
- package/.agent/skills/api-patterns/versioning.md +0 -22
- package/.agent/skills/app-builder/SKILL.md +0 -75
- package/.agent/skills/app-builder/agent-coordination.md +0 -71
- package/.agent/skills/app-builder/feature-building.md +0 -53
- package/.agent/skills/app-builder/project-detection.md +0 -34
- package/.agent/skills/app-builder/scaffolding.md +0 -118
- package/.agent/skills/app-builder/tech-stack.md +0 -40
- package/.agent/skills/app-builder/templates/SKILL.md +0 -39
- package/.agent/skills/app-builder/templates/astro-static/TEMPLATE.md +0 -76
- package/.agent/skills/app-builder/templates/chrome-extension/TEMPLATE.md +0 -92
- package/.agent/skills/app-builder/templates/cli-tool/TEMPLATE.md +0 -88
- package/.agent/skills/app-builder/templates/electron-desktop/TEMPLATE.md +0 -88
- package/.agent/skills/app-builder/templates/express-api/TEMPLATE.md +0 -83
- package/.agent/skills/app-builder/templates/flutter-app/TEMPLATE.md +0 -90
- package/.agent/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +0 -90
- package/.agent/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +0 -122
- package/.agent/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +0 -122
- package/.agent/skills/app-builder/templates/nextjs-static/TEMPLATE.md +0 -169
- package/.agent/skills/app-builder/templates/nuxt-app/TEMPLATE.md +0 -134
- package/.agent/skills/app-builder/templates/python-fastapi/TEMPLATE.md +0 -83
- package/.agent/skills/app-builder/templates/react-native-app/TEMPLATE.md +0 -119
- package/.agent/skills/architecture/SKILL.md +0 -55
- package/.agent/skills/architecture/context-discovery.md +0 -43
- package/.agent/skills/architecture/examples.md +0 -94
- package/.agent/skills/architecture/pattern-selection.md +0 -68
- package/.agent/skills/architecture/patterns-reference.md +0 -50
- package/.agent/skills/architecture/trade-off-analysis.md +0 -77
- package/.agent/skills/clean-code/SKILL.md +0 -201
- package/.agent/skills/doc.md +0 -177
- package/.agent/skills/frontend-design/SKILL.md +0 -418
- package/.agent/skills/frontend-design/animation-guide.md +0 -331
- package/.agent/skills/frontend-design/color-system.md +0 -311
- package/.agent/skills/frontend-design/decision-trees.md +0 -418
- package/.agent/skills/frontend-design/motion-graphics.md +0 -306
- package/.agent/skills/frontend-design/scripts/accessibility_checker.py +0 -183
- package/.agent/skills/frontend-design/scripts/ux_audit.py +0 -722
- package/.agent/skills/frontend-design/typography-system.md +0 -345
- package/.agent/skills/frontend-design/ux-psychology.md +0 -1116
- package/.agent/skills/frontend-design/visual-effects.md +0 -383
- package/.agent/skills/i18n-localization/SKILL.md +0 -154
- package/.agent/skills/i18n-localization/scripts/i18n_checker.py +0 -241
- package/.agent/skills/mcp-builder/SKILL.md +0 -176
- package/.agent/skills/web-design-guidelines/SKILL.md +0 -57
- package/.agent/workflows/brainstorm.md +0 -113
- package/.agent/workflows/create.md +0 -59
- package/.agent/workflows/debug.md +0 -103
- package/.agent/workflows/deploy.md +0 -176
- package/.agent/workflows/enhance.md +0 -63
- package/.agent/workflows/orchestrate.md +0 -237
- package/.agent/workflows/plan.md +0 -89
- package/.agent/workflows/preview.md +0 -81
- package/.agent/workflows/simple-test.md +0 -42
- package/.agent/workflows/status.md +0 -86
- package/.agent/workflows/structured-orchestrate.md +0 -180
- package/.agent/workflows/test.md +0 -144
- package/.agent/workflows/ui-ux-pro-max.md +0 -296
- package/output/beef-love-poster.png +0 -0
- package/output/international-news-daily.png +0 -0
- package/poster-test-2.png +0 -0
|
@@ -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,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!');
|
package/.agent/plugins.json
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
"enabled": true
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"email": {
|
|
3
|
+
"enabled": true,
|
|
4
|
+
"smtp": {
|
|
5
|
+
"host": "smtp.gmail.com",
|
|
6
|
+
"port": 587,
|
|
7
|
+
"secure": false
|
|
8
|
+
},
|
|
9
|
+
"imap": {
|
|
10
|
+
"host": "imap.gmail.com",
|
|
11
|
+
"port": 993
|
|
12
|
+
}
|
|
7
13
|
}
|
|
8
14
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
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()
|