重构:更新前端开发者角色文档,移除冗余的执行策略,新增微信小程序专项开发部分;更新资源注册表,统一时间戳格式,移除不再使用的资源注册逻辑,优化工具定义获取方式,提升代码可读性和维护性。
This commit is contained in:
@ -44,59 +44,37 @@ class ExecutionProtocol extends ResourceProtocol {
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析资源路径
|
||||
* 解析执行协议
|
||||
* @param {string} executionPath - 执行路径,如 'best-practice'
|
||||
* @param {Object} queryParams - 查询参数(暂未使用)
|
||||
* @returns {Promise<string>} 执行文件内容
|
||||
*/
|
||||
async resolvePath (resourcePath, queryParams) {
|
||||
const executionId = resourcePath.trim()
|
||||
const fullResourceId = `execution:${executionId}`
|
||||
|
||||
// 优先使用统一注册表管理器
|
||||
if (this.registryManager) {
|
||||
const reference = this.registryManager.registry.get(fullResourceId)
|
||||
if (!reference) {
|
||||
const availableExecutions = this.registryManager.registry.keys()
|
||||
.filter(id => id.startsWith('execution:'))
|
||||
.map(id => id.replace('execution:', ''))
|
||||
throw new Error(`执行模式 "${executionId}" 未在注册表中找到。可用执行模式:${availableExecutions.join(', ')}`)
|
||||
async resolve(executionPath, queryParams = {}) {
|
||||
try {
|
||||
// 构建可能的资源ID格式
|
||||
const fullResourceId = `execution:${executionPath}`
|
||||
|
||||
// 从RegistryData查找资源
|
||||
let resourceData = this.registryManager.registryData.findResourceById(executionPath, 'execution')
|
||||
|
||||
if (!resourceData) {
|
||||
// 如果没找到,尝试其他格式
|
||||
resourceData = this.registryManager.registryData.findResourceById(fullResourceId)
|
||||
}
|
||||
|
||||
if (!resourceData) {
|
||||
const availableExecutions = this.registryManager.registryData.getResourcesByProtocol('execution')
|
||||
.map(r => r.id).join(', ')
|
||||
throw new Error(`执行模式 '${executionPath}' 未找到。可用执行模式: ${availableExecutions}`)
|
||||
}
|
||||
|
||||
let resolvedPath = reference
|
||||
|
||||
// 处理 @package:// 前缀
|
||||
if (resolvedPath.startsWith('@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://', '')
|
||||
resolvedPath = path.join(process.cwd(), relativePath)
|
||||
}
|
||||
|
||||
return resolvedPath
|
||||
// 通过ResourceManager加载实际内容
|
||||
const result = await this.registryManager.loadResourceByProtocol(resourceData.reference)
|
||||
|
||||
return result
|
||||
} catch (error) {
|
||||
throw new Error(`ExecutionProtocol.resolve failed: ${error.message}`)
|
||||
}
|
||||
|
||||
// 向后兼容:使用旧的registry
|
||||
if (!this.registry[executionId]) {
|
||||
throw new Error(`执行模式 "${executionId}" 未在注册表中找到`)
|
||||
}
|
||||
|
||||
let resolvedPath = this.registry[executionId]
|
||||
|
||||
// 处理 @package:// 前缀
|
||||
if (resolvedPath.startsWith('@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://', '')
|
||||
resolvedPath = path.join(process.cwd(), relativePath)
|
||||
}
|
||||
|
||||
return resolvedPath
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -43,59 +43,37 @@ class KnowledgeProtocol extends ResourceProtocol {
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析资源路径
|
||||
* 解析知识协议
|
||||
* @param {string} knowledgePath - 知识路径,如 'scrum'
|
||||
* @param {Object} queryParams - 查询参数(暂未使用)
|
||||
* @returns {Promise<string>} 知识文件内容
|
||||
*/
|
||||
async resolvePath (resourcePath, queryParams) {
|
||||
const knowledgeId = resourcePath.trim()
|
||||
const fullResourceId = `knowledge:${knowledgeId}`
|
||||
|
||||
// 优先使用统一注册表管理器
|
||||
if (this.registryManager) {
|
||||
const reference = this.registryManager.registry.get(fullResourceId)
|
||||
if (!reference) {
|
||||
const availableKnowledge = this.registryManager.registry.keys()
|
||||
.filter(id => id.startsWith('knowledge:'))
|
||||
.map(id => id.replace('knowledge:', ''))
|
||||
throw new Error(`知识资源 "${knowledgeId}" 未在注册表中找到。可用知识资源:${availableKnowledge.join(', ')}`)
|
||||
async resolve(knowledgePath, queryParams = {}) {
|
||||
try {
|
||||
// 构建可能的资源ID格式
|
||||
const fullResourceId = `knowledge:${knowledgePath}`
|
||||
|
||||
// 从RegistryData查找资源
|
||||
let resourceData = this.registryManager.registryData.findResourceById(knowledgePath, 'knowledge')
|
||||
|
||||
if (!resourceData) {
|
||||
// 如果没找到,尝试其他格式
|
||||
resourceData = this.registryManager.registryData.findResourceById(fullResourceId)
|
||||
}
|
||||
|
||||
if (!resourceData) {
|
||||
const availableKnowledge = this.registryManager.registryData.getResourcesByProtocol('knowledge')
|
||||
.map(r => r.id).join(', ')
|
||||
throw new Error(`知识模块 '${knowledgePath}' 未找到。可用知识模块: ${availableKnowledge}`)
|
||||
}
|
||||
|
||||
let resolvedPath = reference
|
||||
|
||||
// 处理 @package:// 前缀
|
||||
if (resolvedPath.startsWith('@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://', '')
|
||||
resolvedPath = path.join(process.cwd(), relativePath)
|
||||
}
|
||||
|
||||
return resolvedPath
|
||||
// 通过ResourceManager加载实际内容
|
||||
const result = await this.registryManager.loadResourceByProtocol(resourceData.reference)
|
||||
|
||||
return result
|
||||
} catch (error) {
|
||||
throw new Error(`KnowledgeProtocol.resolve failed: ${error.message}`)
|
||||
}
|
||||
|
||||
// 向后兼容:使用旧的registry
|
||||
if (!this.registry[knowledgeId]) {
|
||||
throw new Error(`知识资源 "${knowledgeId}" 未在注册表中找到`)
|
||||
}
|
||||
|
||||
let resolvedPath = this.registry[knowledgeId]
|
||||
|
||||
// 处理 @package:// 前缀
|
||||
if (resolvedPath.startsWith('@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://', '')
|
||||
resolvedPath = path.join(process.cwd(), relativePath)
|
||||
}
|
||||
|
||||
return resolvedPath
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -45,56 +45,38 @@ class RoleProtocol extends ResourceProtocol {
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析资源路径
|
||||
* 解析角色协议
|
||||
* @param {string} rolePath - 角色路径,如 'java-developer'
|
||||
* @param {Object} queryParams - 查询参数(暂未使用)
|
||||
* @returns {Promise<string>} 角色文件内容
|
||||
*/
|
||||
async resolvePath (resourcePath, queryParams) {
|
||||
const roleId = resourcePath.trim()
|
||||
const fullResourceId = `role:${roleId}`
|
||||
|
||||
// 优先使用统一注册表管理器
|
||||
if (this.registryManager) {
|
||||
const reference = this.registryManager.registry.get(fullResourceId)
|
||||
if (!reference) {
|
||||
const availableRoles = this.registryManager.registry.keys()
|
||||
.filter(id => id.startsWith('role:'))
|
||||
.map(id => id.replace('role:', ''))
|
||||
throw new Error(`角色 "${roleId}" 未在注册表中找到。可用角色:${availableRoles.join(', ')}`)
|
||||
async resolve(rolePath, queryParams = {}) {
|
||||
try {
|
||||
// 构建可能的资源ID格式
|
||||
const fullResourceId = `role:${rolePath}`
|
||||
const shortResourceId = rolePath
|
||||
|
||||
// 从RegistryData查找资源
|
||||
let resourceData = this.registryManager.registryData.findResourceById(rolePath, 'role')
|
||||
|
||||
if (!resourceData) {
|
||||
// 如果没找到,尝试其他格式
|
||||
resourceData = this.registryManager.registryData.findResourceById(fullResourceId)
|
||||
}
|
||||
|
||||
let resolvedPath = reference
|
||||
|
||||
// 处理 @package:// 前缀
|
||||
if (resolvedPath.startsWith('@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://', '')
|
||||
resolvedPath = path.join(process.cwd(), relativePath)
|
||||
if (!resourceData) {
|
||||
const availableRoles = this.registryManager.registryData.getResourcesByProtocol('role')
|
||||
.map(r => r.id).join(', ')
|
||||
throw new Error(`角色 '${rolePath}' 未找到。可用角色: ${availableRoles}`)
|
||||
}
|
||||
|
||||
return resolvedPath
|
||||
// 通过ResourceManager加载实际内容
|
||||
const result = await this.registryManager.loadResourceByProtocol(resourceData.reference)
|
||||
|
||||
return result
|
||||
} catch (error) {
|
||||
throw new Error(`RoleProtocol.resolve failed: ${error.message}`)
|
||||
}
|
||||
|
||||
// 向后兼容:使用旧的registry
|
||||
if (!this.registry[roleId]) {
|
||||
throw new Error(`角色 "${roleId}" 未在注册表中找到。可用角色:${Object.keys(this.registry).join(', ')}`)
|
||||
}
|
||||
|
||||
const roleInfo = this.registry[roleId]
|
||||
let resolvedPath = typeof roleInfo === 'string' ? roleInfo : roleInfo.file
|
||||
|
||||
// 处理 @package:// 前缀
|
||||
if (resolvedPath.startsWith('@package://')) {
|
||||
const PackageProtocol = require('./PackageProtocol')
|
||||
const packageProtocol = new PackageProtocol()
|
||||
const relativePath = resolvedPath.replace('@package://', '')
|
||||
resolvedPath = await packageProtocol.resolvePath(relativePath)
|
||||
}
|
||||
|
||||
return resolvedPath
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -43,59 +43,37 @@ class ThoughtProtocol extends ResourceProtocol {
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析资源路径
|
||||
* 解析思维协议
|
||||
* @param {string} thoughtPath - 思维路径,如 'remember'
|
||||
* @param {Object} queryParams - 查询参数(暂未使用)
|
||||
* @returns {Promise<string>} 思维文件内容
|
||||
*/
|
||||
async resolvePath (resourcePath, queryParams) {
|
||||
const thoughtId = resourcePath.trim()
|
||||
const fullResourceId = `thought:${thoughtId}`
|
||||
|
||||
// 优先使用统一注册表管理器
|
||||
if (this.registryManager) {
|
||||
const reference = this.registryManager.registry.get(fullResourceId)
|
||||
if (!reference) {
|
||||
const availableThoughts = this.registryManager.registry.keys()
|
||||
.filter(id => id.startsWith('thought:'))
|
||||
.map(id => id.replace('thought:', ''))
|
||||
throw new Error(`思维模式 "${thoughtId}" 未在注册表中找到。可用思维模式:${availableThoughts.join(', ')}`)
|
||||
async resolve(thoughtPath, queryParams = {}) {
|
||||
try {
|
||||
// 构建可能的资源ID格式
|
||||
const fullResourceId = `thought:${thoughtPath}`
|
||||
|
||||
// 从RegistryData查找资源
|
||||
let resourceData = this.registryManager.registryData.findResourceById(thoughtPath, 'thought')
|
||||
|
||||
if (!resourceData) {
|
||||
// 如果没找到,尝试其他格式
|
||||
resourceData = this.registryManager.registryData.findResourceById(fullResourceId)
|
||||
}
|
||||
|
||||
if (!resourceData) {
|
||||
const availableThoughts = this.registryManager.registryData.getResourcesByProtocol('thought')
|
||||
.map(r => r.id).join(', ')
|
||||
throw new Error(`思维模式 '${thoughtPath}' 未找到。可用思维模式: ${availableThoughts}`)
|
||||
}
|
||||
|
||||
let resolvedPath = reference
|
||||
|
||||
// 处理 @package:// 前缀
|
||||
if (resolvedPath.startsWith('@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://', '')
|
||||
resolvedPath = path.join(process.cwd(), relativePath)
|
||||
}
|
||||
|
||||
return resolvedPath
|
||||
// 通过ResourceManager加载实际内容
|
||||
const result = await this.registryManager.loadResourceByProtocol(resourceData.reference)
|
||||
|
||||
return result
|
||||
} catch (error) {
|
||||
throw new Error(`ThoughtProtocol.resolve failed: ${error.message}`)
|
||||
}
|
||||
|
||||
// 向后兼容:使用旧的registry
|
||||
if (!this.registry[thoughtId]) {
|
||||
throw new Error(`思维模式 "${thoughtId}" 未在注册表中找到`)
|
||||
}
|
||||
|
||||
let resolvedPath = this.registry[thoughtId]
|
||||
|
||||
// 处理 @package:// 前缀
|
||||
if (resolvedPath.startsWith('@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://', '')
|
||||
resolvedPath = path.join(process.cwd(), relativePath)
|
||||
}
|
||||
|
||||
return resolvedPath
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user