🚀 feat: 记忆系统架构升级 + declarative.dpml命名重构 + MCP边界条件Bug修复
## 📊 变更概览 - declarative.dpml架构升级:memory.xml → declarative.dpml (认知科学语义精准) - MCP环境边界条件Bug修复:解决空文件导致的记忆保存失败问题 - 跨项目角色发现Bug修复:优化环境检测顺序,MCP环境角色发现从1个→9个 - XML转义处理增强:完整的存储-显示分离架构,数据安全+用户友好 ## 🎯 核心成就 ✅ declarative.dpml升级:100%测试验证通过 ✅ 边界条件修复:三重保护机制,文件状态自动检测修复 ✅ 角色发现修复:环境检测顺序优化,跨项目使用稳定 ✅ 存储分离架构:XML转义安全存储 + AI友好显示 ## 📁 主要文件变更 - RememberCommand.js/RecallCommand.js: declarative.dpml升级 + 边界条件修复 - PackageDiscovery.js: 环境检测顺序优化 - 新增思维模式文件: recall-xml.thought.md, remember-xml.thought.md - 新增测试: memory-dpml-integration.test.js - 完整文档: PR文档 + Bug报告 + 修复总结 🎉 架构升级验证:MCP重启测试100%通过,零中断平滑切换
This commit is contained in:
@ -471,21 +471,21 @@ class PackageDiscovery extends BaseDiscovery {
|
||||
* @returns {Promise<string>} 环境类型:development, npx, local, unknown
|
||||
*/
|
||||
async _detectExecutionEnvironment() {
|
||||
// 1. 检查是否在开发环境
|
||||
if (await this._isDevelopmentMode()) {
|
||||
return 'development'
|
||||
}
|
||||
|
||||
// 2. 检查是否通过npx执行
|
||||
// 1. 优先检查npx执行(具体环境,避免MCP误判)
|
||||
if (this._isNpxExecution()) {
|
||||
return 'npx'
|
||||
}
|
||||
|
||||
// 3. 检查是否在node_modules中安装
|
||||
// 2. 检查本地安装(具体环境)
|
||||
if (this._isLocalInstallation()) {
|
||||
return 'local'
|
||||
}
|
||||
|
||||
// 3. 最后检查开发环境(通用环境,优先级降低)
|
||||
if (await this._isDevelopmentMode()) {
|
||||
return 'development'
|
||||
}
|
||||
|
||||
return 'unknown'
|
||||
}
|
||||
|
||||
@ -673,11 +673,24 @@ class PackageDiscovery extends BaseDiscovery {
|
||||
*/
|
||||
async _findFallbackRoot() {
|
||||
try {
|
||||
// 优先使用__dirname计算包根目录(更可靠的路径)
|
||||
const packageRoot = path.resolve(__dirname, '../../../../../')
|
||||
|
||||
// 验证是否为有效的dpml-prompt包
|
||||
const packageJsonPath = path.join(packageRoot, 'package.json')
|
||||
if (await fs.pathExists(packageJsonPath)) {
|
||||
const packageJson = await fs.readJSON(packageJsonPath)
|
||||
if (packageJson.name === 'dpml-prompt') {
|
||||
return packageRoot
|
||||
}
|
||||
}
|
||||
|
||||
// 后备方案:使用模块解析(使用__dirname作为basedir)
|
||||
const resolve = require('resolve')
|
||||
const packageJsonPath = resolve.sync('dpml-prompt/package.json', {
|
||||
basedir: process.cwd()
|
||||
const resolvedPackageJsonPath = resolve.sync('dpml-prompt/package.json', {
|
||||
basedir: __dirname
|
||||
})
|
||||
return path.dirname(packageJsonPath)
|
||||
return path.dirname(resolvedPackageJsonPath)
|
||||
} catch (error) {
|
||||
return null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user