重构:更新前端开发者角色文档,移除冗余的执行策略,新增微信小程序专项开发部分;更新资源注册表,统一时间戳格式,移除不再使用的资源注册逻辑,优化工具定义获取方式,提升代码可读性和维护性。
This commit is contained in:
@ -3,6 +3,7 @@ const { StdioServerTransport } = require('@modelcontextprotocol/sdk/server/stdio
|
||||
const { cli } = require('../core/pouch');
|
||||
const { MCPOutputAdapter } = require('../adapters/MCPOutputAdapter');
|
||||
const { getExecutionContext, getDebugInfo } = require('../utils/executionContext');
|
||||
const { getToolDefinitions } = require('../mcp/toolDefinitions');
|
||||
|
||||
/**
|
||||
* MCP Server 适配器 - 函数调用架构
|
||||
@ -131,88 +132,7 @@ class MCPServerCommand {
|
||||
* 获取工具定义
|
||||
*/
|
||||
getToolDefinitions() {
|
||||
return [
|
||||
{
|
||||
name: 'promptx_init',
|
||||
description: '🏗️ [环境初始化锦囊] 初始化PromptX工作环境,创建配置目录,准备专业能力增强系统',
|
||||
inputSchema: {
|
||||
type: 'object',
|
||||
properties: {}
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'promptx_hello',
|
||||
description: '👋 [角色发现锦囊] 让AI浏览专业角色库(产品经理、Java开发者、设计师等),当需要专业能力时使用,引导角色激活',
|
||||
inputSchema: {
|
||||
type: 'object',
|
||||
properties: {}
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'promptx_action',
|
||||
description: '⚡ [专家变身锦囊] 让AI获得指定专业角色的思维模式和核心能力,即时变身领域专家,开始提供专业服务',
|
||||
inputSchema: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
role: {
|
||||
type: 'string',
|
||||
description: '要激活的角色ID,如:copywriter, product-manager, java-backend-developer'
|
||||
}
|
||||
},
|
||||
required: ['role']
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'promptx_learn',
|
||||
description: '📚 [专业深化锦囊] 让AI学习特定领域的思维模式和执行模式(如敏捷开发、产品设计),强化当前专家角色能力',
|
||||
inputSchema: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
resource: {
|
||||
type: 'string',
|
||||
description: '资源URL,支持格式:thought://creativity, execution://best-practice, knowledge://scrum'
|
||||
}
|
||||
},
|
||||
required: ['resource']
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'promptx_recall',
|
||||
description: '🔍 [经验检索锦囊] 让AI从专业记忆库中检索相关经验和最佳实践,当需要基于历史经验工作时使用',
|
||||
inputSchema: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
random_string: {
|
||||
type: 'string',
|
||||
description: 'Dummy parameter for no-parameter tools'
|
||||
},
|
||||
query: {
|
||||
type: 'string',
|
||||
description: '检索关键词或描述,可选参数,不提供则返回所有记忆'
|
||||
}
|
||||
},
|
||||
required: ['random_string']
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'promptx_remember',
|
||||
description: '💾 [知识积累锦囊] 让AI将重要经验和专业知识保存到记忆库,构建可复用的专业知识体系,供未来检索应用',
|
||||
inputSchema: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
content: {
|
||||
type: 'string',
|
||||
description: '要保存的重要信息或经验'
|
||||
},
|
||||
tags: {
|
||||
type: 'string',
|
||||
description: '自定义标签,用空格分隔,可选'
|
||||
}
|
||||
},
|
||||
required: ['content']
|
||||
}
|
||||
}
|
||||
];
|
||||
return getToolDefinitions();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -6,6 +6,7 @@ const { SSEServerTransport } = require('@modelcontextprotocol/sdk/server/sse.js'
|
||||
const { isInitializeRequest } = require('@modelcontextprotocol/sdk/types.js');
|
||||
const { cli } = require('../core/pouch');
|
||||
const { MCPOutputAdapter } = require('../adapters/MCPOutputAdapter');
|
||||
const { getToolDefinitions, getToolDefinition, getToolZodSchema } = require('../mcp/toolDefinitions');
|
||||
const logger = require('../utils/logger');
|
||||
|
||||
/**
|
||||
@ -261,51 +262,16 @@ class MCPStreamableHttpCommand {
|
||||
* 设置 MCP 工具
|
||||
*/
|
||||
setupMCPTools(server) {
|
||||
const { z } = require('zod');
|
||||
// 使用共享的工具定义
|
||||
const toolDefinitions = getToolDefinitions();
|
||||
|
||||
// 注册 promptx_init 工具
|
||||
server.tool('promptx_init', '🎯 [AI专业能力启动器] ⚡ 让你瞬间拥有任何领域的专家级思维和技能 - 一键激活丰富的专业角色库(产品经理/开发者/设计师/营销专家等),获得跨对话记忆能力,30秒内从普通AI变身行业专家,每次需要专业服务时都应该先用这个', {}, async (args, extra) => {
|
||||
this.log('🔧 调用工具: promptx_init');
|
||||
return await this.callTool('promptx_init', {});
|
||||
});
|
||||
|
||||
// 注册 promptx_hello 工具
|
||||
server.tool('promptx_hello', '🎭 [专业角色选择菜单] 🔥 当你需要专业能力时必须先看这个 - 展示大量可激活的专家身份清单:产品经理/Java开发者/UI设计师/文案策划师/数据分析师/项目经理等,每个角色都有完整的专业思维模式和工作技能,看完后选择最适合当前任务的专家身份', {}, async (args, extra) => {
|
||||
this.log('🔧 调用工具: promptx_hello');
|
||||
return await this.callTool('promptx_hello', {});
|
||||
});
|
||||
|
||||
// 注册 promptx_action 工具
|
||||
server.tool('promptx_action', '⚡ [专家身份变身器] 🚀 让你瞬间获得指定专业角色的完整思维和技能包 - 输入角色ID立即获得该领域专家的思考方式/工作原则/专业知识,同时自动加载相关历史经验和最佳实践,3秒内完成专业化转换,每次需要专业服务时必须使用', {
|
||||
role: z.string().describe('要激活的角色ID,如:copywriter, product-manager, java-backend-developer')
|
||||
}, async (args, extra) => {
|
||||
this.log(`🔧 调用工具: promptx_action 参数: ${JSON.stringify(args)}`);
|
||||
return await this.callTool('promptx_action', args);
|
||||
});
|
||||
|
||||
// 注册 promptx_learn 工具
|
||||
server.tool('promptx_learn', '🧠 [专业技能学习器] 💎 让你快速掌握特定专业技能和思维方式 - 学习创意思维/最佳实践/敏捷开发/产品设计等专业能力,支持thought://(思维模式) execution://(执行技能) knowledge://(专业知识)三种学习类型,学会后立即可以运用到工作中,想要专业化成长时使用', {
|
||||
resource: z.string().describe('资源URL,支持格式:thought://creativity, execution://best-practice, knowledge://scrum')
|
||||
}, async (args, extra) => {
|
||||
this.log(`🔧 调用工具: promptx_learn 参数: ${JSON.stringify(args)}`);
|
||||
return await this.callTool('promptx_learn', args);
|
||||
});
|
||||
|
||||
// 注册 promptx_recall 工具
|
||||
server.tool('promptx_recall', '🔍 [记忆回想器] ⚡ 让你记住并运用以前的经验和知识 - 瞬间检索之前学会的专业技能/处理过的项目经验/掌握的最佳实践/解决过的问题方案,避免重复犯错和重新学习,当需要参考历史经验做决策时必须使用,让你的工作越来越专业', {
|
||||
query: z.string().optional().describe('检索关键词或描述,可选参数,不提供则返回所有记忆')
|
||||
}, async (args, extra) => {
|
||||
this.log(`🔧 调用工具: promptx_recall 参数: ${JSON.stringify(args)}`);
|
||||
return await this.callTool('promptx_recall', args);
|
||||
});
|
||||
|
||||
// 注册 promptx_remember 工具
|
||||
server.tool('promptx_remember', '💾 [经验记忆存储器] 🧠 让你永久记住重要的经验和知识 - 将有价值的经验/学到的最佳实践/项目解决方案/工作心得保存到长期记忆中,下次遇到类似问题时可以快速回想起来,让你越来越聪明和专业,每次获得重要经验时都应该存储', {
|
||||
content: z.string().describe('要保存的重要信息或经验'),
|
||||
tags: z.string().optional().describe('自定义标签,用空格分隔,可选')
|
||||
}, async (args, extra) => {
|
||||
this.log(`🔧 调用工具: promptx_remember 参数: ${JSON.stringify(args)}`);
|
||||
return await this.callTool('promptx_remember', args);
|
||||
toolDefinitions.forEach(toolDef => {
|
||||
const zodSchema = getToolZodSchema(toolDef.name);
|
||||
|
||||
server.tool(toolDef.name, toolDef.description, zodSchema, async (args, extra) => {
|
||||
this.log(`🔧 调用工具: ${toolDef.name} 参数: ${JSON.stringify(args)}`);
|
||||
return await this.callTool(toolDef.name, args || {});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@ -313,88 +279,7 @@ class MCPStreamableHttpCommand {
|
||||
* 获取工具定义
|
||||
*/
|
||||
getToolDefinitions() {
|
||||
return [
|
||||
{
|
||||
name: 'promptx_init',
|
||||
description: '🎯 [AI专业能力启动器] ⚡ 让你瞬间拥有任何领域的专家级思维和技能 - 一键激活丰富的专业角色库(产品经理/开发者/设计师/营销专家等),获得跨对话记忆能力,30秒内从普通AI变身行业专家,每次需要专业服务时都应该先用这个',
|
||||
inputSchema: {
|
||||
type: 'object',
|
||||
properties: {}
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'promptx_hello',
|
||||
description: '🎭 [专业角色选择菜单] 🔥 当你需要专业能力时必须先看这个 - 展示大量可激活的专家身份清单:产品经理/Java开发者/UI设计师/文案策划师/数据分析师/项目经理等,每个角色都有完整的专业思维模式和工作技能,看完后选择最适合当前任务的专家身份',
|
||||
inputSchema: {
|
||||
type: 'object',
|
||||
properties: {}
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'promptx_action',
|
||||
description: '⚡ [专家身份变身器] 🚀 让你瞬间获得指定专业角色的完整思维和技能包 - 输入角色ID立即获得该领域专家的思考方式/工作原则/专业知识,同时自动加载相关历史经验和最佳实践,3秒内完成专业化转换,每次需要专业服务时必须使用',
|
||||
inputSchema: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
role: {
|
||||
type: 'string',
|
||||
description: '要激活的角色ID,如:copywriter, product-manager, java-backend-developer'
|
||||
}
|
||||
},
|
||||
required: ['role']
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'promptx_learn',
|
||||
description: '🧠 [专业技能学习器] 💎 让你快速掌握特定专业技能和思维方式 - 学习创意思维/最佳实践/敏捷开发/产品设计等专业能力,支持thought://(思维模式) execution://(执行技能) knowledge://(专业知识)三种学习类型,学会后立即可以运用到工作中,想要专业化成长时使用',
|
||||
inputSchema: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
resource: {
|
||||
type: 'string',
|
||||
description: '资源URL,支持格式:thought://creativity, execution://best-practice, knowledge://scrum'
|
||||
}
|
||||
},
|
||||
required: ['resource']
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'promptx_recall',
|
||||
description: '🔍 [记忆回想器] ⚡ 让你记住并运用以前的经验和知识 - 瞬间检索之前学会的专业技能/处理过的项目经验/掌握的最佳实践/解决过的问题方案,避免重复犯错和重新学习,当需要参考历史经验做决策时必须使用,让你的工作越来越专业',
|
||||
inputSchema: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
random_string: {
|
||||
type: 'string',
|
||||
description: 'Dummy parameter for no-parameter tools'
|
||||
},
|
||||
query: {
|
||||
type: 'string',
|
||||
description: '检索关键词或描述,可选参数,不提供则返回所有记忆'
|
||||
}
|
||||
},
|
||||
required: ['random_string']
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'promptx_remember',
|
||||
description: '💾 [经验记忆存储器] 🧠 让你永久记住重要的经验和知识 - 将有价值的经验/学到的最佳实践/项目解决方案/工作心得保存到长期记忆中,下次遇到类似问题时可以快速回想起来,让你越来越聪明和专业,每次获得重要经验时都应该存储',
|
||||
inputSchema: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
content: {
|
||||
type: 'string',
|
||||
description: '要保存的重要信息或经验'
|
||||
},
|
||||
tags: {
|
||||
type: 'string',
|
||||
description: '自定义标签,用空格分隔,可选'
|
||||
}
|
||||
},
|
||||
required: ['content']
|
||||
}
|
||||
}
|
||||
];
|
||||
return getToolDefinitions();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -20,8 +20,7 @@ class HelloCommand extends BasePouchCommand {
|
||||
}
|
||||
|
||||
/**
|
||||
* 动态加载角色注册表 - 使用新的ResourceManager架构
|
||||
* 直接使用现有资源注册表,避免重复刷新导致的死循环
|
||||
* 动态加载角色注册表 - 使用新的RegistryData架构
|
||||
*/
|
||||
async loadRoleRegistry () {
|
||||
try {
|
||||
@ -32,12 +31,10 @@ class HelloCommand extends BasePouchCommand {
|
||||
|
||||
const roleRegistry = {}
|
||||
|
||||
// 使用新的RegistryData v2.0格式获取角色资源
|
||||
// 使用新的RegistryData获取角色资源
|
||||
const registryData = this.resourceManager.registryData
|
||||
|
||||
// 检查是否有RegistryData(v2.0格式)
|
||||
if (registryData && registryData.resources && registryData.resources.length > 0) {
|
||||
// 使用v2.0格式:直接从RegistryData获取角色资源
|
||||
const roleResources = registryData.getResourcesByProtocol('role')
|
||||
|
||||
for (const resource of roleResources) {
|
||||
@ -55,48 +52,6 @@ class HelloCommand extends BasePouchCommand {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 降级到旧格式处理(向后兼容)
|
||||
const registry = this.resourceManager.registry
|
||||
for (const [resourceId, reference] of registry.index) {
|
||||
let roleId = null
|
||||
let isRoleResource = false
|
||||
|
||||
if (resourceId.startsWith('role:')) {
|
||||
roleId = resourceId.substring(5)
|
||||
isRoleResource = true
|
||||
} else if (resourceId.startsWith('package:') || resourceId.startsWith('project:') || resourceId.startsWith('user:')) {
|
||||
const parts = resourceId.split(':')
|
||||
if (parts.length === 2 && !parts[1].includes(':')) {
|
||||
roleId = parts[1]
|
||||
isRoleResource = true
|
||||
}
|
||||
} else if (!resourceId.includes(':')) {
|
||||
roleId = resourceId
|
||||
isRoleResource = true
|
||||
}
|
||||
|
||||
if (isRoleResource && roleId && !roleRegistry[roleId]) {
|
||||
try {
|
||||
const result = await this.resourceManager.loadResource(resourceId)
|
||||
if (result.success) {
|
||||
const name = this.extractRoleNameFromContent(result.content) || roleId
|
||||
const description = this.extractDescriptionFromContent(result.content) || `${name}专业角色`
|
||||
|
||||
roleRegistry[roleId] = {
|
||||
id: roleId,
|
||||
name,
|
||||
description,
|
||||
source: reference.startsWith('@package://') ? 'package' : 'project',
|
||||
file: reference,
|
||||
protocol: 'role'
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
// 静默处理,避免干扰用户界面
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 如果没有任何角色,使用基础角色
|
||||
@ -217,6 +172,7 @@ class HelloCommand extends BasePouchCommand {
|
||||
|
||||
> 💡 **重要说明**:以下是可激活的AI专业角色。每个角色都有唯一的ID,可通过MCP工具激活。
|
||||
|
||||
|
||||
## 📋 可用角色列表
|
||||
|
||||
`
|
||||
@ -246,6 +202,7 @@ class HelloCommand extends BasePouchCommand {
|
||||
content += `#### ${roleIndex}. ${role.name}
|
||||
**角色ID**: \`${role.id}\`
|
||||
**专业能力**: ${role.description}
|
||||
**文件路径**: ${role.file}
|
||||
**来源**: ${sourceLabel}
|
||||
|
||||
---
|
||||
@ -294,7 +251,7 @@ class HelloCommand extends BasePouchCommand {
|
||||
metadata: {
|
||||
totalRoles: allRoles.length,
|
||||
availableRoles,
|
||||
dataSource: 'resource.registry.json',
|
||||
dataSource: 'RegistryData v2.0',
|
||||
systemVersion: '锦囊串联状态机 v1.0',
|
||||
designPhilosophy: 'AI use MCP tools for role activation'
|
||||
}
|
||||
@ -369,10 +326,16 @@ class HelloCommand extends BasePouchCommand {
|
||||
logger.info('🔍 没有发现任何角色资源')
|
||||
}
|
||||
|
||||
// 同时显示ResourceManager的注册表
|
||||
logger.info('\n📋 ResourceManager 注册表:')
|
||||
logger.info('-'.repeat(30))
|
||||
this.resourceManager.registry.printAll('底层资源注册表')
|
||||
// 显示RegistryData统计信息
|
||||
logger.info('\n📋 RegistryData 统计信息:')
|
||||
if (this.resourceManager && this.resourceManager.registryData) {
|
||||
const stats = this.resourceManager.registryData.getStats()
|
||||
logger.info(`总资源数: ${stats.totalResources}`)
|
||||
logger.info(`按协议分布: ${JSON.stringify(stats.byProtocol, null, 2)}`)
|
||||
logger.info(`按来源分布: ${JSON.stringify(stats.bySource, null, 2)}`)
|
||||
} else {
|
||||
logger.info('❌ RegistryData 不可用')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -46,7 +46,7 @@ class ResourceData {
|
||||
|
||||
/**
|
||||
* 从文件路径和协议推断创建ResourceData
|
||||
* @param {string} filePath - 文件路径
|
||||
* @param {string} filePath - 文件路径(仅用于提取ID,不保存)
|
||||
* @param {string} source - 资源来源
|
||||
* @param {string} protocol - 资源协议
|
||||
* @param {string} reference - 资源引用
|
||||
@ -64,7 +64,6 @@ class ResourceData {
|
||||
description: ResourceData._generateDefaultDescription(fileName, protocol),
|
||||
reference,
|
||||
metadata: {
|
||||
filePath,
|
||||
inferredFromFile: true
|
||||
}
|
||||
})
|
||||
@ -189,6 +188,23 @@ class ResourceData {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 动态获取文件路径
|
||||
* 通过解析 reference 动态计算实际的文件路径
|
||||
* @returns {Promise<string>} 文件路径
|
||||
*/
|
||||
async getFilePath() {
|
||||
const ProtocolResolver = require('./ProtocolResolver')
|
||||
const resolver = new ProtocolResolver()
|
||||
|
||||
try {
|
||||
const resolvedPath = await resolver.resolve(this.reference)
|
||||
return resolvedPath
|
||||
} catch (error) {
|
||||
throw new Error(`无法解析资源路径 ${this.reference}: ${error.message}`)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 克隆资源数据
|
||||
* @returns {ResourceData} 克隆的实例
|
||||
|
||||
@ -84,50 +84,7 @@ class DiscoveryManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* 发现资源并直接注册到指定注册表(新的简化方法)
|
||||
* @param {ResourceRegistry} registry - 目标注册表
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async discoverAndDirectRegister(registry) {
|
||||
logger.info(`[DiscoveryManager] 🚀 开始直接注册,发现器数量: ${this.discoveries.length}`)
|
||||
|
||||
// 按优先级顺序直接注册,让高优先级的覆盖低优先级的
|
||||
for (const discovery of this.discoveries) {
|
||||
try {
|
||||
logger.debug(`[DiscoveryManager] 🔍 处理发现器: ${discovery.source} (优先级: ${discovery.priority})`)
|
||||
|
||||
if (typeof discovery.discoverRegistry === 'function') {
|
||||
// 使用新的discoverRegistry方法
|
||||
const discoveredRegistry = await discovery.discoverRegistry()
|
||||
if (discoveredRegistry instanceof Map) {
|
||||
logger.debug(`[DiscoveryManager] ✅ ${discovery.source} 发现 ${discoveredRegistry.size} 个资源`)
|
||||
for (const [resourceId, reference] of discoveredRegistry) {
|
||||
registry.register(resourceId, reference) // 直接注册,自动覆盖
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 向后兼容:使用discover()方法
|
||||
const resources = await discovery.discover()
|
||||
if (Array.isArray(resources)) {
|
||||
logger.debug(`[DiscoveryManager] ✅ ${discovery.source} 发现 ${resources.length} 个资源 (兼容模式)`)
|
||||
resources.forEach(resource => {
|
||||
if (resource.id && resource.reference) {
|
||||
registry.register(resource.id, resource.reference) // 直接注册
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
logger.warn(`[DiscoveryManager] ❌ ${discovery.source} direct registration failed: ${error.message}`)
|
||||
// 单个发现器失败不影响其他发现器
|
||||
}
|
||||
}
|
||||
|
||||
logger.info(`[DiscoveryManager] 🎯 注册完成,注册表总资源数: ${registry.size}`)
|
||||
}
|
||||
|
||||
/**
|
||||
* 发现并合并所有注册表(新架构方法)
|
||||
* 发现并合并所有注册表(RegistryData架构)
|
||||
* @returns {Promise<Map>} 合并后的资源注册表 Map<resourceId, reference>
|
||||
*/
|
||||
async discoverRegistries() {
|
||||
|
||||
@ -201,18 +201,17 @@ class PackageDiscovery extends BaseDiscovery {
|
||||
if (await fs.pathExists(roleFile)) {
|
||||
const reference = `@package://prompt/domain/${item}/${item}.role.md`
|
||||
|
||||
const resourceData = new ResourceData({
|
||||
id: item,
|
||||
source: 'package',
|
||||
protocol: 'role',
|
||||
name: ResourceData._generateDefaultName(item, 'role'),
|
||||
description: ResourceData._generateDefaultDescription(item, 'role'),
|
||||
reference: reference,
|
||||
metadata: {
|
||||
filePath: roleFile,
|
||||
scannedAt: new Date().toISOString()
|
||||
}
|
||||
})
|
||||
const resourceData = new ResourceData({
|
||||
id: item,
|
||||
source: 'package',
|
||||
protocol: 'role',
|
||||
name: ResourceData._generateDefaultName(item, 'role'),
|
||||
description: ResourceData._generateDefaultDescription(item, 'role'),
|
||||
reference: reference,
|
||||
metadata: {
|
||||
scannedAt: new Date().toISOString()
|
||||
}
|
||||
})
|
||||
|
||||
registryData.addResource(resourceData)
|
||||
}
|
||||
@ -232,7 +231,6 @@ class PackageDiscovery extends BaseDiscovery {
|
||||
description: ResourceData._generateDefaultDescription(item, 'thought'),
|
||||
reference: reference,
|
||||
metadata: {
|
||||
filePath: thoughtFile,
|
||||
scannedAt: new Date().toISOString()
|
||||
}
|
||||
})
|
||||
@ -258,7 +256,6 @@ class PackageDiscovery extends BaseDiscovery {
|
||||
description: ResourceData._generateDefaultDescription(execId, 'execution'),
|
||||
reference: reference,
|
||||
metadata: {
|
||||
filePath: path.join(executionDir, execFile),
|
||||
scannedAt: new Date().toISOString()
|
||||
}
|
||||
})
|
||||
@ -304,7 +301,6 @@ class PackageDiscovery extends BaseDiscovery {
|
||||
description: ResourceData._generateDefaultDescription(id, protocol),
|
||||
reference: reference,
|
||||
metadata: {
|
||||
filePath: path.join(itemPath, file),
|
||||
scannedAt: new Date().toISOString()
|
||||
}
|
||||
})
|
||||
@ -328,7 +324,6 @@ class PackageDiscovery extends BaseDiscovery {
|
||||
description: ResourceData._generateDefaultDescription(id, protocol),
|
||||
reference: reference,
|
||||
metadata: {
|
||||
filePath: path.join(coreDir, item),
|
||||
scannedAt: new Date().toISOString()
|
||||
}
|
||||
})
|
||||
@ -557,26 +552,52 @@ class PackageDiscovery extends BaseDiscovery {
|
||||
* @returns {Promise<string|null>} 包根目录路径或null
|
||||
*/
|
||||
async _findDevelopmentRoot() {
|
||||
// 策略1:检查当前工作目录
|
||||
const cwd = process.cwd()
|
||||
const hasPackageJson = await fs.pathExists(path.join(cwd, 'package.json'))
|
||||
const hasPromptDir = await fs.pathExists(path.join(cwd, 'prompt'))
|
||||
|
||||
if (!hasPackageJson || !hasPromptDir) {
|
||||
return null
|
||||
if (await this._isValidDevelopmentRoot(cwd)) {
|
||||
return fs.realpathSync(cwd)
|
||||
}
|
||||
|
||||
try {
|
||||
const packageJson = await fs.readJSON(path.join(cwd, 'package.json'))
|
||||
if (packageJson.name === 'dpml-prompt') {
|
||||
return fs.realpathSync(cwd) // 解析符号链接
|
||||
// 策略2:检查启动脚本的目录(适用于通过脚本启动的情况)
|
||||
const scriptDir = path.dirname(process.argv[1])
|
||||
let searchDir = scriptDir
|
||||
|
||||
// 向上查找最多5级目录
|
||||
for (let i = 0; i < 5; i++) {
|
||||
if (await this._isValidDevelopmentRoot(searchDir)) {
|
||||
return fs.realpathSync(searchDir)
|
||||
}
|
||||
} catch (error) {
|
||||
// Ignore JSON parsing errors
|
||||
|
||||
const parentDir = path.dirname(searchDir)
|
||||
if (parentDir === searchDir) break // 已到根目录
|
||||
searchDir = parentDir
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查目录是否为有效的开发环境根目录
|
||||
* @param {string} dir - 要检查的目录
|
||||
* @returns {Promise<boolean>} 是否为有效的开发根目录
|
||||
* @private
|
||||
*/
|
||||
async _isValidDevelopmentRoot(dir) {
|
||||
const hasPackageJson = await fs.pathExists(path.join(dir, 'package.json'))
|
||||
const hasPromptDir = await fs.pathExists(path.join(dir, 'prompt'))
|
||||
|
||||
if (!hasPackageJson || !hasPromptDir) {
|
||||
return false
|
||||
}
|
||||
|
||||
try {
|
||||
const packageJson = await fs.readJSON(path.join(dir, 'package.json'))
|
||||
return packageJson.name === 'dpml-prompt'
|
||||
} catch (error) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找已安装包的根目录
|
||||
* @returns {Promise<string|null>} 包根目录路径或null
|
||||
|
||||
@ -374,7 +374,6 @@ class ProjectDiscovery extends BaseDiscovery {
|
||||
description: ResourceData._generateDefaultDescription(item, 'role'),
|
||||
reference: reference,
|
||||
metadata: {
|
||||
filePath: roleFile,
|
||||
scannedAt: new Date().toISOString()
|
||||
}
|
||||
})
|
||||
@ -399,7 +398,6 @@ class ProjectDiscovery extends BaseDiscovery {
|
||||
description: ResourceData._generateDefaultDescription(thoughtId, 'thought'),
|
||||
reference: reference,
|
||||
metadata: {
|
||||
filePath: path.join(thoughtDir, thoughtFile),
|
||||
scannedAt: new Date().toISOString()
|
||||
}
|
||||
})
|
||||
@ -426,7 +424,6 @@ class ProjectDiscovery extends BaseDiscovery {
|
||||
description: ResourceData._generateDefaultDescription(execId, 'execution'),
|
||||
reference: reference,
|
||||
metadata: {
|
||||
filePath: path.join(executionDir, execFile),
|
||||
scannedAt: new Date().toISOString()
|
||||
}
|
||||
})
|
||||
@ -453,7 +450,6 @@ class ProjectDiscovery extends BaseDiscovery {
|
||||
description: ResourceData._generateDefaultDescription(knowledgeId, 'knowledge'),
|
||||
reference: reference,
|
||||
metadata: {
|
||||
filePath: path.join(knowledgeDir, knowledgeFile),
|
||||
scannedAt: new Date().toISOString()
|
||||
}
|
||||
})
|
||||
|
||||
@ -10,7 +10,6 @@ const ResourceManager = require('./resourceManager')
|
||||
|
||||
// 核心组件
|
||||
const ResourceProtocolParser = require('./resourceProtocolParser')
|
||||
const ResourceRegistry = require('./resourceRegistry')
|
||||
|
||||
// 数据类型
|
||||
const {
|
||||
@ -58,7 +57,6 @@ module.exports = {
|
||||
|
||||
// 核心组件
|
||||
ResourceProtocolParser,
|
||||
ResourceRegistry,
|
||||
|
||||
// 数据类型
|
||||
LoadingSemantics,
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
const fs = require('fs')
|
||||
const ResourceRegistry = require('./resourceRegistry')
|
||||
const RegistryData = require('./RegistryData')
|
||||
const ResourceProtocolParser = require('./resourceProtocolParser')
|
||||
const DiscoveryManager = require('./discovery/DiscoveryManager')
|
||||
@ -15,12 +14,15 @@ const KnowledgeProtocol = require('./protocols/KnowledgeProtocol')
|
||||
|
||||
class ResourceManager {
|
||||
constructor() {
|
||||
// 使用新的RegistryData替代旧的ResourceRegistry
|
||||
this.registry = new ResourceRegistry() // 保持向后兼容
|
||||
this.registryData = RegistryData.createEmpty('merged', null) // 新的v2.0注册表
|
||||
// 新架构:统一的资源注册表
|
||||
this.registryData = RegistryData.createEmpty('merged', null)
|
||||
|
||||
// 协议解析器
|
||||
this.protocolParser = new ResourceProtocolParser()
|
||||
this.parser = new ResourceProtocolParser() // 向后兼容别名
|
||||
this.discoveryManager = new DiscoveryManager() // 新发现管理器
|
||||
|
||||
// 资源发现管理器
|
||||
this.discoveryManager = new DiscoveryManager()
|
||||
|
||||
// 初始化协议处理器
|
||||
this.protocols = new Map()
|
||||
@ -47,8 +49,7 @@ class ResourceManager {
|
||||
*/
|
||||
async initializeWithNewArchitecture() {
|
||||
try {
|
||||
// 1. 清空现有注册表(支持重新初始化)
|
||||
this.registry.clear()
|
||||
// 1. 清空现有注册表
|
||||
this.registryData.clear()
|
||||
|
||||
// 2. 清除发现器缓存
|
||||
@ -56,16 +57,13 @@ class ResourceManager {
|
||||
this.discoveryManager.clearCache()
|
||||
}
|
||||
|
||||
// 3. 直接发现并注册资源到旧的ResourceRegistry(保持向后兼容)
|
||||
await this.discoveryManager.discoverAndDirectRegister(this.registry)
|
||||
|
||||
// 4. 同时填充新的RegistryData
|
||||
// 3. 填充新的RegistryData
|
||||
await this.populateRegistryData()
|
||||
|
||||
// 5. 为逻辑协议设置注册表引用
|
||||
// 4. 为逻辑协议设置注册表引用
|
||||
this.setupLogicalProtocols()
|
||||
|
||||
// 6. 设置初始化状态
|
||||
// 5. 设置初始化状态
|
||||
this.initialized = true
|
||||
|
||||
// 初始化完成,不输出日志避免干扰用户界面
|
||||
@ -155,13 +153,16 @@ class ResourceManager {
|
||||
|
||||
async loadResource(resourceId) {
|
||||
try {
|
||||
// 不再每次刷新资源,依赖初始化时的资源发现
|
||||
// 确保ResourceManager已初始化
|
||||
if (!this.initialized) {
|
||||
await this.initializeWithNewArchitecture()
|
||||
}
|
||||
|
||||
// 处理@!开头的DPML格式(如 @!role://java-developer)
|
||||
if (resourceId.startsWith('@!')) {
|
||||
const parsed = this.protocolParser.parse(resourceId)
|
||||
|
||||
// 从新的RegistryData查找资源
|
||||
// 从RegistryData查找资源
|
||||
const resourceData = this.registryData.findResourceById(parsed.path, parsed.protocol)
|
||||
if (!resourceData) {
|
||||
throw new Error(`Resource not found: ${parsed.protocol}:${parsed.path}`)
|
||||
@ -179,7 +180,6 @@ class ResourceManager {
|
||||
}
|
||||
|
||||
// 处理传统格式(如 role:java-developer)
|
||||
// 先尝试从新的RegistryData查找
|
||||
let reference = null
|
||||
|
||||
// 如果包含协议前缀(如 thought:remember)
|
||||
@ -197,11 +197,6 @@ class ResourceManager {
|
||||
}
|
||||
}
|
||||
|
||||
// 如果新的RegistryData中没找到,回退到旧的registry
|
||||
if (!reference) {
|
||||
reference = this.registry.get(resourceId)
|
||||
}
|
||||
|
||||
if (!reference) {
|
||||
throw new Error(`Resource not found: ${resourceId}`)
|
||||
}
|
||||
@ -216,34 +211,40 @@ class ResourceManager {
|
||||
reference
|
||||
}
|
||||
} catch (error) {
|
||||
logger.debug(`ResourceManager.loadResource failed for ${resourceId}: ${error.message}`)
|
||||
return {
|
||||
success: false,
|
||||
error: error,
|
||||
message: error.message
|
||||
error: error, // 返回完整的Error对象,而不是message字符串
|
||||
resourceId
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 统一协议解析入口点 - 按照架构文档设计
|
||||
* 解析协议引用并返回相关信息
|
||||
*/
|
||||
async resolveProtocolReference(reference) {
|
||||
// 1. 使用ResourceProtocolParser解析DPML语法
|
||||
const parsed = this.parser.parse(reference)
|
||||
|
||||
// 2. 获取对应的协议处理器
|
||||
const protocol = this.protocols.get(parsed.protocol)
|
||||
if (!protocol) {
|
||||
throw new Error(`不支持的协议: ${parsed.protocol}`)
|
||||
try {
|
||||
const parsed = this.protocolParser.parse(reference)
|
||||
|
||||
return {
|
||||
success: true,
|
||||
protocol: parsed.protocol,
|
||||
path: parsed.path,
|
||||
queryParams: parsed.queryParams,
|
||||
reference
|
||||
}
|
||||
} catch (error) {
|
||||
return {
|
||||
success: false,
|
||||
error: error.message,
|
||||
reference
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 委托给协议处理器解析
|
||||
return await protocol.resolve(parsed.path, parsed.queryParams)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有已注册的协议
|
||||
* @returns {Array<string>} 协议名称列表
|
||||
* 获取所有可用的协议列表
|
||||
*/
|
||||
getAvailableProtocols() {
|
||||
return Array.from(this.protocols.keys())
|
||||
@ -251,8 +252,6 @@ class ResourceManager {
|
||||
|
||||
/**
|
||||
* 检查是否支持指定协议
|
||||
* @param {string} protocol - 协议名称
|
||||
* @returns {boolean} 是否支持
|
||||
*/
|
||||
supportsProtocol(protocol) {
|
||||
return this.protocols.has(protocol)
|
||||
@ -272,77 +271,49 @@ class ResourceManager {
|
||||
return this._initialized || false
|
||||
}
|
||||
|
||||
// 向后兼容方法
|
||||
/**
|
||||
* 解析资源URL(向后兼容接口)
|
||||
* 返回格式:{success: boolean, content?: string, error?: Error}
|
||||
*/
|
||||
async resolve(resourceUrl) {
|
||||
try {
|
||||
// 不再每次刷新资源,依赖初始化时的资源发现
|
||||
|
||||
// Handle old format: role:java-backend-developer or @package://...
|
||||
if (resourceUrl.startsWith('@')) {
|
||||
// Parse the reference to check if it's a custom protocol
|
||||
const parsed = this.protocolParser.parse(resourceUrl)
|
||||
|
||||
// Check if it's a basic protocol that can be handled directly
|
||||
const basicProtocols = ['package', 'project', 'file']
|
||||
if (basicProtocols.includes(parsed.protocol)) {
|
||||
// Direct protocol format - use protocol resolution
|
||||
const content = await this.loadResourceByProtocol(resourceUrl)
|
||||
return {
|
||||
success: true,
|
||||
content,
|
||||
path: resourceUrl,
|
||||
reference: resourceUrl
|
||||
}
|
||||
} else {
|
||||
// Custom protocol - extract resource ID and use ResourceRegistry
|
||||
const resourceId = `${parsed.protocol}:${parsed.path}`
|
||||
return await this.loadResource(resourceId)
|
||||
}
|
||||
} else {
|
||||
// Legacy format: treat as resource ID
|
||||
return await this.loadResource(resourceUrl)
|
||||
}
|
||||
} catch (error) {
|
||||
return {
|
||||
success: false,
|
||||
error: error,
|
||||
message: error.message
|
||||
}
|
||||
return await this.loadResource(resourceUrl)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取注册表统计信息
|
||||
*/
|
||||
getStats() {
|
||||
return {
|
||||
totalResources: this.registryData.size,
|
||||
protocols: this.getAvailableProtocols(),
|
||||
initialized: this.initialized
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 无状态资源刷新(推荐方法)
|
||||
* 每次都重新发现并注册资源,无需维护初始化状态
|
||||
* 刷新资源(重新发现并注册)
|
||||
*/
|
||||
async refreshResources() {
|
||||
try {
|
||||
// 1. 清空当前注册表
|
||||
this.registry.clear()
|
||||
// 1. 标记为未初始化
|
||||
this.initialized = false
|
||||
|
||||
// 2. 清除发现器缓存
|
||||
// 2. 清空注册表
|
||||
this.registryData.clear()
|
||||
|
||||
// 3. 清除发现器缓存
|
||||
if (this.discoveryManager && typeof this.discoveryManager.clearCache === 'function') {
|
||||
this.discoveryManager.clearCache()
|
||||
}
|
||||
|
||||
// 3. 重新发现并直接注册
|
||||
await this.discoveryManager.discoverAndDirectRegister(this.registry)
|
||||
// 4. 重新初始化
|
||||
await this.initializeWithNewArchitecture()
|
||||
|
||||
// 4. 更新协议引用
|
||||
this.setupLogicalProtocols()
|
||||
|
||||
// 无状态设计:不设置initialized标志
|
||||
} catch (error) {
|
||||
logger.warn(`ResourceManager resource refresh failed: ${error.message}`)
|
||||
// 失败时保持注册表为空状态,下次调用时重试
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 强制重新初始化资源发现(清除缓存)
|
||||
* 用于解决新创建角色无法被发现的问题
|
||||
* @deprecated 推荐使用 refreshResources() 方法
|
||||
*/
|
||||
}
|
||||
|
||||
module.exports = ResourceManager
|
||||
@ -1,163 +0,0 @@
|
||||
const logger = require('../../utils/logger')
|
||||
|
||||
/**
|
||||
* 资源注册表
|
||||
* 新架构中用于存储动态发现的资源映射关系
|
||||
*/
|
||||
class ResourceRegistry {
|
||||
constructor() {
|
||||
this.index = new Map()
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册资源
|
||||
* @param {string} id - 资源ID (如 'role:java-developer')
|
||||
* @param {string} reference - 资源引用 (如 '@package://prompt/domain/java-developer/java-developer.role.md')
|
||||
*/
|
||||
register(id, reference) {
|
||||
this.index.set(id, reference)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取资源引用
|
||||
* @param {string} resourceId - 资源ID
|
||||
* @returns {string|undefined} 资源引用
|
||||
*/
|
||||
get(resourceId) {
|
||||
return this.index.get(resourceId)
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查资源是否存在
|
||||
* @param {string} resourceId - 资源ID
|
||||
* @returns {boolean} 是否存在
|
||||
*/
|
||||
has(resourceId) {
|
||||
return this.index.has(resourceId)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取注册表大小
|
||||
* @returns {number} 注册的资源数量
|
||||
*/
|
||||
get size() {
|
||||
return this.index.size
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空注册表
|
||||
*/
|
||||
clear() {
|
||||
this.index.clear()
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有资源ID
|
||||
* @returns {Array<string>} 资源ID列表
|
||||
*/
|
||||
keys() {
|
||||
return Array.from(this.index.keys())
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有资源条目
|
||||
* @returns {Array<[string, string]>} [resourceId, reference] 对的数组
|
||||
*/
|
||||
entries() {
|
||||
return Array.from(this.index.entries())
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印所有注册的资源(调试用)
|
||||
* @param {string} title - 可选标题
|
||||
*/
|
||||
printAll(title = '注册表资源清单') {
|
||||
logger.info(`\n📋 ${title}`)
|
||||
logger.info('='.repeat(50))
|
||||
|
||||
if (this.size === 0) {
|
||||
logger.info('🔍 注册表为空')
|
||||
return
|
||||
}
|
||||
|
||||
logger.info(`📊 总计: ${this.size} 个资源\n`)
|
||||
|
||||
// 按协议分组显示
|
||||
const groupedResources = this.groupByProtocol()
|
||||
|
||||
for (const [protocol, resources] of Object.entries(groupedResources)) {
|
||||
logger.info(`🔖 ${protocol.toUpperCase()} 协议 (${resources.length}个):`)
|
||||
resources.forEach(({ id, reference }) => {
|
||||
const resourceName = id.split(':')[1] || id
|
||||
logger.info(` • ${resourceName}`)
|
||||
logger.info(` └─ ${reference}`)
|
||||
})
|
||||
logger.info('')
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 按协议分组资源
|
||||
* @returns {Object} 分组后的资源,格式:{ protocol: [{ id, reference }, ...] }
|
||||
*/
|
||||
groupByProtocol() {
|
||||
const groups = {}
|
||||
|
||||
for (const [id, reference] of this.entries()) {
|
||||
const protocol = id.includes(':') ? id.split(':')[0] : 'other'
|
||||
|
||||
if (!groups[protocol]) {
|
||||
groups[protocol] = []
|
||||
}
|
||||
|
||||
groups[protocol].push({ id, reference })
|
||||
}
|
||||
|
||||
return groups
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取资源统计信息
|
||||
* @returns {Object} 统计信息
|
||||
*/
|
||||
getStats() {
|
||||
const groups = this.groupByProtocol()
|
||||
const stats = {
|
||||
total: this.size,
|
||||
byProtocol: {}
|
||||
}
|
||||
|
||||
for (const [protocol, resources] of Object.entries(groups)) {
|
||||
stats.byProtocol[protocol] = resources.length
|
||||
}
|
||||
|
||||
return stats
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索资源
|
||||
* @param {string} searchTerm - 搜索词
|
||||
* @returns {Array<[string, string]>} 匹配的资源
|
||||
*/
|
||||
search(searchTerm) {
|
||||
const term = searchTerm.toLowerCase()
|
||||
return this.entries().filter(([id, reference]) =>
|
||||
id.toLowerCase().includes(term) ||
|
||||
reference.toLowerCase().includes(term)
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 以JSON格式导出注册表
|
||||
* @returns {Object} 注册表数据
|
||||
*/
|
||||
toJSON() {
|
||||
return {
|
||||
size: this.size,
|
||||
resources: Object.fromEntries(this.entries()),
|
||||
stats: this.getStats()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ResourceRegistry
|
||||
148
src/lib/mcp/toolDefinitions.js
Normal file
148
src/lib/mcp/toolDefinitions.js
Normal file
@ -0,0 +1,148 @@
|
||||
/**
|
||||
* MCP 工具定义 - 共享配置
|
||||
* 统一管理所有MCP工具的描述和Schema定义,避免重复维护
|
||||
*/
|
||||
|
||||
const { z } = require('zod');
|
||||
|
||||
/**
|
||||
* 工具定义配置
|
||||
*/
|
||||
const TOOL_DEFINITIONS = [
|
||||
{
|
||||
name: 'promptx_init',
|
||||
description: '🎯 [AI专业能力启动器] ⚡ 让你瞬间拥有任何领域的专家级思维和技能 - 一键激活丰富的专业角色库(产品经理/开发者/设计师/营销专家等),获得跨对话记忆能力,30秒内从普通AI变身行业专家,每次需要专业服务时都应该先用这个',
|
||||
inputSchema: {
|
||||
type: 'object',
|
||||
properties: {}
|
||||
},
|
||||
zodSchema: z.object({})
|
||||
},
|
||||
{
|
||||
name: 'promptx_hello',
|
||||
description: '🎭 [专业角色选择菜单] 🔥 当你需要专业能力时必须先看这个 - 展示大量可激活的专家身份清单:产品经理/Java开发者/UI设计师/文案策划师/数据分析师/项目经理等,每个角色都有完整的专业思维模式和工作技能,看完后选择最适合当前任务的专家身份',
|
||||
inputSchema: {
|
||||
type: 'object',
|
||||
properties: {}
|
||||
},
|
||||
zodSchema: z.object({})
|
||||
},
|
||||
{
|
||||
name: 'promptx_action',
|
||||
description: '⚡ [专家身份变身器] 🚀 让你瞬间获得指定专业角色的完整思维和技能包 - 输入角色ID立即获得该领域专家的思考方式/工作原则/专业知识,同时自动加载相关历史经验和最佳实践,3秒内完成专业化转换,每次需要专业服务时必须使用',
|
||||
inputSchema: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
role: {
|
||||
type: 'string',
|
||||
description: '要激活的角色ID,如:copywriter, product-manager, java-backend-developer'
|
||||
}
|
||||
},
|
||||
required: ['role']
|
||||
},
|
||||
zodSchema: z.object({
|
||||
role: z.string().describe('要激活的角色ID,如:copywriter, product-manager, java-backend-developer')
|
||||
})
|
||||
},
|
||||
{
|
||||
name: 'promptx_learn',
|
||||
description: '🧠 [专业技能学习器] 💎 让你快速掌握特定专业技能和思维方式 - 学习创意思维/最佳实践/敏捷开发/产品设计等专业能力,支持thought://(思维模式) execution://(执行技能) knowledge://(专业知识)三种学习类型,学会后立即可以运用到工作中,想要专业化成长时使用',
|
||||
inputSchema: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
resource: {
|
||||
type: 'string',
|
||||
description: '资源URL,支持格式:thought://creativity, execution://best-practice, knowledge://scrum'
|
||||
}
|
||||
},
|
||||
required: ['resource']
|
||||
},
|
||||
zodSchema: z.object({
|
||||
resource: z.string().describe('资源URL,支持格式:thought://creativity, execution://best-practice, knowledge://scrum')
|
||||
})
|
||||
},
|
||||
{
|
||||
name: 'promptx_recall',
|
||||
description: '🔍 [记忆回想器] ⚡ 让你记住并运用以前的经验和知识 - 瞬间检索之前学会的专业技能/处理过的项目经验/掌握的最佳实践/解决过的问题方案,避免重复犯错和重新学习,当需要参考历史经验做决策时必须使用,让你的工作越来越专业',
|
||||
inputSchema: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
random_string: {
|
||||
type: 'string',
|
||||
description: 'Dummy parameter for no-parameter tools'
|
||||
},
|
||||
query: {
|
||||
type: 'string',
|
||||
description: '检索关键词或描述,可选参数,不提供则返回所有记忆'
|
||||
}
|
||||
},
|
||||
required: ['random_string']
|
||||
},
|
||||
zodSchema: z.object({
|
||||
query: z.string().optional().describe('检索关键词或描述,可选参数,不提供则返回所有记忆')
|
||||
})
|
||||
},
|
||||
{
|
||||
name: 'promptx_remember',
|
||||
description: '💾 [经验记忆存储器] 🧠 让你永久记住重要的经验和知识 - 将有价值的经验/学到的最佳实践/项目解决方案/工作心得保存到长期记忆中,下次遇到类似问题时可以快速回想起来,让你越来越聪明和专业,每次获得重要经验时都应该存储',
|
||||
inputSchema: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
content: {
|
||||
type: 'string',
|
||||
description: '要保存的重要信息或经验'
|
||||
},
|
||||
tags: {
|
||||
type: 'string',
|
||||
description: '自定义标签,用空格分隔,可选'
|
||||
}
|
||||
},
|
||||
required: ['content']
|
||||
},
|
||||
zodSchema: z.object({
|
||||
content: z.string().describe('要保存的重要信息或经验'),
|
||||
tags: z.string().optional().describe('自定义标签,用空格分隔,可选')
|
||||
})
|
||||
}
|
||||
];
|
||||
|
||||
/**
|
||||
* 获取所有工具定义 - 用于MCP Server
|
||||
*/
|
||||
function getToolDefinitions() {
|
||||
return TOOL_DEFINITIONS.map(tool => ({
|
||||
name: tool.name,
|
||||
description: tool.description,
|
||||
inputSchema: tool.inputSchema
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定工具的定义
|
||||
*/
|
||||
function getToolDefinition(toolName) {
|
||||
return TOOL_DEFINITIONS.find(tool => tool.name === toolName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取工具的Zod Schema - 用于HTTP Server
|
||||
*/
|
||||
function getToolZodSchema(toolName) {
|
||||
const tool = getToolDefinition(toolName);
|
||||
return tool ? tool.zodSchema : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有工具名称
|
||||
*/
|
||||
function getToolNames() {
|
||||
return TOOL_DEFINITIONS.map(tool => tool.name);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
TOOL_DEFINITIONS,
|
||||
getToolDefinitions,
|
||||
getToolDefinition,
|
||||
getToolZodSchema,
|
||||
getToolNames
|
||||
};
|
||||
@ -4,8 +4,8 @@
|
||||
"metadata": {
|
||||
"version": "2.0.0",
|
||||
"description": "package 级资源注册表",
|
||||
"createdAt": "2025-06-13T00:41:50.641Z",
|
||||
"updatedAt": "2025-06-13T00:41:50.644Z",
|
||||
"createdAt": "2025-06-13T14:10:05.651Z",
|
||||
"updatedAt": "2025-06-13T14:10:05.654Z",
|
||||
"resourceCount": 45
|
||||
},
|
||||
"resources": [
|
||||
@ -17,10 +17,9 @@
|
||||
"description": "专业角色,提供特定领域的专业能力",
|
||||
"reference": "@package://prompt/domain/assistant/assistant.role.md",
|
||||
"metadata": {
|
||||
"createdAt": "2025-06-13T00:41:50.643Z",
|
||||
"updatedAt": "2025-06-13T00:41:50.643Z",
|
||||
"filePath": "/Users/sean/WorkSpaces/DeepracticeProjects/PromptX/prompt/domain/assistant/assistant.role.md",
|
||||
"scannedAt": "2025-06-13T00:41:50.643Z"
|
||||
"createdAt": "2025-06-13T14:10:05.652Z",
|
||||
"updatedAt": "2025-06-13T14:10:05.652Z",
|
||||
"scannedAt": "2025-06-13T14:10:05.652Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -31,10 +30,9 @@
|
||||
"description": "思维模式,指导AI的思考方式",
|
||||
"reference": "@package://prompt/domain/assistant/thought/assistant.thought.md",
|
||||
"metadata": {
|
||||
"createdAt": "2025-06-13T00:41:50.643Z",
|
||||
"updatedAt": "2025-06-13T00:41:50.643Z",
|
||||
"filePath": "/Users/sean/WorkSpaces/DeepracticeProjects/PromptX/prompt/domain/assistant/thought/assistant.thought.md",
|
||||
"scannedAt": "2025-06-13T00:41:50.643Z"
|
||||
"createdAt": "2025-06-13T14:10:05.652Z",
|
||||
"updatedAt": "2025-06-13T14:10:05.652Z",
|
||||
"scannedAt": "2025-06-13T14:10:05.652Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -45,10 +43,9 @@
|
||||
"description": "执行模式,定义具体的行为模式",
|
||||
"reference": "@package://prompt/domain/assistant/execution/assistant.execution.md",
|
||||
"metadata": {
|
||||
"createdAt": "2025-06-13T00:41:50.643Z",
|
||||
"updatedAt": "2025-06-13T00:41:50.643Z",
|
||||
"filePath": "/Users/sean/WorkSpaces/DeepracticeProjects/PromptX/prompt/domain/assistant/execution/assistant.execution.md",
|
||||
"scannedAt": "2025-06-13T00:41:50.643Z"
|
||||
"createdAt": "2025-06-13T14:10:05.652Z",
|
||||
"updatedAt": "2025-06-13T14:10:05.652Z",
|
||||
"scannedAt": "2025-06-13T14:10:05.652Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -59,10 +56,9 @@
|
||||
"description": "专业角色,提供特定领域的专业能力",
|
||||
"reference": "@package://prompt/domain/frontend-developer/frontend-developer.role.md",
|
||||
"metadata": {
|
||||
"createdAt": "2025-06-13T00:41:50.643Z",
|
||||
"updatedAt": "2025-06-13T00:41:50.643Z",
|
||||
"filePath": "/Users/sean/WorkSpaces/DeepracticeProjects/PromptX/prompt/domain/frontend-developer/frontend-developer.role.md",
|
||||
"scannedAt": "2025-06-13T00:41:50.643Z"
|
||||
"createdAt": "2025-06-13T14:10:05.653Z",
|
||||
"updatedAt": "2025-06-13T14:10:05.653Z",
|
||||
"scannedAt": "2025-06-13T14:10:05.653Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -73,10 +69,9 @@
|
||||
"description": "思维模式,指导AI的思考方式",
|
||||
"reference": "@package://prompt/domain/frontend-developer/thought/frontend-developer.thought.md",
|
||||
"metadata": {
|
||||
"createdAt": "2025-06-13T00:41:50.643Z",
|
||||
"updatedAt": "2025-06-13T00:41:50.643Z",
|
||||
"filePath": "/Users/sean/WorkSpaces/DeepracticeProjects/PromptX/prompt/domain/frontend-developer/thought/frontend-developer.thought.md",
|
||||
"scannedAt": "2025-06-13T00:41:50.643Z"
|
||||
"createdAt": "2025-06-13T14:10:05.653Z",
|
||||
"updatedAt": "2025-06-13T14:10:05.653Z",
|
||||
"scannedAt": "2025-06-13T14:10:05.653Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -87,10 +82,9 @@
|
||||
"description": "执行模式,定义具体的行为模式",
|
||||
"reference": "@package://prompt/domain/java-backend-developer/execution/code-quality.execution.md",
|
||||
"metadata": {
|
||||
"createdAt": "2025-06-13T00:41:50.643Z",
|
||||
"updatedAt": "2025-06-13T00:41:50.643Z",
|
||||
"filePath": "/Users/sean/WorkSpaces/DeepracticeProjects/PromptX/prompt/domain/java-backend-developer/execution/code-quality.execution.md",
|
||||
"scannedAt": "2025-06-13T00:41:50.643Z"
|
||||
"createdAt": "2025-06-13T14:10:05.653Z",
|
||||
"updatedAt": "2025-06-13T14:10:05.653Z",
|
||||
"scannedAt": "2025-06-13T14:10:05.653Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -101,10 +95,9 @@
|
||||
"description": "执行模式,定义具体的行为模式",
|
||||
"reference": "@package://prompt/domain/frontend-developer/execution/frontend-developer.execution.md",
|
||||
"metadata": {
|
||||
"createdAt": "2025-06-13T00:41:50.643Z",
|
||||
"updatedAt": "2025-06-13T00:41:50.643Z",
|
||||
"filePath": "/Users/sean/WorkSpaces/DeepracticeProjects/PromptX/prompt/domain/frontend-developer/execution/frontend-developer.execution.md",
|
||||
"scannedAt": "2025-06-13T00:41:50.643Z"
|
||||
"createdAt": "2025-06-13T14:10:05.653Z",
|
||||
"updatedAt": "2025-06-13T14:10:05.653Z",
|
||||
"scannedAt": "2025-06-13T14:10:05.653Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -115,10 +108,9 @@
|
||||
"description": "执行模式,定义具体的行为模式",
|
||||
"reference": "@package://prompt/domain/frontend-developer/execution/technical-architecture.execution.md",
|
||||
"metadata": {
|
||||
"createdAt": "2025-06-13T00:41:50.643Z",
|
||||
"updatedAt": "2025-06-13T00:41:50.643Z",
|
||||
"filePath": "/Users/sean/WorkSpaces/DeepracticeProjects/PromptX/prompt/domain/frontend-developer/execution/technical-architecture.execution.md",
|
||||
"scannedAt": "2025-06-13T00:41:50.643Z"
|
||||
"createdAt": "2025-06-13T14:10:05.653Z",
|
||||
"updatedAt": "2025-06-13T14:10:05.653Z",
|
||||
"scannedAt": "2025-06-13T14:10:05.653Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -129,10 +121,9 @@
|
||||
"description": "执行模式,定义具体的行为模式",
|
||||
"reference": "@package://prompt/domain/frontend-developer/execution/user-experience.execution.md",
|
||||
"metadata": {
|
||||
"createdAt": "2025-06-13T00:41:50.643Z",
|
||||
"updatedAt": "2025-06-13T00:41:50.643Z",
|
||||
"filePath": "/Users/sean/WorkSpaces/DeepracticeProjects/PromptX/prompt/domain/frontend-developer/execution/user-experience.execution.md",
|
||||
"scannedAt": "2025-06-13T00:41:50.643Z"
|
||||
"createdAt": "2025-06-13T14:10:05.653Z",
|
||||
"updatedAt": "2025-06-13T14:10:05.653Z",
|
||||
"scannedAt": "2025-06-13T14:10:05.653Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -143,10 +134,9 @@
|
||||
"description": "执行模式,定义具体的行为模式",
|
||||
"reference": "@package://prompt/domain/frontend-developer/execution/wechat-miniprogram-development.execution.md",
|
||||
"metadata": {
|
||||
"createdAt": "2025-06-13T00:41:50.643Z",
|
||||
"updatedAt": "2025-06-13T00:41:50.643Z",
|
||||
"filePath": "/Users/sean/WorkSpaces/DeepracticeProjects/PromptX/prompt/domain/frontend-developer/execution/wechat-miniprogram-development.execution.md",
|
||||
"scannedAt": "2025-06-13T00:41:50.643Z"
|
||||
"createdAt": "2025-06-13T14:10:05.653Z",
|
||||
"updatedAt": "2025-06-13T14:10:05.653Z",
|
||||
"scannedAt": "2025-06-13T14:10:05.653Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -157,10 +147,9 @@
|
||||
"description": "专业角色,提供特定领域的专业能力",
|
||||
"reference": "@package://prompt/domain/java-backend-developer/java-backend-developer.role.md",
|
||||
"metadata": {
|
||||
"createdAt": "2025-06-13T00:41:50.643Z",
|
||||
"updatedAt": "2025-06-13T00:41:50.643Z",
|
||||
"filePath": "/Users/sean/WorkSpaces/DeepracticeProjects/PromptX/prompt/domain/java-backend-developer/java-backend-developer.role.md",
|
||||
"scannedAt": "2025-06-13T00:41:50.643Z"
|
||||
"createdAt": "2025-06-13T14:10:05.653Z",
|
||||
"updatedAt": "2025-06-13T14:10:05.653Z",
|
||||
"scannedAt": "2025-06-13T14:10:05.653Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -171,10 +160,9 @@
|
||||
"description": "思维模式,指导AI的思考方式",
|
||||
"reference": "@package://prompt/domain/java-backend-developer/thought/java-backend-developer.thought.md",
|
||||
"metadata": {
|
||||
"createdAt": "2025-06-13T00:41:50.643Z",
|
||||
"updatedAt": "2025-06-13T00:41:50.643Z",
|
||||
"filePath": "/Users/sean/WorkSpaces/DeepracticeProjects/PromptX/prompt/domain/java-backend-developer/thought/java-backend-developer.thought.md",
|
||||
"scannedAt": "2025-06-13T00:41:50.643Z"
|
||||
"createdAt": "2025-06-13T14:10:05.653Z",
|
||||
"updatedAt": "2025-06-13T14:10:05.653Z",
|
||||
"scannedAt": "2025-06-13T14:10:05.653Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -185,10 +173,9 @@
|
||||
"description": "执行模式,定义具体的行为模式",
|
||||
"reference": "@package://prompt/domain/java-backend-developer/execution/database-design.execution.md",
|
||||
"metadata": {
|
||||
"createdAt": "2025-06-13T00:41:50.643Z",
|
||||
"updatedAt": "2025-06-13T00:41:50.643Z",
|
||||
"filePath": "/Users/sean/WorkSpaces/DeepracticeProjects/PromptX/prompt/domain/java-backend-developer/execution/database-design.execution.md",
|
||||
"scannedAt": "2025-06-13T00:41:50.643Z"
|
||||
"createdAt": "2025-06-13T14:10:05.653Z",
|
||||
"updatedAt": "2025-06-13T14:10:05.653Z",
|
||||
"scannedAt": "2025-06-13T14:10:05.653Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -199,10 +186,9 @@
|
||||
"description": "执行模式,定义具体的行为模式",
|
||||
"reference": "@package://prompt/domain/java-backend-developer/execution/java-backend-developer.execution.md",
|
||||
"metadata": {
|
||||
"createdAt": "2025-06-13T00:41:50.643Z",
|
||||
"updatedAt": "2025-06-13T00:41:50.643Z",
|
||||
"filePath": "/Users/sean/WorkSpaces/DeepracticeProjects/PromptX/prompt/domain/java-backend-developer/execution/java-backend-developer.execution.md",
|
||||
"scannedAt": "2025-06-13T00:41:50.643Z"
|
||||
"createdAt": "2025-06-13T14:10:05.653Z",
|
||||
"updatedAt": "2025-06-13T14:10:05.653Z",
|
||||
"scannedAt": "2025-06-13T14:10:05.653Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -213,10 +199,9 @@
|
||||
"description": "执行模式,定义具体的行为模式",
|
||||
"reference": "@package://prompt/domain/java-backend-developer/execution/spring-ecosystem.execution.md",
|
||||
"metadata": {
|
||||
"createdAt": "2025-06-13T00:41:50.643Z",
|
||||
"updatedAt": "2025-06-13T00:41:50.643Z",
|
||||
"filePath": "/Users/sean/WorkSpaces/DeepracticeProjects/PromptX/prompt/domain/java-backend-developer/execution/spring-ecosystem.execution.md",
|
||||
"scannedAt": "2025-06-13T00:41:50.643Z"
|
||||
"createdAt": "2025-06-13T14:10:05.653Z",
|
||||
"updatedAt": "2025-06-13T14:10:05.653Z",
|
||||
"scannedAt": "2025-06-13T14:10:05.653Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -227,10 +212,9 @@
|
||||
"description": "执行模式,定义具体的行为模式",
|
||||
"reference": "@package://prompt/domain/java-backend-developer/execution/system-architecture.execution.md",
|
||||
"metadata": {
|
||||
"createdAt": "2025-06-13T00:41:50.643Z",
|
||||
"updatedAt": "2025-06-13T00:41:50.643Z",
|
||||
"filePath": "/Users/sean/WorkSpaces/DeepracticeProjects/PromptX/prompt/domain/java-backend-developer/execution/system-architecture.execution.md",
|
||||
"scannedAt": "2025-06-13T00:41:50.643Z"
|
||||
"createdAt": "2025-06-13T14:10:05.653Z",
|
||||
"updatedAt": "2025-06-13T14:10:05.653Z",
|
||||
"scannedAt": "2025-06-13T14:10:05.653Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -241,10 +225,9 @@
|
||||
"description": "专业角色,提供特定领域的专业能力",
|
||||
"reference": "@package://prompt/domain/product-manager/product-manager.role.md",
|
||||
"metadata": {
|
||||
"createdAt": "2025-06-13T00:41:50.643Z",
|
||||
"updatedAt": "2025-06-13T00:41:50.643Z",
|
||||
"filePath": "/Users/sean/WorkSpaces/DeepracticeProjects/PromptX/prompt/domain/product-manager/product-manager.role.md",
|
||||
"scannedAt": "2025-06-13T00:41:50.643Z"
|
||||
"createdAt": "2025-06-13T14:10:05.653Z",
|
||||
"updatedAt": "2025-06-13T14:10:05.653Z",
|
||||
"scannedAt": "2025-06-13T14:10:05.653Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -255,10 +238,9 @@
|
||||
"description": "思维模式,指导AI的思考方式",
|
||||
"reference": "@package://prompt/domain/product-manager/thought/product-manager.thought.md",
|
||||
"metadata": {
|
||||
"createdAt": "2025-06-13T00:41:50.643Z",
|
||||
"updatedAt": "2025-06-13T00:41:50.643Z",
|
||||
"filePath": "/Users/sean/WorkSpaces/DeepracticeProjects/PromptX/prompt/domain/product-manager/thought/product-manager.thought.md",
|
||||
"scannedAt": "2025-06-13T00:41:50.643Z"
|
||||
"createdAt": "2025-06-13T14:10:05.653Z",
|
||||
"updatedAt": "2025-06-13T14:10:05.653Z",
|
||||
"scannedAt": "2025-06-13T14:10:05.653Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -269,10 +251,9 @@
|
||||
"description": "执行模式,定义具体的行为模式",
|
||||
"reference": "@package://prompt/domain/product-manager/execution/market-analysis.execution.md",
|
||||
"metadata": {
|
||||
"createdAt": "2025-06-13T00:41:50.643Z",
|
||||
"updatedAt": "2025-06-13T00:41:50.643Z",
|
||||
"filePath": "/Users/sean/WorkSpaces/DeepracticeProjects/PromptX/prompt/domain/product-manager/execution/market-analysis.execution.md",
|
||||
"scannedAt": "2025-06-13T00:41:50.643Z"
|
||||
"createdAt": "2025-06-13T14:10:05.653Z",
|
||||
"updatedAt": "2025-06-13T14:10:05.653Z",
|
||||
"scannedAt": "2025-06-13T14:10:05.653Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -283,10 +264,9 @@
|
||||
"description": "执行模式,定义具体的行为模式",
|
||||
"reference": "@package://prompt/domain/product-manager/execution/product-manager.execution.md",
|
||||
"metadata": {
|
||||
"createdAt": "2025-06-13T00:41:50.643Z",
|
||||
"updatedAt": "2025-06-13T00:41:50.643Z",
|
||||
"filePath": "/Users/sean/WorkSpaces/DeepracticeProjects/PromptX/prompt/domain/product-manager/execution/product-manager.execution.md",
|
||||
"scannedAt": "2025-06-13T00:41:50.643Z"
|
||||
"createdAt": "2025-06-13T14:10:05.653Z",
|
||||
"updatedAt": "2025-06-13T14:10:05.653Z",
|
||||
"scannedAt": "2025-06-13T14:10:05.653Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -297,10 +277,9 @@
|
||||
"description": "执行模式,定义具体的行为模式",
|
||||
"reference": "@package://prompt/domain/product-manager/execution/user-research.execution.md",
|
||||
"metadata": {
|
||||
"createdAt": "2025-06-13T00:41:50.643Z",
|
||||
"updatedAt": "2025-06-13T00:41:50.643Z",
|
||||
"filePath": "/Users/sean/WorkSpaces/DeepracticeProjects/PromptX/prompt/domain/product-manager/execution/user-research.execution.md",
|
||||
"scannedAt": "2025-06-13T00:41:50.643Z"
|
||||
"createdAt": "2025-06-13T14:10:05.653Z",
|
||||
"updatedAt": "2025-06-13T14:10:05.653Z",
|
||||
"scannedAt": "2025-06-13T14:10:05.653Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -311,10 +290,9 @@
|
||||
"description": "专业角色,提供特定领域的专业能力",
|
||||
"reference": "@package://prompt/domain/xiaohongshu-marketer/xiaohongshu-marketer.role.md",
|
||||
"metadata": {
|
||||
"createdAt": "2025-06-13T00:41:50.643Z",
|
||||
"updatedAt": "2025-06-13T00:41:50.643Z",
|
||||
"filePath": "/Users/sean/WorkSpaces/DeepracticeProjects/PromptX/prompt/domain/xiaohongshu-marketer/xiaohongshu-marketer.role.md",
|
||||
"scannedAt": "2025-06-13T00:41:50.643Z"
|
||||
"createdAt": "2025-06-13T14:10:05.653Z",
|
||||
"updatedAt": "2025-06-13T14:10:05.653Z",
|
||||
"scannedAt": "2025-06-13T14:10:05.653Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -325,10 +303,9 @@
|
||||
"description": "思维模式,指导AI的思考方式",
|
||||
"reference": "@package://prompt/domain/xiaohongshu-marketer/thought/xiaohongshu-marketer.thought.md",
|
||||
"metadata": {
|
||||
"createdAt": "2025-06-13T00:41:50.643Z",
|
||||
"updatedAt": "2025-06-13T00:41:50.643Z",
|
||||
"filePath": "/Users/sean/WorkSpaces/DeepracticeProjects/PromptX/prompt/domain/xiaohongshu-marketer/thought/xiaohongshu-marketer.thought.md",
|
||||
"scannedAt": "2025-06-13T00:41:50.643Z"
|
||||
"createdAt": "2025-06-13T14:10:05.653Z",
|
||||
"updatedAt": "2025-06-13T14:10:05.653Z",
|
||||
"scannedAt": "2025-06-13T14:10:05.653Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -339,10 +316,9 @@
|
||||
"description": "执行模式,定义具体的行为模式",
|
||||
"reference": "@package://prompt/domain/xiaohongshu-marketer/execution/brand-marketing.execution.md",
|
||||
"metadata": {
|
||||
"createdAt": "2025-06-13T00:41:50.644Z",
|
||||
"updatedAt": "2025-06-13T00:41:50.644Z",
|
||||
"filePath": "/Users/sean/WorkSpaces/DeepracticeProjects/PromptX/prompt/domain/xiaohongshu-marketer/execution/brand-marketing.execution.md",
|
||||
"scannedAt": "2025-06-13T00:41:50.644Z"
|
||||
"createdAt": "2025-06-13T14:10:05.653Z",
|
||||
"updatedAt": "2025-06-13T14:10:05.653Z",
|
||||
"scannedAt": "2025-06-13T14:10:05.653Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -353,10 +329,9 @@
|
||||
"description": "执行模式,定义具体的行为模式",
|
||||
"reference": "@package://prompt/domain/xiaohongshu-marketer/execution/community-building.execution.md",
|
||||
"metadata": {
|
||||
"createdAt": "2025-06-13T00:41:50.644Z",
|
||||
"updatedAt": "2025-06-13T00:41:50.644Z",
|
||||
"filePath": "/Users/sean/WorkSpaces/DeepracticeProjects/PromptX/prompt/domain/xiaohongshu-marketer/execution/community-building.execution.md",
|
||||
"scannedAt": "2025-06-13T00:41:50.644Z"
|
||||
"createdAt": "2025-06-13T14:10:05.653Z",
|
||||
"updatedAt": "2025-06-13T14:10:05.653Z",
|
||||
"scannedAt": "2025-06-13T14:10:05.653Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -367,10 +342,9 @@
|
||||
"description": "执行模式,定义具体的行为模式",
|
||||
"reference": "@package://prompt/domain/xiaohongshu-marketer/execution/content-creation.execution.md",
|
||||
"metadata": {
|
||||
"createdAt": "2025-06-13T00:41:50.644Z",
|
||||
"updatedAt": "2025-06-13T00:41:50.644Z",
|
||||
"filePath": "/Users/sean/WorkSpaces/DeepracticeProjects/PromptX/prompt/domain/xiaohongshu-marketer/execution/content-creation.execution.md",
|
||||
"scannedAt": "2025-06-13T00:41:50.644Z"
|
||||
"createdAt": "2025-06-13T14:10:05.653Z",
|
||||
"updatedAt": "2025-06-13T14:10:05.653Z",
|
||||
"scannedAt": "2025-06-13T14:10:05.653Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -381,10 +355,9 @@
|
||||
"description": "执行模式,定义具体的行为模式",
|
||||
"reference": "@package://prompt/domain/xiaohongshu-marketer/execution/content-optimization.execution.md",
|
||||
"metadata": {
|
||||
"createdAt": "2025-06-13T00:41:50.644Z",
|
||||
"updatedAt": "2025-06-13T00:41:50.644Z",
|
||||
"filePath": "/Users/sean/WorkSpaces/DeepracticeProjects/PromptX/prompt/domain/xiaohongshu-marketer/execution/content-optimization.execution.md",
|
||||
"scannedAt": "2025-06-13T00:41:50.644Z"
|
||||
"createdAt": "2025-06-13T14:10:05.653Z",
|
||||
"updatedAt": "2025-06-13T14:10:05.653Z",
|
||||
"scannedAt": "2025-06-13T14:10:05.653Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -395,10 +368,9 @@
|
||||
"description": "执行模式,定义具体的行为模式",
|
||||
"reference": "@package://prompt/domain/xiaohongshu-marketer/execution/data-analytics.execution.md",
|
||||
"metadata": {
|
||||
"createdAt": "2025-06-13T00:41:50.644Z",
|
||||
"updatedAt": "2025-06-13T00:41:50.644Z",
|
||||
"filePath": "/Users/sean/WorkSpaces/DeepracticeProjects/PromptX/prompt/domain/xiaohongshu-marketer/execution/data-analytics.execution.md",
|
||||
"scannedAt": "2025-06-13T00:41:50.644Z"
|
||||
"createdAt": "2025-06-13T14:10:05.653Z",
|
||||
"updatedAt": "2025-06-13T14:10:05.653Z",
|
||||
"scannedAt": "2025-06-13T14:10:05.653Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -409,10 +381,9 @@
|
||||
"description": "执行模式,定义具体的行为模式",
|
||||
"reference": "@package://prompt/domain/xiaohongshu-marketer/execution/ecommerce-conversion.execution.md",
|
||||
"metadata": {
|
||||
"createdAt": "2025-06-13T00:41:50.644Z",
|
||||
"updatedAt": "2025-06-13T00:41:50.644Z",
|
||||
"filePath": "/Users/sean/WorkSpaces/DeepracticeProjects/PromptX/prompt/domain/xiaohongshu-marketer/execution/ecommerce-conversion.execution.md",
|
||||
"scannedAt": "2025-06-13T00:41:50.644Z"
|
||||
"createdAt": "2025-06-13T14:10:05.653Z",
|
||||
"updatedAt": "2025-06-13T14:10:05.653Z",
|
||||
"scannedAt": "2025-06-13T14:10:05.653Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -423,10 +394,9 @@
|
||||
"description": "执行模式,定义具体的行为模式",
|
||||
"reference": "@package://prompt/domain/xiaohongshu-marketer/execution/performance-optimization.execution.md",
|
||||
"metadata": {
|
||||
"createdAt": "2025-06-13T00:41:50.644Z",
|
||||
"updatedAt": "2025-06-13T00:41:50.644Z",
|
||||
"filePath": "/Users/sean/WorkSpaces/DeepracticeProjects/PromptX/prompt/domain/xiaohongshu-marketer/execution/performance-optimization.execution.md",
|
||||
"scannedAt": "2025-06-13T00:41:50.644Z"
|
||||
"createdAt": "2025-06-13T14:10:05.653Z",
|
||||
"updatedAt": "2025-06-13T14:10:05.653Z",
|
||||
"scannedAt": "2025-06-13T14:10:05.653Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -437,10 +407,9 @@
|
||||
"description": "执行模式,定义具体的行为模式",
|
||||
"reference": "@package://prompt/domain/xiaohongshu-marketer/execution/platform-compliance.execution.md",
|
||||
"metadata": {
|
||||
"createdAt": "2025-06-13T00:41:50.644Z",
|
||||
"updatedAt": "2025-06-13T00:41:50.644Z",
|
||||
"filePath": "/Users/sean/WorkSpaces/DeepracticeProjects/PromptX/prompt/domain/xiaohongshu-marketer/execution/platform-compliance.execution.md",
|
||||
"scannedAt": "2025-06-13T00:41:50.644Z"
|
||||
"createdAt": "2025-06-13T14:10:05.653Z",
|
||||
"updatedAt": "2025-06-13T14:10:05.653Z",
|
||||
"scannedAt": "2025-06-13T14:10:05.653Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -451,10 +420,9 @@
|
||||
"description": "执行模式,定义具体的行为模式",
|
||||
"reference": "@package://prompt/domain/xiaohongshu-marketer/execution/team-collaboration.execution.md",
|
||||
"metadata": {
|
||||
"createdAt": "2025-06-13T00:41:50.644Z",
|
||||
"updatedAt": "2025-06-13T00:41:50.644Z",
|
||||
"filePath": "/Users/sean/WorkSpaces/DeepracticeProjects/PromptX/prompt/domain/xiaohongshu-marketer/execution/team-collaboration.execution.md",
|
||||
"scannedAt": "2025-06-13T00:41:50.644Z"
|
||||
"createdAt": "2025-06-13T14:10:05.653Z",
|
||||
"updatedAt": "2025-06-13T14:10:05.653Z",
|
||||
"scannedAt": "2025-06-13T14:10:05.653Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -465,10 +433,9 @@
|
||||
"description": "执行模式,定义具体的行为模式",
|
||||
"reference": "@package://prompt/domain/xiaohongshu-marketer/execution/user-operation.execution.md",
|
||||
"metadata": {
|
||||
"createdAt": "2025-06-13T00:41:50.644Z",
|
||||
"updatedAt": "2025-06-13T00:41:50.644Z",
|
||||
"filePath": "/Users/sean/WorkSpaces/DeepracticeProjects/PromptX/prompt/domain/xiaohongshu-marketer/execution/user-operation.execution.md",
|
||||
"scannedAt": "2025-06-13T00:41:50.644Z"
|
||||
"createdAt": "2025-06-13T14:10:05.653Z",
|
||||
"updatedAt": "2025-06-13T14:10:05.653Z",
|
||||
"scannedAt": "2025-06-13T14:10:05.653Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -479,10 +446,9 @@
|
||||
"description": "执行模式,定义具体的行为模式",
|
||||
"reference": "@package://prompt/domain/xiaohongshu-marketer/execution/xiaohongshu-marketer.execution.md",
|
||||
"metadata": {
|
||||
"createdAt": "2025-06-13T00:41:50.644Z",
|
||||
"updatedAt": "2025-06-13T00:41:50.644Z",
|
||||
"filePath": "/Users/sean/WorkSpaces/DeepracticeProjects/PromptX/prompt/domain/xiaohongshu-marketer/execution/xiaohongshu-marketer.execution.md",
|
||||
"scannedAt": "2025-06-13T00:41:50.644Z"
|
||||
"createdAt": "2025-06-13T14:10:05.653Z",
|
||||
"updatedAt": "2025-06-13T14:10:05.653Z",
|
||||
"scannedAt": "2025-06-13T14:10:05.653Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -493,10 +459,9 @@
|
||||
"description": "执行模式,定义具体的行为模式",
|
||||
"reference": "@package://prompt/core/execution/dpml-protocol-knowledge.execution.md",
|
||||
"metadata": {
|
||||
"createdAt": "2025-06-13T00:41:50.644Z",
|
||||
"updatedAt": "2025-06-13T00:41:50.644Z",
|
||||
"filePath": "/Users/sean/WorkSpaces/DeepracticeProjects/PromptX/prompt/core/execution/dpml-protocol-knowledge.execution.md",
|
||||
"scannedAt": "2025-06-13T00:41:50.644Z"
|
||||
"createdAt": "2025-06-13T14:10:05.654Z",
|
||||
"updatedAt": "2025-06-13T14:10:05.654Z",
|
||||
"scannedAt": "2025-06-13T14:10:05.654Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -507,10 +472,9 @@
|
||||
"description": "执行模式,定义具体的行为模式",
|
||||
"reference": "@package://prompt/core/execution/execution-authoring.execution.md",
|
||||
"metadata": {
|
||||
"createdAt": "2025-06-13T00:41:50.644Z",
|
||||
"updatedAt": "2025-06-13T00:41:50.644Z",
|
||||
"filePath": "/Users/sean/WorkSpaces/DeepracticeProjects/PromptX/prompt/core/execution/execution-authoring.execution.md",
|
||||
"scannedAt": "2025-06-13T00:41:50.644Z"
|
||||
"createdAt": "2025-06-13T14:10:05.654Z",
|
||||
"updatedAt": "2025-06-13T14:10:05.654Z",
|
||||
"scannedAt": "2025-06-13T14:10:05.654Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -521,10 +485,9 @@
|
||||
"description": "执行模式,定义具体的行为模式",
|
||||
"reference": "@package://prompt/core/execution/resource-authoring.execution.md",
|
||||
"metadata": {
|
||||
"createdAt": "2025-06-13T00:41:50.644Z",
|
||||
"updatedAt": "2025-06-13T00:41:50.644Z",
|
||||
"filePath": "/Users/sean/WorkSpaces/DeepracticeProjects/PromptX/prompt/core/execution/resource-authoring.execution.md",
|
||||
"scannedAt": "2025-06-13T00:41:50.644Z"
|
||||
"createdAt": "2025-06-13T14:10:05.654Z",
|
||||
"updatedAt": "2025-06-13T14:10:05.654Z",
|
||||
"scannedAt": "2025-06-13T14:10:05.654Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -535,10 +498,9 @@
|
||||
"description": "执行模式,定义具体的行为模式",
|
||||
"reference": "@package://prompt/core/execution/role-authoring.execution.md",
|
||||
"metadata": {
|
||||
"createdAt": "2025-06-13T00:41:50.644Z",
|
||||
"updatedAt": "2025-06-13T00:41:50.644Z",
|
||||
"filePath": "/Users/sean/WorkSpaces/DeepracticeProjects/PromptX/prompt/core/execution/role-authoring.execution.md",
|
||||
"scannedAt": "2025-06-13T00:41:50.644Z"
|
||||
"createdAt": "2025-06-13T14:10:05.654Z",
|
||||
"updatedAt": "2025-06-13T14:10:05.654Z",
|
||||
"scannedAt": "2025-06-13T14:10:05.654Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -549,10 +511,9 @@
|
||||
"description": "执行模式,定义具体的行为模式",
|
||||
"reference": "@package://prompt/core/execution/role-design-patterns.execution.md",
|
||||
"metadata": {
|
||||
"createdAt": "2025-06-13T00:41:50.644Z",
|
||||
"updatedAt": "2025-06-13T00:41:50.644Z",
|
||||
"filePath": "/Users/sean/WorkSpaces/DeepracticeProjects/PromptX/prompt/core/execution/role-design-patterns.execution.md",
|
||||
"scannedAt": "2025-06-13T00:41:50.644Z"
|
||||
"createdAt": "2025-06-13T14:10:05.654Z",
|
||||
"updatedAt": "2025-06-13T14:10:05.654Z",
|
||||
"scannedAt": "2025-06-13T14:10:05.654Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -563,10 +524,9 @@
|
||||
"description": "执行模式,定义具体的行为模式",
|
||||
"reference": "@package://prompt/core/execution/role-generation.execution.md",
|
||||
"metadata": {
|
||||
"createdAt": "2025-06-13T00:41:50.644Z",
|
||||
"updatedAt": "2025-06-13T00:41:50.644Z",
|
||||
"filePath": "/Users/sean/WorkSpaces/DeepracticeProjects/PromptX/prompt/core/execution/role-generation.execution.md",
|
||||
"scannedAt": "2025-06-13T00:41:50.644Z"
|
||||
"createdAt": "2025-06-13T14:10:05.654Z",
|
||||
"updatedAt": "2025-06-13T14:10:05.654Z",
|
||||
"scannedAt": "2025-06-13T14:10:05.654Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -577,10 +537,9 @@
|
||||
"description": "执行模式,定义具体的行为模式",
|
||||
"reference": "@package://prompt/core/execution/thought-authoring.execution.md",
|
||||
"metadata": {
|
||||
"createdAt": "2025-06-13T00:41:50.644Z",
|
||||
"updatedAt": "2025-06-13T00:41:50.644Z",
|
||||
"filePath": "/Users/sean/WorkSpaces/DeepracticeProjects/PromptX/prompt/core/execution/thought-authoring.execution.md",
|
||||
"scannedAt": "2025-06-13T00:41:50.644Z"
|
||||
"createdAt": "2025-06-13T14:10:05.654Z",
|
||||
"updatedAt": "2025-06-13T14:10:05.654Z",
|
||||
"scannedAt": "2025-06-13T14:10:05.654Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -591,10 +550,9 @@
|
||||
"description": "专业角色,提供特定领域的专业能力",
|
||||
"reference": "@package://prompt/core/nuwa/nuwa.role.md",
|
||||
"metadata": {
|
||||
"createdAt": "2025-06-13T00:41:50.644Z",
|
||||
"updatedAt": "2025-06-13T00:41:50.644Z",
|
||||
"filePath": "/Users/sean/WorkSpaces/DeepracticeProjects/PromptX/prompt/core/nuwa/nuwa.role.md",
|
||||
"scannedAt": "2025-06-13T00:41:50.644Z"
|
||||
"createdAt": "2025-06-13T14:10:05.654Z",
|
||||
"updatedAt": "2025-06-13T14:10:05.654Z",
|
||||
"scannedAt": "2025-06-13T14:10:05.654Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -605,10 +563,9 @@
|
||||
"description": "思维模式,指导AI的思考方式",
|
||||
"reference": "@package://prompt/core/thought/recall.thought.md",
|
||||
"metadata": {
|
||||
"createdAt": "2025-06-13T00:41:50.644Z",
|
||||
"updatedAt": "2025-06-13T00:41:50.644Z",
|
||||
"filePath": "/Users/sean/WorkSpaces/DeepracticeProjects/PromptX/prompt/core/thought/recall.thought.md",
|
||||
"scannedAt": "2025-06-13T00:41:50.644Z"
|
||||
"createdAt": "2025-06-13T14:10:05.654Z",
|
||||
"updatedAt": "2025-06-13T14:10:05.654Z",
|
||||
"scannedAt": "2025-06-13T14:10:05.654Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -619,10 +576,9 @@
|
||||
"description": "思维模式,指导AI的思考方式",
|
||||
"reference": "@package://prompt/core/thought/remember.thought.md",
|
||||
"metadata": {
|
||||
"createdAt": "2025-06-13T00:41:50.644Z",
|
||||
"updatedAt": "2025-06-13T00:41:50.644Z",
|
||||
"filePath": "/Users/sean/WorkSpaces/DeepracticeProjects/PromptX/prompt/core/thought/remember.thought.md",
|
||||
"scannedAt": "2025-06-13T00:41:50.644Z"
|
||||
"createdAt": "2025-06-13T14:10:05.654Z",
|
||||
"updatedAt": "2025-06-13T14:10:05.654Z",
|
||||
"scannedAt": "2025-06-13T14:10:05.654Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -633,10 +589,9 @@
|
||||
"description": "思维模式,指导AI的思考方式",
|
||||
"reference": "@package://prompt/core/thought/role-creation.thought.md",
|
||||
"metadata": {
|
||||
"createdAt": "2025-06-13T00:41:50.644Z",
|
||||
"updatedAt": "2025-06-13T00:41:50.644Z",
|
||||
"filePath": "/Users/sean/WorkSpaces/DeepracticeProjects/PromptX/prompt/core/thought/role-creation.thought.md",
|
||||
"scannedAt": "2025-06-13T00:41:50.644Z"
|
||||
"createdAt": "2025-06-13T14:10:05.654Z",
|
||||
"updatedAt": "2025-06-13T14:10:05.654Z",
|
||||
"scannedAt": "2025-06-13T14:10:05.654Z"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
@ -1,146 +0,0 @@
|
||||
const ResourceRegistry = require('../../../lib/core/resource/resourceRegistry')
|
||||
|
||||
describe('ResourceRegistry - New Architecture Unit Tests', () => {
|
||||
let registry
|
||||
|
||||
beforeEach(() => {
|
||||
registry = new ResourceRegistry()
|
||||
})
|
||||
|
||||
describe('核心注册功能', () => {
|
||||
test('应该注册和获取资源', () => {
|
||||
const resourceId = 'role:java-developer'
|
||||
const reference = '@package://prompt/domain/java-developer/java-developer.role.md'
|
||||
|
||||
registry.register(resourceId, reference)
|
||||
|
||||
expect(registry.get(resourceId)).toBe(reference)
|
||||
expect(registry.has(resourceId)).toBe(true)
|
||||
expect(registry.size).toBe(1)
|
||||
})
|
||||
|
||||
test('应该处理多个资源注册', () => {
|
||||
const resources = [
|
||||
['role:java-developer', '@package://prompt/domain/java-developer/java-developer.role.md'],
|
||||
['thought:analysis', '@package://prompt/core/thought/analysis.thought.md'],
|
||||
['execution:code-review', '@package://prompt/core/execution/code-review.execution.md']
|
||||
]
|
||||
|
||||
resources.forEach(([id, ref]) => registry.register(id, ref))
|
||||
|
||||
expect(registry.size).toBe(3)
|
||||
resources.forEach(([id, ref]) => {
|
||||
expect(registry.get(id)).toBe(ref)
|
||||
expect(registry.has(id)).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
test('应该覆盖现有注册', () => {
|
||||
const resourceId = 'role:test'
|
||||
const oldReference = '@package://old.md'
|
||||
const newReference = '@package://new.md'
|
||||
|
||||
registry.register(resourceId, oldReference)
|
||||
expect(registry.get(resourceId)).toBe(oldReference)
|
||||
|
||||
registry.register(resourceId, newReference)
|
||||
expect(registry.get(resourceId)).toBe(newReference)
|
||||
expect(registry.size).toBe(1) // Size should not change
|
||||
})
|
||||
|
||||
test('应该处理不存在的资源', () => {
|
||||
expect(registry.get('non-existent')).toBeUndefined()
|
||||
expect(registry.has('non-existent')).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe('注册表操作', () => {
|
||||
beforeEach(() => {
|
||||
registry.register('role:assistant', '@package://assistant.role.md')
|
||||
registry.register('thought:analysis', '@package://analysis.thought.md')
|
||||
registry.register('execution:review', '@package://review.execution.md')
|
||||
})
|
||||
|
||||
test('应该返回所有资源键', () => {
|
||||
const keys = registry.keys()
|
||||
expect(keys).toHaveLength(3)
|
||||
expect(keys).toContain('role:assistant')
|
||||
expect(keys).toContain('thought:analysis')
|
||||
expect(keys).toContain('execution:review')
|
||||
})
|
||||
|
||||
test('应该返回所有条目', () => {
|
||||
const entries = registry.entries()
|
||||
expect(entries).toHaveLength(3)
|
||||
expect(entries).toContainEqual(['role:assistant', '@package://assistant.role.md'])
|
||||
expect(entries).toContainEqual(['thought:analysis', '@package://analysis.thought.md'])
|
||||
expect(entries).toContainEqual(['execution:review', '@package://review.execution.md'])
|
||||
})
|
||||
|
||||
test('应该清空注册表', () => {
|
||||
expect(registry.size).toBe(3)
|
||||
|
||||
registry.clear()
|
||||
|
||||
expect(registry.size).toBe(0)
|
||||
expect(registry.keys()).toHaveLength(0)
|
||||
expect(registry.has('role:assistant')).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe('边界情况处理', () => {
|
||||
test('应该处理空字符串资源ID', () => {
|
||||
registry.register('', '@package://empty.md')
|
||||
expect(registry.get('')).toBe('@package://empty.md')
|
||||
expect(registry.has('')).toBe(true)
|
||||
})
|
||||
|
||||
test('应该处理特殊字符的资源ID', () => {
|
||||
const specialId = 'role:java-developer@v2.0'
|
||||
const reference = '@package://special.md'
|
||||
|
||||
registry.register(specialId, reference)
|
||||
expect(registry.get(specialId)).toBe(reference)
|
||||
})
|
||||
|
||||
test('应该处理大量注册', () => {
|
||||
const count = 1000
|
||||
for (let i = 0; i < count; i++) {
|
||||
registry.register(`resource:${i}`, `@package://resource-${i}.md`)
|
||||
}
|
||||
|
||||
expect(registry.size).toBe(count)
|
||||
expect(registry.get('resource:500')).toBe('@package://resource-500.md')
|
||||
})
|
||||
})
|
||||
|
||||
describe('数据类型安全', () => {
|
||||
test('应该接受字符串类型的ID和引用', () => {
|
||||
// Valid strings
|
||||
registry.register('valid:id', 'valid-reference')
|
||||
expect(registry.get('valid:id')).toBe('valid-reference')
|
||||
})
|
||||
|
||||
test('应该严格按键类型匹配', () => {
|
||||
// Number key
|
||||
registry.register(123, 'number-key-value')
|
||||
expect(registry.get(123)).toBe('number-key-value')
|
||||
expect(registry.get('123')).toBeUndefined() // String '123' ≠ Number 123
|
||||
|
||||
// String key
|
||||
registry.register('456', 'string-key-value')
|
||||
expect(registry.get('456')).toBe('string-key-value')
|
||||
expect(registry.get(456)).toBeUndefined() // Number 456 ≠ String '456'
|
||||
})
|
||||
|
||||
test('应该保持原始数据类型', () => {
|
||||
const id = 'role:test'
|
||||
const reference = '@package://test.md'
|
||||
|
||||
registry.register(id, reference)
|
||||
|
||||
expect(typeof registry.get(id)).toBe('string')
|
||||
expect(registry.get(id)).toBe(reference)
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user