foliko 2.0.5 → 2.0.7
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/.claude/settings.local.json +4 -1
- package/.cli_default_systemPrompt.md +291 -0
- package/CLAUDE.md +3 -0
- package/README.md +20 -3
- package/docs/architecture.md +34 -2
- package/docs/extensions.md +199 -0
- package/docs/migration.md +100 -0
- package/docs/public-api.md +280 -24
- package/docs/usage.md +122 -30
- package/package.json +1 -1
- package/plugins/core/audit/index.js +1 -1
- package/plugins/core/default/bootstrap.js +44 -19
- package/plugins/core/python-loader/index.js +43 -25
- package/plugins/core/scheduler/index.js +1 -0
- package/plugins/core/skill-manager/PROMPT.md +6 -0
- package/plugins/core/skill-manager/index.js +402 -115
- package/plugins/core/sub-agent/PROMPT.md +10 -0
- package/plugins/core/sub-agent/index.js +36 -3
- package/plugins/core/think/index.js +1 -0
- package/plugins/core/workflow/context.js +941 -0
- package/plugins/core/workflow/engine.js +66 -0
- package/plugins/core/workflow/examples/01-basic.js +42 -0
- package/plugins/core/workflow/examples/01-basic.json +30 -0
- package/plugins/core/workflow/examples/02-choice.js +75 -0
- package/plugins/core/workflow/examples/02-choice.json +59 -0
- package/plugins/core/workflow/examples/03-chain-style.js +114 -0
- package/plugins/core/workflow/examples/03-each.json +41 -0
- package/plugins/core/workflow/examples/04-parallel.js +52 -0
- package/plugins/core/workflow/examples/04-parallel.json +51 -0
- package/plugins/core/workflow/examples/05-chain-style.json +68 -0
- package/plugins/core/workflow/examples/05-each.js +65 -0
- package/plugins/core/workflow/examples/06-script.js +82 -0
- package/plugins/core/workflow/examples/07-module-export.js +43 -0
- package/plugins/core/workflow/examples/08-default-export.js +29 -0
- package/plugins/core/workflow/examples/09-next-with-args.js +50 -0
- package/plugins/core/workflow/examples/10-logger.js +34 -0
- package/plugins/core/workflow/examples/11-storage.js +68 -0
- package/plugins/core/workflow/examples/simple.js +77 -0
- package/plugins/core/workflow/examples/simple.json +75 -0
- package/plugins/core/workflow/index.js +204 -78
- package/plugins/core/workflow/js-runner.js +318 -0
- package/plugins/core/workflow/json-runner.js +323 -0
- package/plugins/core/workflow/stages/action.js +211 -0
- package/plugins/core/workflow/stages/choice.js +74 -0
- package/plugins/core/workflow/stages/delay.js +73 -0
- package/plugins/core/workflow/stages/each.js +123 -0
- package/plugins/core/workflow/stages/parallel.js +69 -0
- package/plugins/core/workflow/stages/try.js +142 -0
- package/plugins/executors/data-splitter/PROMPT.md +13 -0
- package/plugins/executors/data-splitter/index.js +8 -6
- package/plugins/executors/extension/extension-registry.js +145 -0
- package/plugins/executors/extension/index.js +405 -437
- package/plugins/executors/extension/prompt-builder.js +359 -0
- package/plugins/executors/extension/skill-helper.js +143 -0
- package/plugins/messaging/feishu/index.js +5 -3
- package/plugins/messaging/qq/index.js +6 -4
- package/plugins/messaging/telegram/index.js +6 -3
- package/plugins/messaging/weixin/index.js +5 -3
- package/plugins/tools/PROMPT.md +26 -0
- package/plugins/tools/index.js +6 -5
- package/sandbox/check-context.js +5 -0
- package/sandbox/test-context.js +27 -0
- package/sandbox/test-fixes.js +40 -0
- package/sandbox/test-hello-js.js +46 -0
- package/skills/foliko/AGENTS.md +196 -43
- package/skills/foliko/SKILL.md +157 -28
- package/skills/mcp/SKILL.md +77 -118
- package/skills/plugins/SKILL.md +89 -3
- package/skills/python/SKILL.md +57 -39
- package/skills/skill-guide/SKILL.md +42 -34
- package/skills/workflows/SKILL.md +753 -436
- package/src/agent/chat.js +56 -28
- package/src/agent/main.js +39 -14
- package/src/agent/prompt-registry.js +56 -16
- package/src/agent/prompts/PROMPT.md +3 -0
- package/src/agent/sub.js +1 -1
- package/src/cli/ui/chat-ui-old.js +5 -2
- package/src/cli/ui/chat-ui.js +9 -5
- package/src/common/constants.js +12 -0
- package/src/common/error-capture.js +91 -0
- package/src/common/json-safe.js +20 -0
- package/src/common/logger.js +2 -2
- package/src/context/compressor.js +6 -2
- package/src/executors/mcp-executor.js +105 -125
- package/src/framework/framework.js +78 -12
- package/src/index.js +4 -0
- package/src/plugin/base.js +908 -5
- package/src/plugin/manager.js +124 -9
- package/src/tool/schema.js +32 -9
- package/src/utils/sandbox.js +1 -1
- package/website/index.html +821 -0
- package/skills/workflows/workflow-troubleshooting/DEBUGGING.md +0 -197
- package/skills/workflows/workflow-troubleshooting/SKILL.md +0 -391
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
## 大数据处理能力
|
|
2
|
+
|
|
3
|
+
你具备自动处理大文件和大网页的能力:
|
|
4
|
+
|
|
5
|
+
1. **内容预览**:当工具返回的内容很大时,先用 `get_content_preview` 查看统计信息
|
|
6
|
+
2. **分拆处理**:如果内容超过 10 万字符,用 `split_and_process` 将内容分块,每块交给独立的子 Agent 并行处理
|
|
7
|
+
3. **自动汇总**:`split_and_process` 会自动汇总所有子 Agent 的处理结果,你只需基于汇总结果回答即可
|
|
8
|
+
4. **性能提示**:分拆处理会并行运行多个子 Agent,处理大文件时效率很高
|
|
9
|
+
|
|
10
|
+
### 使用建议
|
|
11
|
+
- 读取大文件(> 100KB)时:先读取,如果内容太大,用 `split_and_process` 分拆分析
|
|
12
|
+
- 抓取网页时:如果页面内容过多,用 `split_and_process` 分拆提取
|
|
13
|
+
- 分拆时指定清晰的任务描述,例如"提取所有关键代码函数"、"总结每段内容要点"
|
|
@@ -2,12 +2,15 @@
|
|
|
2
2
|
* DataSplitterPlugin — 大数据自动分拆插件
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
+
const path = require('path');
|
|
5
6
|
const { Plugin } = require('../../../src/plugin/base');
|
|
6
7
|
const { z } = require('zod');
|
|
7
8
|
const { logger } = require('../../../src/common/logger');
|
|
8
9
|
const { DataSplitter } = require('../../../src/utils/data-splitter');
|
|
10
|
+
const { safeStringify } = require('../../../src/common/json-safe');
|
|
9
11
|
|
|
10
12
|
const AUTO_SPLIT_THRESHOLD = 50000;
|
|
13
|
+
const PROMPT_DIR = __dirname;
|
|
11
14
|
|
|
12
15
|
class DataSplitterPlugin extends Plugin {
|
|
13
16
|
constructor(config = {}) {
|
|
@@ -43,11 +46,10 @@ class DataSplitterPlugin extends Plugin {
|
|
|
43
46
|
prompts = [
|
|
44
47
|
{
|
|
45
48
|
name: 'data-splitter-rules',
|
|
46
|
-
|
|
49
|
+
file: path.join(PROMPT_DIR, 'PROMPT.md'),
|
|
50
|
+
scope: 'global',
|
|
51
|
+
priority: 50,
|
|
47
52
|
description: '大工具结果自动分拆规则',
|
|
48
|
-
provider: function () {
|
|
49
|
-
return this._getPromptRules();
|
|
50
|
-
},
|
|
51
53
|
},
|
|
52
54
|
];
|
|
53
55
|
|
|
@@ -176,9 +178,9 @@ class DataSplitterPlugin extends Plugin {
|
|
|
176
178
|
|
|
177
179
|
let checkContent = '';
|
|
178
180
|
if (result && typeof result === 'object' && result.data) {
|
|
179
|
-
checkContent = typeof result.data === 'string' ? result.data :
|
|
181
|
+
checkContent = typeof result.data === 'string' ? result.data : safeStringify(result.data);
|
|
180
182
|
} else {
|
|
181
|
-
checkContent = typeof result === 'string' ? result :
|
|
183
|
+
checkContent = typeof result === 'string' ? result : safeStringify(result);
|
|
182
184
|
}
|
|
183
185
|
if (!checkContent || checkContent.length < this.config.autoSplitThreshold) return;
|
|
184
186
|
};
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* ExtensionRegistry - 扩展注册表
|
|
5
|
+
* 管理扩展插件及其工具的增删改查
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
class ExtensionRegistry {
|
|
9
|
+
constructor(framework) {
|
|
10
|
+
this._extensions = new Map();
|
|
11
|
+
this._framework = framework;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// ============ 注册 ============
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 注册或获取扩展条目
|
|
18
|
+
*/
|
|
19
|
+
_getOrCreate(pluginName, pluginInfo) {
|
|
20
|
+
if (!this._extensions.has(pluginName)) {
|
|
21
|
+
this._extensions.set(pluginName, {
|
|
22
|
+
name: pluginInfo.name || pluginName,
|
|
23
|
+
description: pluginInfo.description || '',
|
|
24
|
+
version: pluginInfo.version || '1.0.0',
|
|
25
|
+
tools: [],
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return this._extensions.get(pluginName);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 注册扩展工具
|
|
33
|
+
*/
|
|
34
|
+
registerTool(pluginName, pluginInfo, toolDef) {
|
|
35
|
+
if (!toolDef || !toolDef.name) return false;
|
|
36
|
+
|
|
37
|
+
const ext = this._getOrCreate(pluginName, pluginInfo);
|
|
38
|
+
|
|
39
|
+
const toolEntry = {
|
|
40
|
+
name: toolDef.name,
|
|
41
|
+
description: toolDef.description || '',
|
|
42
|
+
inputSchema: toolDef.inputSchema,
|
|
43
|
+
execute: toolDef.execute,
|
|
44
|
+
};
|
|
45
|
+
if (toolDef._options) {
|
|
46
|
+
toolEntry._options = toolDef._options;
|
|
47
|
+
}
|
|
48
|
+
if (toolDef._rawSchema) {
|
|
49
|
+
toolEntry._rawSchema = toolDef._rawSchema;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const existingIdx = ext.tools.findIndex((t) => t.name === toolDef.name);
|
|
53
|
+
if (existingIdx >= 0) {
|
|
54
|
+
ext.tools[existingIdx] = toolEntry;
|
|
55
|
+
} else {
|
|
56
|
+
ext.tools.push(toolEntry);
|
|
57
|
+
}
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* 注销扩展工具
|
|
63
|
+
* @returns {boolean} 是否真正移除了扩展
|
|
64
|
+
*/
|
|
65
|
+
unregisterTool(pluginName, toolName) {
|
|
66
|
+
const ext = this._extensions.get(pluginName);
|
|
67
|
+
if (!ext) return false;
|
|
68
|
+
|
|
69
|
+
const idx = ext.tools.findIndex((t) => t.name === toolName);
|
|
70
|
+
if (idx >= 0) {
|
|
71
|
+
ext.tools.splice(idx, 1);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// 如果扩展没有工具了,删除整个扩展
|
|
75
|
+
if (ext.tools.length === 0) {
|
|
76
|
+
this._extensions.delete(pluginName);
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* 清空指定扩展的所有工具
|
|
84
|
+
*/
|
|
85
|
+
clearPlugin(pluginName) {
|
|
86
|
+
const ext = this._extensions.get(pluginName);
|
|
87
|
+
if (!ext) return false;
|
|
88
|
+
ext.tools = [];
|
|
89
|
+
this._extensions.delete(pluginName);
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* 清空所有
|
|
95
|
+
*/
|
|
96
|
+
clear() {
|
|
97
|
+
this._extensions.clear();
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// ============ 查询 ============
|
|
101
|
+
|
|
102
|
+
hasPlugin(name) {
|
|
103
|
+
return this._extensions.has(name);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
hasTool(pluginName, toolName) {
|
|
107
|
+
const ext = this._extensions.get(pluginName);
|
|
108
|
+
if (!ext) return false;
|
|
109
|
+
return ext.tools.some((t) => t.name === toolName);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
getPlugin(name) {
|
|
113
|
+
return this._extensions.get(name) || null;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
getTool(pluginName, toolName) {
|
|
117
|
+
const ext = this._extensions.get(pluginName);
|
|
118
|
+
if (!ext) return null;
|
|
119
|
+
return ext.tools.find((t) => t.name === toolName) || null;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
listPlugins() {
|
|
123
|
+
return Array.from(this._extensions.keys());
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
listTools(pluginName) {
|
|
127
|
+
const ext = this._extensions.get(pluginName);
|
|
128
|
+
return ext ? ext.tools : [];
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
getAll() {
|
|
132
|
+
return Array.from(this._extensions.entries()).map(([name, ext]) => ({
|
|
133
|
+
name,
|
|
134
|
+
description: ext.description,
|
|
135
|
+
version: ext.version,
|
|
136
|
+
tools: ext.tools,
|
|
137
|
+
}));
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
size() {
|
|
141
|
+
return this._extensions.size;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
module.exports = { ExtensionRegistry };
|