From aed3d0f1d67d1bac74795e27a6e69f688e114854 Mon Sep 17 00:00:00 2001 From: sean Date: Sun, 22 Jun 2025 11:14:55 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20=E8=BF=99=E5=87=A0?= =?UTF-8?q?=E4=B8=AA=E5=91=BD=E4=BB=A4=E4=BD=BF=E7=94=A8=E4=BA=86=E5=BA=9F?= =?UTF-8?q?=E5=BC=83=E7=9A=84=E9=A1=B9=E7=9B=AE=E8=B7=AF=E5=BE=84=E5=AE=9A?= =?UTF-8?q?=E4=BD=8D=E6=96=B9=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/core/pouch/commands/RecallCommand.js | 13 ++++++++++--- src/lib/core/pouch/commands/RegisterCommand.js | 9 +++++++-- src/lib/core/pouch/commands/RememberCommand.js | 13 ++++++++++--- 3 files changed, 27 insertions(+), 8 deletions(-) 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) } /**