foliko 1.0.87 → 1.1.1

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 (259) 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 +325 -21
  39. package/.agent/data/plugins-state.json +194 -162
  40. package/.agent/data/puppeteer-sessions/undefined.json +6 -0
  41. package/.agent/mcp_config.json +0 -1
  42. package/.agent/mcp_config_updated.json +12 -0
  43. package/.agent/plugins/poster-plugin/README.md +304 -0
  44. package/.agent/plugins/poster-plugin/fonts/NotoColorEmoji-Regular.ttf +0 -0
  45. package/.agent/plugins/poster-plugin/fonts/PatuaOne-Regular.ttf +0 -0
  46. package/.agent/plugins/poster-plugin/fonts//345/276/256/350/275/257/351/233/205/351/273/221.ttf +0 -0
  47. package/.agent/plugins/poster-plugin/fonts//345/276/256/350/275/257/351/233/205/351/273/221/347/262/227/344/275/223.ttf +0 -0
  48. package/.agent/plugins/poster-plugin/index.js +13 -0
  49. package/.agent/plugins/poster-plugin/package.json +28 -0
  50. package/.agent/plugins/poster-plugin/src/canvas.js +161 -0
  51. package/.agent/plugins/poster-plugin/src/components/arrow.js +84 -0
  52. package/.agent/plugins/poster-plugin/src/components/avatar.js +71 -0
  53. package/.agent/plugins/poster-plugin/src/components/badge.js +85 -0
  54. package/.agent/plugins/poster-plugin/src/components/card.js +88 -0
  55. package/.agent/plugins/poster-plugin/src/components/chart.js +127 -0
  56. package/.agent/plugins/poster-plugin/src/components/chip.js +88 -0
  57. package/.agent/plugins/poster-plugin/src/components/columns.js +107 -0
  58. package/.agent/plugins/poster-plugin/src/components/cta.js +85 -0
  59. package/.agent/plugins/poster-plugin/src/components/divider.js +55 -0
  60. package/.agent/plugins/poster-plugin/src/components/feature.js +85 -0
  61. package/.agent/plugins/poster-plugin/src/components/featureGrid.js +112 -0
  62. package/.agent/plugins/poster-plugin/src/components/grid.js +118 -0
  63. package/.agent/plugins/poster-plugin/src/components/imageFrame.js +155 -0
  64. package/.agent/plugins/poster-plugin/src/components/index.js +62 -0
  65. package/.agent/plugins/poster-plugin/src/components/listItem.js +146 -0
  66. package/.agent/plugins/poster-plugin/src/components/notification.js +123 -0
  67. package/.agent/plugins/poster-plugin/src/components/progress.js +79 -0
  68. package/.agent/plugins/poster-plugin/src/components/progressCircle.js +117 -0
  69. package/.agent/plugins/poster-plugin/src/components/quote.js +97 -0
  70. package/.agent/plugins/poster-plugin/src/components/rating.js +85 -0
  71. package/.agent/plugins/poster-plugin/src/components/star.js +70 -0
  72. package/.agent/plugins/poster-plugin/src/components/statCard.js +105 -0
  73. package/.agent/plugins/poster-plugin/src/components/stepper.js +118 -0
  74. package/.agent/plugins/poster-plugin/src/components/table.js +159 -0
  75. package/.agent/plugins/poster-plugin/src/components/tagCloud.js +78 -0
  76. package/.agent/plugins/poster-plugin/src/components/timeline.js +105 -0
  77. package/.agent/plugins/poster-plugin/src/components/watermark.js +52 -0
  78. package/.agent/plugins/poster-plugin/src/composer.js +1904 -0
  79. package/.agent/plugins/poster-plugin/src/elements/artText.js +60 -0
  80. package/.agent/plugins/poster-plugin/src/elements/background.js +52 -0
  81. package/.agent/plugins/poster-plugin/src/elements/circle.js +31 -0
  82. package/.agent/plugins/poster-plugin/src/elements/image.js +71 -0
  83. package/.agent/plugins/poster-plugin/src/elements/index.js +26 -0
  84. package/.agent/plugins/poster-plugin/src/elements/line.js +23 -0
  85. package/.agent/plugins/poster-plugin/src/elements/polygon.js +63 -0
  86. package/.agent/plugins/poster-plugin/src/elements/rectangle.js +32 -0
  87. package/.agent/plugins/poster-plugin/src/elements/svg.js +92 -0
  88. package/.agent/plugins/poster-plugin/src/elements/text.js +107 -0
  89. package/.agent/plugins/poster-plugin/src/fonts.js +233 -0
  90. package/.agent/plugins/poster-plugin/src/index.js +1658 -0
  91. package/.agent/plugins/poster-plugin/src/presets.js +36 -0
  92. package/.agent/plugins/poster-plugin/src/templates/business.js +60 -0
  93. package/.agent/plugins/poster-plugin/src/templates/gradient.js +64 -0
  94. package/.agent/plugins/poster-plugin/src/templates/index.js +43 -0
  95. package/.agent/plugins/poster-plugin/src/templates/modern.js +69 -0
  96. package/.agent/plugins/poster-plugin/src/templates/simple.js +58 -0
  97. package/.agent/plugins/poster-plugin/src/templates/social.js +62 -0
  98. package/.agent/plugins/poster-plugin/src/templates/tech.js +84 -0
  99. package/.agent/plugins/{temp-repo/puppeteer-plugin → puppeteer-plugin}/index.js +1 -1
  100. package/.agent/plugins.json +5 -11
  101. package/.agent/rules/GEMINI.md +273 -0
  102. package/.agent/rules/allow-rule.md +77 -0
  103. package/.agent/rules/log-rule.md +83 -0
  104. package/.agent/rules/security-rule.md +93 -0
  105. package/.agent/scripts/auto_preview.py +148 -0
  106. package/.agent/scripts/checklist.py +217 -0
  107. package/.agent/scripts/session_manager.py +120 -0
  108. package/.agent/scripts/verify_all.py +327 -0
  109. package/.agent/sessions/cli_default.json +419 -0
  110. package/.agent/sessions/weixin_o9cq80zgZqKPA2-s59PN43GdDy1w@im.wechat.json +2195 -0
  111. package/.agent/skills/api-patterns/SKILL.md +81 -0
  112. package/.agent/skills/api-patterns/api-style.md +42 -0
  113. package/.agent/skills/api-patterns/auth.md +24 -0
  114. package/.agent/skills/api-patterns/documentation.md +26 -0
  115. package/.agent/skills/api-patterns/graphql.md +41 -0
  116. package/.agent/skills/api-patterns/rate-limiting.md +31 -0
  117. package/.agent/skills/api-patterns/response.md +37 -0
  118. package/.agent/skills/api-patterns/rest.md +40 -0
  119. package/.agent/skills/api-patterns/scripts/api_validator.py +211 -0
  120. package/.agent/skills/api-patterns/security-testing.md +122 -0
  121. package/.agent/skills/api-patterns/trpc.md +41 -0
  122. package/.agent/skills/api-patterns/versioning.md +22 -0
  123. package/.agent/skills/app-builder/SKILL.md +75 -0
  124. package/.agent/skills/app-builder/agent-coordination.md +71 -0
  125. package/.agent/skills/app-builder/feature-building.md +53 -0
  126. package/.agent/skills/app-builder/project-detection.md +34 -0
  127. package/.agent/skills/app-builder/scaffolding.md +118 -0
  128. package/.agent/skills/app-builder/tech-stack.md +40 -0
  129. package/.agent/skills/app-builder/templates/SKILL.md +39 -0
  130. package/.agent/skills/app-builder/templates/astro-static/TEMPLATE.md +76 -0
  131. package/.agent/skills/app-builder/templates/chrome-extension/TEMPLATE.md +92 -0
  132. package/.agent/skills/app-builder/templates/cli-tool/TEMPLATE.md +88 -0
  133. package/.agent/skills/app-builder/templates/electron-desktop/TEMPLATE.md +88 -0
  134. package/.agent/skills/app-builder/templates/express-api/TEMPLATE.md +83 -0
  135. package/.agent/skills/app-builder/templates/flutter-app/TEMPLATE.md +90 -0
  136. package/.agent/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +90 -0
  137. package/.agent/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +122 -0
  138. package/.agent/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +122 -0
  139. package/.agent/skills/app-builder/templates/nextjs-static/TEMPLATE.md +169 -0
  140. package/.agent/skills/app-builder/templates/nuxt-app/TEMPLATE.md +134 -0
  141. package/.agent/skills/app-builder/templates/python-fastapi/TEMPLATE.md +83 -0
  142. package/.agent/skills/app-builder/templates/react-native-app/TEMPLATE.md +119 -0
  143. package/.agent/skills/architecture/SKILL.md +55 -0
  144. package/.agent/skills/architecture/context-discovery.md +43 -0
  145. package/.agent/skills/architecture/examples.md +94 -0
  146. package/.agent/skills/architecture/pattern-selection.md +68 -0
  147. package/.agent/skills/architecture/patterns-reference.md +50 -0
  148. package/.agent/skills/architecture/trade-off-analysis.md +77 -0
  149. package/.agent/skills/clean-code/SKILL.md +201 -0
  150. package/.agent/skills/doc.md +177 -0
  151. package/.agent/skills/frontend-design/SKILL.md +418 -0
  152. package/.agent/skills/frontend-design/animation-guide.md +331 -0
  153. package/.agent/skills/frontend-design/color-system.md +311 -0
  154. package/.agent/skills/frontend-design/decision-trees.md +418 -0
  155. package/.agent/skills/frontend-design/motion-graphics.md +306 -0
  156. package/.agent/skills/frontend-design/scripts/accessibility_checker.py +183 -0
  157. package/.agent/skills/frontend-design/scripts/ux_audit.py +722 -0
  158. package/.agent/skills/frontend-design/typography-system.md +345 -0
  159. package/.agent/skills/frontend-design/ux-psychology.md +1116 -0
  160. package/.agent/skills/frontend-design/visual-effects.md +383 -0
  161. package/.agent/skills/i18n-localization/SKILL.md +154 -0
  162. package/.agent/skills/i18n-localization/scripts/i18n_checker.py +241 -0
  163. package/.agent/skills/mcp-builder/SKILL.md +176 -0
  164. package/.agent/skills/web-design-guidelines/SKILL.md +57 -0
  165. package/.agent/workflows/brainstorm.md +113 -0
  166. package/.agent/workflows/create.md +59 -0
  167. package/.agent/workflows/debug.md +103 -0
  168. package/.agent/workflows/deploy.md +176 -0
  169. package/.agent/workflows/enhance.md +63 -0
  170. package/.agent/workflows/orchestrate.md +237 -0
  171. package/.agent/workflows/plan.md +89 -0
  172. package/.agent/workflows/preview.md +81 -0
  173. package/.agent/workflows/simple-test.md +42 -0
  174. package/.agent/workflows/status.md +86 -0
  175. package/.agent/workflows/structured-orchestrate.md +180 -0
  176. package/.agent/workflows/test.md +144 -0
  177. package/.agent/workflows/ui-ux-pro-max.md +296 -0
  178. package/.claude/settings.local.json +20 -8
  179. package/.env.example +56 -56
  180. package/CLAUDE.md +144 -108
  181. package/README.md +441 -441
  182. package/calc_tokens_weixin.js +81 -0
  183. package/cli/src/commands/chat.js +2 -1
  184. package/docs/CONTEXT_DESIGN.md +1596 -0
  185. package/examples/test-concurrent-chat.js +60 -60
  186. package/foliko-creative-3.png +0 -0
  187. package/foliko-creative-4.png +0 -0
  188. package/foliko-creative-5.png +0 -0
  189. package/package.json +2 -2
  190. package/plugins/default-plugins.js +2 -1
  191. package/plugins/extension-executor-plugin.js +91 -2
  192. package/plugins/file-system-plugin.js +2 -2
  193. package/plugins/memory-plugin.js +984 -0
  194. package/plugins/session-plugin.js +57 -1
  195. package/plugins/weixin-plugin.js +33 -23
  196. package/skills/find-skills/AGENTS.md +162 -162
  197. package/skills/find-skills/SKILL.md +133 -133
  198. package/skills/poster-guide/SKILL.md +1059 -0
  199. package/skills/python-plugin-dev/SKILL.md +238 -238
  200. package/skills/skill-guide/SKILL.md +130 -108
  201. package/src/capabilities/skill-manager.js +99 -0
  202. package/src/core/agent-chat.js +620 -141
  203. package/src/core/agent-context.js +188 -0
  204. package/src/core/agent.js +6 -2
  205. package/src/core/context-manager.js +283 -0
  206. package/src/core/framework.js +264 -3
  207. package/src/core/plugin-manager.js +79 -2
  208. package/src/core/request-context.js +98 -0
  209. package/src/core/session-context.js +341 -0
  210. package/src/core/session-storage.js +274 -0
  211. package/src/executors/mcp-executor.js +2 -2
  212. package/src/utils/index.js +239 -67
  213. package/src/utils/plugin-helpers.js +17 -0
  214. package/story-cover-book-v2.png +0 -0
  215. package/story-cover-japanese-1.png +0 -0
  216. package/story-cover-japanese-2.png +0 -0
  217. package/story-cover-japanese-3.png +0 -0
  218. package/story-cover-moran.png +0 -0
  219. package/undefined.png +0 -0
  220. package//346/265/267/346/212/245/346/217/222/344/273/266.md +621 -0
  221. package/.agent/agents/code-assistant.json +0 -14
  222. package/.agent/agents/email-assistant.json +0 -14
  223. package/.agent/agents/file-assistant.json +0 -15
  224. package/.agent/agents/system-assistant.json +0 -15
  225. package/.agent/agents/web-assistant.json +0 -12
  226. package/.agent/data/ambient/goals.json +0 -50
  227. package/.agent/data/ambient/memories.json +0 -7
  228. package/.agent/data/scheduler/tasks.json +0 -1
  229. package/.agent/package.json +0 -8
  230. package/.agent/plugins/__pycache__/test_plugin.cpython-312.pyc +0 -0
  231. package/.agent/plugins/daytona/README.md +0 -89
  232. package/.agent/plugins/daytona/index.js +0 -377
  233. package/.agent/plugins/daytona/package.json +0 -12
  234. package/.agent/plugins/marknative/README.md +0 -134
  235. package/.agent/plugins/marknative/index.js +0 -228
  236. package/.agent/plugins/marknative/package.json +0 -12
  237. package/.agent/plugins/marknative/update-readme.js +0 -134
  238. package/.agent/plugins/system-info/index.js +0 -387
  239. package/.agent/plugins/system-info/package.json +0 -4
  240. package/.agent/plugins/system-info/test.js +0 -40
  241. package/.agent/plugins/temp-repo/LICENSE +0 -201
  242. package/.agent/plugins/test_plugin.py +0 -304
  243. package/.agent/python-scripts/test_sample.py +0 -24
  244. package/.agent/skills/agent-browser/SKILL.md +0 -311
  245. package/.agent/skills/agent-browser/TEST_PLAN.md +0 -200
  246. package/.agent/skills/sysinfo/SKILL.md +0 -38
  247. package/.agent/skills/sysinfo/system-info.sh +0 -130
  248. package/.agent/skills/workflow/SKILL.md +0 -324
  249. package/.agent/workflows/email-digest.json +0 -50
  250. package/.agent/workflows/file-backup.json +0 -21
  251. package/.agent/workflows/get-ip-notify.json +0 -32
  252. package/.agent/workflows/news-aggregator.json +0 -93
  253. package/.agent/workflows/news-dashboard-v2.json +0 -94
  254. package/.agent/workflows/notification-batch.json +0 -32
  255. package/examples/test-chat-debug.js +0 -102
  256. package/examples/test-chat-result.js +0 -76
  257. package/examples/test-chat-stream-diff.js +0 -63
  258. /package/.agent/plugins/{temp-repo/puppeteer-plugin → puppeteer-plugin}/README.md +0 -0
  259. /package/.agent/plugins/{temp-repo/puppeteer-plugin → puppeteer-plugin}/package.json +0 -0
@@ -39,7 +39,11 @@ class SessionPlugin extends Plugin {
39
39
  maxHistoryLength: config.maxHistoryLength || 150, // 放宽到 150,Agent 已有智能压缩
40
40
  autoCleanup: config.autoCleanup||false, // 默认不开启自动清理,避免误删会话
41
41
  cleanupInterval: config.cleanupInterval || 5 * 60 * 1000, // 5分钟
42
- persistToStorage: config.persistToStorage !== false // 默认持久化到 storage
42
+ persistToStorage: config.persistToStorage !== false, // 默认持久化到 storage
43
+ // Session 钩子配置
44
+ onSessionStart: config.onSessionStart || null,
45
+ onSessionEnd: config.onSessionEnd || null,
46
+ onSessionCreated: config.onSessionCreated || null
43
47
  }
44
48
  // console.log('SessionPlugin config:', this.config)
45
49
  this._framework = null
@@ -287,6 +291,15 @@ class SessionPlugin extends Plugin {
287
291
 
288
292
  this._sessions.set(id, session)
289
293
  this._saveToStorage(session)
294
+
295
+ // 触发 session:created 事件
296
+ this._events.emit('session:created', session)
297
+
298
+ // 调用 onSessionCreated 钩子
299
+ if (this.config.onSessionCreated) {
300
+ this._callHook(this.config.onSessionCreated, session)
301
+ }
302
+
290
303
  return session
291
304
  }
292
305
 
@@ -340,6 +353,15 @@ class SessionPlugin extends Plugin {
340
353
  log.warn('Invalid message format, skipping:', { sessionId, message });
341
354
  return session;
342
355
  }
356
+
357
+ // 触发 session:started 事件(首次添加消息时)
358
+ if (session.messages.length === 0) {
359
+ this._events.emit('session:started', session)
360
+ if (this.config.onSessionStart) {
361
+ this._callHook(this.config.onSessionStart, session)
362
+ }
363
+ }
364
+
343
365
  session.messages.push(message)
344
366
  session.lastActive = new Date()
345
367
 
@@ -483,6 +505,40 @@ class SessionPlugin extends Plugin {
483
505
  this._events.off(event, listener)
484
506
  }
485
507
 
508
+ /**
509
+ * 调用会话钩子
510
+ * @param {Function} hook - 钩子函数
511
+ * @param {Object} session - 会话对象
512
+ * @private
513
+ */
514
+ _callHook(hook, session) {
515
+ if (typeof hook === 'function') {
516
+ try {
517
+ const result = hook(session)
518
+ if (result && typeof result.catch === 'function') {
519
+ result.catch(err => log.warn('Session hook error:', err.message))
520
+ }
521
+ } catch (err) {
522
+ log.warn('Session hook error:', err.message)
523
+ }
524
+ }
525
+ }
526
+
527
+ /**
528
+ * 结束会话(触发 session:ended 事件)
529
+ * 当会话完成处理时调用
530
+ * @param {string} sessionId - 会话 ID
531
+ */
532
+ endSession(sessionId) {
533
+ const session = this.getSession(sessionId)
534
+ if (session) {
535
+ this._events.emit('session:ended', session)
536
+ if (this.config.onSessionEnd) {
537
+ this._callHook(this.config.onSessionEnd, session)
538
+ }
539
+ }
540
+ }
541
+
486
542
  /**
487
543
  * 启动自动清理定时器
488
544
  */
@@ -6,7 +6,7 @@
6
6
  * - forceLogin: 是否强制重新扫码登录
7
7
  * - qrcodeTerminal: 是否在终端渲染二维码 (默认 true)
8
8
  */
9
-
9
+ const { CLEAR_LINE, CYAN, DIM, GREEN, RED, YELLOW, colored } = require('../cli/src/utils/ansi');
10
10
  const { Plugin } = require('../src/core/plugin-base')
11
11
  const { logger } = require('../src/utils/logger')
12
12
  const log = logger.child('WeChat')
@@ -372,8 +372,9 @@ class WeixinPlugin extends Plugin {
372
372
  return { agent, sessionId: `weixin_${userId}` }
373
373
  }
374
374
 
375
- // 创建新 agent
376
- const agent = this._framework.createSessionAgent(`weixin_${userId}`, {
375
+ // 创建新 agent - 和 CLI 一样使用 createAgent
376
+ const agent = this._framework.createAgent({
377
+ name: `weixin_${userId}`,
377
378
  systemPrompt: this.systemPrompt,
378
379
  sharedPrompt: `工作目录: {{WORK_DIR}}`,
379
380
  metadata: { WORK_DIR: process.cwd() }
@@ -466,14 +467,21 @@ class WeixinPlugin extends Plugin {
466
467
  await new Promise((resolve) => setTimeout(resolve, 1000))
467
468
 
468
469
  try {
469
- const result = await agent.chat(text, {
470
- sessionId: sessionId
471
- })
472
- const fullResponse = cleanResponse(result.message || '')
470
+ // 使用 chatStream 保持和 CLI 一致的行为
471
+ let fullResponse = '';
472
+ for await (const chunk of agent.chatStream(text, { sessionId })) {
473
+ if (chunk.type === 'text') {
474
+ fullResponse += chunk.text;
475
+ } else if (chunk.type === 'tool-call') {
476
+ log.info(`[工具调用] ${chunk.toolName}`);
477
+ } else if (chunk.type === 'error') {
478
+ log.warn(' Chat stream error:', chunk.error);
479
+ }
480
+ }
481
+ const response = cleanResponse(fullResponse);
473
482
 
474
- if (fullResponse) {
475
- await this._sendMessageBatch(originalMsg, userId, fullResponse, true)
476
- // log.info(` 回复成功 (${fullResponse.length} 字符)`)
483
+ if (response) {
484
+ await this._sendMessageBatch(originalMsg, userId, response, true)
477
485
  }
478
486
  } catch (err) {
479
487
  log.error(' Media chat error:', err)
@@ -506,21 +514,23 @@ class WeixinPlugin extends Plugin {
506
514
  await new Promise((resolve) => setTimeout(resolve, 1000))
507
515
 
508
516
  try {
509
- // 使用非流式响应
510
- const result = await agent.chat(text, {
511
- sessionId: sessionId
512
- })
513
- const fullResponse = cleanResponse(result.message || '')
514
-
515
- // 保存助手回复到历史(使用 SessionPlugin)
516
- // if (this._sessionPlugin) {
517
- // this._sessionPlugin.addMessage(sessionId, { role: 'assistant', content: fullResponse })
518
- // }
517
+ // 使用 chatStream 保持和 CLI 一致的行为
518
+ let fullResponse = '';
519
+ for await (const chunk of agent.chatStream(text, { sessionId })) {
520
+ if (chunk.type === 'text') {
521
+ fullResponse += chunk.text;
522
+ } else if (chunk.type === 'tool-call') {
523
+ // 发送工具调用提示
524
+ log.info(`[工具调用] ${chunk.toolName}`);
525
+ } else if (chunk.type === 'error') {
526
+ log.warn(' Chat stream error:', chunk.error);
527
+ }
528
+ }
529
+ const response = cleanResponse(fullResponse);
519
530
 
520
531
  // 发送回复(超过500字自动分批)
521
- if (fullResponse) {
522
- await this._sendMessageBatch(originalMsg, userId, fullResponse, true)
523
- // log.info(` 回复成功 (${fullResponse.length} 字符)`)
532
+ if (response) {
533
+ await this._sendMessageBatch(originalMsg, userId, response, true)
524
534
  } else {
525
535
  await this._sendMessageBatch(originalMsg, userId, '抱歉,我没有收到有效的回复。', true)
526
536
  }
@@ -1,162 +1,162 @@
1
- # AGENTS.md
2
-
3
- This file provides guidance to AI coding agents working on the `skills` CLI codebase.
4
-
5
- ## Project Overview
6
-
7
- `skills` is the CLI for the open agent skills ecosystem.
8
-
9
- ## Commands
10
-
11
- | Command | Description |
12
- | ----------------------------- | --------------------------------------------------- |
13
- | `skills` | Show banner with available commands |
14
- | `skills add <pkg>` | Install skills from git repos, URLs, or local paths |
15
- | `skills experimental_install` | Restore skills from skills-lock.json |
16
- | `skills experimental_sync` | Sync skills from node_modules into agent dirs |
17
- | `skills list` | List installed skills (alias: `ls`) |
18
- | `skills check` | Check for available skill updates |
19
- | `skills update` | Update all skills to latest versions |
20
- | `skills init [name]` | Create a new SKILL.md template |
21
-
22
- Aliases: `skills a` works for `add`. `skills i`, `skills install` (no args) restore from `skills-lock.json`. `skills ls` works for `list`. `skills experimental_install` restores from `skills-lock.json`. `skills experimental_sync` crawls `node_modules` for skills.
23
-
24
- ## Architecture
25
-
26
- ```
27
- src/
28
- ├── cli.ts # Main entry point, command routing, init/check/update
29
- ├── cli.test.ts # CLI tests
30
- ├── add.ts # Core add command logic
31
- ├── add.test.ts # Add command tests
32
- ├── list.ts # List installed skills command
33
- ├── list.test.ts # List command tests
34
- ├── agents.ts # Agent definitions and detection
35
- ├── installer.ts # Skill installation logic (symlink/copy) + listInstalledSkills
36
- ├── skills.ts # Skill discovery and parsing
37
- ├── skill-lock.ts # Global lock file management (~/.agents/.skill-lock.json)
38
- ├── local-lock.ts # Local lock file management (skills-lock.json, checked in)
39
- ├── sync.ts # Sync command - crawl node_modules for skills
40
- ├── source-parser.ts # Parse git URLs, GitHub shorthand, local paths
41
- ├── git.ts # Git clone operations
42
- ├── telemetry.ts # Anonymous usage tracking
43
- ├── types.ts # TypeScript types
44
- ├── mintlify.ts # Mintlify skill fetching (legacy)
45
- ├── providers/ # Remote skill providers (GitHub, HuggingFace, Mintlify)
46
- │ ├── index.ts
47
- │ ├── registry.ts
48
- │ ├── types.ts
49
- │ ├── huggingface.ts
50
- │ └── mintlify.ts
51
- ├── init.test.ts # Init command tests
52
- └── test-utils.ts # Test utilities
53
-
54
- tests/
55
- ├── sanitize-name.test.ts # Tests for sanitizeName (path traversal prevention)
56
- ├── skill-matching.test.ts # Tests for filterSkills (multi-word skill name matching)
57
- ├── source-parser.test.ts # Tests for URL/path parsing
58
- ├── installer-symlink.test.ts # Tests for symlink installation
59
- ├── list-installed.test.ts # Tests for listing installed skills
60
- ├── skill-path.test.ts # Tests for skill path handling
61
- ├── wellknown-provider.test.ts # Tests for well-known provider
62
- └── dist.test.ts # Tests for built distribution
63
- ```
64
-
65
- ## Update Checking System
66
-
67
- ### How `skills check` and `skills update` Work
68
-
69
- 1. Read `~/.agents/.skill-lock.json` for installed skills
70
- 2. For each skill, get `skillFolderHash` from lock file
71
- 3. POST to `https://add-skill.vercel.sh/check-updates` with:
72
- ```json
73
- {
74
- "skills": [{ "name": "...", "source": "...", "skillFolderHash": "..." }],
75
- "forceRefresh": true
76
- }
77
- ```
78
- 4. API fetches fresh content from GitHub, computes hash, compares
79
- 5. Returns list of skills with different hashes (updates available)
80
-
81
- ### Why `forceRefresh: true`?
82
-
83
- Both `check` and `update` always send `forceRefresh: true`. This ensures the API fetches fresh content from GitHub rather than using its Redis cache.
84
-
85
- **Without forceRefresh:** Users saw phantom "updates available" due to stale cached hashes. The fix was to always fetch fresh.
86
-
87
- **Tradeoff:** Slightly slower (GitHub API call per skill), but always accurate.
88
-
89
- ### Lock File Compatibility
90
-
91
- The lock file format is v3. Key field: `skillFolderHash` (GitHub tree SHA for the skill folder).
92
-
93
- If reading an older lock file version, it's wiped. Users must reinstall skills to populate the new format.
94
-
95
- ## Key Integration Points
96
-
97
- | Feature | Implementation |
98
- | -------------------------- | ------------------------------------------- |
99
- | `skills add` | `src/add.ts` - full implementation |
100
- | `skills experimental_sync` | `src/sync.ts` - crawl node_modules |
101
- | `skills check` | `POST /check-updates` API |
102
- | `skills update` | `POST /check-updates` + reinstall per skill |
103
-
104
- ## Development
105
-
106
- ```bash
107
- # Install dependencies
108
- pnpm install
109
-
110
- # Build
111
- pnpm build
112
-
113
- # Test locally
114
- pnpm dev add vercel-labs/agent-skills --list
115
- pnpm dev experimental_sync
116
- pnpm dev check
117
- pnpm dev update
118
- pnpm dev init my-skill
119
-
120
- # Run all tests
121
- pnpm test
122
-
123
- # Run specific test file(s)
124
- pnpm test tests/sanitize-name.test.ts
125
- pnpm test tests/skill-matching.test.ts tests/source-parser.test.ts
126
-
127
- # Type check
128
- pnpm type-check
129
-
130
- # Format code
131
- pnpm format
132
- ```
133
-
134
- ## Code Style
135
-
136
- This project uses Prettier for code formatting. **Always run `pnpm format` before committing changes** to ensure consistent formatting.
137
-
138
- ```bash
139
- # Format all files
140
- pnpm format
141
-
142
- # Check formatting without fixing
143
- pnpm prettier --check .
144
- ```
145
-
146
- CI will fail if code is not properly formatted.
147
-
148
- ## Publishing
149
-
150
- ```bash
151
- # 1. Bump version in package.json
152
- # 2. Build
153
- pnpm build
154
- # 3. Publish
155
- npm publish
156
- ```
157
-
158
- ## Adding a New Agent
159
-
160
- 1. Add the agent definition to `src/agents.ts`
161
- 2. Run `pnpm run -C scripts validate-agents.ts` to validate
162
- 3. Run `pnpm run -C scripts sync-agents.ts` to update README.md
1
+ # AGENTS.md
2
+
3
+ This file provides guidance to AI coding agents working on the `skills` CLI codebase.
4
+
5
+ ## Project Overview
6
+
7
+ `skills` is the CLI for the open agent skills ecosystem.
8
+
9
+ ## Commands
10
+
11
+ | Command | Description |
12
+ | ----------------------------- | --------------------------------------------------- |
13
+ | `skills` | Show banner with available commands |
14
+ | `skills add <pkg>` | Install skills from git repos, URLs, or local paths |
15
+ | `skills experimental_install` | Restore skills from skills-lock.json |
16
+ | `skills experimental_sync` | Sync skills from node_modules into agent dirs |
17
+ | `skills list` | List installed skills (alias: `ls`) |
18
+ | `skills check` | Check for available skill updates |
19
+ | `skills update` | Update all skills to latest versions |
20
+ | `skills init [name]` | Create a new SKILL.md template |
21
+
22
+ Aliases: `skills a` works for `add`. `skills i`, `skills install` (no args) restore from `skills-lock.json`. `skills ls` works for `list`. `skills experimental_install` restores from `skills-lock.json`. `skills experimental_sync` crawls `node_modules` for skills.
23
+
24
+ ## Architecture
25
+
26
+ ```
27
+ src/
28
+ ├── cli.ts # Main entry point, command routing, init/check/update
29
+ ├── cli.test.ts # CLI tests
30
+ ├── add.ts # Core add command logic
31
+ ├── add.test.ts # Add command tests
32
+ ├── list.ts # List installed skills command
33
+ ├── list.test.ts # List command tests
34
+ ├── agents.ts # Agent definitions and detection
35
+ ├── installer.ts # Skill installation logic (symlink/copy) + listInstalledSkills
36
+ ├── skills.ts # Skill discovery and parsing
37
+ ├── skill-lock.ts # Global lock file management (~/.agents/.skill-lock.json)
38
+ ├── local-lock.ts # Local lock file management (skills-lock.json, checked in)
39
+ ├── sync.ts # Sync command - crawl node_modules for skills
40
+ ├── source-parser.ts # Parse git URLs, GitHub shorthand, local paths
41
+ ├── git.ts # Git clone operations
42
+ ├── telemetry.ts # Anonymous usage tracking
43
+ ├── types.ts # TypeScript types
44
+ ├── mintlify.ts # Mintlify skill fetching (legacy)
45
+ ├── providers/ # Remote skill providers (GitHub, HuggingFace, Mintlify)
46
+ │ ├── index.ts
47
+ │ ├── registry.ts
48
+ │ ├── types.ts
49
+ │ ├── huggingface.ts
50
+ │ └── mintlify.ts
51
+ ├── init.test.ts # Init command tests
52
+ └── test-utils.ts # Test utilities
53
+
54
+ tests/
55
+ ├── sanitize-name.test.ts # Tests for sanitizeName (path traversal prevention)
56
+ ├── skill-matching.test.ts # Tests for filterSkills (multi-word skill name matching)
57
+ ├── source-parser.test.ts # Tests for URL/path parsing
58
+ ├── installer-symlink.test.ts # Tests for symlink installation
59
+ ├── list-installed.test.ts # Tests for listing installed skills
60
+ ├── skill-path.test.ts # Tests for skill path handling
61
+ ├── wellknown-provider.test.ts # Tests for well-known provider
62
+ └── dist.test.ts # Tests for built distribution
63
+ ```
64
+
65
+ ## Update Checking System
66
+
67
+ ### How `skills check` and `skills update` Work
68
+
69
+ 1. Read `~/.agents/.skill-lock.json` for installed skills
70
+ 2. For each skill, get `skillFolderHash` from lock file
71
+ 3. POST to `https://add-skill.vercel.sh/check-updates` with:
72
+ ```json
73
+ {
74
+ "skills": [{ "name": "...", "source": "...", "skillFolderHash": "..." }],
75
+ "forceRefresh": true
76
+ }
77
+ ```
78
+ 4. API fetches fresh content from GitHub, computes hash, compares
79
+ 5. Returns list of skills with different hashes (updates available)
80
+
81
+ ### Why `forceRefresh: true`?
82
+
83
+ Both `check` and `update` always send `forceRefresh: true`. This ensures the API fetches fresh content from GitHub rather than using its Redis cache.
84
+
85
+ **Without forceRefresh:** Users saw phantom "updates available" due to stale cached hashes. The fix was to always fetch fresh.
86
+
87
+ **Tradeoff:** Slightly slower (GitHub API call per skill), but always accurate.
88
+
89
+ ### Lock File Compatibility
90
+
91
+ The lock file format is v3. Key field: `skillFolderHash` (GitHub tree SHA for the skill folder).
92
+
93
+ If reading an older lock file version, it's wiped. Users must reinstall skills to populate the new format.
94
+
95
+ ## Key Integration Points
96
+
97
+ | Feature | Implementation |
98
+ | -------------------------- | ------------------------------------------- |
99
+ | `skills add` | `src/add.ts` - full implementation |
100
+ | `skills experimental_sync` | `src/sync.ts` - crawl node_modules |
101
+ | `skills check` | `POST /check-updates` API |
102
+ | `skills update` | `POST /check-updates` + reinstall per skill |
103
+
104
+ ## Development
105
+
106
+ ```bash
107
+ # Install dependencies
108
+ pnpm install
109
+
110
+ # Build
111
+ pnpm build
112
+
113
+ # Test locally
114
+ pnpm dev add vercel-labs/agent-skills --list
115
+ pnpm dev experimental_sync
116
+ pnpm dev check
117
+ pnpm dev update
118
+ pnpm dev init my-skill
119
+
120
+ # Run all tests
121
+ pnpm test
122
+
123
+ # Run specific test file(s)
124
+ pnpm test tests/sanitize-name.test.ts
125
+ pnpm test tests/skill-matching.test.ts tests/source-parser.test.ts
126
+
127
+ # Type check
128
+ pnpm type-check
129
+
130
+ # Format code
131
+ pnpm format
132
+ ```
133
+
134
+ ## Code Style
135
+
136
+ This project uses Prettier for code formatting. **Always run `pnpm format` before committing changes** to ensure consistent formatting.
137
+
138
+ ```bash
139
+ # Format all files
140
+ pnpm format
141
+
142
+ # Check formatting without fixing
143
+ pnpm prettier --check .
144
+ ```
145
+
146
+ CI will fail if code is not properly formatted.
147
+
148
+ ## Publishing
149
+
150
+ ```bash
151
+ # 1. Bump version in package.json
152
+ # 2. Build
153
+ pnpm build
154
+ # 3. Publish
155
+ npm publish
156
+ ```
157
+
158
+ ## Adding a New Agent
159
+
160
+ 1. Add the agent definition to `src/agents.ts`
161
+ 2. Run `pnpm run -C scripts validate-agents.ts` to validate
162
+ 3. Run `pnpm run -C scripts sync-agents.ts` to update README.md