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

@ -1,32 +1,32 @@
const BasePouchCommand = require('../BasePouchCommand');
const fs = require('fs-extra');
const path = require('path');
const { ResourceManager } = require('../../resource');
const { COMMANDS } = require('../../../../constants');
const BasePouchCommand = require('../BasePouchCommand')
const fs = require('fs-extra')
const path = require('path')
const { ResourceManager } = require('../../resource')
const { COMMANDS } = require('../../../../constants')
/**
* 初始化锦囊命令
* 负责准备工作环境和传达系统协议
*/
class InitCommand extends BasePouchCommand {
constructor() {
super();
this.resourceManager = new ResourceManager();
constructor () {
super()
this.resourceManager = new ResourceManager()
}
getPurpose() {
return '初始化PromptX工作环境传达系统基本诺记协议体系';
getPurpose () {
return '初始化PromptX工作环境传达系统基本诺记协议体系'
}
async getContent(args) {
const [workspacePath = '.'] = args;
async getContent (args) {
const [workspacePath = '.'] = args
// 1. 技术初始化
await this.initializeWorkspace(workspacePath);
await this.initializeWorkspace(workspacePath)
// 2. 加载协议体系
const protocolContent = await this.loadProtocolSystem();
const protocolContent = await this.loadProtocolSystem()
return `🎯 PromptX 系统初始化完成!
## 🏗️ 技术环境准备
@ -48,33 +48,33 @@ ${protocolContent}
⚠️ **AI执行指令**
🚀 **立即执行下一个锦囊:${COMMANDS.HELLO}**
📢 **不要等待确认直接进入hello命令发现可用角色**
🎯 **记住锦囊串联设计init完成后必须自动进入hello**`;
🎯 **记住锦囊串联设计init完成后必须自动进入hello**`
}
/**
* 加载协议体系内容
*/
async loadProtocolSystem() {
async loadProtocolSystem () {
try {
// 加载完整协议体系PATEOAS + DPML + 所有标签协议
const result = await this.resourceManager.resolve('@prompt://protocols');
const result = await this.resourceManager.resolve('@prompt://protocols')
if (result.success) {
return result.content;
return result.content
} else {
console.warn('⚠️ 协议加载失败:', result.error?.message);
return this.getCoreProtocolSummary();
console.warn('⚠️ 协议加载失败:', result.error?.message)
return this.getCoreProtocolSummary()
}
} catch (error) {
console.warn('⚠️ 无法加载完整协议体系,使用核心摘要:', error.message);
return this.getCoreProtocolSummary();
console.warn('⚠️ 无法加载完整协议体系,使用核心摘要:', error.message)
return this.getCoreProtocolSummary()
}
}
/**
* 获取核心协议摘要fallback
*/
getCoreProtocolSummary() {
getCoreProtocolSummary () {
return `### 🎯 核心理念AI use CLI get prompt for AI
**PATEOAS协议** - Prompt as the Engine of Application State
@ -91,10 +91,10 @@ ${protocolContent}
**三大解决方案**
- **上下文遗忘** → 锦囊自包含,每个命令独立执行
- **注意力分散** → 分阶段专注,每锦囊专注单一任务
- **能力局限** → 即时专家化,通过提示词获得专业能力`;
- **能力局限** → 即时专家化,通过提示词获得专业能力`
}
getPATEOAS(args) {
getPATEOAS (args) {
return {
currentState: 'initialized',
availableTransitions: ['hello', 'action', 'learn'],
@ -117,10 +117,10 @@ ${protocolContent}
version: '0.0.1',
philosophy: 'AI use CLI get prompt for AI - 锦囊串联无缝衔接'
}
};
}
}
async initializeWorkspace(workspacePath) {
async initializeWorkspace (workspacePath) {
// 创建基础目录结构
const dirs = [
'prompt/core',
@ -128,23 +128,23 @@ ${protocolContent}
'prompt/protocol',
'prompt/resource',
'.promptx'
];
]
for (const dir of dirs) {
await fs.ensureDir(path.join(workspacePath, dir));
await fs.ensureDir(path.join(workspacePath, dir))
}
// 创建锦囊状态配置文件
const configPath = path.join(workspacePath, '.promptx', 'pouch.json');
const configPath = path.join(workspacePath, '.promptx', 'pouch.json')
if (!await fs.pathExists(configPath)) {
await fs.writeJson(configPath, {
version: '0.0.1',
initialized: new Date().toISOString(),
defaultFormat: 'human',
stateHistory: []
}, { spaces: 2 });
}, { spaces: 2 })
}
}
}
module.exports = InitCommand;
module.exports = InitCommand