diff --git a/src/lib/core/pouch/commands/RecallCommand.js b/src/lib/core/pouch/commands/RecallCommand.js index d7506ca..1dfda8a 100644 --- a/src/lib/core/pouch/commands/RecallCommand.js +++ b/src/lib/core/pouch/commands/RecallCommand.js @@ -3,6 +3,7 @@ const fs = require('fs-extra') const path = require('path') const { COMMANDS } = require('../../../../constants') const { getGlobalResourceManager } = require('../../resource') +const { getDirectoryService } = require('../../../utils/DirectoryService') /** * 记忆检索锦囊命令 @@ -13,6 +14,7 @@ class RecallCommand extends BasePouchCommand { super() // 复用ActionCommand的ResourceManager方式 this.resourceManager = getGlobalResourceManager() + this.directoryService = getDirectoryService() } getPurpose () { @@ -139,11 +141,16 @@ ${formattedMemories} } /** - * 获取项目路径(复用ActionCommand逻辑) + * 获取项目路径(与InitCommand保持一致) */ async getProjectPath() { - // 使用ResourceManager的项目路径获取逻辑 - return this.resourceManager.projectPath || process.cwd() + // 使用DirectoryService统一获取项目路径 + const context = { + startDir: process.cwd(), + platform: process.platform, + avoidUserHome: true + } + return await this.directoryService.getProjectRoot(context) } /** diff --git a/src/lib/core/pouch/commands/RegisterCommand.js b/src/lib/core/pouch/commands/RegisterCommand.js index 98f96b1..8bbd928 100644 --- a/src/lib/core/pouch/commands/RegisterCommand.js +++ b/src/lib/core/pouch/commands/RegisterCommand.js @@ -184,8 +184,13 @@ class RegisterCommand extends BasePouchCommand { * 获取项目路径(复用ActionCommand逻辑) */ async getProjectPath() { - // 使用ResourceManager的项目路径获取逻辑 - return this.resourceManager.projectPath || process.cwd() + // 使用DirectoryService统一获取项目路径(与InitCommand保持一致) + const context = { + startDir: process.cwd(), + platform: process.platform, + avoidUserHome: true + } + return await this.directoryService.getProjectRoot(context) } getPATEOAS (args) { diff --git a/src/lib/core/pouch/commands/RememberCommand.js b/src/lib/core/pouch/commands/RememberCommand.js index 7843ad3..4decf4c 100644 --- a/src/lib/core/pouch/commands/RememberCommand.js +++ b/src/lib/core/pouch/commands/RememberCommand.js @@ -3,6 +3,7 @@ const fs = require('fs-extra') const path = require('path') const { COMMANDS } = require('../../../../constants') const { getGlobalResourceManager } = require('../../resource') +const { getDirectoryService } = require('../../../utils/DirectoryService') /** * 记忆保存锦囊命令 @@ -13,6 +14,7 @@ class RememberCommand extends BasePouchCommand { super() // 复用ActionCommand的ResourceManager方式 this.resourceManager = getGlobalResourceManager() + this.directoryService = getDirectoryService() } getPurpose () { @@ -87,11 +89,16 @@ class RememberCommand extends BasePouchCommand { } /** - * 获取项目路径(复用ActionCommand逻辑) + * 获取项目路径(与InitCommand保持一致) */ async getProjectPath() { - // 使用ResourceManager的项目路径获取逻辑 - return this.resourceManager.projectPath || process.cwd() + // 使用DirectoryService统一获取项目路径 + const context = { + startDir: process.cwd(), + platform: process.platform, + avoidUserHome: true + } + return await this.directoryService.getProjectRoot(context) } /**