删除不再使用的bootstrap.md文件,更新promptx.js、MCPStreamableHttpCommand.js等文件以使用logger进行日志记录,重构资源管理和发现逻辑,确保代码一致性和可维护性。

This commit is contained in:
sean
2025-06-13 09:33:56 +08:00
parent cdd748d0dc
commit 2ecebac50b
29 changed files with 3561 additions and 450 deletions

View File

@ -1,57 +0,0 @@
{
"version": "0.0.1",
"initialized": "2025-05-31T06:15:39.372Z",
"defaultFormat": "human",
"stateHistory": [
{
"from": "initial",
"to": "init",
"timestamp": "2025-05-31T06:15:39.370Z",
"args": []
},
{
"from": "init",
"to": "hello",
"timestamp": "2025-05-31T06:15:39.373Z",
"args": []
},
{
"from": "hello",
"command": "init",
"timestamp": "2025-05-31T06:16:28.040Z",
"args": []
},
{
"from": "initialized",
"command": "hello",
"timestamp": "2025-05-31T06:16:28.042Z",
"args": []
},
{
"from": "discovering",
"command": "action",
"timestamp": "2025-05-31T06:16:28.042Z",
"args": [
"copywriter"
]
},
{
"from": "activated-copywriter",
"command": "learn",
"timestamp": "2025-05-31T06:16:28.046Z",
"args": [
"scrum"
]
},
{
"from": "learned-scrum",
"command": "recall",
"timestamp": "2025-05-31T06:16:28.047Z",
"args": [
"test"
]
}
],
"currentState": "recalled-test",
"lastUpdated": "2025-05-31T06:16:28.047Z"
}

View File

@ -95,7 +95,7 @@ class BasePouchCommand {
toString () {
const divider = '='.repeat(60)
const nextSteps = (pateoas.nextActions || [])
.map(action => ` - ${action.name}: ${action.description}\n 命令: ${action.command}`)
.map(action => ` - ${action.name}: ${action.description}\n 方式: ${action.method || action.command || '通过MCP工具'}`)
.join('\n')
return `

View File

@ -2,6 +2,7 @@ const PouchStateMachine = require('./state/PouchStateMachine')
const PouchRegistry = require('./PouchRegistry')
const commands = require('./commands')
const { COMMANDS } = require('../../../constants')
const logger = require('../../utils/logger')
/**
* 锦囊CLI主入口
@ -70,9 +71,9 @@ class PouchCLI {
if (!silent) {
// 如果结果有 toString 方法,打印人类可读格式
if (result && result.toString && typeof result.toString === 'function') {
console.log(result.toString())
logger.log(result.toString())
} else {
console.log(JSON.stringify(result, null, 2))
logger.log(JSON.stringify(result, null, 2))
}
}
@ -80,7 +81,7 @@ class PouchCLI {
} catch (error) {
// 错误输出始终使用stderr不干扰MCP协议
if (!silent) {
console.error(`执行命令出错: ${error.message}`)
logger.error(`执行命令出错: ${error.message}`)
}
throw error
}
@ -162,8 +163,8 @@ class PouchCLI {
* 运行交互式CLI
*/
async runInteractive () {
console.log('🎯 欢迎使用 PromptX 锦囊系统!')
console.log('输入 "help" 查看帮助,"exit" 退出\n')
logger.info('🎯 欢迎使用 PromptX 锦囊系统!')
logger.info('输入 "help" 查看帮助,"exit" 退出\n')
const readline = require('readline')
const rl = readline.createInterface({
@ -178,21 +179,21 @@ class PouchCLI {
const input = line.trim()
if (input === 'exit' || input === 'quit') {
console.log('再见!')
logger.info('再见!')
rl.close()
return
}
if (input === 'help') {
console.log(this.getHelp())
logger.info(this.getHelp())
} else if (input === 'status') {
console.log(JSON.stringify(this.getStatus(), null, 2))
logger.info(JSON.stringify(this.getStatus(), null, 2))
} else if (input) {
const { command, args } = this.parseCommand(input)
try {
await this.execute(command, args)
} catch (error) {
console.error(error.message)
logger.error(error.message)
}
}

View File

@ -1,8 +1,8 @@
const BasePouchCommand = require('../BasePouchCommand')
const fs = require('fs-extra')
const path = require('path')
const { COMMANDS, buildCommand } = require('../../../../constants')
const ResourceManager = require('../../resource/resourceManager')
const { COMMANDS } = require('../../../../constants')
const { getGlobalResourceManager } = require('../../resource')
const DPMLContentParser = require('../../resource/DPMLContentParser')
const SemanticRenderer = require('../../resource/SemanticRenderer')
const logger = require('../../../utils/logger')
@ -16,7 +16,8 @@ class ActionCommand extends BasePouchCommand {
super()
// 获取HelloCommand的角色注册表
this.helloCommand = null
this.resourceManager = new ResourceManager()
// 使用全局单例 ResourceManager
this.resourceManager = getGlobalResourceManager()
this.dpmlParser = new DPMLContentParser()
this.semanticRenderer = new SemanticRenderer()
}
@ -32,19 +33,20 @@ class ActionCommand extends BasePouchCommand {
return `❌ 请指定要激活的角色ID
🔍 使用方法:
\`\`\`bash
${buildCommand.action('<角色ID>')}
\`\`\`
通过 MCP PromptX 工具的 action 功能激活角色
💡 查看可用角色:
\`\`\`bash
${COMMANDS.HELLO}
\`\`\``
使用 MCP PromptX 工具的 hello 功能`
}
try {
logger.debug(`[ActionCommand] 开始激活角色: ${roleId}`)
// 0. 初始化 ResourceManager确保引用解析正常工作
if (!this.resourceManager.initialized) {
await this.resourceManager.initializeWithNewArchitecture()
}
// 1. 获取角色信息
const roleInfo = await this.getRoleInfo(roleId)
logger.debug(`[ActionCommand] getRoleInfo结果:`, roleInfo)
@ -53,10 +55,7 @@ ${COMMANDS.HELLO}
logger.warn(`[ActionCommand] 角色 "${roleId}" 不存在!`)
return `❌ 角色 "${roleId}" 不存在!
🔍 请使用以下命令查看可用角色
\`\`\`bash
${COMMANDS.HELLO}
\`\`\``
🔍 请使用 MCP PromptX 工具的 hello 功能查看可用角色`
}
// 2. 分析角色文件,提取依赖
@ -65,7 +64,7 @@ ${COMMANDS.HELLO}
// 3. 生成学习计划并直接加载所有内容
return await this.generateLearningPlan(roleInfo.id, dependencies)
} catch (error) {
console.error('Action command error:', error)
logger.error('Action command error:', error)
return `❌ 激活角色 "${roleId}" 时发生错误。
🔍 可能的原因:
@ -73,7 +72,7 @@ ${COMMANDS.HELLO}
- 权限不足
- 系统资源问题
💡 请使用 \`${COMMANDS.HELLO}\` 查看可用角色列表。`
💡 请使用 MCP PromptX 工具的 hello 功能查看可用角色列表。`
}
}
@ -158,7 +157,7 @@ ${COMMANDS.HELLO}
}
}
} catch (error) {
console.error('Error analyzing role dependencies:', error)
logger.error('Error analyzing role dependencies:', error)
// 如果分析失败,返回基础结构
return {
thoughts: [],
@ -408,11 +407,11 @@ ${recallContent}
⚠️ **重要**: recall已自动执行完成以上记忆将作为角色工作的重要参考依据
`
} catch (error) {
console.error('Auto recall error:', error)
logger.error('Auto recall error:', error)
return `---
## 🧠 自动记忆检索结果
⚠️ **记忆检索出现问题**: ${error.message}
💡 **建议**: 可手动执行 \`${buildCommand.recall()}\` 来检索相关记忆
💡 **建议**: 可使用 MCP PromptX 工具的 recall 功能来检索相关记忆
`
}
}
@ -425,12 +424,12 @@ ${recallContent}
currentState: 'action_awaiting_role',
availableTransitions: ['hello'],
nextActions: [
{
name: '查看可用角色',
description: '返回角色发现页面',
command: COMMANDS.HELLO,
priority: 'high'
}
{
name: '查看可用角色',
description: '返回角色发现页面',
method: 'MCP PromptX hello 工具',
priority: 'high'
}
],
metadata: {
message: '需要指定角色ID'
@ -445,25 +444,25 @@ ${recallContent}
{
name: '开始专业服务',
description: '角色已激活并完成记忆检索,可直接提供专业服务',
command: '开始对话',
method: '开始对话',
priority: 'high'
},
{
name: '返回角色选择',
description: '选择其他角色',
command: COMMANDS.HELLO,
method: 'MCP PromptX hello 工具',
priority: 'medium'
},
{
name: '记忆新知识',
description: '内化更多专业知识',
command: buildCommand.remember('<新知识>'),
method: 'MCP PromptX remember 工具',
priority: 'low'
},
{
name: '学习新资源',
description: '学习相关专业资源',
command: buildCommand.learn('<protocol>://<resource>'),
method: 'MCP PromptX learn 工具',
priority: 'low'
}
],

View File

@ -1,8 +1,7 @@
const BasePouchCommand = require('../BasePouchCommand')
const fs = require('fs-extra')
const path = require('path')
const { buildCommand } = require('../../../../constants')
const ResourceManager = require('../../resource/resourceManager')
const { getGlobalResourceManager } = require('../../resource')
const logger = require('../../../utils/logger')
/**
@ -12,8 +11,8 @@ const logger = require('../../../utils/logger')
class HelloCommand extends BasePouchCommand {
constructor () {
super()
// 使用新的ResourceManager架构替代SimplifiedRoleDiscovery
this.resourceManager = new ResourceManager()
// 使用全局单例 ResourceManager
this.resourceManager = getGlobalResourceManager()
}
getPurpose () {
@ -22,39 +21,80 @@ class HelloCommand extends BasePouchCommand {
/**
* 动态加载角色注册表 - 使用新的ResourceManager架构
* 移除缓存机制,每次都实时扫描,确保角色发现的一致性
* 直接使用现有资源注册表,避免重复刷新导致的死循环
*/
async loadRoleRegistry () {
try {
// 无状态资源刷新,确保能发现新创建的角色
await this.resourceManager.refreshResources()
// 获取所有角色相关的资源
// 确保ResourceManager已初始化
if (!this.resourceManager.initialized) {
await this.resourceManager.initializeWithNewArchitecture()
}
const roleRegistry = {}
// 从ResourceRegistry中获取所有role:开头的资源
const registry = this.resourceManager.registry
for (const [resourceId, reference] of registry.index) {
if (resourceId.startsWith('role:')) {
const roleId = resourceId.substring(5) // 移除 'role:' 前缀
// 使用新的RegistryData v2.0格式获取角色资源
const registryData = this.resourceManager.registryData
// 检查是否有RegistryDatav2.0格式)
if (registryData && registryData.resources && registryData.resources.length > 0) {
// 使用v2.0格式直接从RegistryData获取角色资源
const roleResources = registryData.getResourcesByProtocol('role')
for (const resource of roleResources) {
const roleId = resource.id
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] = {
file: reference,
name,
description,
source: reference.startsWith('@package://') ? 'system' : 'user-generated'
}
// 避免重复角色同一个ID可能有多个来源
if (!roleRegistry[roleId]) {
roleRegistry[roleId] = {
id: resource.id,
name: resource.name,
description: resource.description,
source: resource.source,
file: resource.reference,
protocol: resource.protocol
}
}
}
} 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) {
// 静默处理,避免干扰用户界面
}
} catch (error) {
// 单个角色加载失败不影响其他角色
logger.warn(`角色${roleId}加载失败: ${error.message}`)
}
}
}
@ -62,24 +102,26 @@ class HelloCommand extends BasePouchCommand {
// 如果没有任何角色,使用基础角色
if (Object.keys(roleRegistry).length === 0) {
roleRegistry.assistant = {
file: '@package://prompt/domain/assistant/assistant.role.md',
id: 'assistant',
name: '🙋 智能助手',
description: '通用助理角色,提供基础的助理服务和记忆支持',
source: 'fallback'
source: 'fallback',
file: '@package://prompt/domain/assistant/assistant.role.md',
protocol: 'role'
}
}
return roleRegistry
} catch (error) {
logger.warn('角色注册表加载失败,使用基础角色:', error.message)
// 使用基础角色作为fallback
return {
assistant: {
file: '@package://prompt/domain/assistant/assistant.role.md',
id: 'assistant',
name: '🙋 智能助手',
description: '通用助理角色,提供基础的助理服务和记忆支持',
source: 'fallback'
source: 'fallback',
file: '@package://prompt/domain/assistant/assistant.role.md',
protocol: 'role'
}
}
}
@ -151,68 +193,79 @@ class HelloCommand extends BasePouchCommand {
*/
getSourceLabel(source) {
switch (source) {
case 'user-generated':
return '(用户生成)'
case 'system':
return '(系统角色)'
case 'package':
return '📦 系统角色'
case 'project':
return '🏗️ 项目角色'
case 'user':
return '<27><> 用户角色'
case 'merged':
return '📦 系统角色' // merged来源的资源主要来自package
case 'fallback':
return '(默认角色)'
return '🔄 默认角色'
default:
return ''
return '❓ 未知来源'
}
}
async getContent (args) {
await this.loadRoleRegistry()
const allRoles = await this.getAllRoles()
const roleRegistry = await this.loadRoleRegistry()
const allRoles = Object.values(roleRegistry)
const totalRoles = allRoles.length
let content = `🤖 **AI专业角色服务清单** (共 ${totalRoles} 个专业角色可供选择)
> 💡 **重要说明**以下是可激活的AI专业角色。每个角色都有唯一的ID使用action命令激活。
> 💡 **重要说明**以下是可激活的AI专业角色。每个角色都有唯一的ID可通过MCP工具激活。
## 📋 可用角色列表
`
// 清楚显示角色ID和激活命令
allRoles.forEach((role, index) => {
const sourceLabel = this.getSourceLabel(role.source)
content += `### ${index + 1}. ${role.name} ${sourceLabel}
// 按来源分组显示角色
const rolesBySource = {}
allRoles.forEach(role => {
const source = role.source || 'unknown'
if (!rolesBySource[source]) {
rolesBySource[source] = []
}
rolesBySource[source].push(role)
})
let roleIndex = 1
// 优先显示系统角色
const sourceOrder = ['package', 'merged', 'project', 'user', 'fallback', 'unknown']
for (const source of sourceOrder) {
if (!rolesBySource[source] || rolesBySource[source].length === 0) continue
const sourceLabel = this.getSourceLabel(source)
content += `### ${sourceLabel}\n\n`
rolesBySource[source].forEach(role => {
content += `#### ${roleIndex}. ${role.name}
**角色ID**: \`${role.id}\`
**专业能力**: ${role.description}
**激活命令**: \`${buildCommand.action(role.id)}\`
**来源**: ${sourceLabel}
---
`
})
roleIndex++
})
}
content += `
## 🎯 **角色激活指南**
### 🔧 激活步骤
1. **选择角色**: 从上述列表中选择需要的专业角色
2. **使用角色ID**: 复制对应的角色ID\`${allRoles[0]?.id || 'assistant'}\`
3. **执行命令**: 运行 \`${buildCommand.action('<角色ID>')}\`
### 📝 激活示例
\`\`\`bash
# 激活智能助手角色
${buildCommand.action(allRoles[0]?.id || 'assistant')}
\`\`\`
### 🔧 激活方式
- 使用 **MCP PromptX 工具** 中的 \`action\` 功能
- 选择需要的角色ID进行激活
### ⚡ 激活后效果
- ✅ **获得专业能力** - AI将具备该角色的专业技能
- ✅ **学习技能组合** - 自动学习角色需要的思维和行为模式
- ✅ **即时专业化** - 立即可以提供该领域的专业服务
---
⚠️ **AI执行指令**
📢 **向主人汇报角色选项,明确说明使用方法:"请选择角色ID然后我将执行对应的action命令"**
🎯 **等待主人指定具体的角色ID后立即执行 \`${buildCommand.action('<角色ID>')}\`**
💡 **强调action命令需要具体的角色ID不是角色名称**
`
return content
@ -223,7 +276,7 @@ ${buildCommand.action(allRoles[0]?.id || 'assistant')}
const availableRoles = allRoles.map(role => ({
roleId: role.id,
name: role.name,
actionCommand: buildCommand.action(role.id)
source: role.source
}))
return {
@ -233,7 +286,7 @@ ${buildCommand.action(allRoles[0]?.id || 'assistant')}
{
name: '向主人汇报服务选项',
description: '将上述专业服务清单告知主人,并询问需求',
command: '等待主人选择后使用: ' + buildCommand.action('<选择的角色ID>'),
method: 'MCP PromptX action 工具',
priority: 'critical',
instruction: '必须先询问主人需求,不要自主选择角色'
}
@ -243,7 +296,7 @@ ${buildCommand.action(allRoles[0]?.id || 'assistant')}
availableRoles,
dataSource: 'resource.registry.json',
systemVersion: '锦囊串联状态机 v1.0',
designPhilosophy: 'AI use CLI get prompt for AI'
designPhilosophy: 'AI use MCP tools for role activation'
}
}
}
@ -298,27 +351,27 @@ ${buildCommand.action(allRoles[0]?.id || 'assistant')}
async debugRegistry() {
await this.loadRoleRegistry()
console.log('\n🔍 HelloCommand - 注册表调试信息')
console.log('='.repeat(50))
logger.info('\n🔍 HelloCommand - 注册表调试信息')
logger.info('='.repeat(50))
if (this.roleRegistry && Object.keys(this.roleRegistry).length > 0) {
console.log(`📊 发现 ${Object.keys(this.roleRegistry).length} 个角色资源:\n`)
logger.info(`📊 发现 ${Object.keys(this.roleRegistry).length} 个角色资源:\n`)
Object.entries(this.roleRegistry).forEach(([id, roleInfo]) => {
console.log(`🎭 ${id}`)
console.log(` 名称: ${roleInfo.name || '未命名'}`)
console.log(` 描述: ${roleInfo.description || '无描述'}`)
console.log(` 文件: ${roleInfo.file}`)
console.log(` 来源: ${roleInfo.source || '未知'}`)
console.log('')
logger.info(`🎭 ${id}`)
logger.info(` 名称: ${roleInfo.name || '未命名'}`)
logger.info(` 描述: ${roleInfo.description || '无描述'}`)
logger.info(` 文件: ${roleInfo.file}`)
logger.info(` 来源: ${roleInfo.source || '未知'}`)
logger.info('')
})
} else {
console.log('🔍 没有发现任何角色资源')
logger.info('🔍 没有发现任何角色资源')
}
// 同时显示ResourceManager的注册表
console.log('\n📋 ResourceManager 注册表:')
console.log('-'.repeat(30))
logger.info('\n📋 ResourceManager 注册表:')
logger.info('-'.repeat(30))
this.resourceManager.registry.printAll('底层资源注册表')
}
}

View File

@ -1,7 +1,10 @@
const BasePouchCommand = require('../BasePouchCommand')
const { ResourceManager } = require('../../resource')
const { getGlobalResourceManager } = require('../../resource')
const { COMMANDS } = require('../../../../constants')
const PromptXConfig = require('../../../utils/promptxConfig')
const RegistryData = require('../../resource/RegistryData')
const ProjectDiscovery = require('../../resource/discovery/ProjectDiscovery')
const logger = require('../../../utils/logger')
const path = require('path')
const fs = require('fs-extra')
@ -12,11 +15,13 @@ const fs = require('fs-extra')
class InitCommand extends BasePouchCommand {
constructor () {
super()
this.resourceManager = new ResourceManager()
// 使用全局单例 ResourceManager
this.resourceManager = getGlobalResourceManager()
this.projectDiscovery = new ProjectDiscovery()
}
getPurpose () {
return '初始化PromptX工作环境创建必要的配置目录和文件'
return '初始化PromptX工作环境创建必要的配置目录和文件,生成项目级资源注册表'
}
async getContent (args) {
@ -28,6 +33,12 @@ class InitCommand extends BasePouchCommand {
// 2. 基础环境准备 - 只创建 .promptx 目录
await this.ensurePromptXDirectory(workspacePath)
// 3. 生成项目级资源注册表
const registryStats = await this.generateProjectRegistry(workspacePath)
// 4. 刷新全局 ResourceManager确保新资源立即可用
await this.refreshGlobalResourceManager()
return `🎯 PromptX 初始化完成!
## 📦 版本信息
@ -37,13 +48,68 @@ class InitCommand extends BasePouchCommand {
✅ 创建了 \`.promptx\` 配置目录
✅ 工作环境就绪
## 📋 项目资源注册表
${registryStats.message}
## 🚀 下一步建议
- 使用 \`hello\` 发现可用的专业角色
- 使用 \`action\` 激活特定角色获得专业能力
- 使用 \`learn\` 深入学习专业知识
- 使用 \`remember/recall\` 管理专业记忆
💡 **提示**: 现在可以开始使用专业角色系统来增强AI能力了`
💡 **提示**: ${registryStats.totalResources > 0 ? '项目资源已优化为注册表模式,性能大幅提升!' : '现在可以开始创建项目级资源了!'}`
}
/**
* 生成项目级资源注册表
* @param {string} workspacePath - 工作目录路径
* @returns {Promise<Object>} 注册表生成统计信息
*/
async generateProjectRegistry(workspacePath) {
try {
// 1. 获取项目根目录
const projectRoot = await this.projectDiscovery._findProjectRoot()
// 2. 确保 .promptx/resource/domain 目录结构存在
const resourceDir = path.join(projectRoot, '.promptx', 'resource')
const domainDir = path.join(resourceDir, 'domain')
await fs.ensureDir(domainDir)
logger.debug(`[InitCommand] 确保目录结构存在: ${domainDir}`)
// 3. 使用 ProjectDiscovery 的正确方法生成注册表
logger.step('正在扫描项目资源...')
const registryData = await this.projectDiscovery.generateRegistry(projectRoot)
// 4. 生成统计信息
const stats = registryData.getStats()
const registryPath = path.join(projectRoot, '.promptx', 'resource', 'project.registry.json')
if (registryData.size === 0) {
return {
message: `✅ 项目资源目录已创建,注册表已初始化
📂 目录: ${path.relative(process.cwd(), domainDir)}
💾 注册表: ${path.relative(process.cwd(), registryPath)}
💡 现在可以在 domain 目录下创建角色资源了`,
totalResources: 0
}
}
return {
message: `✅ 项目资源注册表已重新生成
📊 总计: ${registryData.size} 个资源
📋 分类: role(${stats.byProtocol.role || 0}), thought(${stats.byProtocol.thought || 0}), execution(${stats.byProtocol.execution || 0}), knowledge(${stats.byProtocol.knowledge || 0})
💾 位置: ${path.relative(process.cwd(), registryPath)}`,
totalResources: registryData.size
}
} catch (error) {
logger.error('生成项目注册表时出错:', error)
return {
message: `❌ 生成项目注册表失败: ${error.message}`,
totalResources: 0
}
}
}
/**
@ -56,6 +122,24 @@ class InitCommand extends BasePouchCommand {
await config.ensureDir()
}
/**
* 刷新全局 ResourceManager
* 确保新创建的资源立即可用,无需重启 MCP Server
*/
async refreshGlobalResourceManager() {
try {
logger.debug('[InitCommand] 刷新全局 ResourceManager...')
// 重新初始化 ResourceManager清除缓存并重新发现资源
await this.resourceManager.initializeWithNewArchitecture()
logger.debug('[InitCommand] 全局 ResourceManager 刷新完成')
} catch (error) {
logger.warn(`[InitCommand] 刷新 ResourceManager 失败: ${error.message}`)
// 不抛出错误,避免影响 init 命令的主要功能
}
}
/**
* 获取版本信息
*/
@ -71,7 +155,7 @@ class InitCommand extends BasePouchCommand {
return `${baseVersion} (${packageName}@${baseVersion}, Node.js ${nodeVersion})`
}
} catch (error) {
console.warn('⚠️ 无法读取版本信息:', error.message)
logger.warn('无法读取版本信息:', error.message)
}
return '未知版本'
}
@ -102,6 +186,8 @@ class InitCommand extends BasePouchCommand {
}
}
}
}
module.exports = InitCommand

View File

@ -1,19 +1,25 @@
const BasePouchCommand = require('../BasePouchCommand')
const ResourceManager = require('../../resource/resourceManager')
const { COMMANDS, buildCommand } = require('../../../../constants')
const { getGlobalResourceManager } = require('../../resource')
const DPMLContentParser = require('../../resource/DPMLContentParser')
const SemanticRenderer = require('../../resource/SemanticRenderer')
const { COMMANDS } = require('../../../../constants')
/**
* 智能学习锦囊命令
* 支持加载thought、execution、memory等协议资源以及角色的personality、principle、knowledge
* 支持语义占位符渲染,将@引用展开为完整的语义内容
*/
class LearnCommand extends BasePouchCommand {
constructor () {
super()
this.resourceManager = new ResourceManager()
// 使用全局单例 ResourceManager
this.resourceManager = getGlobalResourceManager()
this.dpmlParser = new DPMLContentParser()
this.semanticRenderer = new SemanticRenderer()
}
getPurpose () {
return '智能学习指定协议的资源内容支持thought、execution、memory等DPML协议以及角色组件'
return '智能学习指定协议的资源内容支持thought、execution、memory等DPML协议以及角色组件,支持@引用的语义渲染'
}
async getContent (args) {
@ -24,13 +30,6 @@ class LearnCommand extends BasePouchCommand {
}
try {
// 直接使用ResourceManager解析资源
const result = await this.resourceManager.resolve(resourceUrl)
if (!result.success) {
return this.formatErrorResponse(resourceUrl, result.error.message)
}
// 解析协议信息
const urlMatch = resourceUrl.match(/^(@[!?]?)?([a-zA-Z][a-zA-Z0-9_-]*):\/\/(.+)$/)
if (!urlMatch) {
@ -39,12 +38,62 @@ class LearnCommand extends BasePouchCommand {
const [, loadingSemantic, protocol, resourceId] = urlMatch
return this.formatSuccessResponse(protocol, resourceId, result.content)
// 使用ResourceManager解析资源
const result = await this.resourceManager.resolve(resourceUrl)
if (!result.success) {
return this.formatErrorResponse(resourceUrl, result.error.message)
}
// 检查内容是否包含@引用,如果包含则进行语义渲染
let finalContent = result.content
if (this.containsReferences(result.content)) {
// 对于完整的DPML标签如<execution>...</execution>),提取标签内容进行渲染
const innerContent = this.extractTagInnerContent(result.content, protocol)
if (innerContent) {
// 解析标签内的混合内容(@引用 + 直接内容)
const tagSemantics = this.dpmlParser.parseTagContent(innerContent, protocol)
// 使用SemanticRenderer进行语义占位符渲染
const renderedInnerContent = await this.semanticRenderer.renderSemanticContent(tagSemantics, this.resourceManager)
// 如果渲染成功重新包装为完整的DPML标签
if (renderedInnerContent && renderedInnerContent.trim()) {
finalContent = `<${protocol}>\n${renderedInnerContent}\n</${protocol}>`
}
}
}
return this.formatSuccessResponse(protocol, resourceId, finalContent)
} catch (error) {
return this.formatErrorResponse(resourceUrl, error.message)
}
}
/**
* 检查内容是否包含@引用
* @param {string} content - 要检查的内容
* @returns {boolean} 是否包含@引用
*/
containsReferences(content) {
const resourceRegex = /@([!?]?)([a-zA-Z][a-zA-Z0-9_-]*):\/\/([a-zA-Z0-9_\/.,-]+)/g
return resourceRegex.test(content)
}
/**
* 提取完整的DPML标签内容
* @param {string} content - 要提取的内容
* @param {string} protocol - 协议
* @returns {string} 提取的完整DPML标签内容
*/
extractTagInnerContent(content, protocol) {
const tagRegex = new RegExp(`<${protocol}>([\\s\\S]*?)<\\/${protocol}>`, 'i')
const match = content.match(tagRegex)
return match ? match[1].trim() : null
}
/**
* 格式化成功响应
*/
@ -72,12 +121,9 @@ ${content}
- ✅ **可立即应用于实际场景**
## 🔄 下一步行动:
- 继续学习: 学习其他相关资源
命令: \`${buildCommand.learn('<protocol>://<resource-id>')}\`
- 应用记忆: 检索相关经验
命令: \`${COMMANDS.RECALL}\`
- 激活角色: 激活完整角色能力
命令: \`${buildCommand.action('<role-id>')}\`
- 继续学习: 使用 MCP PromptX learn 工具学习其他相关资源
- 应用记忆: 使用 MCP PromptX recall 工具检索相关经验
- 激活角色: 使用 MCP PromptX action 工具激活完整角色能力
📍 当前状态learned_${protocol}`
}
@ -100,19 +146,13 @@ ${errorMessage}
- \`knowledge://role-id\` - 学习角色知识
🔍 查看可用资源:
\`\`\`bash
${buildCommand.action('<role-id>')} # 查看角色的所有依赖
\`\`\`
使用 MCP PromptX action 工具查看角色的所有依赖
🔄 下一步行动:
- 继续学习: 学习其他资源
命令: ${buildCommand.learn('<protocol>://<resource-id>')}
- 应用记忆: 检索相关经验
命令: ${COMMANDS.RECALL}
- 激活角色: 激活完整角色能力
命令: ${buildCommand.action('<role-id>')}
- 查看角色列表: 选择其他角色
命令: ${COMMANDS.HELLO}`
- 继续学习: 使用 MCP PromptX learn 工具学习其他资源
- 应用记忆: 使用 MCP PromptX recall 工具检索相关经验
- 激活角色: 使用 MCP PromptX action 工具激活完整角色能力
- 查看角色列表: 使用 MCP PromptX hello 工具选择其他角色`
}
/**
@ -122,9 +162,8 @@ ${buildCommand.action('<role-id>')} # 查看角色的所有依赖
return `🎓 **Learn锦囊 - 智能学习系统**
## 📖 基本用法
\`\`\`bash
promptx learn <protocol>://<resource-id>
\`\`\`
通过 MCP PromptX learn 工具学习资源:
\`<protocol>://<resource-id>\`
## 🎯 支持的协议
@ -139,28 +178,18 @@ promptx learn <protocol>://<resource-id>
- **\`knowledge://\`** - 专业知识
## 📝 使用示例
\`\`\`bash
# 学习执行技能
${buildCommand.learn('execution://deal-at-reference')}
# 学习思维模式
${buildCommand.learn('thought://prompt-developer')}
# 学习角色人格
${buildCommand.learn('personality://video-copywriter')}
\`\`\`
通过 MCP PromptX learn 工具学习各种资源:
- 学习执行技能: \`execution://deal-at-reference\`
- 学习思维模式: \`thought://prompt-developer\`
- 学习角色人格: \`personality://video-copywriter\`
## 🔍 发现可学习资源
\`\`\`bash
${buildCommand.action('<role-id>')} # 查看角色需要的所有资源
${COMMANDS.HELLO} # 查看可用角色列表
\`\`\`
- 使用 MCP PromptX action 工具查看角色需要的所有资源
- 使用 MCP PromptX hello 工具查看可用角色列表
🔄 下一步行动:
- 激活角色: 分析角色依赖
命令: ${buildCommand.action('<role-id>')}
- 查看角色: 选择感兴趣的角色
命令: ${COMMANDS.HELLO}`
- 激活角色: 使用 MCP PromptX action 工具分析角色依赖
- 查看角色: 使用 MCP PromptX hello 工具选择感兴趣的角色`
}
/**
@ -177,13 +206,13 @@ ${COMMANDS.HELLO} # 查看可用角色列表
{
name: '查看可用角色',
description: '返回角色选择页面',
command: COMMANDS.HELLO,
method: 'MCP PromptX hello 工具',
priority: 'high'
},
{
name: '生成学习计划',
description: '为特定角色生成学习计划',
command: buildCommand.action('<role-id>'),
method: 'MCP PromptX action 工具',
priority: 'high'
}
]
@ -199,7 +228,7 @@ ${COMMANDS.HELLO} # 查看可用角色列表
{
name: '查看使用帮助',
description: '重新学习命令使用方法',
command: COMMANDS.LEARN,
method: 'MCP PromptX learn 工具',
priority: 'high'
}
]
@ -215,25 +244,25 @@ ${COMMANDS.HELLO} # 查看可用角色列表
{
name: '继续学习',
description: '学习其他资源',
command: buildCommand.learn('<protocol>://<resource-id>'),
method: 'MCP PromptX learn 工具',
priority: 'medium'
},
{
name: '应用记忆',
description: '检索相关经验',
command: COMMANDS.RECALL,
method: 'MCP PromptX recall 工具',
priority: 'medium'
},
{
name: '激活角色',
description: '激活完整角色能力',
command: buildCommand.action('<role-id>'),
method: 'MCP PromptX action 工具',
priority: 'high'
},
{
name: '查看角色列表',
description: '选择其他角色',
command: COMMANDS.HELLO,
method: 'MCP PromptX hello 工具',
priority: 'low'
}
],

View File

@ -0,0 +1,279 @@
const BasePouchCommand = require('../BasePouchCommand')
const ResourceManager = require('../../resource/resourceManager')
const DPMLContentParser = require('../../resource/DPMLContentParser')
const SemanticRenderer = require('../../resource/SemanticRenderer')
const { COMMANDS } = require('../../../../constants')
/**
* 智能学习锦囊命令
* 支持加载thought、execution、memory等协议资源以及角色的personality、principle、knowledge
* 支持语义占位符渲染,将@引用展开为完整的语义内容
*/
class LearnCommand extends BasePouchCommand {
constructor () {
super()
this.resourceManager = new ResourceManager()
this.dpmlParser = new DPMLContentParser()
this.semanticRenderer = new SemanticRenderer()
}
getPurpose () {
return '智能学习指定协议的资源内容支持thought、execution、memory等DPML协议以及角色组件支持@引用的语义渲染'
}
async getContent (args) {
const [resourceUrl] = args
if (!resourceUrl) {
return this.getUsageHelp()
}
try {
// 解析协议信息
const urlMatch = resourceUrl.match(/^(@[!?]?)?([a-zA-Z][a-zA-Z0-9_-]*):\/\/(.+)$/)
if (!urlMatch) {
return this.formatErrorResponse(resourceUrl, '无效的资源URL格式')
}
const [, loadingSemantic, protocol, resourceId] = urlMatch
// 使用ResourceManager解析资源
const result = await this.resourceManager.resolve(resourceUrl)
if (!result.success) {
return this.formatErrorResponse(resourceUrl, result.error.message)
}
// 检查内容是否包含@引用,如果包含则进行语义渲染
let finalContent = result.content
if (this.containsReferences(result.content)) {
// 对于完整的DPML标签如<execution>...</execution>),提取标签内容进行渲染
const innerContent = this.extractTagInnerContent(result.content, protocol)
if (innerContent) {
// 解析标签内的混合内容(@引用 + 直接内容)
const tagSemantics = this.dpmlParser.parseTagContent(innerContent, protocol)
// 使用SemanticRenderer进行语义占位符渲染
const renderedInnerContent = await this.semanticRenderer.renderSemanticContent(tagSemantics, this.resourceManager)
// 如果渲染成功重新包装为完整的DPML标签
if (renderedInnerContent && renderedInnerContent.trim()) {
finalContent = `<${protocol}>\n${renderedInnerContent}\n</${protocol}>`
}
}
}
return this.formatSuccessResponse(protocol, resourceId, finalContent)
} catch (error) {
return this.formatErrorResponse(resourceUrl, error.message)
}
}
/**
* 检查内容是否包含@引用
* @param {string} content - 要检查的内容
* @returns {boolean} 是否包含@引用
*/
containsReferences(content) {
const resourceRegex = /@([!?]?)([a-zA-Z][a-zA-Z0-9_-]*):\/\/([a-zA-Z0-9_\/.,-]+)/g
return resourceRegex.test(content)
}
/**
* 提取完整的DPML标签内容
* @param {string} content - 要提取的内容
* @param {string} protocol - 协议
* @returns {string} 提取的完整DPML标签内容
*/
extractTagInnerContent(content, protocol) {
const tagRegex = new RegExp(`<${protocol}>([\\s\\S]*?)<\\/${protocol}>`, 'i')
const match = content.match(tagRegex)
return match ? match[1].trim() : null
}
/**
* 格式化成功响应
*/
formatSuccessResponse (protocol, resourceId, content) {
const protocolLabels = {
thought: '🧠 思维模式',
execution: '⚡ 执行模式',
memory: '💾 记忆模式',
personality: '👤 角色人格',
principle: '⚖️ 行为原则',
knowledge: '📚 专业知识'
}
const label = protocolLabels[protocol] || `📄 ${protocol}`
return `✅ **成功学习${label}${resourceId}**
## 📋 学习内容
${content}
## 🎯 学习效果
- ✅ **已激活${label}能力**
- ✅ **相关知识已整合到AI认知体系**
- ✅ **可立即应用于实际场景**
## 🔄 下一步行动:
- 继续学习: 使用 MCP PromptX learn 工具学习其他相关资源
- 应用记忆: 使用 MCP PromptX recall 工具检索相关经验
- 激活角色: 使用 MCP PromptX action 工具激活完整角色能力
📍 当前状态learned_${protocol}`
}
/**
* 格式化错误响应
*/
formatErrorResponse (resourceUrl, errorMessage) {
return `❌ 学习资源失败:${resourceUrl}
🔍 错误详情:
${errorMessage}
💡 支持的协议:
- \`thought://resource-id\` - 学习思维模式
- \`execution://resource-id\` - 学习执行模式
- \`memory://resource-id\` - 学习记忆模式
- \`personality://role-id\` - 学习角色思维
- \`principle://role-id\` - 学习角色原则
- \`knowledge://role-id\` - 学习角色知识
🔍 查看可用资源:
使用 MCP PromptX action 工具查看角色的所有依赖
🔄 下一步行动:
- 继续学习: 使用 MCP PromptX learn 工具学习其他资源
- 应用记忆: 使用 MCP PromptX recall 工具检索相关经验
- 激活角色: 使用 MCP PromptX action 工具激活完整角色能力
- 查看角色列表: 使用 MCP PromptX hello 工具选择其他角色`
}
/**
* 获取使用帮助
*/
getUsageHelp () {
return `🎓 **Learn锦囊 - 智能学习系统**
## 📖 基本用法
\`\`\`bash
promptx learn <protocol>://<resource-id>
\`\`\`
## 🎯 支持的协议
### 🔧 DPML核心协议
- **\`thought://\`** - 思维模式资源
- **\`execution://\`** - 执行模式资源
- **\`memory://\`** - 记忆系统资源
### 👤 角色组件协议
- **\`personality://\`** - 角色人格特征
- **\`principle://\`** - 行为原则
- **\`knowledge://\`** - 专业知识
## 📝 使用示例
通过 MCP PromptX learn 工具学习各种资源:
- 学习执行技能: `execution://deal-at-reference`
- 学习思维模式: `thought://prompt-developer`
- 学习角色人格: `personality://video-copywriter`
## 🔍 发现可学习资源
- 使用 MCP PromptX action 工具查看角色需要的所有资源
- 使用 MCP PromptX hello 工具查看可用角色列表
🔄 下一步行动:
- 激活角色: 使用 MCP PromptX action 工具分析角色依赖
- 查看角色: 使用 MCP PromptX hello 工具选择感兴趣的角色`
}
/**
* 获取PATEOAS导航信息
*/
getPATEOAS (args) {
const [resourceUrl] = args
if (!resourceUrl) {
return {
currentState: 'learn_awaiting_resource',
availableTransitions: ['hello', 'action'],
nextActions: [
{
name: '查看可用角色',
description: '返回角色选择页面',
command: COMMANDS.HELLO,
priority: 'high'
},
{
name: '生成学习计划',
description: '为特定角色生成学习计划',
method: 'MCP PromptX action 工具',
priority: 'high'
}
]
}
}
const urlMatch = resourceUrl.match(/^([a-zA-Z]+):\/\/(.+)$/)
if (!urlMatch) {
return {
currentState: 'learn_error',
availableTransitions: ['hello', 'action'],
nextActions: [
{
name: '查看使用帮助',
description: '重新学习命令使用方法',
command: COMMANDS.LEARN,
priority: 'high'
}
]
}
}
const [, protocol, resourceId] = urlMatch
return {
currentState: `learned_${protocol}`,
availableTransitions: ['learn', 'recall', 'hello', 'action'],
nextActions: [
{
name: '继续学习',
description: '学习其他资源',
command: buildCommand.learn('<protocol>://<resource-id>'),
priority: 'medium'
},
{
name: '应用记忆',
description: '检索相关经验',
command: COMMANDS.RECALL,
priority: 'medium'
},
{
name: '激活角色',
description: '激活完整角色能力',
command: buildCommand.action('<role-id>'),
priority: 'high'
},
{
name: '查看角色列表',
description: '选择其他角色',
command: COMMANDS.HELLO,
priority: 'low'
}
],
metadata: {
learnedResource: resourceUrl,
protocol,
resourceId,
systemVersion: '锦囊串联状态机 v1.0'
}
}
}
}
module.exports = LearnCommand

View File

@ -1,7 +1,7 @@
const BasePouchCommand = require('../BasePouchCommand')
const fs = require('fs-extra')
const path = require('path')
const { COMMANDS, buildCommand } = require('../../../../constants')
const { COMMANDS } = require('../../../../constants')
/**
* 记忆检索锦囊命令
@ -25,8 +25,8 @@ class RecallCommand extends BasePouchCommand {
if (memories.length === 0) {
return `🧠 AI记忆体系中暂无内容。
💡 建议:
1. 使用 ${COMMANDS.REMEMBER} 内化新知识
2. 使用 ${COMMANDS.LEARN} 学习后再内化
1. 使用 MCP PromptX remember 工具内化新知识
2. 使用 MCP PromptX learn 工具学习后再内化
3. 开始构建AI的专业知识体系`
}
@ -54,22 +54,22 @@ ${formattedMemories}
{
name: '选择角色',
description: '选择专业角色来应用检索到的知识',
command: COMMANDS.HELLO
method: 'MCP PromptX hello 工具'
},
{
name: '记忆新知识',
description: '继续内化更多专业知识',
command: COMMANDS.REMEMBER + ' "<新的知识内容>"'
method: 'MCP PromptX remember 工具'
},
{
name: '学习资源',
description: '学习相关专业资源',
command: COMMANDS.LEARN + ' <protocol>://<resource>'
method: 'MCP PromptX learn 工具'
},
{
name: '继续检索',
description: '检索其他相关记忆',
command: COMMANDS.RECALL + ' <关键词>'
method: 'MCP PromptX recall 工具'
}
],
metadata: {

View File

@ -2,7 +2,6 @@ const BasePouchCommand = require('../BasePouchCommand')
const fs = require('fs-extra')
const path = require('path')
const PackageProtocol = require('../../resource/protocols/PackageProtocol')
const { buildCommand } = require('../../../../constants')
/**
* 角色注册锦囊命令
@ -25,14 +24,10 @@ class RegisterCommand extends BasePouchCommand {
return `❌ 请指定要注册的角色ID
🔍 使用方法:
\`\`\`bash
${buildCommand.register('<角色ID>')}
\`\`\`
通过 MCP PromptX register 工具注册角色
💡 例如:
\`\`\`bash
${buildCommand.register('my-custom-role')}
\`\`\``
注册角色ID: 'my-custom-role'`
}
try {
@ -47,9 +42,7 @@ ${buildCommand.register('my-custom-role')}
- prompt/domain/${roleId}/execution/${roleId}.execution.md
💡 您可以使用女娲来创建完整的角色套件:
\`\`\`bash
${buildCommand.action('nuwa')}
\`\`\``
使用 MCP PromptX action 工具激活 'nuwa' 角色`
}
// 2. 提取角色元数据
@ -67,9 +60,7 @@ ${buildCommand.action('nuwa')}
- 文件路径:${roleMetadata.filePath}
🎯 **下一步操作**
\`\`\`bash
${buildCommand.action(roleId)}
\`\`\`
使用 MCP PromptX action 工具激活角色: ${roleId}
💡 现在您可以激活这个角色了!`
} else {
@ -188,13 +179,13 @@ ${buildCommand.action(roleId)}
{
name: '查看可用角色',
description: '查看已注册的角色',
command: buildCommand.hello(),
method: 'MCP PromptX hello 工具',
priority: 'medium'
},
{
name: '创建新角色',
description: '使用女娲创建新角色',
command: buildCommand.action('nuwa'),
method: 'MCP PromptX action 工具 (nuwa)',
priority: 'high'
}
],
@ -211,13 +202,13 @@ ${buildCommand.action(roleId)}
{
name: '激活角色',
description: '激活刚注册的角色',
command: buildCommand.action(roleId),
method: `MCP PromptX action 工具 (${roleId})`,
priority: 'high'
},
{
name: '查看所有角色',
description: '查看角色列表',
command: buildCommand.hello(),
method: 'MCP PromptX hello 工具',
priority: 'medium'
}
],

View File

@ -1,7 +1,7 @@
const BasePouchCommand = require('../BasePouchCommand')
const fs = require('fs-extra')
const path = require('path')
const { COMMANDS, buildCommand } = require('../../../../constants')
const { COMMANDS } = require('../../../../constants')
/**
* 记忆保存锦囊命令
@ -153,12 +153,9 @@ ${memoryLine}
- ✅ **支持跨会话记忆保持**
## 🔄 下一步行动:
- 记忆检索: 验证知识内化效果
命令: \`${buildCommand.recall(value)}\`
- 能力强化: 学习相关知识增强记忆
命令: \`${buildCommand.learn('<protocol>://<resource-id>')}\`
- 应用实践: 在实际场景中运用记忆
命令: \`${buildCommand.action('<role-id>')}\`
- 记忆检索: 使用 MCP PromptX recall 工具验证知识内化效果
- 能力强化: 使用 MCP PromptX learn 工具学习相关知识增强记忆
- 应用实践: 使用 MCP PromptX action 工具在实际场景中运用记忆
📍 当前状态memory_saved`
}
@ -170,32 +167,24 @@ ${memoryLine}
return `🧠 **Remember锦囊 - AI记忆增强系统**
## 📖 基本用法
\`\`\`bash
${buildCommand.remember('<知识内容>')}
\`\`\`
通过 MCP PromptX remember 工具内化知识
## 💡 记忆内化示例
### 📝 AI记忆内化
AI学习和内化各种专业知识
\`\`\`bash
${buildCommand.remember('"构建代码 → 运行测试 → 部署到staging → 验证功能 → 发布生产"')}
${buildCommand.remember('"用户反馈视频加载慢排查发现是CDN配置问题修改后加载速度提升60%"')}
${buildCommand.remember('"React Hooks允许在函数组件中使用state和其他React特性"')}
${buildCommand.remember('"每个PR至少需要2个人review必须包含测试用例"')}
\`\`\`
AI学习和内化各种专业知识
- "构建代码 → 运行测试 → 部署到staging → 验证功能 → 发布生产"
- "用户反馈视频加载慢排查发现是CDN配置问题修改后加载速度提升60%"
- "React Hooks允许在函数组件中使用state和其他React特性"
- "每个PR至少需要2个人review必须包含测试用例"
## 🔍 记忆检索与应用
\`\`\`bash
${buildCommand.recall('<关键词>')} # AI主动检索记忆
${buildCommand.action('<role-id>')} # AI运用记忆激活角色
\`\`\`
- 使用 MCP PromptX recall 工具主动检索记忆
- 使用 MCP PromptX action 工具运用记忆激活角色
🔄 下一步行动:
- 开始记忆: 内化第一条知识
命令: ${buildCommand.remember('<content>')}
- 学习资源: 学习新知识再内化
命令: ${buildCommand.learn('<protocol>://<resource>')}`
- 开始记忆: 使用 MCP PromptX remember 工具内化第一条知识
- 学习资源: 使用 MCP PromptX learn 工具学习新知识再内化`
}
/**
@ -212,13 +201,13 @@ ${buildCommand.action('<role-id>')} # AI运用记忆激活角色
{
name: '查看角色',
description: '选择角色获取专业知识',
command: COMMANDS.HELLO,
method: 'MCP PromptX hello 工具',
priority: 'medium'
},
{
name: '学习资源',
description: '学习新知识然后保存',
command: buildCommand.learn('<protocol>://<resource>'),
method: 'MCP PromptX learn 工具',
priority: 'high'
}
]
@ -232,25 +221,25 @@ ${buildCommand.action('<role-id>')} # AI运用记忆激活角色
{
name: '检索记忆',
description: '测试记忆是否可检索',
command: buildCommand.recall('<关键词>'),
method: 'MCP PromptX recall 工具',
priority: 'high'
},
{
name: '学习强化',
description: '学习相关知识加强记忆',
command: buildCommand.learn('<protocol>://<resource>'),
method: 'MCP PromptX learn 工具',
priority: 'medium'
},
{
name: '应用记忆',
description: '在实际场景中应用记忆',
command: buildCommand.action('<role-id>'),
method: 'MCP PromptX action 工具',
priority: 'medium'
},
{
name: '继续内化',
description: 'AI继续内化更多知识',
command: buildCommand.remember('<content>'),
method: 'MCP PromptX remember 工具',
priority: 'low'
}
],