feat: 更新命令名称为dpml-prompt,保持PromptX品牌名称
This commit is contained in:
@ -1,70 +1,70 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const { Command } = require('commander');
|
||||
const chalk = require('chalk');
|
||||
const packageJson = require('../../package.json');
|
||||
const { Command } = require('commander')
|
||||
const chalk = require('chalk')
|
||||
const packageJson = require('../../package.json')
|
||||
|
||||
// 导入锦囊框架
|
||||
const { cli } = require('../lib/core/pouch');
|
||||
const { cli } = require('../lib/core/pouch')
|
||||
|
||||
// 创建主程序
|
||||
const program = new Command();
|
||||
const program = new Command()
|
||||
|
||||
// 设置程序信息
|
||||
program
|
||||
.name('promptx')
|
||||
.description(packageJson.description)
|
||||
.version(packageJson.version, '-v, --version', 'display version number');
|
||||
.version(packageJson.version, '-v, --version', 'display version number')
|
||||
|
||||
// 五大核心锦囊命令
|
||||
program
|
||||
.command('init [workspacePath]')
|
||||
.description('🏗️ init锦囊 - 初始化工作环境,传达系统基本诺记')
|
||||
.action(async (workspacePath, options) => {
|
||||
await cli.execute('init', workspacePath ? [workspacePath] : []);
|
||||
});
|
||||
await cli.execute('init', workspacePath ? [workspacePath] : [])
|
||||
})
|
||||
|
||||
program
|
||||
.command('hello')
|
||||
.description('👋 hello锦囊 - 发现并展示所有可用的AI角色和领域专家')
|
||||
.action(async (options) => {
|
||||
await cli.execute('hello', []);
|
||||
});
|
||||
await cli.execute('hello', [])
|
||||
})
|
||||
|
||||
program
|
||||
.command('action <role>')
|
||||
.description('⚡ action锦囊 - 激活特定AI角色,获取专业提示词')
|
||||
.action(async (role, options) => {
|
||||
await cli.execute('action', [role]);
|
||||
});
|
||||
await cli.execute('action', [role])
|
||||
})
|
||||
|
||||
program
|
||||
.command('learn [resourceUrl]')
|
||||
.description('📚 learn锦囊 - 学习指定协议的资源内容(thought://、execution://等)')
|
||||
.action(async (resourceUrl, options) => {
|
||||
await cli.execute('learn', resourceUrl ? [resourceUrl] : []);
|
||||
});
|
||||
await cli.execute('learn', resourceUrl ? [resourceUrl] : [])
|
||||
})
|
||||
|
||||
program
|
||||
.command('recall [query]')
|
||||
.description('🔍 recall锦囊 - AI主动从记忆中检索相关的专业知识')
|
||||
.action(async (query, options) => {
|
||||
await cli.execute('recall', query ? [query] : []);
|
||||
});
|
||||
await cli.execute('recall', query ? [query] : [])
|
||||
})
|
||||
|
||||
program
|
||||
.command('remember <key> [value...]')
|
||||
.description('🧠 remember锦囊 - AI主动内化知识和经验到记忆体系')
|
||||
.action(async (key, value, options) => {
|
||||
const args = [key, ...(value || [])];
|
||||
await cli.execute('remember', args);
|
||||
});
|
||||
const args = [key, ...(value || [])]
|
||||
await cli.execute('remember', args)
|
||||
})
|
||||
|
||||
// 全局错误处理
|
||||
program.configureHelp({
|
||||
helpWidth: 100,
|
||||
sortSubcommands: true
|
||||
});
|
||||
})
|
||||
|
||||
// 添加示例说明
|
||||
program.addHelpText('after', `
|
||||
@ -115,19 +115,19 @@ ${chalk.cyan('💭 核心理念:')}
|
||||
${chalk.cyan('更多信息:')}
|
||||
GitHub: ${chalk.underline('https://github.com/Deepractice/PromptX')}
|
||||
组织: ${chalk.underline('https://github.com/Deepractice')}
|
||||
`);
|
||||
`)
|
||||
|
||||
// 处理未知命令
|
||||
program.on('command:*', () => {
|
||||
console.error(chalk.red(`错误: 未知命令 '${program.args.join(' ')}'`));
|
||||
console.log('');
|
||||
program.help();
|
||||
});
|
||||
console.error(chalk.red(`错误: 未知命令 '${program.args.join(' ')}'`))
|
||||
console.log('')
|
||||
program.help()
|
||||
})
|
||||
|
||||
// 如果没有参数,显示帮助
|
||||
if (process.argv.length === 2) {
|
||||
program.help();
|
||||
program.help()
|
||||
}
|
||||
|
||||
// 解析命令行参数
|
||||
program.parse(process.argv);
|
||||
program.parse(process.argv)
|
||||
|
||||
Reference in New Issue
Block a user