feat: 实现动态命令前缀检测机制 - 新增 PromptXConfig 工具类统一管理 .promptx 目录配置文件 - 重构 constants.js 为函数式,支持动态命令前缀检测 - init 命令自动保存用户实际使用的命令前缀 - 优先级:环境变量 > 配置文件 > npm环境检测 > 默认值 - 解决 AI 提示命令与用户实际使用不一致的问题 - 完整的 E2E 测试覆盖所有使用场景 核心价值:用户怎么调用 init,AI 就提示相同的命令前缀,确保 AI-First CLI 的用户体验一致性

This commit is contained in:
sean
2025-06-02 10:49:52 +08:00
parent ca9f306c67
commit 268a64a227
4 changed files with 492 additions and 22 deletions

View File

@ -2,7 +2,7 @@ const BasePouchCommand = require('../BasePouchCommand')
const fs = require('fs-extra')
const path = require('path')
const { ResourceManager } = require('../../resource')
const { COMMANDS } = require('../../../../constants')
const { COMMANDS, saveCommandPrefix } = require('../../../../constants')
/**
* 初始化锦囊命令
@ -24,7 +24,10 @@ class InitCommand extends BasePouchCommand {
// 1. 技术初始化
await this.initializeWorkspace(workspacePath)
// 2. 加载协议体系
// 2. 保存命令前缀配置
const savedPrefix = await saveCommandPrefix()
// 3. 加载协议体系
const protocolContent = await this.loadProtocolSystem()
return `🎯 PromptX 系统初始化完成!
@ -32,6 +35,7 @@ class InitCommand extends BasePouchCommand {
## 🏗️ 技术环境准备
✅ 创建了项目目录结构
✅ 配置了 .promptx/pouch.json 锦囊状态文件
✅ 保存了命令前缀配置:${savedPrefix || '默认前缀'}
✅ 准备了锦囊状态机框架
## 📋 系统基本诺记 (协议体系)