Files
PromptX/src/constants.js

83 lines
1.8 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* PromptX 系统常量配置
* 统一管理命令格式、路径等配置信息
*/
// 固定命令前缀 - 使用 -y -f 确保总是获取最新版本
const COMMAND_PREFIX = 'npx -y -f dpml-prompt@latest'
// 静态命令常量
const COMMANDS = {
INIT: `${COMMAND_PREFIX} init`,
HELLO: `${COMMAND_PREFIX} hello`,
ACTION: `${COMMAND_PREFIX} action`,
LEARN: `${COMMAND_PREFIX} learn`,
RECALL: `${COMMAND_PREFIX} recall`,
REMEMBER: `${COMMAND_PREFIX} remember`,
HELP: `${COMMAND_PREFIX} help`
}
// 带参数的命令构建函数
const buildCommand = {
action: (roleId) => `${COMMAND_PREFIX} action ${roleId}`,
learn: (resource) => `${COMMAND_PREFIX} learn ${resource}`,
recall: (query = '') => `${COMMAND_PREFIX} recall${query ? ' ' + query : ''}`,
remember: (content = '<content>') => `${COMMAND_PREFIX} remember${content !== '<content>' ? ' "' + content + '"' : ' <content>'}`
}
// 为了向后兼容保留函数式API
function getCommands() {
return COMMANDS
}
function getBuildCommand() {
return buildCommand
}
function detectCommandPrefix() {
return COMMAND_PREFIX
}
// 系统路径配置(静态)
const PATHS = {
POUCH_DIR: '.promptx',
MEMORY_DIR: '.promptx/memory',
STATE_FILE: '.promptx/pouch.json',
MEMORY_FILE: '.promptx/memory/declarative.md'
}
// 版本信息
const VERSION = '0.0.1'
// 系统状态
const STATES = {
INITIALIZED: 'initialized',
ROLE_DISCOVERY: 'role_discovery',
ACTION_PLAN_GENERATED: 'action_plan_generated',
LEARNED_ROLE: 'learned_role',
MEMORY_SAVED: 'memory_saved',
RECALL_WAITING: 'recall-waiting'
}
// 导出
module.exports = {
// 固定命令前缀
COMMAND_PREFIX,
// 命令常量
COMMANDS,
buildCommand,
// 向后兼容的函数式API
getCommands,
getBuildCommand,
detectCommandPrefix,
// 其他静态常量
PATHS,
VERSION,
STATES
}