foliko 2.0.5 → 2.0.6
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/.editorconfig +56 -56
- package/.lintstagedrc +7 -7
- package/.prettierignore +29 -29
- package/.prettierrc +11 -11
- package/CLAUDE.md +3 -0
- package/Dockerfile +63 -63
- 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/install.ps1 +129 -129
- package/install.sh +121 -121
- 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/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/index.js +82 -22
- package/plugins/executors/data-splitter/PROMPT.md +13 -0
- package/plugins/executors/data-splitter/index.js +5 -4
- 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/skills/find-skills/SKILL.md +133 -133
- 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 +224 -9
- package/skills/workflows/workflow-troubleshooting/SKILL.md +221 -281
- package/src/agent/chat.js +48 -27
- package/src/agent/main.js +34 -13
- 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 +5 -2
- package/src/common/constants.js +12 -0
- package/src/common/error-capture.js +91 -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 +23 -11
- package/src/index.js +4 -0
- package/src/plugin/base.js +908 -5
- package/src/plugin/manager.js +29 -8
- package/src/tool/schema.js +32 -9
- package/website/index.html +821 -0
|
@@ -53,15 +53,14 @@ class PythonPluginLoader extends Plugin {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
let desc = '## 【Python 插件】\n\n'
|
|
56
|
-
desc += 'Python
|
|
56
|
+
desc += '每个 Python 插件自动注册为 `python:<插件名>` 扩展,通过 `ext_skill` + `ext_call` 统一调用:\n\n'
|
|
57
57
|
|
|
58
58
|
for (const [name, plugin] of this._pythonPlugins) {
|
|
59
|
-
desc += `###
|
|
59
|
+
desc += `### python:${plugin.info.name}\n`
|
|
60
60
|
desc += `${plugin.info.description || ''}\n\n`
|
|
61
61
|
if (plugin.info.tools && Array.isArray(plugin.info.tools)) {
|
|
62
62
|
for (const tool of plugin.info.tools) {
|
|
63
|
-
|
|
64
|
-
desc += `- **${fullName}**: ${tool.description || '无描述'}\n`
|
|
63
|
+
desc += `- **${tool.name}**: ${tool.description || '无描述'}\n`
|
|
65
64
|
// 使用 zodSchemaToMarkdown 生成参数描述
|
|
66
65
|
const params = tool.params || {}
|
|
67
66
|
if (Object.keys(params).length > 0) {
|
|
@@ -82,7 +81,9 @@ class PythonPluginLoader extends Plugin {
|
|
|
82
81
|
}
|
|
83
82
|
|
|
84
83
|
desc += '**调用格式:**\n'
|
|
85
|
-
desc += '```\
|
|
84
|
+
desc += '```\n'
|
|
85
|
+
desc += '// 1. 查询参数\next_skill({ plugin: "python:<插件名>" })\n'
|
|
86
|
+
desc += '// 2. 调用\next_call({ plugin: "python:<插件名>", tool: "<工具名>", args: {...} })\n'
|
|
86
87
|
desc += '```\n'
|
|
87
88
|
return desc.trim()
|
|
88
89
|
}
|
|
@@ -151,7 +152,7 @@ class PythonPluginLoader extends Plugin {
|
|
|
151
152
|
// 注册插件的每个工具
|
|
152
153
|
if (pluginInfo.tools && Array.isArray(pluginInfo.tools)) {
|
|
153
154
|
for (const tool of pluginInfo.tools) {
|
|
154
|
-
this._registerPythonTool(pluginName, tool)
|
|
155
|
+
this._registerPythonTool(pluginName, tool, pluginInfo);
|
|
155
156
|
}
|
|
156
157
|
}
|
|
157
158
|
}
|
|
@@ -160,22 +161,32 @@ class PythonPluginLoader extends Plugin {
|
|
|
160
161
|
}
|
|
161
162
|
}
|
|
162
163
|
|
|
164
|
+
// 所有 Python 插件注册完毕后,强制失效 prompt 缓存,让 LLM 看到新的扩展
|
|
165
|
+
this._extensionExecutor?._invalidatePromptCaches?.(this._framework);
|
|
166
|
+
|
|
163
167
|
//log.info(` Total Python plugins: ${this._pythonPlugins.size}`)
|
|
164
168
|
}
|
|
165
169
|
|
|
166
170
|
/**
|
|
167
|
-
* 注册 Python
|
|
168
|
-
*
|
|
169
|
-
*
|
|
171
|
+
* 注册 Python 插件的单个工具到 ExtensionExecutor
|
|
172
|
+
*
|
|
173
|
+
* 每个 Python 插件注册为独立扩展 `python:<插件名>`,工具名是原始名(不带前缀)。
|
|
174
|
+
* LLM 通过以下方式调用:
|
|
175
|
+
* 1. 查询参数:ext_skill({ plugin: "python:<插件名>" })
|
|
176
|
+
* 2. 调用:ext_call({ plugin: "python:<插件名>", tool: "<工具名>", args: {...} })
|
|
177
|
+
*
|
|
178
|
+
* @param {string} pluginName Python 插件名(PLUGIN.name,例如 'stock')
|
|
179
|
+
* @param {Object} tool 工具定义对象
|
|
180
|
+
* @param {string} tool.name 工具名(PLUGIN.TOOLS[].name,例如 'get_price')
|
|
181
|
+
* @param {string} [tool.description] 工具描述(用于提示词)
|
|
182
|
+
* @param {Object} [tool.params] 工具参数定义(key → 类型占位符或 JSON Schema)
|
|
183
|
+
* @param {Object} [pluginMeta] 插件元信息(含 description),用于丰富扩展描述
|
|
170
184
|
*/
|
|
171
|
-
_registerPythonTool(pluginName, tool) {
|
|
185
|
+
_registerPythonTool(pluginName, tool, pluginMeta = null) {
|
|
172
186
|
if (!tool.name) return
|
|
173
187
|
|
|
174
|
-
// 格式:pluginname_toolname
|
|
175
|
-
const fullToolName = `${pluginName}_${tool.name}`
|
|
176
|
-
|
|
177
188
|
const toolDef = {
|
|
178
|
-
name:
|
|
189
|
+
name: tool.name, // 工具原始名(如 get_price),不带 pluginName_ 前缀
|
|
179
190
|
description: tool.description || `${pluginName} 的 ${tool.name} 工具`,
|
|
180
191
|
inputSchema: this._parseToolParams(tool.params || {}),
|
|
181
192
|
execute: async (args) => {
|
|
@@ -183,26 +194,33 @@ class PythonPluginLoader extends Plugin {
|
|
|
183
194
|
}
|
|
184
195
|
}
|
|
185
196
|
|
|
197
|
+
// 每个 Python 插件注册为独立扩展 `python:<pluginName>`
|
|
198
|
+
// 优先用 PLUGIN.description,fallback 到默认描述
|
|
199
|
+
const extName = `python:${pluginName}`;
|
|
200
|
+
const extDescription = pluginMeta?.description
|
|
201
|
+
? pluginMeta.description
|
|
202
|
+
: `Python 插件 ${pluginName}`;
|
|
203
|
+
const pluginInfo = {
|
|
204
|
+
name: extName,
|
|
205
|
+
description: extDescription,
|
|
206
|
+
version: pluginMeta?.version || '1.0.0',
|
|
207
|
+
};
|
|
208
|
+
|
|
186
209
|
try {
|
|
187
|
-
// 直接注册到 ExtensionExecutor(如果可用)
|
|
188
210
|
if (this._extensionExecutor) {
|
|
189
|
-
this._extensionExecutor.registerTool(
|
|
190
|
-
'python', // 插件名,用于 ext_call 的 plugin 参数
|
|
191
|
-
{ name: 'python', description: 'Python 插件工具', version: '1.0.0' },
|
|
192
|
-
toolDef
|
|
193
|
-
)
|
|
211
|
+
this._extensionExecutor.registerTool(extName, pluginInfo, toolDef);
|
|
194
212
|
} else {
|
|
195
|
-
// 回退到基类的 registerTool
|
|
213
|
+
// 回退到基类的 registerTool(带 pluginName 前缀以避免冲突)
|
|
196
214
|
this.registerTool({
|
|
197
|
-
name:
|
|
198
|
-
description:
|
|
215
|
+
name: `${pluginName}_${tool.name}`,
|
|
216
|
+
description: tool.description || `${pluginName} 的 ${tool.name} 工具`,
|
|
199
217
|
pluginName: pluginName,
|
|
200
218
|
inputSchema: this._parseToolParams(tool.params || {}),
|
|
201
219
|
execute: toolDef.execute
|
|
202
|
-
})
|
|
220
|
+
});
|
|
203
221
|
}
|
|
204
222
|
} catch (err) {
|
|
205
|
-
log.error(` Failed to register tool ${
|
|
223
|
+
log.error(` Failed to register tool ${tool.name} for ${extName}:`, err.message)
|
|
206
224
|
}
|
|
207
225
|
}
|
|
208
226
|
|