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.
- package/.agent/.shared/ui-ux-pro-max/data/charts.csv +26 -0
- package/.agent/.shared/ui-ux-pro-max/data/colors.csv +97 -0
- package/.agent/.shared/ui-ux-pro-max/data/icons.csv +101 -0
- package/.agent/.shared/ui-ux-pro-max/data/landing.csv +31 -0
- package/.agent/.shared/ui-ux-pro-max/data/products.csv +97 -0
- package/.agent/.shared/ui-ux-pro-max/data/prompts.csv +24 -0
- package/.agent/.shared/ui-ux-pro-max/data/react-performance.csv +45 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/react.csv +54 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/vue.csv +50 -0
- package/.agent/.shared/ui-ux-pro-max/data/styles.csv +59 -0
- package/.agent/.shared/ui-ux-pro-max/data/typography.csv +58 -0
- package/.agent/.shared/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
- package/.agent/.shared/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
- package/.agent/.shared/ui-ux-pro-max/data/web-interface.csv +31 -0
- 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 +258 -0
- package/.agent/.shared/ui-ux-pro-max/scripts/design_system.py +1067 -0
- package/.agent/.shared/ui-ux-pro-max/scripts/search.py +106 -0
- package/.agent/ARCHITECTURE.md +288 -0
- package/.agent/agents/ambient-agent.md +57 -0
- package/.agent/agents/debugger.md +55 -0
- package/.agent/agents/email-assistant.md +49 -0
- package/.agent/agents/file-manager.md +42 -0
- package/.agent/agents/python-developer.md +60 -0
- package/.agent/agents/scheduler.md +59 -0
- package/.agent/agents/web-developer.md +45 -0
- package/.agent/data/default.json +325 -21
- package/.agent/data/plugins-state.json +194 -162
- package/.agent/data/puppeteer-sessions/undefined.json +6 -0
- package/.agent/mcp_config.json +0 -1
- package/.agent/mcp_config_updated.json +12 -0
- package/.agent/plugins/poster-plugin/README.md +304 -0
- package/.agent/plugins/poster-plugin/fonts/NotoColorEmoji-Regular.ttf +0 -0
- package/.agent/plugins/poster-plugin/fonts/PatuaOne-Regular.ttf +0 -0
- package/.agent/plugins/poster-plugin/fonts//345/276/256/350/275/257/351/233/205/351/273/221.ttf +0 -0
- 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
- package/.agent/plugins/poster-plugin/index.js +13 -0
- package/.agent/plugins/poster-plugin/package.json +28 -0
- package/.agent/plugins/poster-plugin/src/canvas.js +161 -0
- package/.agent/plugins/poster-plugin/src/components/arrow.js +84 -0
- package/.agent/plugins/poster-plugin/src/components/avatar.js +71 -0
- package/.agent/plugins/poster-plugin/src/components/badge.js +85 -0
- package/.agent/plugins/poster-plugin/src/components/card.js +88 -0
- package/.agent/plugins/poster-plugin/src/components/chart.js +127 -0
- package/.agent/plugins/poster-plugin/src/components/chip.js +88 -0
- package/.agent/plugins/poster-plugin/src/components/columns.js +107 -0
- package/.agent/plugins/poster-plugin/src/components/cta.js +85 -0
- package/.agent/plugins/poster-plugin/src/components/divider.js +55 -0
- package/.agent/plugins/poster-plugin/src/components/feature.js +85 -0
- package/.agent/plugins/poster-plugin/src/components/featureGrid.js +112 -0
- package/.agent/plugins/poster-plugin/src/components/grid.js +118 -0
- package/.agent/plugins/poster-plugin/src/components/imageFrame.js +155 -0
- package/.agent/plugins/poster-plugin/src/components/index.js +62 -0
- package/.agent/plugins/poster-plugin/src/components/listItem.js +146 -0
- package/.agent/plugins/poster-plugin/src/components/notification.js +123 -0
- package/.agent/plugins/poster-plugin/src/components/progress.js +79 -0
- package/.agent/plugins/poster-plugin/src/components/progressCircle.js +117 -0
- package/.agent/plugins/poster-plugin/src/components/quote.js +97 -0
- package/.agent/plugins/poster-plugin/src/components/rating.js +85 -0
- package/.agent/plugins/poster-plugin/src/components/star.js +70 -0
- package/.agent/plugins/poster-plugin/src/components/statCard.js +105 -0
- package/.agent/plugins/poster-plugin/src/components/stepper.js +118 -0
- package/.agent/plugins/poster-plugin/src/components/table.js +159 -0
- package/.agent/plugins/poster-plugin/src/components/tagCloud.js +78 -0
- package/.agent/plugins/poster-plugin/src/components/timeline.js +105 -0
- package/.agent/plugins/poster-plugin/src/components/watermark.js +52 -0
- package/.agent/plugins/poster-plugin/src/composer.js +1904 -0
- package/.agent/plugins/poster-plugin/src/elements/artText.js +60 -0
- package/.agent/plugins/poster-plugin/src/elements/background.js +52 -0
- package/.agent/plugins/poster-plugin/src/elements/circle.js +31 -0
- package/.agent/plugins/poster-plugin/src/elements/image.js +71 -0
- package/.agent/plugins/poster-plugin/src/elements/index.js +26 -0
- package/.agent/plugins/poster-plugin/src/elements/line.js +23 -0
- package/.agent/plugins/poster-plugin/src/elements/polygon.js +63 -0
- package/.agent/plugins/poster-plugin/src/elements/rectangle.js +32 -0
- package/.agent/plugins/poster-plugin/src/elements/svg.js +92 -0
- package/.agent/plugins/poster-plugin/src/elements/text.js +107 -0
- package/.agent/plugins/poster-plugin/src/fonts.js +233 -0
- package/.agent/plugins/poster-plugin/src/index.js +1658 -0
- package/.agent/plugins/poster-plugin/src/presets.js +36 -0
- package/.agent/plugins/poster-plugin/src/templates/business.js +60 -0
- package/.agent/plugins/poster-plugin/src/templates/gradient.js +64 -0
- package/.agent/plugins/poster-plugin/src/templates/index.js +43 -0
- package/.agent/plugins/poster-plugin/src/templates/modern.js +69 -0
- package/.agent/plugins/poster-plugin/src/templates/simple.js +58 -0
- package/.agent/plugins/poster-plugin/src/templates/social.js +62 -0
- package/.agent/plugins/poster-plugin/src/templates/tech.js +84 -0
- package/.agent/plugins/{temp-repo/puppeteer-plugin → puppeteer-plugin}/index.js +1 -1
- package/.agent/plugins.json +5 -11
- package/.agent/rules/GEMINI.md +273 -0
- package/.agent/rules/allow-rule.md +77 -0
- package/.agent/rules/log-rule.md +83 -0
- package/.agent/rules/security-rule.md +93 -0
- package/.agent/scripts/auto_preview.py +148 -0
- package/.agent/scripts/checklist.py +217 -0
- package/.agent/scripts/session_manager.py +120 -0
- package/.agent/scripts/verify_all.py +327 -0
- package/.agent/sessions/cli_default.json +419 -0
- package/.agent/sessions/weixin_o9cq80zgZqKPA2-s59PN43GdDy1w@im.wechat.json +2195 -0
- package/.agent/skills/api-patterns/SKILL.md +81 -0
- package/.agent/skills/api-patterns/api-style.md +42 -0
- package/.agent/skills/api-patterns/auth.md +24 -0
- package/.agent/skills/api-patterns/documentation.md +26 -0
- package/.agent/skills/api-patterns/graphql.md +41 -0
- package/.agent/skills/api-patterns/rate-limiting.md +31 -0
- package/.agent/skills/api-patterns/response.md +37 -0
- package/.agent/skills/api-patterns/rest.md +40 -0
- package/.agent/skills/api-patterns/scripts/api_validator.py +211 -0
- package/.agent/skills/api-patterns/security-testing.md +122 -0
- package/.agent/skills/api-patterns/trpc.md +41 -0
- package/.agent/skills/api-patterns/versioning.md +22 -0
- package/.agent/skills/app-builder/SKILL.md +75 -0
- package/.agent/skills/app-builder/agent-coordination.md +71 -0
- package/.agent/skills/app-builder/feature-building.md +53 -0
- package/.agent/skills/app-builder/project-detection.md +34 -0
- package/.agent/skills/app-builder/scaffolding.md +118 -0
- package/.agent/skills/app-builder/tech-stack.md +40 -0
- package/.agent/skills/app-builder/templates/SKILL.md +39 -0
- package/.agent/skills/app-builder/templates/astro-static/TEMPLATE.md +76 -0
- package/.agent/skills/app-builder/templates/chrome-extension/TEMPLATE.md +92 -0
- package/.agent/skills/app-builder/templates/cli-tool/TEMPLATE.md +88 -0
- package/.agent/skills/app-builder/templates/electron-desktop/TEMPLATE.md +88 -0
- package/.agent/skills/app-builder/templates/express-api/TEMPLATE.md +83 -0
- package/.agent/skills/app-builder/templates/flutter-app/TEMPLATE.md +90 -0
- package/.agent/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +90 -0
- package/.agent/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +122 -0
- package/.agent/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +122 -0
- package/.agent/skills/app-builder/templates/nextjs-static/TEMPLATE.md +169 -0
- package/.agent/skills/app-builder/templates/nuxt-app/TEMPLATE.md +134 -0
- package/.agent/skills/app-builder/templates/python-fastapi/TEMPLATE.md +83 -0
- package/.agent/skills/app-builder/templates/react-native-app/TEMPLATE.md +119 -0
- package/.agent/skills/architecture/SKILL.md +55 -0
- package/.agent/skills/architecture/context-discovery.md +43 -0
- package/.agent/skills/architecture/examples.md +94 -0
- package/.agent/skills/architecture/pattern-selection.md +68 -0
- package/.agent/skills/architecture/patterns-reference.md +50 -0
- package/.agent/skills/architecture/trade-off-analysis.md +77 -0
- package/.agent/skills/clean-code/SKILL.md +201 -0
- package/.agent/skills/doc.md +177 -0
- package/.agent/skills/frontend-design/SKILL.md +418 -0
- package/.agent/skills/frontend-design/animation-guide.md +331 -0
- package/.agent/skills/frontend-design/color-system.md +311 -0
- package/.agent/skills/frontend-design/decision-trees.md +418 -0
- package/.agent/skills/frontend-design/motion-graphics.md +306 -0
- package/.agent/skills/frontend-design/scripts/accessibility_checker.py +183 -0
- package/.agent/skills/frontend-design/scripts/ux_audit.py +722 -0
- package/.agent/skills/frontend-design/typography-system.md +345 -0
- package/.agent/skills/frontend-design/ux-psychology.md +1116 -0
- package/.agent/skills/frontend-design/visual-effects.md +383 -0
- package/.agent/skills/i18n-localization/SKILL.md +154 -0
- package/.agent/skills/i18n-localization/scripts/i18n_checker.py +241 -0
- package/.agent/skills/mcp-builder/SKILL.md +176 -0
- package/.agent/skills/web-design-guidelines/SKILL.md +57 -0
- package/.agent/workflows/brainstorm.md +113 -0
- package/.agent/workflows/create.md +59 -0
- package/.agent/workflows/debug.md +103 -0
- package/.agent/workflows/deploy.md +176 -0
- package/.agent/workflows/enhance.md +63 -0
- package/.agent/workflows/orchestrate.md +237 -0
- package/.agent/workflows/plan.md +89 -0
- package/.agent/workflows/preview.md +81 -0
- package/.agent/workflows/simple-test.md +42 -0
- package/.agent/workflows/status.md +86 -0
- package/.agent/workflows/structured-orchestrate.md +180 -0
- package/.agent/workflows/test.md +144 -0
- package/.agent/workflows/ui-ux-pro-max.md +296 -0
- package/.claude/settings.local.json +20 -8
- package/.env.example +56 -56
- package/CLAUDE.md +144 -108
- package/README.md +441 -441
- package/calc_tokens_weixin.js +81 -0
- package/cli/src/commands/chat.js +2 -1
- package/docs/CONTEXT_DESIGN.md +1596 -0
- package/examples/test-concurrent-chat.js +60 -60
- package/foliko-creative-3.png +0 -0
- package/foliko-creative-4.png +0 -0
- package/foliko-creative-5.png +0 -0
- package/package.json +2 -2
- package/plugins/default-plugins.js +2 -1
- package/plugins/extension-executor-plugin.js +91 -2
- package/plugins/file-system-plugin.js +2 -2
- package/plugins/memory-plugin.js +984 -0
- package/plugins/session-plugin.js +57 -1
- package/plugins/weixin-plugin.js +33 -23
- package/skills/find-skills/AGENTS.md +162 -162
- package/skills/find-skills/SKILL.md +133 -133
- package/skills/poster-guide/SKILL.md +1059 -0
- package/skills/python-plugin-dev/SKILL.md +238 -238
- package/skills/skill-guide/SKILL.md +130 -108
- package/src/capabilities/skill-manager.js +99 -0
- package/src/core/agent-chat.js +620 -141
- package/src/core/agent-context.js +188 -0
- package/src/core/agent.js +6 -2
- package/src/core/context-manager.js +283 -0
- package/src/core/framework.js +264 -3
- package/src/core/plugin-manager.js +79 -2
- package/src/core/request-context.js +98 -0
- package/src/core/session-context.js +341 -0
- package/src/core/session-storage.js +274 -0
- package/src/executors/mcp-executor.js +2 -2
- package/src/utils/index.js +239 -67
- package/src/utils/plugin-helpers.js +17 -0
- package/story-cover-book-v2.png +0 -0
- package/story-cover-japanese-1.png +0 -0
- package/story-cover-japanese-2.png +0 -0
- package/story-cover-japanese-3.png +0 -0
- package/story-cover-moran.png +0 -0
- package/undefined.png +0 -0
- package//346/265/267/346/212/245/346/217/222/344/273/266.md +621 -0
- package/.agent/agents/code-assistant.json +0 -14
- package/.agent/agents/email-assistant.json +0 -14
- package/.agent/agents/file-assistant.json +0 -15
- package/.agent/agents/system-assistant.json +0 -15
- package/.agent/agents/web-assistant.json +0 -12
- package/.agent/data/ambient/goals.json +0 -50
- package/.agent/data/ambient/memories.json +0 -7
- package/.agent/data/scheduler/tasks.json +0 -1
- package/.agent/package.json +0 -8
- package/.agent/plugins/__pycache__/test_plugin.cpython-312.pyc +0 -0
- package/.agent/plugins/daytona/README.md +0 -89
- package/.agent/plugins/daytona/index.js +0 -377
- package/.agent/plugins/daytona/package.json +0 -12
- package/.agent/plugins/marknative/README.md +0 -134
- package/.agent/plugins/marknative/index.js +0 -228
- package/.agent/plugins/marknative/package.json +0 -12
- package/.agent/plugins/marknative/update-readme.js +0 -134
- package/.agent/plugins/system-info/index.js +0 -387
- package/.agent/plugins/system-info/package.json +0 -4
- package/.agent/plugins/system-info/test.js +0 -40
- package/.agent/plugins/temp-repo/LICENSE +0 -201
- package/.agent/plugins/test_plugin.py +0 -304
- package/.agent/python-scripts/test_sample.py +0 -24
- package/.agent/skills/agent-browser/SKILL.md +0 -311
- package/.agent/skills/agent-browser/TEST_PLAN.md +0 -200
- package/.agent/skills/sysinfo/SKILL.md +0 -38
- package/.agent/skills/sysinfo/system-info.sh +0 -130
- package/.agent/skills/workflow/SKILL.md +0 -324
- package/.agent/workflows/email-digest.json +0 -50
- package/.agent/workflows/file-backup.json +0 -21
- package/.agent/workflows/get-ip-notify.json +0 -32
- package/.agent/workflows/news-aggregator.json +0 -93
- package/.agent/workflows/news-dashboard-v2.json +0 -94
- package/.agent/workflows/notification-batch.json +0 -32
- package/examples/test-chat-debug.js +0 -102
- package/examples/test-chat-result.js +0 -76
- package/examples/test-chat-stream-diff.js +0 -63
- /package/.agent/plugins/{temp-repo/puppeteer-plugin → puppeteer-plugin}/README.md +0 -0
- /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
|
*/
|
package/plugins/weixin-plugin.js
CHANGED
|
@@ -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.
|
|
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
|
-
|
|
470
|
-
|
|
471
|
-
})
|
|
472
|
-
|
|
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 (
|
|
475
|
-
await this._sendMessageBatch(originalMsg, userId,
|
|
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
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
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 (
|
|
522
|
-
await this._sendMessageBatch(originalMsg, userId,
|
|
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
|