Develop (#70)
* 重构ActionCommand和LearnCommand,更新DPMLContentParser和SemanticRenderer的导入路径,确保模块结构一致性。删除不再使用的DPMLContentParser和SemanticRenderer文件,优化代码结构,提升可维护性。 * 重构PromptX资源协议系统,采用极简两层协议架构,删除不必要的语义层,优化路径解析和资源加载流程。引入AI协作优化,支持直接生成完整协议路径,提升系统性能和用户体验。整体架构简化60%,实现零配置启动,显著降低内存占用和启动时间。 * optimize:优化女娲提示词 * Optimize:更新记忆策略文档,增加角色专业记忆的独特价值和工作流程,强调角色记忆与客户端记忆的差异,优化记忆引导话术和决策规则,以提升用户对专业记忆系统的理解和应用。 * feature:增加 Sean 角色 * optimize:优化记忆格式化逻辑,确保完整记忆内容不被截断,同时更新工具定义中的描述,增强用户对记忆回想器的理解和使用指导。 * feat: 添加DACP服务支持,允许通过命令行调用DACP专业服务,增强AI角色的执行能力,同时更新相关依赖和工具定义。 * feat: 在MCPServerCommand和MCPStreamableHttpCommand中添加'promptx_dacp'参数映射,同时在DACPCommand中优化参数处理逻辑,以支持数组参数的正确解析。 * feat: 更新DACP演示服务,重命名服务和描述,简化功能,删除不必要的日历和文档操作,增强演示效果。同时,优化了API接口和README文档,确保用户更易于理解和使用。 * feat: 添加DACP邮件发送功能,支持真实发送与Demo模式,增强邮件发送的配置管理和错误提示,优化用户体验。 * feat: 更新女娲和Sean角色文档,增强角色身份、核心特质和决策框架的描述,优化内容结构,提升用户理解和使用体验。同时,更新产品哲学知识体系,明确矛盾驱动和简洁性原则的应用。 * Add product management submodule * fix: 修复 recall 和 learn 的 bug * refactor: 把 hello 改成 welcome * feat: 添加DACP服务启动脚本和测试命令,更新相关依赖,优化配置文件路径处理 * fix: 更新pnpm-lock.yaml以匹配DACP依赖,解决CI中--frozen-lockfile的错误 * 更新DACP白皮书的更新日期至2025-01-19;在DACPConfigManager中优化配置管理,支持项目级和用户级配置的优先级处理,增强错误提示信息,更新相关方法以支持异步操作。 * fix: 统一Pouch命令路径获取机制,解决Issue #69记忆持久化问题 修复多实例MCP环境下的路径不一致问题: - RememberCommand: 使用ResourceManager替代DirectoryService直接调用 - RecallCommand: 使用ResourceManager替代DirectoryService直接调用 - RegisterCommand: 使用ResourceManager+DirectoryService统一路径获取 核心改进: 1. 所有命令现在使用相同的getGlobalResourceManager()初始化 2. 通过resourceManager.initializeWithNewArchitecture()确保路径一致性 3. 实现"要对一起对,要错一起错"的一致性原则 测试验证: - 记忆写入和读取使用相同项目路径 - 多实例环境下路径解析行为完全一致 - 向后兼容,无破坏性变更 Fixes #69 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@ -2,6 +2,7 @@ const BasePouchCommand = require('../BasePouchCommand')
|
||||
const fs = require('fs-extra')
|
||||
const path = require('path')
|
||||
const { COMMANDS } = require('../../../../constants')
|
||||
const { getGlobalResourceManager } = require('../../resource')
|
||||
|
||||
/**
|
||||
* 记忆检索锦囊命令
|
||||
@ -10,6 +11,8 @@ const { COMMANDS } = require('../../../../constants')
|
||||
class RecallCommand extends BasePouchCommand {
|
||||
constructor () {
|
||||
super()
|
||||
// 复用ActionCommand的ResourceManager方式
|
||||
this.resourceManager = getGlobalResourceManager()
|
||||
}
|
||||
|
||||
getPurpose () {
|
||||
@ -99,16 +102,20 @@ ${formattedMemories}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有记忆(支持多行格式)
|
||||
* 获取所有记忆(支持多行格式,使用ResourceManager路径获取)
|
||||
*/
|
||||
async getAllMemories (query) {
|
||||
this.lastSearchCount = 0
|
||||
const memories = []
|
||||
|
||||
// 读取单一记忆文件
|
||||
const { getDirectoryService } = require('../../../utils/DirectoryService')
|
||||
const directoryService = getDirectoryService()
|
||||
const memoryDir = await directoryService.getMemoryDirectory()
|
||||
// 确保ResourceManager已初始化(就像ActionCommand那样)
|
||||
if (!this.resourceManager.initialized) {
|
||||
await this.resourceManager.initializeWithNewArchitecture()
|
||||
}
|
||||
|
||||
// 通过ResourceManager获取项目路径(与ActionCommand一致)
|
||||
const projectPath = await this.getProjectPath()
|
||||
const memoryDir = path.join(projectPath, '.promptx', 'memory')
|
||||
const memoryFile = path.join(memoryDir, 'declarative.md')
|
||||
|
||||
try {
|
||||
@ -131,6 +138,14 @@ ${formattedMemories}
|
||||
return memories
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取项目路径(复用ActionCommand逻辑)
|
||||
*/
|
||||
async getProjectPath() {
|
||||
// 使用ResourceManager的项目路径获取逻辑
|
||||
return this.resourceManager.projectPath || process.cwd()
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析记忆块(新多行格式)
|
||||
*/
|
||||
|
||||
@ -2,6 +2,8 @@ const BasePouchCommand = require('../BasePouchCommand')
|
||||
const fs = require('fs-extra')
|
||||
const path = require('path')
|
||||
const PackageProtocol = require('../../resource/protocols/PackageProtocol')
|
||||
const { getGlobalResourceManager } = require('../../resource')
|
||||
const { getDirectoryService } = require('../../../utils/DirectoryService')
|
||||
|
||||
/**
|
||||
* 角色注册锦囊命令
|
||||
@ -11,6 +13,9 @@ class RegisterCommand extends BasePouchCommand {
|
||||
constructor () {
|
||||
super()
|
||||
this.packageProtocol = new PackageProtocol()
|
||||
// 复用ActionCommand的ResourceManager方式
|
||||
this.resourceManager = getGlobalResourceManager()
|
||||
this.directoryService = getDirectoryService()
|
||||
}
|
||||
|
||||
getPurpose () {
|
||||
@ -80,12 +85,18 @@ class RegisterCommand extends BasePouchCommand {
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查角色文件是否存在
|
||||
* 检查角色文件是否存在(使用ResourceManager路径获取)
|
||||
*/
|
||||
async checkRoleExists (roleId) {
|
||||
try {
|
||||
const packageRoot = await this.packageProtocol.getPackageRoot()
|
||||
const roleFile = path.join(packageRoot, 'prompt', 'domain', roleId, `${roleId}.role.md`)
|
||||
// 确保ResourceManager已初始化(就像ActionCommand那样)
|
||||
if (!this.resourceManager.initialized) {
|
||||
await this.resourceManager.initializeWithNewArchitecture()
|
||||
}
|
||||
|
||||
// 通过ResourceManager获取项目路径(与ActionCommand一致)
|
||||
const projectPath = await this.getProjectPath()
|
||||
const roleFile = path.join(projectPath, 'prompt', 'domain', roleId, `${roleId}.role.md`)
|
||||
|
||||
return await fs.pathExists(roleFile)
|
||||
} catch (error) {
|
||||
@ -94,14 +105,15 @@ class RegisterCommand extends BasePouchCommand {
|
||||
}
|
||||
|
||||
/**
|
||||
* 提取角色元数据
|
||||
* 提取角色元数据(使用ResourceManager路径获取)
|
||||
*/
|
||||
async extractRoleMetadata (roleId) {
|
||||
const packageRoot = await this.packageProtocol.getPackageRoot()
|
||||
const roleFile = path.join(packageRoot, 'prompt', 'domain', roleId, `${roleId}.role.md`)
|
||||
// 通过ResourceManager获取项目路径(与ActionCommand一致)
|
||||
const projectPath = await this.getProjectPath()
|
||||
const roleFile = path.join(projectPath, 'prompt', 'domain', roleId, `${roleId}.role.md`)
|
||||
|
||||
const content = await fs.readFile(roleFile, 'utf-8')
|
||||
const relativePath = path.relative(packageRoot, roleFile)
|
||||
const relativePath = path.relative(projectPath, roleFile)
|
||||
|
||||
// 提取元数据
|
||||
let name = `🎭 ${roleId}`
|
||||
@ -138,12 +150,12 @@ class RegisterCommand extends BasePouchCommand {
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册角色到系统
|
||||
* 注册角色到系统(使用DirectoryService统一路径获取)
|
||||
*/
|
||||
async registerRole (roleId, metadata) {
|
||||
try {
|
||||
const packageRoot = await this.packageProtocol.getPackageRoot()
|
||||
const registryPath = path.join(packageRoot, 'src', 'resource.registry.json')
|
||||
// 通过DirectoryService获取注册表路径(与其他命令一致)
|
||||
const registryPath = await this.directoryService.getRegistryPath()
|
||||
|
||||
// 读取当前注册表
|
||||
const registry = await fs.readJson(registryPath)
|
||||
@ -168,6 +180,14 @@ class RegisterCommand extends BasePouchCommand {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取项目路径(复用ActionCommand逻辑)
|
||||
*/
|
||||
async getProjectPath() {
|
||||
// 使用ResourceManager的项目路径获取逻辑
|
||||
return this.resourceManager.projectPath || process.cwd()
|
||||
}
|
||||
|
||||
getPATEOAS (args) {
|
||||
const [roleId] = args
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@ const BasePouchCommand = require('../BasePouchCommand')
|
||||
const fs = require('fs-extra')
|
||||
const path = require('path')
|
||||
const { COMMANDS } = require('../../../../constants')
|
||||
const { getGlobalResourceManager } = require('../../resource')
|
||||
|
||||
/**
|
||||
* 记忆保存锦囊命令
|
||||
@ -10,6 +11,8 @@ const { COMMANDS } = require('../../../../constants')
|
||||
class RememberCommand extends BasePouchCommand {
|
||||
constructor () {
|
||||
super()
|
||||
// 复用ActionCommand的ResourceManager方式
|
||||
this.resourceManager = getGlobalResourceManager()
|
||||
}
|
||||
|
||||
getPurpose () {
|
||||
@ -67,18 +70,30 @@ class RememberCommand extends BasePouchCommand {
|
||||
}
|
||||
|
||||
/**
|
||||
* 确保AI记忆体系目录存在
|
||||
* 确保AI记忆体系目录存在(使用ResourceManager路径获取)
|
||||
*/
|
||||
async ensureMemoryDirectory () {
|
||||
const { getDirectoryService } = require('../../../utils/DirectoryService')
|
||||
const directoryService = getDirectoryService()
|
||||
// 确保ResourceManager已初始化(就像ActionCommand那样)
|
||||
if (!this.resourceManager.initialized) {
|
||||
await this.resourceManager.initializeWithNewArchitecture()
|
||||
}
|
||||
|
||||
// 通过ResourceManager获取项目路径(与ActionCommand一致)
|
||||
const projectPath = await this.getProjectPath()
|
||||
const memoryDir = path.join(projectPath, '.promptx', 'memory')
|
||||
|
||||
const memoryDir = await directoryService.getMemoryDirectory()
|
||||
await fs.ensureDir(memoryDir)
|
||||
|
||||
return memoryDir
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取项目路径(复用ActionCommand逻辑)
|
||||
*/
|
||||
async getProjectPath() {
|
||||
// 使用ResourceManager的项目路径获取逻辑
|
||||
return this.resourceManager.projectPath || process.cwd()
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化为多行记忆块(新格式)
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user