feat: 更新命令名称为dpml-prompt,保持PromptX品牌名称

This commit is contained in:
sean
2025-05-31 18:59:25 +08:00
parent 0bdb5e865b
commit 0466cd3289
44 changed files with 3138 additions and 3127 deletions

View File

@ -3,8 +3,8 @@
* 负责管理和注册所有锦囊命令
*/
class PouchRegistry {
constructor() {
this.commands = new Map();
constructor () {
this.commands = new Map()
}
/**
@ -12,16 +12,16 @@ class PouchRegistry {
* @param {string} name - 命令名称
* @param {BasePouchCommand} command - 命令实例
*/
register(name, command) {
register (name, command) {
if (!name || typeof name !== 'string') {
throw new Error('命令名称必须是非空字符串');
throw new Error('命令名称必须是非空字符串')
}
if (!command || typeof command.execute !== 'function') {
throw new Error('命令必须实现 execute 方法');
throw new Error('命令必须实现 execute 方法')
}
this.commands.set(name.toLowerCase(), command);
this.commands.set(name.toLowerCase(), command)
}
/**
@ -29,16 +29,16 @@ class PouchRegistry {
* @param {string} name - 命令名称
* @returns {BasePouchCommand} 命令实例
*/
get(name) {
return this.commands.get(name.toLowerCase());
get (name) {
return this.commands.get(name.toLowerCase())
}
/**
* 列出所有已注册的命令
* @returns {string[]} 命令名称列表
*/
list() {
return Array.from(this.commands.keys());
list () {
return Array.from(this.commands.keys())
}
/**
@ -46,46 +46,46 @@ class PouchRegistry {
* @param {string} name - 命令名称
* @returns {boolean} 是否存在
*/
validate(name) {
return this.commands.has(name.toLowerCase());
validate (name) {
return this.commands.has(name.toLowerCase())
}
/**
* 获取命令详情
* @returns {Object[]} 命令详情列表
*/
getCommandDetails() {
const details = [];
getCommandDetails () {
const details = []
for (const [name, command] of this.commands) {
details.push({
name: name,
name,
purpose: command.getPurpose ? command.getPurpose() : '未定义',
className: command.constructor.name
});
})
}
return details;
return details
}
/**
* 清空注册器
*/
clear() {
this.commands.clear();
clear () {
this.commands.clear()
}
/**
* 批量注册命令
* @param {Object} commandMap - 命令映射对象
*/
registerBatch(commandMap) {
registerBatch (commandMap) {
for (const [name, CommandClass] of Object.entries(commandMap)) {
if (typeof CommandClass === 'function') {
this.register(name.toLowerCase(), new CommandClass());
this.register(name.toLowerCase(), new CommandClass())
}
}
}
}
module.exports = PouchRegistry;
module.exports = PouchRegistry