foliko 1.1.13 → 1.1.14

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 (246) 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/poster-expert.md +135 -196
  36. package/.agent/agents/python-developer.md +60 -0
  37. package/.agent/agents/scheduler.md +59 -0
  38. package/.agent/agents/web-developer.md +45 -0
  39. package/.agent/data/default.json +404 -9
  40. package/.agent/data/plugins-state.json +172 -173
  41. package/.agent/data/puppeteer-sessions/undefined.json +6 -0
  42. package/.agent/data/weixin-media/2026-04-08/img_1775618677512.jpg +0 -0
  43. package/.agent/data/weixin-media/2026-04-08/img_1775619073340.jpg +0 -0
  44. package/.agent/data/weixin-media/2026-04-08/img_1775619097536.jpg +0 -0
  45. package/.agent/data/weixin-media/2026-04-08/img_1775619209388.jpg +0 -0
  46. package/.agent/mcp_config.json +21 -0
  47. package/.agent/memory/feedback/mnygjgox-ualjip.md +11 -0
  48. package/.agent/memory/project/mnqx54u5-loqtoe.md +9 -0
  49. package/.agent/memory/project/mnqx84cv-mx6dmd.md +9 -0
  50. package/.agent/memory/project/mnsacuyr-hgtk5n.md +20 -0
  51. package/.agent/memory/project/mnu5hy2x-bjsg7u.md +9 -0
  52. package/.agent/memory/project/mny28ot4-8qe9au.md +9 -0
  53. package/.agent/memory/reference/mnre3cww-penbo1.md +9 -0
  54. package/.agent/memory/reference/mns9wn48-luerua.md +14 -0
  55. package/.agent/memory/reference/mns9yz5c-thc2s0.md +16 -0
  56. package/.agent/memory/reference/mnsfy4um-910f1o.md +23 -0
  57. package/.agent/memory/reference/mnsg37dp-lmfj18.md +32 -0
  58. package/.agent/memory/reference/mnsll60q-0j911u.md +36 -0
  59. package/.agent/memory/reference/mnsmlb5y-nej31u.md +16 -0
  60. package/.agent/memory/reference/mnssle72-yrot96.md +9 -0
  61. package/.agent/memory/reference/mnygj8nb-bjthmc.md +20 -0
  62. package/.agent/memory/user/mnsfuon6-l416q1.md +21 -0
  63. package/.agent/memory/user/mnsg9kut-95m7rf.md +20 -0
  64. package/.agent/memory/user/mnu2eo1v-yy6fhe.md +9 -0
  65. package/.agent/memory/user/mnu2etuo-8u8jk8.md +9 -0
  66. package/.agent/memory/user/mnx0rk6g-gsznjj.md +9 -0
  67. package/.agent/memory/user/mnyf1riz-4yo5yz.md +9 -0
  68. package/.agent/plugins/puppeteer-plugin/README.md +147 -0
  69. package/.agent/plugins/puppeteer-plugin/index.js +1422 -0
  70. package/.agent/plugins/puppeteer-plugin/package.json +9 -0
  71. package/.agent/plugins.json +5 -11
  72. package/.agent/rules/GEMINI.md +273 -0
  73. package/.agent/rules/allow-rule.md +77 -0
  74. package/.agent/rules/log-rule.md +83 -0
  75. package/.agent/rules/security-rule.md +93 -0
  76. package/.agent/scripts/auto_preview.py +148 -0
  77. package/.agent/scripts/checklist.py +217 -0
  78. package/.agent/scripts/session_manager.py +120 -0
  79. package/.agent/scripts/verify_all.py +327 -0
  80. package/.agent/sessions/cli_default.json +11 -641
  81. package/.agent/skills/api-patterns/SKILL.md +81 -0
  82. package/.agent/skills/api-patterns/api-style.md +42 -0
  83. package/.agent/skills/api-patterns/auth.md +24 -0
  84. package/.agent/skills/api-patterns/documentation.md +26 -0
  85. package/.agent/skills/api-patterns/graphql.md +41 -0
  86. package/.agent/skills/api-patterns/rate-limiting.md +31 -0
  87. package/.agent/skills/api-patterns/response.md +37 -0
  88. package/.agent/skills/api-patterns/rest.md +40 -0
  89. package/.agent/skills/api-patterns/scripts/api_validator.py +211 -0
  90. package/.agent/skills/api-patterns/security-testing.md +122 -0
  91. package/.agent/skills/api-patterns/trpc.md +41 -0
  92. package/.agent/skills/api-patterns/versioning.md +22 -0
  93. package/.agent/skills/app-builder/SKILL.md +75 -0
  94. package/.agent/skills/app-builder/agent-coordination.md +71 -0
  95. package/.agent/skills/app-builder/feature-building.md +53 -0
  96. package/.agent/skills/app-builder/project-detection.md +34 -0
  97. package/.agent/skills/app-builder/scaffolding.md +118 -0
  98. package/.agent/skills/app-builder/tech-stack.md +40 -0
  99. package/.agent/skills/app-builder/templates/SKILL.md +39 -0
  100. package/.agent/skills/app-builder/templates/astro-static/TEMPLATE.md +76 -0
  101. package/.agent/skills/app-builder/templates/chrome-extension/TEMPLATE.md +92 -0
  102. package/.agent/skills/app-builder/templates/cli-tool/TEMPLATE.md +88 -0
  103. package/.agent/skills/app-builder/templates/electron-desktop/TEMPLATE.md +88 -0
  104. package/.agent/skills/app-builder/templates/express-api/TEMPLATE.md +83 -0
  105. package/.agent/skills/app-builder/templates/flutter-app/TEMPLATE.md +90 -0
  106. package/.agent/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +90 -0
  107. package/.agent/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +122 -0
  108. package/.agent/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +122 -0
  109. package/.agent/skills/app-builder/templates/nextjs-static/TEMPLATE.md +169 -0
  110. package/.agent/skills/app-builder/templates/nuxt-app/TEMPLATE.md +134 -0
  111. package/.agent/skills/app-builder/templates/python-fastapi/TEMPLATE.md +83 -0
  112. package/.agent/skills/app-builder/templates/react-native-app/TEMPLATE.md +119 -0
  113. package/.agent/skills/architecture/SKILL.md +55 -0
  114. package/.agent/skills/architecture/context-discovery.md +43 -0
  115. package/.agent/skills/architecture/examples.md +94 -0
  116. package/.agent/skills/architecture/pattern-selection.md +68 -0
  117. package/.agent/skills/architecture/patterns-reference.md +50 -0
  118. package/.agent/skills/architecture/trade-off-analysis.md +77 -0
  119. package/.agent/skills/clean-code/SKILL.md +201 -0
  120. package/.agent/skills/doc.md +177 -0
  121. package/.agent/skills/frontend-design/SKILL.md +418 -0
  122. package/.agent/skills/frontend-design/animation-guide.md +331 -0
  123. package/.agent/skills/frontend-design/color-system.md +311 -0
  124. package/.agent/skills/frontend-design/decision-trees.md +418 -0
  125. package/.agent/skills/frontend-design/motion-graphics.md +306 -0
  126. package/.agent/skills/frontend-design/scripts/accessibility_checker.py +183 -0
  127. package/.agent/skills/frontend-design/scripts/ux_audit.py +722 -0
  128. package/.agent/skills/frontend-design/typography-system.md +345 -0
  129. package/.agent/skills/frontend-design/ux-psychology.md +1116 -0
  130. package/.agent/skills/frontend-design/visual-effects.md +383 -0
  131. package/.agent/skills/i18n-localization/SKILL.md +154 -0
  132. package/.agent/skills/i18n-localization/scripts/i18n_checker.py +241 -0
  133. package/.agent/skills/mcp-builder/SKILL.md +176 -0
  134. package/.agent/skills/poster-design/SKILL.md +385 -0
  135. package/.agent/skills/web-design-guidelines/SKILL.md +57 -0
  136. package/.agent/workflows/brainstorm.md +113 -0
  137. package/.agent/workflows/create.md +59 -0
  138. package/.agent/workflows/debug.md +103 -0
  139. package/.agent/workflows/deploy.md +176 -0
  140. package/.agent/workflows/enhance.md +63 -0
  141. package/.agent/workflows/orchestrate.md +237 -0
  142. package/.agent/workflows/plan.md +89 -0
  143. package/.agent/workflows/preview.md +81 -0
  144. package/.agent/workflows/simple-test.md +42 -0
  145. package/.agent/workflows/status.md +86 -0
  146. package/.agent/workflows/structured-orchestrate.md +180 -0
  147. package/.agent/workflows/test.md +144 -0
  148. package/.agent/workflows/ui-ux-pro-max.md +296 -0
  149. package/.claude/settings.local.json +23 -1
  150. package/.env.example +56 -56
  151. package/README.md +441 -441
  152. package/cli/src/commands/chat.js +9 -15
  153. package/cli/src/ui/chat-ui.js +41 -71
  154. package/package.json +1 -1
  155. package/plugins/default-plugins.js +5 -5
  156. package/plugins/file-system-plugin.js +1 -1
  157. package/plugins/memory-plugin.js +12 -12
  158. package/plugins/plugin-manager-plugin.js +1 -0
  159. package/plugins/subagent-plugin.js +55 -1
  160. package/plugins/telegram-plugin.js +9 -6
  161. package/plugins/weixin-plugin.js +50 -34
  162. package/skills/find-skills/AGENTS.md +162 -162
  163. package/skills/find-skills/SKILL.md +133 -133
  164. package/src/core/agent-chat.js +460 -1612
  165. package/src/core/agent.js +53 -134
  166. package/src/core/chat-session.js +423 -0
  167. package/src/core/context-compressor.js +473 -0
  168. package/src/core/context-manager.js +0 -48
  169. package/src/core/framework.js +95 -68
  170. package/src/core/index.js +11 -0
  171. package/src/core/notification-manager.js +125 -0
  172. package/src/core/subagent.js +295 -0
  173. package/src/core/token-counter.js +190 -0
  174. package/src/core/tool-executor.js +270 -0
  175. package/src/executors/mcp-executor.js +14 -1
  176. package/system.md +312 -2373
  177. package/.agent/agents/code-assistant.json +0 -17
  178. package/.agent/agents/email-assistant.json +0 -14
  179. package/.agent/agents/file-assistant.json +0 -18
  180. package/.agent/agents/orchestrator-demo.md +0 -53
  181. package/.agent/agents/orchestrator.json +0 -7
  182. package/.agent/agents/system-assistant.json +0 -15
  183. package/.agent/agents/web-assistant.json +0 -12
  184. package/.agent/data/email/processed-emails.json +0 -1
  185. package/.agent/data/scheduler/tasks.json +0 -1
  186. package/.agent/data/web/web-config.json +0 -5
  187. package/.agent/memory/feedback/mnv3nu27-3o15pf.md +0 -9
  188. package/.agent/memory/feedback/mnv3o078-b959yj.md +0 -9
  189. package/.agent/memory/feedback/mnv3o6ej-u0fif5.md +0 -9
  190. package/.agent/memory/feedback/mnv3obgl-bkkjoj.md +0 -9
  191. package/.agent/memory/feedback/mnv4a3js-dv6onx.md +0 -9
  192. package/.agent/memory/feedback/mnv4aacm-sxxowp.md +0 -9
  193. package/.agent/memory/feedback/mnv4ahto-w40ffm.md +0 -9
  194. package/.agent/memory/feedback/mnv4anvp-3cs06y.md +0 -9
  195. package/.agent/memory/feedback/mnvzgvtd-0o2900.md +0 -9
  196. package/.agent/memory/feedback/mnvzhajn-swbx61.md +0 -15
  197. package/.agent/memory/feedback/mnvzhgsp-p5vog3.md +0 -9
  198. package/.agent/memory/feedback/mnvzho0c-fgql7q.md +0 -14
  199. package/.agent/memory/feedback/mnvzhtzq-ufr5at.md +0 -9
  200. package/.agent/memory/feedback/mnvzhyb3-9byq2z.md +0 -9
  201. package/.agent/memory/feedback/mnvzi7hp-hyeafp.md +0 -9
  202. package/.agent/memory/feedback/mnvzibph-z7rwp5.md +0 -9
  203. package/.agent/memory/feedback/mnvzilys-7h176w.md +0 -14
  204. package/.agent/memory/feedback/mnvziuh5-zjshci.md +0 -9
  205. package/.agent/memory/feedback/mnw07wde-6zqsc8.md +0 -9
  206. package/.agent/memory/feedback/mnw084bp-j0ba2a.md +0 -9
  207. package/.agent/memory/user/mnv3n62r-y0h79j.md +0 -21
  208. package/.agent/memory/user/mnv3n9yf-ead4g8.md +0 -13
  209. package/.agent/memory/user/mnv3ne3j-82tq1k.md +0 -19
  210. package/.agent/memory/user/mnv3nhgm-g2s2us.md +0 -11
  211. package/.agent/memory/user/mnv3nl9u-ejd998.md +0 -16
  212. package/.agent/memory/user/mnv3nofp-ya5szl.md +0 -10
  213. package/.agent/memory/user/mnv49qne-bhk0ki.md +0 -9
  214. package/.agent/memory/user/mnv49w3y-rzr8ju.md +0 -13
  215. package/.agent/package.json +0 -8
  216. package/.agent/plugins/__pycache__/file_writer.cpython-312.pyc +0 -0
  217. package/.agent/plugins/daytona/README.md +0 -89
  218. package/.agent/plugins/daytona/index.js +0 -377
  219. package/.agent/plugins/daytona/package.json +0 -12
  220. package/.agent/plugins/marknative/README.md +0 -134
  221. package/.agent/plugins/marknative/fonts/SegoeUI Emoji.ttf +0 -0
  222. package/.agent/plugins/marknative/fonts.zip +0 -0
  223. package/.agent/plugins/marknative/index.js +0 -256
  224. package/.agent/plugins/marknative/package.json +0 -12
  225. package/.agent/plugins/system-info/index.js +0 -387
  226. package/.agent/plugins/system-info/package.json +0 -4
  227. package/.agent/plugins/system-info/test.js +0 -40
  228. package/.agent/plugins/test-plugin.py +0 -123
  229. package/.agent/plugins/test_nested_plugin.py +0 -85
  230. package/.agent/python-scripts/test_sample.py +0 -24
  231. package/.agent/sessions/test.json +0 -16
  232. package/.agent/skills/agent-browser/SKILL.md +0 -311
  233. package/.agent/skills/agent-browser/TEST_PLAN.md +0 -200
  234. package/.agent/skills/sysinfo/SKILL.md +0 -38
  235. package/.agent/skills/sysinfo/system-info.sh +0 -130
  236. package/.agent/skills/workflow/SKILL.md +0 -324
  237. package/.agent/test-agent.js +0 -35
  238. package/.agent/weixin.json +0 -6
  239. package/.agent/workflows/email-digest.json +0 -50
  240. package/.agent/workflows/file-backup.json +0 -21
  241. package/.agent/workflows/get-ip-notify.json +0 -32
  242. package/.agent/workflows/news-aggregator.json +0 -93
  243. package/.agent/workflows/news-dashboard-v2.json +0 -94
  244. package/.agent/workflows/notification-batch.json +0 -32
  245. package/plugins/python-plugin-loader.js.bak +0 -856
  246. package/src/core/agent-context.js +0 -188
@@ -1,256 +0,0 @@
1
- const { z } = require('zod');
2
- const path = require('path');
3
- const fs = require('fs');
4
-
5
- module.exports = function (Plugin) {
6
- return class MarkNativePlugin extends Plugin {
7
- constructor(config = {}) {
8
- super();
9
- this.name = 'marknative';
10
- this.version = '1.0.1';
11
- this.description = 'Markdown 转图片插件 - 将 Markdown 转换为 PNG/SVG';
12
- this.priority = 10;
13
- this.marknative = null;
14
- this.checked = false;
15
- }
16
-
17
- async _ensureMarkNative() {
18
- if (this.checked) return;
19
- this.checked = true;
20
-
21
- this.marknative = await import('marknative');
22
- }
23
-
24
- tools = {
25
- marknative_render: {
26
- description: '将 Markdown 渲染为图片并保存到文件(返回文件路径)',
27
- inputSchema: z.object({
28
- markdown: z.string().describe('Markdown 内容'),
29
- outputPath: z.string().optional().describe('输出文件路径(如 output.png),不提供则自动生成'),
30
- format: z.enum(['png', 'svg']).optional().describe('输出格式:png 或 svg,默认 png'),
31
- theme: z.string().optional().describe('主题:default, github, solarized, sepia, rose, dark, nord, dracula, ocean, forest'),
32
- singlePage: z.boolean().optional().describe('是否渲染为单张图片(默认 false)'),
33
- codeTheme: z.string().optional().describe('代码高亮主题(如 github-dark, nord 等)'),
34
- }),
35
- execute: async (args) => {
36
- try {
37
- await this._ensureMarkNative();
38
-
39
- if (!this.marknative) {
40
- return {
41
- success: false,
42
- error: 'marknative 未安装。请运行: cd .agent/plugins/marknative && npm install'
43
- };
44
- }
45
-
46
- const { renderMarkdown } = this.marknative;
47
-
48
- const format = args.format || 'png';
49
- const options = {
50
- format,
51
- singlePage: args.singlePage || false
52
- };
53
-
54
- if (args.theme) options.theme = args.theme;
55
- if (args.codeTheme) options.codeHighlighting = { theme: args.codeTheme };
56
-
57
- const pages = await renderMarkdown(args.markdown, options);
58
-
59
- if (pages.length === 0) {
60
- return { success: false, error: '渲染失败,无输出' };
61
- }
62
-
63
- // 自动生成输出路径
64
- let basePath = args.outputPath;
65
- if (!basePath) {
66
- const timestamp = Date.now().toString(36);
67
- basePath = `output/markdown-${timestamp}.${format}`;
68
- }
69
-
70
- const dir = path.dirname(basePath);
71
- if (dir && dir !== '.' && !fs.existsSync(dir)) {
72
- fs.mkdirSync(dir, { recursive: true });
73
- }
74
-
75
- const files = [];
76
- for (let i = 0; i < pages.length; i++) {
77
- const page = pages[i];
78
- const filePath = pages.length === 1
79
- ? basePath
80
- : basePath.replace(/(\.[^.]+)$/, `-${String(i + 1).padStart(2, '0')}$1`);
81
-
82
- if (page.format === 'png') {
83
- fs.writeFileSync(filePath, page.data);
84
- } else {
85
- fs.writeFileSync(filePath, page.data, 'utf-8');
86
- }
87
- files.push(filePath);
88
- }
89
-
90
- return {
91
- success: true,
92
- files,
93
- pageCount: pages.length,
94
- message: pages.length === 1
95
- ? `图片已生成: ${files[0]}`
96
- : `已生成 ${pages.length} 页图片: ${files.join(', ')}`
97
- };
98
- } catch (error) {
99
- return { success: false, error: error.message };
100
- }
101
- },
102
- },
103
-
104
- marknative_render_to_file: {
105
- description: '将 Markdown 渲染为图片并保存到文件',
106
- inputSchema: z.object({
107
- markdown: z.string().describe('Markdown 内容'),
108
- outputPath: z.string().describe('输出文件路径(如 output.png)'),
109
- format: z.enum(['png', 'svg']).optional().describe('输出格式,默认根据文件扩展名'),
110
- theme: z.string().optional().describe('主题'),
111
- codeTheme: z.string().optional().describe('代码高亮主题'),
112
- }),
113
- execute: async (args) => {
114
- try {
115
- await this._ensureMarkNative();
116
-
117
- if (!this.marknative) {
118
- return {
119
- success: false,
120
- error: 'marknative 未安装。请运行: cd .agent/plugins/marknative && npm install'
121
- };
122
- }
123
-
124
- const { renderMarkdown } = this.marknative;
125
-
126
- const ext = path.extname(args.outputPath).toLowerCase();
127
- const format = args.format || (ext === '.svg' ? 'svg' : 'png');
128
-
129
- const options = { format };
130
- if (args.theme) options.theme = args.theme;
131
- if (args.codeTheme) options.codeHighlighting = { theme: args.codeTheme };
132
-
133
- const pages = await renderMarkdown(args.markdown, options);
134
-
135
- const dir = path.dirname(args.outputPath);
136
- if (dir && dir !== '.' && !fs.existsSync(dir)) {
137
- fs.mkdirSync(dir, { recursive: true });
138
- }
139
-
140
- const files = [];
141
- for (let i = 0; i < pages.length; i++) {
142
- const page = pages[i];
143
- const filePath = pages.length === 1
144
- ? args.outputPath
145
- : args.outputPath.replace(/(\.[^.]+)$/, `-${String(i + 1).padStart(2, '0')}$1`);
146
-
147
- if (page.format === 'png') {
148
- fs.writeFileSync(filePath, page.data);
149
- } else {
150
- fs.writeFileSync(filePath, page.data, 'utf-8');
151
- }
152
- files.push(filePath);
153
- }
154
-
155
- return {
156
- success: true,
157
- files,
158
- pageCount: pages.length,
159
- message: `已生成 ${pages.length} 页图片: ${files.join(', ')}`
160
- };
161
- } catch (error) {
162
- return { success: false, error: error.message };
163
- }
164
- },
165
- },
166
-
167
- marknative_preview: {
168
- description: '预览 Markdown 渲染效果(返回第一页 Base64)',
169
- inputSchema: z.object({
170
- markdown: z.string().describe('Markdown 内容'),
171
- theme: z.string().optional().describe('主题'),
172
- codeTheme: z.string().optional().describe('代码高亮主题'),
173
- }),
174
- execute: async (args) => {
175
- try {
176
- await this._ensureMarkNative();
177
-
178
- if (!this.marknative) {
179
- return {
180
- success: false,
181
- error: 'marknative 未安装。请运行: cd .agent/plugins/marknative && npm install'
182
- };
183
- }
184
-
185
- const { renderMarkdown } = this.marknative;
186
-
187
- const options = {
188
- format: 'png',
189
- singlePage: true
190
- };
191
-
192
- if (args.theme) options.theme = args.theme;
193
- if (args.codeTheme) options.codeHighlighting = { theme: args.codeTheme };
194
-
195
- const pages = await renderMarkdown(args.markdown, options);
196
-
197
- if (pages.length === 0) {
198
- return { success: false, error: '预览生成失败' };
199
- }
200
-
201
- return {
202
- success: true,
203
- preview: pages[0].data.toString('base64'),
204
- format: 'png'
205
- };
206
- } catch (error) {
207
- return { success: false, error: error.message };
208
- }
209
- },
210
- },
211
-
212
- marknative_get_themes: {
213
- description: '获取所有可用的主题列表',
214
- inputSchema: z.object({}),
215
- execute: async () => {
216
- return {
217
- success: true,
218
- themes: [
219
- { name: 'default', description: '默认主题(浅色)' },
220
- { name: 'github', description: 'GitHub 风格' },
221
- { name: 'solarized', description: 'Solarized 风格' },
222
- { name: 'sepia', description: '复古纸张风格' },
223
- { name: 'rose', description: '玫瑰粉风格' },
224
- { name: 'dark', description: '深色主题' },
225
- { name: 'nord', description: 'Nord 风格' },
226
- { name: 'dracula', description: 'Dracula 风格' },
227
- { name: 'ocean', description: '海洋风格' },
228
- { name: 'forest', description: '森林风格' }
229
- ],
230
- codeThemes: ['github-light', 'github-dark', 'nord', 'dracula', 'solarized-light', 'solarized-dark', 'monokai']
231
- };
232
- },
233
- },
234
-
235
- marknative_status: {
236
- description: '检查 marknative 插件状态',
237
- inputSchema: z.object({}),
238
- execute: async () => {
239
- await this._ensureMarkNative();
240
-
241
- return {
242
- success: true,
243
- available: this.marknative !== null,
244
- message: this.marknative ? 'marknative 已就绪' : 'marknative 未安装,请运行: cd .agent/plugins/marknative && npm install'
245
- };
246
- },
247
- },
248
- };
249
-
250
- install(framework) {
251
- return this;
252
- }
253
-
254
- uninstall(framework) {}
255
- };
256
- };
@@ -1,12 +0,0 @@
1
- {
2
- "name": "marknative-plugin",
3
- "version": "1.0.0",
4
- "description": "Markdown 转图片插件 - 将 Markdown 转换为 PNG/SVG",
5
- "main": "index.js",
6
- "keywords": ["markdown", "png", "svg", "image", "render", "foliko", "plugin"],
7
- "author": "",
8
- "license": "MIT",
9
- "dependencies": {
10
- "marknative": "^0.3.1"
11
- }
12
- }
@@ -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!');