foliko 1.1.24 → 1.1.25

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.
@@ -1451,6 +1451,51 @@
1451
1451
  "text": "<think>我已经获取了完整的思考分析。让我整理成一份清晰的分析报告给用户。</think>\n\n\n\n---\n\n## 🧠 持续思考结果 - Website_v2 vs Foliko 真实项目\n\n### 📊 完整差距分析\n\n基于对项目源码的深度分析,发现以下关键差距:\n\n---\n\n### ⚠️ 重大问题\n\n| 问题 | 网站描述 | 实际项目 | 影响 |\n|------|----------|----------|------|\n| **版本号** | v2.0 | 1.1.23 | ❌ 严重不一致 |\n| **安装脚本** | folikoai.com (不可用) | npm install -g foliko | ❌ 用户无法安装 |\n| **SPEC.md** | 声称深色主题 | 实际是浅色主题 | ⚠️ 文档混乱 |\n\n---\n\n### ✅ 准确的描述\n\n| 模块 | 描述 | 实际状态 |\n|------|------|----------|\n| 插件数量 | 40+ | ✅ 41个插件 |\n| AI 支持 | Anthropic/DeepSeek/MiniMax | ✅ 正确 |\n| 语言 | 100% JavaScript | ✅ 正确 |\n| 核心架构 | pluginManager/toolRegistry | ✅ 准确 |\n\n---\n\n### 📋 网站缺失的功能(真实项目有)\n\n| 类别 | 缺失插件 | 功能说明 |\n|------|----------|----------|\n| **交易** | gate-trading.js | Gate.io 加密货币交易 |\n| **Web服务** | web-plugin.js | HTTP 服务、Webhook |\n| **规则引擎** | rules-plugin.js | 行为规则控制 |\n| **协调器** | coordinator-plugin.js | 多 Worker 协作 |\n| **审计** | audit-plugin.js | 日志记录、统计 |\n| **飞书** | feishu-plugin.js | 飞书消息推送 |\n| **海报** | 内置 @chnak/poster-design | 海报生成 |\n\n---\n\n### 📂 Examples 示例(网站完全没提到)\n\n```\nexamples/\n├── basic.js # 基础示例\n├── bootstrap.js # 引导配置\n├── ambient-example.js # Ambient Agent 示例 ⭐\n├── mcp-example.js # MCP 服务器示例\n├── skill-example.js # 技能系统示例\n├── workflow.js # 工作流示例\n├── test-telegram.js # Telegram 集成\n├── test-weixin-feishu.js # 微信/飞书集成\n└── test-web-plugin.js # Web 服务示例\n```\n\n---\n\n### 🔧 真实项目亮点(网站未展示)\n\n| 亮点 | 说明 |\n|------|------|\n| **Ambient Agent** | 8个文件,36,000+ 行代码,比描述更完善 |\n| **ExplorerLoop** | 完整的探索循环机制 |\n| **多思考模式** | reflect, brainstorm, plan, analyze |\n| **MCP 支持** | 支持 Model Context Protocol |\n| **Docker 支持** | docker-compose.yml 已配置 |\n| **完整 CI/CD** | Husky + lint-staged |\n\n---\n\n### 🎯 建议行动(按优先级)\n\n| 优先级 | 任务 | 原因 |\n|--------|------|------|\n| **P0** | 修复版本号:v2.0 → 1.1.23 | 版本信息错误 |\n| **P0** | 修复安装命令:改为 npm install | 当前命令不可用 |\n| **P1** | 添加缺失插件展示 | 展示完整能力 |\n| **P1** | 添加 Examples 示例代码 | 开发者最需要 |\n| **P2** | 添加 Docker 部署说明 | 完善部署文档 |\n| **P2** | 同步 SPEC.md 与实际 CSS | 文档一致性 |\n\n---\n\n### 💬 讨论问题\n\n1. **安装脚本**:`folikoai.com` 需要部署吗?还是只用 npm?\n\n2. **版本号**:要保持 v2.0 营销名,还是改成 1.1.23?\n\n3. **插件展示**:需要把所有 41 个插件都展示吗?还是重点展示核心的?\n\n4. **示例代码**:是否需要添加 examples 中的代码示例到网站?\n\n---\n\n**持续思考正在后台运行,有新想法会通知你!** 🔔"
1452
1452
  }
1453
1453
  ]
1454
+ },
1455
+ {
1456
+ "role": "user",
1457
+ "content": "停止持续讨论"
1458
+ },
1459
+ {
1460
+ "role": "assistant",
1461
+ "content": [
1462
+ {
1463
+ "type": "text",
1464
+ "text": "<think>用户要求停止持续思考和讨论模式。</think>\n\n\n\n\n"
1465
+ },
1466
+ {
1467
+ "type": "tool-call",
1468
+ "toolCallId": "call_17ac5d4c565b4fd79fd440b4",
1469
+ "toolName": "ext_call",
1470
+ "input": {
1471
+ "plugin": "think",
1472
+ "tool": "think_stop"
1473
+ }
1474
+ }
1475
+ ]
1476
+ },
1477
+ {
1478
+ "role": "tool",
1479
+ "content": [
1480
+ {
1481
+ "type": "tool-result",
1482
+ "toolCallId": "call_17ac5d4c565b4fd79fd440b4",
1483
+ "toolName": "ext_call",
1484
+ "output": {
1485
+ "type": "text",
1486
+ "value": "{\"success\":true,\"result\":{\"success\":true,\"message\":\"持续思考已停止\"}}"
1487
+ }
1488
+ }
1489
+ ]
1490
+ },
1491
+ {
1492
+ "role": "assistant",
1493
+ "content": [
1494
+ {
1495
+ "type": "text",
1496
+ "text": "<think>已停止思考,现在给用户一个总结。</think>\n\n\n\n✅ **已停止持续思考和讨论模式**\n\n---\n\n### 📋 讨论总结\n\n针对 **website_v2** 的主要发现:\n\n| 状态 | 问题 | 建议 |\n|------|------|------|\n| ⚠️ | 版本号 v2.0 与实际 1.1.23 不符 | 修复 |\n| ⚠️ | 安装脚本域名不可用 | 改用 npm |\n| ❌ | 缺失多个插件展示 | 补充 |\n| ❌ | Examples 示例未展示 | 添加 |\n\n---\n\n### 🚀 快速行动项\n\n如果现在想做点什么,我建议:\n\n| 任务 | 预计时间 |\n|------|----------|\n| 1. 修复版本号和安装命令 | 5分钟 |\n| 2. 添加缺失插件展示 | 15分钟 |\n| 3. 添加代码示例到快速开始 | 20分钟 |\n| 4. 移动端菜单修复 | 15分钟 |\n\n---\n\n**随时说 \"继续讨论\" 或 \"开启思考\" 来恢复!**"
1497
+ }
1498
+ ]
1454
1499
  }
1455
1500
  ],
1456
1501
  "variables": {},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foliko",
3
- "version": "1.1.24",
3
+ "version": "1.1.25",
4
4
  "description": "简约的插件化 Agent 框架",
5
5
  "main": "src/index.js",
6
6
  "type": "commonjs",
@@ -29,6 +29,8 @@ class ThinkPlugin extends Plugin {
29
29
  this._reflectionChain = [] // 反思链
30
30
  this._continuousMode = false
31
31
  this._continuousTimer = null
32
+ this._continuousTopic = null
33
+ this._continuousMessages = [] // 持续思考的上下文消息
32
34
  this._pendingReflection = null
33
35
  }
34
36
 
@@ -116,6 +118,12 @@ class ThinkPlugin extends Plugin {
116
118
 
117
119
  /**
118
120
  * 触发主动思考
121
+ * @param {Object} args - 参数
122
+ * @param {string} args.topic - 思考主题
123
+ * @param {string} args.mode - 思考模式
124
+ * @param {number} args.depth - 思考深度
125
+ * @param {Object} args.agent - 外部 agent
126
+ * @param {Array} args.messages - 可选,上下文消息数组用于持续对话
119
127
  */
120
128
  async _triggerThinking(args) {
121
129
  const mode = args.mode || 'reflect'
@@ -123,6 +131,8 @@ class ThinkPlugin extends Plugin {
123
131
  const topic = args.topic || '刚才的对话还有什么可以改进或补充的地方?'
124
132
  // 支持外部传入 agent
125
133
  const externalAgent = args.agent
134
+ // 支持传入上下文消息
135
+ const contextMessages = args.messages
126
136
 
127
137
  try {
128
138
  // 检查 AI 配置
@@ -139,7 +149,16 @@ class ThinkPlugin extends Plugin {
139
149
 
140
150
  // 优先使用外部传入的 agent,否则使用缓存的 think agent
141
151
  const thinkAgent = externalAgent || this._thinkAgent || (this._thinkAgent = this._createThinkSubagent())
142
- const result = await thinkAgent.chat(reflectPrompt)
152
+
153
+ let result
154
+ if (contextMessages && contextMessages.length > 0) {
155
+ // 持续对话模式:传入上下文消息
156
+ const messages = [...contextMessages, { role: 'user', content: reflectPrompt }]
157
+ result = await thinkAgent.chatWithMessages(messages)
158
+ } else {
159
+ // 普通模式:新对话
160
+ result = await thinkAgent.chat(reflectPrompt)
161
+ }
143
162
 
144
163
  const thought = {
145
164
  id: Date.now(),
@@ -156,10 +175,14 @@ class ThinkPlugin extends Plugin {
156
175
  this._thoughts = this._thoughts.slice(-100)
157
176
  }
158
177
 
178
+ // 返回消息数组(用于持续对话)
179
+ if (contextMessages) {
180
+ thought.messages = [...contextMessages, { role: 'user', content: reflectPrompt }, { role: 'assistant', content: result.message }]
181
+ }
182
+
159
183
  // 触发思考完成事件(使用文档规定的字段结构)
160
184
  if (this._framework) {
161
185
  this._framework.emit('think:thought_completed', {
162
- mode: thought.mode,
163
186
  topic: thought.topic,
164
187
  thought: thought.result,
165
188
  depth: thought.depth
@@ -306,17 +329,28 @@ ${topic || '接下来的行动'}
306
329
 
307
330
  this._continuousMode = true
308
331
  this._continuousTopic = topic
332
+ this._continuousMessages = [] // 初始化上下文消息
309
333
 
310
334
  const runThink = async () => {
311
335
  if (!this._continuousMode) return
312
336
 
313
337
  try {
314
- await this._triggerThinking({
338
+ const result = await this._triggerThinking({
315
339
  topic: this._continuousTopic,
316
340
  mode: 'reflect',
317
- depth: 2
341
+ depth: 2,
342
+ messages: this._continuousMessages
318
343
  })
319
344
 
345
+ // 更新上下文消息(用于下次思考)
346
+ if (result.messages) {
347
+ this._continuousMessages = result.messages
348
+ // 限制上下文长度,最多保留 10 条消息
349
+ if (this._continuousMessages.length > 10) {
350
+ this._continuousMessages = this._continuousMessages.slice(-10)
351
+ }
352
+ }
353
+
320
354
  // 触发下一轮
321
355
  if (this._continuousMode) {
322
356
  this._continuousTimer = setTimeout(runThink, interval)
@@ -347,6 +381,7 @@ ${topic || '接下来的行动'}
347
381
  clearTimeout(this._continuousTimer)
348
382
  this._continuousTimer = null
349
383
  }
384
+ this._continuousMessages = [] // 清空上下文
350
385
  this._emitNotification('info', 'ℹ️ 持续思考已停止', '')
351
386
  return {
352
387
  success: true,
@@ -229,20 +229,26 @@ class Subagent extends EventEmitter {
229
229
 
230
230
  /**
231
231
  * 执行任务
232
- * @param {string} task - 任务描述
232
+ * @param {string|Array} taskOrMessages - 任务描述或消息数组
233
233
  * @param {Object} [options] - 选项
234
234
  * @param {number} [options.maxSteps] - 最大步数
235
235
  * @param {AbortSignal} [options.signal] - 中止信号
236
236
  * @param {number} [options.maxRetries] - 最大重试次数
237
237
  * @returns {Promise<{success: boolean, message: string, steps: number}>}
238
238
  */
239
- async chat(task, options = {}) {
239
+ async chat(taskOrMessages, options = {}) {
240
240
  const maxSteps = options?.maxSteps || 30;
241
241
  const maxRetries = options?.maxRetries ?? this.maxRetries;
242
242
  const retryDelay = options?.retryDelay ?? this.retryDelay;
243
243
  const aiProvider = this._getAIProvider();
244
- const messages = [];
245
- messages.push({ role: 'user', content: task });
244
+
245
+ // 支持传入消息数组(用于持续对话上下文)或单个任务字符串
246
+ let messages;
247
+ if (Array.isArray(taskOrMessages)) {
248
+ messages = [...taskOrMessages];
249
+ } else {
250
+ messages = [{ role: 'user', content: taskOrMessages }];
251
+ }
246
252
 
247
253
  // logger.info(
248
254
  // `[Subagent:${this.name}] chat called, maxRetries=${maxRetries}, disableTools=${this.disableTools}`