refactor: 把 hello 改成 welcome

This commit is contained in:
sean
2025-06-19 15:59:04 +08:00
parent 11d8c9a75e
commit 90c4e5d8ab
20 changed files with 71 additions and 350 deletions

View File

@ -34,7 +34,7 @@ PromptX 能做什么?简单来说,它让你的 AI 助手拥有了"大脑"和
### 📸 **配置成功后的使用效果** ### 📸 **配置成功后的使用效果**
#### **1. 发现并激活专业角色** #### **1. 发现并激活专业角色**
*使用 `promptx_hello` 发现可用角色,再用 `promptx_action` 激活AI即刻变身领域专家。* *使用 `promptx_welcome` 发现可用角色,再用 `promptx_action` 激活AI即刻变身领域专家。*
<img src="assets/role-discovery.png" alt="角色发现与激活" width="80%"> <img src="assets/role-discovery.png" alt="角色发现与激活" width="80%">
#### **2. 拥有智能记忆** #### **2. 拥有智能记忆**

View File

@ -34,7 +34,7 @@ What can PromptX do? Simply put, it gives your AI assistant a "brain" and "memor
### 📸 **Usage Effects After Configuration** ### 📸 **Usage Effects After Configuration**
#### **1. Discover and Activate Professional Roles** #### **1. Discover and Activate Professional Roles**
*Use `promptx_hello` to discover available roles, then `promptx_action` to activate them, instantly transforming your AI into a domain expert.* *Use `promptx_welcome` to discover available roles, then `promptx_action` to activate them, instantly transforming your AI into a domain expert.*
<img src="assets/role-discovery.png" alt="Role Discovery and Activation" width="80%"> <img src="assets/role-discovery.png" alt="Role Discovery and Activation" width="80%">
#### **2. Intelligent Memory** #### **2. Intelligent Memory**

View File

@ -31,10 +31,10 @@ program
}) })
program program
.command('hello') .command('welcome')
.description('👋 hello锦囊 - 发现并展示所有可用的AI角色和领域专家') .description('👋 welcome锦囊 - 发现并展示所有可用的AI角色和领域专家')
.action(async (options) => { .action(async (options) => {
await cli.execute('hello', []) await cli.execute('welcome', [])
}) })
program program
@ -151,7 +151,7 @@ ${chalk.cyan('💡 PromptX 锦囊框架 - AI use CLI get prompt for AI')}
${chalk.cyan('🎒 七大核心命令:')} ${chalk.cyan('🎒 七大核心命令:')}
🏗️ ${chalk.cyan('init')} → 初始化环境,传达系统协议 🏗️ ${chalk.cyan('init')} → 初始化环境,传达系统协议
👋 ${chalk.yellow('hello')} → 发现可用角色和领域专家 👋 ${chalk.yellow('welcome')} → 发现可用角色和领域专家
${chalk.red('action')} → 激活特定角色,获取专业能力 ${chalk.red('action')} → 激活特定角色,获取专业能力
📚 ${chalk.blue('learn')} → 深入学习领域知识体系 📚 ${chalk.blue('learn')} → 深入学习领域知识体系
🔍 ${chalk.green('recall')} → AI主动检索应用记忆 🔍 ${chalk.green('recall')} → AI主动检索应用记忆
@ -164,7 +164,7 @@ ${chalk.cyan('示例:')}
promptx init promptx init
${chalk.gray('# 2⃣ 发现可用角色')} ${chalk.gray('# 2⃣ 发现可用角色')}
promptx hello promptx welcome
${chalk.gray('# 3⃣ 激活专业角色')} ${chalk.gray('# 3⃣ 激活专业角色')}
promptx action copywriter promptx action copywriter

View File

@ -19,7 +19,7 @@ const COMMAND_PREFIX = getCommandPrefix()
// 静态命令常量 // 静态命令常量
const COMMANDS = { const COMMANDS = {
INIT: `${COMMAND_PREFIX} init`, INIT: `${COMMAND_PREFIX} init`,
HELLO: `${COMMAND_PREFIX} hello`, WELCOME: `${COMMAND_PREFIX} welcome`,
ACTION: `${COMMAND_PREFIX} action`, ACTION: `${COMMAND_PREFIX} action`,
LEARN: `${COMMAND_PREFIX} learn`, LEARN: `${COMMAND_PREFIX} learn`,
RECALL: `${COMMAND_PREFIX} recall`, RECALL: `${COMMAND_PREFIX} recall`,

View File

@ -460,7 +460,7 @@ class MCPServerCommand {
const paramMapping = { const paramMapping = {
'promptx_init': (args) => args.workingDirectory ? [args] : [], 'promptx_init': (args) => args.workingDirectory ? [args] : [],
'promptx_hello': () => [], 'promptx_welcome': () => [],
'promptx_action': (args) => [args.role], 'promptx_action': (args) => [args.role],

View File

@ -431,7 +431,7 @@ class MCPStreamableHttpCommand {
convertMCPToCliParams(toolName, mcpArgs) { convertMCPToCliParams(toolName, mcpArgs) {
const paramMapping = { const paramMapping = {
'promptx_init': () => [], 'promptx_init': () => [],
'promptx_hello': () => [], 'promptx_welcome': () => [],
'promptx_action': (args) => args && args.role ? [args.role] : [], 'promptx_action': (args) => args && args.role ? [args.role] : [],
'promptx_learn': (args) => args && args.resource ? [args.resource] : [], 'promptx_learn': (args) => args && args.resource ? [args.resource] : [],
'promptx_recall': (args) => { 'promptx_recall': (args) => {

View File

@ -26,7 +26,7 @@ class PouchCLI {
// 批量注册所有命令 // 批量注册所有命令
this.registry.registerBatch({ this.registry.registerBatch({
init: commands.InitCommand, init: commands.InitCommand,
hello: commands.HelloCommand, welcome: commands.WelcomeCommand,
action: commands.ActionCommand, action: commands.ActionCommand,
learn: commands.LearnCommand, learn: commands.LearnCommand,
recall: commands.RecallCommand, recall: commands.RecallCommand,
@ -115,7 +115,7 @@ class PouchCLI {
💡 使用示例: 💡 使用示例:
${COMMANDS.INIT} # 初始化工作环境 ${COMMANDS.INIT} # 初始化工作环境
${COMMANDS.HELLO} # 发现可用角色 ${COMMANDS.WELCOME} # 发现可用角色
${COMMANDS.ACTION} copywriter # 激活文案专家 ${COMMANDS.ACTION} copywriter # 激活文案专家
${COMMANDS.LEARN} scrum # 学习敏捷知识 ${COMMANDS.LEARN} scrum # 学习敏捷知识
${COMMANDS.RECALL} frontend # 检索前端记忆 ${COMMANDS.RECALL} frontend # 检索前端记忆

View File

@ -19,7 +19,7 @@
├── PouchStateMachine # 状态机管理器 ├── PouchStateMachine # 状态机管理器
└── Commands/ # 五个核心锦囊 └── Commands/ # 五个核心锦囊
├── InitCommand # 初始化锦囊 ├── InitCommand # 初始化锦囊
├── HelloCommand # 角色发现锦囊 ├── WelcomeCommand # 角色发现锦囊
├── ActionCommand # 角色激活锦囊 ├── ActionCommand # 角色激活锦囊
├── LearnCommand # 领域学习锦囊 ├── LearnCommand # 领域学习锦囊
└── RecallCommand # 记忆检索锦囊 └── RecallCommand # 记忆检索锦囊
@ -43,7 +43,7 @@ const { PouchCLI, BasePouchCommand } = require('./lib/core/pouch');
await cli.execute('init'); await cli.execute('init');
// 发现可用角色 // 发现可用角色
await cli.execute('hello'); await cli.execute('welcome');
// 激活特定角色 // 激活特定角色
await cli.execute('action', ['copywriter']); await cli.execute('action', ['copywriter']);
@ -137,7 +137,7 @@ command.setOutputFormat('human');
| 命令 | 说明 | 示例 | | 命令 | 说明 | 示例 |
|------|------|------| |------|------|------|
| init | 初始化工作环境 | `promptx init` | | init | 初始化工作环境 | `promptx init` |
| hello | 发现可用角色 | `promptx hello` | | welcome | 发现可用角色 | `promptx welcome` |
| action | 激活特定角色 | `promptx action copywriter` | | action | 激活特定角色 | `promptx action copywriter` |
| learn | 学习领域知识 | `promptx learn scrum` | | learn | 学习领域知识 | `promptx learn scrum` |
| recall | 检索相关记忆 | `promptx recall test` | | recall | 检索相关记忆 | `promptx recall test` |
@ -156,7 +156,7 @@ await cli.runInteractive();
```javascript ```javascript
const commands = [ const commands = [
{ name: 'init', args: [] }, { name: 'init', args: [] },
{ name: 'hello', args: [] }, { name: 'welcome', args: [] },
{ name: 'action', args: ['frontend'] } { name: 'action', args: ['frontend'] }
]; ];

View File

@ -15,8 +15,8 @@ const logger = require('../../../utils/logger')
class ActionCommand extends BasePouchCommand { class ActionCommand extends BasePouchCommand {
constructor () { constructor () {
super() super()
// 获取HelloCommand的角色注册表 // 获取WelcomeCommand的角色注册表
this.helloCommand = null this.welcomeCommand = null
// 使用全局单例 ResourceManager // 使用全局单例 ResourceManager
this.resourceManager = getGlobalResourceManager() this.resourceManager = getGlobalResourceManager()
this.dpmlParser = new DPMLContentParser() this.dpmlParser = new DPMLContentParser()
@ -40,7 +40,7 @@ class ActionCommand extends BasePouchCommand {
通过 MCP PromptX 工具的 action 功能激活角色 通过 MCP PromptX 工具的 action 功能激活角色
💡 查看可用角色: 💡 查看可用角色:
使用 MCP PromptX 工具的 hello 功能` 使用 MCP PromptX 工具的 welcome 功能`
} }
try { try {
@ -66,7 +66,7 @@ class ActionCommand extends BasePouchCommand {
💡 解决方案: 💡 解决方案:
1. **首先尝试**:使用 MCP PromptX 工具的 **init** 功能刷新注册表 1. **首先尝试**:使用 MCP PromptX 工具的 **init** 功能刷新注册表
2. **然后重试**:再次使用 action 功能激活角色 2. **然后重试**:再次使用 action 功能激活角色
3. **查看角色**:使用 hello 功能查看所有可用角色 3. **查看角色**:使用 welcome 功能查看所有可用角色
🚨 **特别提示**:如果刚刚用女娲创建了新角色,必须先执行 init 刷新注册表!` 🚨 **特别提示**:如果刚刚用女娲创建了新角色,必须先执行 init 刷新注册表!`
} }
@ -89,7 +89,7 @@ class ActionCommand extends BasePouchCommand {
💡 解决方案: 💡 解决方案:
1. **优先尝试**:使用 MCP PromptX 工具的 **init** 功能刷新注册表 1. **优先尝试**:使用 MCP PromptX 工具的 **init** 功能刷新注册表
2. **然后重试**:再次尝试激活角色 2. **然后重试**:再次尝试激活角色
3. **查看可用角色**:使用 hello 功能查看角色列表 3. **查看可用角色**:使用 welcome 功能查看角色列表
🚨 **新角色提示**:如果是女娲等工具刚创建的角色,必须先执行 init 🚨 **新角色提示**:如果是女娲等工具刚创建的角色,必须先执行 init
@ -98,18 +98,18 @@ class ActionCommand extends BasePouchCommand {
} }
/** /**
* 获取角色信息(从HelloCommand * 获取角色信息(从WelcomeCommand
*/ */
async getRoleInfo (roleId) { async getRoleInfo (roleId) {
logger.debug(`[ActionCommand] getRoleInfo调用角色ID: ${roleId}`) logger.debug(`[ActionCommand] getRoleInfo调用角色ID: ${roleId}`)
// 总是创建新的HelloCommand实例确保获取最新的角色信息 // 总是创建新的WelcomeCommand实例确保获取最新的角色信息
logger.debug(`[ActionCommand] 创建新的HelloCommand实例以获取最新角色信息`) logger.debug(`[ActionCommand] 创建新的WelcomeCommand实例以获取最新角色信息`)
const HelloCommand = require('./HelloCommand') const WelcomeCommand = require('./WelcomeCommand')
this.helloCommand = new HelloCommand() this.welcomeCommand = new WelcomeCommand()
const result = await this.helloCommand.getRoleInfo(roleId) const result = await this.welcomeCommand.getRoleInfo(roleId)
logger.debug(`[ActionCommand] HelloCommand.getRoleInfo返回:`, result) logger.debug(`[ActionCommand] WelcomeCommand.getRoleInfo返回:`, result)
return result return result
} }
@ -276,7 +276,7 @@ promptx learn principle://${roleInfo.id}
角色激活完成后,可以: 角色激活完成后,可以:
- 📝 **开始专业工作** - 运用角色能力解决实际问题 - 📝 **开始专业工作** - 运用角色能力解决实际问题
- 🔍 **调用记忆** - 使用 \`promptx recall\` 检索相关经验 - 🔍 **调用记忆** - 使用 \`promptx recall\` 检索相关经验
- 🔄 **切换角色** - 使用 \`promptx hello\` 选择其他专业角色 - 🔄 **切换角色** - 使用 \`promptx welcome\` 选择其他专业角色
💡 **设计理念**:基于 DPML 基础协议组合通过thought和execution的灵活编排实现角色能力。` 💡 **设计理念**:基于 DPML 基础协议组合通过thought和execution的灵活编排实现角色能力。`
@ -443,12 +443,12 @@ ${recallContent}
if (!roleId) { if (!roleId) {
return { return {
currentState: 'action_awaiting_role', currentState: 'action_awaiting_role',
availableTransitions: ['hello'], availableTransitions: ['welcome'],
nextActions: [ nextActions: [
{ {
name: '查看可用角色', name: '查看可用角色',
description: '返回角色发现页面', description: '返回角色发现页面',
method: 'MCP PromptX hello 工具', method: 'MCP PromptX welcome 工具',
priority: 'high' priority: 'high'
} }
], ],
@ -460,7 +460,7 @@ ${recallContent}
return { return {
currentState: 'role_activated_with_memory', currentState: 'role_activated_with_memory',
availableTransitions: ['hello', 'remember', 'learn'], availableTransitions: ['welcome', 'remember', 'learn'],
nextActions: [ nextActions: [
{ {
name: '开始专业服务', name: '开始专业服务',
@ -471,7 +471,7 @@ ${recallContent}
{ {
name: '返回角色选择', name: '返回角色选择',
description: '选择其他角色', description: '选择其他角色',
method: 'MCP PromptX hello 工具', method: 'MCP PromptX welcome 工具',
priority: 'medium' priority: 'medium'
}, },
{ {

View File

@ -120,7 +120,7 @@ class InitCommand extends BasePouchCommand {
${registryStats.message} ${registryStats.message}
## 🚀 下一步建议 ## 🚀 下一步建议
- 使用 \`hello\` 发现可用的专业角色 - 使用 \`welcome\` 发现可用的专业角色
- 使用 \`action\` 激活特定角色获得专业能力 - 使用 \`action\` 激活特定角色获得专业能力
- 使用 \`learn\` 深入学习专业知识 - 使用 \`learn\` 深入学习专业知识
- 使用 \`remember/recall\` 管理专业记忆 - 使用 \`remember/recall\` 管理专业记忆
@ -231,12 +231,12 @@ ${registryStats.message}
const version = await this.getVersionInfo() const version = await this.getVersionInfo()
return { return {
currentState: 'initialized', currentState: 'initialized',
availableTransitions: ['hello', 'action', 'learn', 'recall', 'remember'], availableTransitions: ['welcome', 'action', 'learn', 'recall', 'remember'],
nextActions: [ nextActions: [
{ {
name: '发现专业角色', name: '发现专业角色',
description: '查看所有可用的AI专业角色', description: '查看所有可用的AI专业角色',
method: 'MCP PromptX hello 工具', method: 'MCP PromptX welcome 工具',
priority: 'recommended' priority: 'recommended'
}, },
{ {

View File

@ -165,7 +165,7 @@ ${errorMessage}
- 继续学习: 使用 MCP PromptX learn 工具学习其他资源 - 继续学习: 使用 MCP PromptX learn 工具学习其他资源
- 应用记忆: 使用 MCP PromptX recall 工具检索相关经验 - 应用记忆: 使用 MCP PromptX recall 工具检索相关经验
- 激活角色: 使用 MCP PromptX action 工具激活完整角色能力 - 激活角色: 使用 MCP PromptX action 工具激活完整角色能力
- 查看角色列表: 使用 MCP PromptX hello 工具选择其他角色` - 查看角色列表: 使用 MCP PromptX welcome 工具选择其他角色`
} }
/** /**
@ -198,11 +198,11 @@ ${errorMessage}
## 🔍 发现可学习资源 ## 🔍 发现可学习资源
- 使用 MCP PromptX action 工具查看角色需要的所有资源 - 使用 MCP PromptX action 工具查看角色需要的所有资源
- 使用 MCP PromptX hello 工具查看可用角色列表 - 使用 MCP PromptX welcome 工具查看可用角色列表
🔄 下一步行动: 🔄 下一步行动:
- 激活角色: 使用 MCP PromptX action 工具分析角色依赖 - 激活角色: 使用 MCP PromptX action 工具分析角色依赖
- 查看角色: 使用 MCP PromptX hello 工具选择感兴趣的角色` - 查看角色: 使用 MCP PromptX welcome 工具选择感兴趣的角色`
} }
/** /**
@ -214,12 +214,12 @@ ${errorMessage}
if (!resourceUrl) { if (!resourceUrl) {
return { return {
currentState: 'learn_awaiting_resource', currentState: 'learn_awaiting_resource',
availableTransitions: ['hello', 'action'], availableTransitions: ['welcome', 'action'],
nextActions: [ nextActions: [
{ {
name: '查看可用角色', name: '查看可用角色',
description: '返回角色选择页面', description: '返回角色选择页面',
method: 'MCP PromptX hello 工具', method: 'MCP PromptX welcome 工具',
priority: 'high' priority: 'high'
}, },
{ {
@ -236,7 +236,7 @@ ${errorMessage}
if (!urlMatch) { if (!urlMatch) {
return { return {
currentState: 'learn_error', currentState: 'learn_error',
availableTransitions: ['hello', 'action'], availableTransitions: ['welcome', 'action'],
nextActions: [ nextActions: [
{ {
name: '查看使用帮助', name: '查看使用帮助',
@ -252,7 +252,7 @@ ${errorMessage}
return { return {
currentState: `learned_${protocol}`, currentState: `learned_${protocol}`,
availableTransitions: ['learn', 'recall', 'hello', 'action'], availableTransitions: ['learn', 'recall', 'welcome', 'action'],
nextActions: [ nextActions: [
{ {
name: '继续学习', name: '继续学习',
@ -275,7 +275,7 @@ ${errorMessage}
{ {
name: '查看角色列表', name: '查看角色列表',
description: '选择其他角色', description: '选择其他角色',
method: 'MCP PromptX hello 工具', method: 'MCP PromptX welcome 工具',
priority: 'low' priority: 'low'
} }
], ],

View File

@ -1,279 +0,0 @@
const BasePouchCommand = require('../BasePouchCommand')
const ResourceManager = require('../../resource/resourceManager')
const DPMLContentParser = require('../../dpml/DPMLContentParser')
const SemanticRenderer = require('../../dpml/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

@ -66,12 +66,12 @@ ${formattedMemories}
return { return {
currentState, currentState,
availableTransitions: ['hello', 'remember', 'learn', 'recall'], availableTransitions: ['welcome', 'remember', 'learn', 'recall'],
nextActions: [ nextActions: [
{ {
name: '选择角色', name: '选择角色',
description: '选择专业角色来应用检索到的知识', description: '选择专业角色来应用检索到的知识',
method: 'MCP PromptX hello 工具' method: 'MCP PromptX welcome 工具'
}, },
{ {
name: '记忆新知识', name: '记忆新知识',

View File

@ -174,12 +174,12 @@ class RegisterCommand extends BasePouchCommand {
if (!roleId) { if (!roleId) {
return { return {
currentState: 'register_awaiting_role', currentState: 'register_awaiting_role',
availableTransitions: ['hello', 'action'], availableTransitions: ['welcome', 'action'],
nextActions: [ nextActions: [
{ {
name: '查看可用角色', name: '查看可用角色',
description: '查看已注册的角色', description: '查看已注册的角色',
method: 'MCP PromptX hello 工具', method: 'MCP PromptX welcome 工具',
priority: 'medium' priority: 'medium'
}, },
{ {
@ -197,7 +197,7 @@ class RegisterCommand extends BasePouchCommand {
return { return {
currentState: 'register_completed', currentState: 'register_completed',
availableTransitions: ['action', 'hello'], availableTransitions: ['action', 'welcome'],
nextActions: [ nextActions: [
{ {
name: '激活角色', name: '激活角色',
@ -208,7 +208,7 @@ class RegisterCommand extends BasePouchCommand {
{ {
name: '查看所有角色', name: '查看所有角色',
description: '查看角色列表', description: '查看角色列表',
method: 'MCP PromptX hello 工具', method: 'MCP PromptX welcome 工具',
priority: 'medium' priority: 'medium'
} }
], ],

View File

@ -201,12 +201,12 @@ AI学习和内化各种专业知识
if (!content) { if (!content) {
return { return {
currentState: 'remember_awaiting_input', currentState: 'remember_awaiting_input',
availableTransitions: ['hello', 'learn', 'recall'], availableTransitions: ['welcome', 'learn', 'recall'],
nextActions: [ nextActions: [
{ {
name: '查看角色', name: '查看角色',
description: '选择角色获取专业知识', description: '选择角色获取专业知识',
method: 'MCP PromptX hello 工具', method: 'MCP PromptX welcome 工具',
priority: 'medium' priority: 'medium'
}, },
{ {

View File

@ -6,10 +6,10 @@ const CurrentProjectManager = require('../../../utils/CurrentProjectManager')
const logger = require('../../../utils/logger') const logger = require('../../../utils/logger')
/** /**
* 角色发现锦囊命令 * 角色欢迎锦囊命令
* 负责展示可用的AI角色和领域专家 * 负责展示可用的AI角色和领域专家
*/ */
class HelloCommand extends BasePouchCommand { class WelcomeCommand extends BasePouchCommand {
constructor () { constructor () {
super() super()
// 使用全局单例 ResourceManager // 使用全局单例 ResourceManager
@ -264,16 +264,16 @@ class HelloCommand extends BasePouchCommand {
* 获取角色信息提供给其他命令使用 * 获取角色信息提供给其他命令使用
*/ */
async getRoleInfo (roleId) { async getRoleInfo (roleId) {
logger.debug(`[HelloCommand] getRoleInfo调用角色ID: ${roleId}`) logger.debug(`[WelcomeCommand] getRoleInfo调用角色ID: ${roleId}`)
const registry = await this.loadRoleRegistry() const registry = await this.loadRoleRegistry()
logger.debug(`[HelloCommand] 注册表加载完成,包含角色:`, Object.keys(registry)) logger.debug(`[WelcomeCommand] 注册表加载完成,包含角色:`, Object.keys(registry))
const roleData = registry[roleId] const roleData = registry[roleId]
logger.debug(`[HelloCommand] 查找角色${roleId}结果:`, roleData ? '找到' : '未找到') logger.debug(`[WelcomeCommand] 查找角色${roleId}结果:`, roleData ? '找到' : '未找到')
if (!roleData) { if (!roleData) {
logger.debug(`[HelloCommand] 角色${roleId}在注册表中不存在`) logger.debug(`[WelcomeCommand] 角色${roleId}在注册表中不存在`)
return null return null
} }
@ -284,7 +284,7 @@ class HelloCommand extends BasePouchCommand {
file: roleData.file file: roleData.file
} }
logger.debug(`[HelloCommand] 返回角色信息:`, result) logger.debug(`[WelcomeCommand] 返回角色信息:`, result)
return result return result
} }
@ -310,7 +310,7 @@ class HelloCommand extends BasePouchCommand {
async debugRegistry() { async debugRegistry() {
await this.loadRoleRegistry() await this.loadRoleRegistry()
logger.info('\n🔍 HelloCommand - 注册表调试信息') logger.info('\n🔍 WelcomeCommand - 注册表调试信息')
logger.info('='.repeat(50)) logger.info('='.repeat(50))
if (this.roleRegistry && Object.keys(this.roleRegistry).length > 0) { if (this.roleRegistry && Object.keys(this.roleRegistry).length > 0) {
@ -400,4 +400,4 @@ ${divider}
} }
} }
module.exports = HelloCommand module.exports = WelcomeCommand

View File

@ -3,7 +3,7 @@
*/ */
const InitCommand = require('./InitCommand') const InitCommand = require('./InitCommand')
const HelloCommand = require('./HelloCommand') const WelcomeCommand = require('./WelcomeCommand')
const ActionCommand = require('./ActionCommand') const ActionCommand = require('./ActionCommand')
const LearnCommand = require('./LearnCommand') const LearnCommand = require('./LearnCommand')
const RecallCommand = require('./RecallCommand') const RecallCommand = require('./RecallCommand')
@ -12,7 +12,7 @@ const DACPCommand = require('./DACPCommand')
module.exports = { module.exports = {
InitCommand, InitCommand,
HelloCommand, WelcomeCommand,
ActionCommand, ActionCommand,
LearnCommand, LearnCommand,
RecallCommand, RecallCommand,

View File

@ -84,11 +84,11 @@ class PouchStateMachine {
*/ */
getAvailableTransitions () { getAvailableTransitions () {
const transitions = { const transitions = {
initial: ['init', 'hello'], initial: ['init', 'welcome'],
initialized: ['hello', 'action', 'learn'], initialized: ['welcome', 'action', 'learn'],
discovering: ['action', 'learn', 'init'], discovering: ['action', 'learn', 'init'],
activated: ['learn', 'recall', 'hello'], activated: ['learn', 'recall', 'welcome'],
learned: ['action', 'recall', 'hello'], learned: ['action', 'recall', 'welcome'],
recalled: ['action', 'learn', 'remember'] recalled: ['action', 'learn', 'remember']
} }
@ -100,7 +100,7 @@ class PouchStateMachine {
} }
// 默认可转换状态 // 默认可转换状态
return ['hello', 'init'] return ['welcome', 'init']
} }
/** /**

View File

@ -26,7 +26,7 @@ const TOOL_DEFINITIONS = [
}) })
}, },
{ {
name: 'promptx_hello', name: 'promptx_welcome',
description: '🎭 [专业角色选择菜单] 🔥 当你需要专业能力时必须先看这个 - 展示大量可激活的专家身份清单:产品经理/Java开发者/UI设计师/文案策划师/数据分析师/项目经理等,每个角色都有完整的专业思维模式和工作技能。🛑 **重要**:使用此工具时必须首先关注并响应工具返回结果开头的项目环境验证提示,确认项目路径正确后再处理角色列表内容,看完后选择最适合当前任务的专家身份', description: '🎭 [专业角色选择菜单] 🔥 当你需要专业能力时必须先看这个 - 展示大量可激活的专家身份清单:产品经理/Java开发者/UI设计师/文案策划师/数据分析师/项目经理等,每个角色都有完整的专业思维模式和工作技能。🛑 **重要**:使用此工具时必须首先关注并响应工具返回结果开头的项目环境验证提示,确认项目路径正确后再处理角色列表内容,看完后选择最适合当前任务的专家身份',
inputSchema: { inputSchema: {
type: 'object', type: 'object',

View File

@ -14,8 +14,8 @@ async function testPouchFramework () {
console.log('\n') console.log('\n')
// 测试2: 发现角色 // 测试2: 发现角色
console.log('2⃣ 测试 hello 命令:') console.log('2⃣ 测试 welcome 命令:')
await cli.execute('hello') await cli.execute('welcome')
console.log('\n') console.log('\n')
// 测试3: 激活角色 // 测试3: 激活角色