From ef39222b83c8f3d97bd5abd9f383abf632945796 Mon Sep 17 00:00:00 2001 From: sean Date: Wed, 11 Jun 2025 22:04:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96ExecutionProtocol=E3=80=81Rol?= =?UTF-8?q?eProtocol=E5=92=8CThoughtProtocol=E4=B8=AD=E7=9A=84@package://?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E6=96=B0=E5=A2=9EPackageProtocol=E4=BB=A5=E8=A7=A3=E6=9E=90?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=EF=BC=8C=E6=8F=90=E5=8D=87=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E8=A7=A3=E6=9E=90=E7=9A=84=E5=87=86=E7=A1=AE=E6=80=A7=E5=92=8C?= =?UTF-8?q?=E7=81=B5=E6=B4=BB=E6=80=A7=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/core/resource/protocols/ExecutionProtocol.js | 5 ++++- src/lib/core/resource/protocols/RoleProtocol.js | 8 ++++++-- src/lib/core/resource/protocols/ThoughtProtocol.js | 5 ++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/lib/core/resource/protocols/ExecutionProtocol.js b/src/lib/core/resource/protocols/ExecutionProtocol.js index 7ad9d19..1ea8843 100644 --- a/src/lib/core/resource/protocols/ExecutionProtocol.js +++ b/src/lib/core/resource/protocols/ExecutionProtocol.js @@ -49,7 +49,10 @@ class ExecutionProtocol extends ResourceProtocol { // 处理 @package:// 前缀 if (resolvedPath.startsWith('@package://')) { - resolvedPath = resolvedPath.replace('@package://', '') + const PackageProtocol = require('./PackageProtocol') + const packageProtocol = new PackageProtocol() + const relativePath = resolvedPath.replace('@package://', '') + resolvedPath = await packageProtocol.resolvePath(relativePath) } else if (resolvedPath.startsWith('@project://')) { // 处理 @project:// 前缀,转换为绝对路径 const relativePath = resolvedPath.replace('@project://', '') diff --git a/src/lib/core/resource/protocols/RoleProtocol.js b/src/lib/core/resource/protocols/RoleProtocol.js index 62f23b3..0f6d122 100644 --- a/src/lib/core/resource/protocols/RoleProtocol.js +++ b/src/lib/core/resource/protocols/RoleProtocol.js @@ -46,11 +46,15 @@ class RoleProtocol extends ResourceProtocol { throw new Error(`角色 "${roleId}" 未在注册表中找到。可用角色:${Object.keys(this.registry).join(', ')}`) } - let resolvedPath = this.registry[roleId] + const roleInfo = this.registry[roleId] + let resolvedPath = typeof roleInfo === 'string' ? roleInfo : roleInfo.file // 处理 @package:// 前缀 if (resolvedPath.startsWith('@package://')) { - resolvedPath = resolvedPath.replace('@package://', '') + const PackageProtocol = require('./PackageProtocol') + const packageProtocol = new PackageProtocol() + const relativePath = resolvedPath.replace('@package://', '') + resolvedPath = await packageProtocol.resolvePath(relativePath) } return resolvedPath diff --git a/src/lib/core/resource/protocols/ThoughtProtocol.js b/src/lib/core/resource/protocols/ThoughtProtocol.js index 9b550de..0922f70 100644 --- a/src/lib/core/resource/protocols/ThoughtProtocol.js +++ b/src/lib/core/resource/protocols/ThoughtProtocol.js @@ -48,7 +48,10 @@ class ThoughtProtocol extends ResourceProtocol { // 处理 @package:// 前缀 if (resolvedPath.startsWith('@package://')) { - resolvedPath = resolvedPath.replace('@package://', '') + const PackageProtocol = require('./PackageProtocol') + const packageProtocol = new PackageProtocol() + const relativePath = resolvedPath.replace('@package://', '') + resolvedPath = await packageProtocol.resolvePath(relativePath) } else if (resolvedPath.startsWith('@project://')) { // 处理 @project:// 前缀,转换为绝对路径 const relativePath = resolvedPath.replace('@project://', '')