优化ExecutionProtocol、RoleProtocol和ThoughtProtocol中的@package://路径处理逻辑,新增PackageProtocol以解析路径,提升路径解析的准确性和灵活性。
This commit is contained in:
@ -49,7 +49,10 @@ class ExecutionProtocol extends ResourceProtocol {
|
|||||||
|
|
||||||
// 处理 @package:// 前缀
|
// 处理 @package:// 前缀
|
||||||
if (resolvedPath.startsWith('@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://')) {
|
} else if (resolvedPath.startsWith('@project://')) {
|
||||||
// 处理 @project:// 前缀,转换为绝对路径
|
// 处理 @project:// 前缀,转换为绝对路径
|
||||||
const relativePath = resolvedPath.replace('@project://', '')
|
const relativePath = resolvedPath.replace('@project://', '')
|
||||||
|
|||||||
@ -46,11 +46,15 @@ class RoleProtocol extends ResourceProtocol {
|
|||||||
throw new Error(`角色 "${roleId}" 未在注册表中找到。可用角色:${Object.keys(this.registry).join(', ')}`)
|
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:// 前缀
|
// 处理 @package:// 前缀
|
||||||
if (resolvedPath.startsWith('@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
|
return resolvedPath
|
||||||
|
|||||||
@ -48,7 +48,10 @@ class ThoughtProtocol extends ResourceProtocol {
|
|||||||
|
|
||||||
// 处理 @package:// 前缀
|
// 处理 @package:// 前缀
|
||||||
if (resolvedPath.startsWith('@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://')) {
|
} else if (resolvedPath.startsWith('@project://')) {
|
||||||
// 处理 @project:// 前缀,转换为绝对路径
|
// 处理 @project:// 前缀,转换为绝对路径
|
||||||
const relativePath = resolvedPath.replace('@project://', '')
|
const relativePath = resolvedPath.replace('@project://', '')
|
||||||
|
|||||||
Reference in New Issue
Block a user