修复中文路径URL编码问题 (#100)

- 在InitCommand中添加decodeURIComponent()处理中文路径
- 解决MCP传入URL编码路径导致验证失败的问题
- 支持类似 /home/azu/%E6%A1%8C%E9%9D%A2/PromptX 的编码路径

Co-authored-by: Cen-Yaozu <azu@example.com>
This commit is contained in:
阿祖
2025-07-01 10:00:41 +08:00
committed by GitHub
parent 08d4c1d194
commit 71ce235904

View File

@ -45,8 +45,9 @@ class InitCommand extends BasePouchCommand {
let projectPath let projectPath
if (workingDirectory) { if (workingDirectory) {
// AI提供了工作目录使用AI提供的路径 // AI提供了工作目录先解码中文路径,然后使用
projectPath = path.resolve(workingDirectory) const decodedWorkingDirectory = decodeURIComponent(workingDirectory)
projectPath = path.resolve(decodedWorkingDirectory)
// 验证AI提供的路径是否有效 // 验证AI提供的路径是否有效
if (!await this.currentProjectManager.validateProjectPath(projectPath)) { if (!await this.currentProjectManager.validateProjectPath(projectPath)) {
@ -153,7 +154,7 @@ ${registryStats.message}
if (registryData.size === 0) { if (registryData.size === 0) {
return { return {
message: `✅ 项目资源目录已创建,注册表已初始化 message: `✅ 项目资源目录已创建,注册表已初始化
📂 目录: ${path.relative(process.cwd(), domainDir)} 📂 目录: ${path.relative(process.cwd(), resourceDir)}
💾 注册表: ${path.relative(process.cwd(), registryPath)} 💾 注册表: ${path.relative(process.cwd(), registryPath)}
💡 现在可以在 domain 目录下创建角色资源了`, 💡 现在可以在 domain 目录下创建角色资源了`,
totalResources: 0 totalResources: 0