foliko 1.1.91 → 1.1.93

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foliko",
3
- "version": "1.1.91",
3
+ "version": "1.1.93",
4
4
  "description": "简约的插件化 Agent 框架",
5
5
  "main": "src/index.js",
6
6
  "type": "commonjs",
@@ -137,26 +137,25 @@ function loadAgentConfig(framework, agentDir = '.foliko') {
137
137
  }
138
138
 
139
139
  // 添加 .foliko/skills 目录(不存在则创建)
140
- const skillsDir = path.join(resolvedDir, 'skills')
141
- if (fs.existsSync(resolvedDir) && !fs.existsSync(skillsDir)) {
142
- fs.mkdirSync(skillsDir, { recursive: true })
143
- //log.info(` Created skills directory: ${skillsDir}`)
140
+ // 使用相对路径存储,这样 setCwd 时能自动随新 cwd 重新解析
141
+ const projectSkillsRel = path.join(agentDir, 'skills')
142
+ const projectSkillsAbs = path.resolve(cwd, projectSkillsRel)
143
+ if (fs.existsSync(resolvedDir) && !fs.existsSync(projectSkillsAbs)) {
144
+ fs.mkdirSync(projectSkillsAbs, { recursive: true })
145
+ //log.info(` Created skills directory: ${projectSkillsAbs}`)
144
146
  }
145
- if (fs.existsSync(skillsDir)) {
146
- config.skillsDirs.push(skillsDir)
147
+ if (fs.existsSync(projectSkillsAbs)) {
148
+ config.skillsDirs.push(projectSkillsRel)
147
149
  }
148
150
 
149
- // 添加 .foliko/skills 目录(不存在则创建)
150
- const cmdskillsDir = path.join(cmdDir, 'skills')
151
- // if (fs.existsSync(resolvedDir) && !fs.existsSync(cmdskillsDir)) {
152
- // fs.mkdirSync(cmdskillsDir, { recursive: true })
153
- // //log.info(` Created skills directory: ${cmdskillsDir}`)
154
- // }
155
- if (fs.existsSync(cmdskillsDir)) {
156
- config.skillsDirs.push(cmdskillsDir)
151
+ // 添加 cwd 下的 skills/ 目录(相对路径,与 setCwd 联动)
152
+ const cmdskillsRel = 'skills'
153
+ const cmdskillsAbs = path.resolve(cwd, cmdskillsRel)
154
+ if (fs.existsSync(cmdskillsAbs)) {
155
+ config.skillsDirs.push(cmdskillsRel)
157
156
  }
158
157
 
159
- // 添加 agentDir 父目录的 skills/ 目录
158
+ // 添加框架根目录的 skills/ 目录(绝对路径,与 cwd 无关)
160
159
  const parentDir = path.dirname(__dirname)
161
160
  const rootSkillsDir = path.join(parentDir, 'skills')
162
161
  if (fs.existsSync(rootSkillsDir)) {
@@ -622,7 +622,9 @@ class ExtensionExecutorPlugin extends Plugin {
622
622
  this._extensions.clear();
623
623
  const plugins = framework.pluginManager.getAll();
624
624
  for (const { instance: plugin } of plugins) {
625
- this._scanPluginTools(plugin);
625
+ // 使用 _rescanPluginTools 以正确处理 skill-manager 的 'skill' extName 映射
626
+ // (_scanPluginTools 不传 extName 时会用 pluginName,对 skill-manager 不正确)
627
+ this._rescanPluginTools(plugin);
626
628
  }
627
629
  // 重新获取 MCP executor 引用
628
630
  this._mcpExecutor = framework.pluginManager?.get('mcp') || null;
@@ -938,6 +938,8 @@ class SkillManagerPlugin extends Plugin {
938
938
  reload(framework) {
939
939
  // log.info(' Reloading...');
940
940
  this._skills.clear();
941
+ // 清空 this.tools,避免旧 skill 命令残留(否则 setCwd 后旧 cwd 的命令会留在 _extensions 中)
942
+ this.tools = {};
941
943
  this._loaded = false;
942
944
  this._framework = framework;
943
945
  this._loadAllSkills();
@@ -117,6 +117,9 @@ const DEFAULT_PLUGIN_PRIORITY = 100;
117
117
  const SYSTEM_PLUGINS = new Set([
118
118
  'ai', 'defaults', 'tools', 'skill-manager', 'session',
119
119
  'storage', 'audit', 'rules', 'file-system',
120
+ // extension-executor 也是 system:true,必须保留以保证 rescanProject 后
121
+ // 用户持有的 extExec 引用始终有效,否则该实例会被卸载重建导致引用悬空
122
+ 'extension-executor',
120
123
  ]);
121
124
 
122
125
  /** Agent 配置目录名 */