feat: 添加 Commands 系统支持斜杠命令

实现类似 OpenCode 的 Commands 功能:
- 支持 Markdown 格式定义命令,带 YAML frontmatter
- 变量替换:$ARGUMENTS, $1/$2, @filepath, !`shell`
- 三级加载:builtin < user < project
- 7 个内置命令:init, review, test, fix, explain, commit, help
- 集成终端 UI 支持 /commands 列表和命令执行
- 完整单元测试覆盖 (46 tests)
This commit is contained in:
2025-12-11 16:12:28 +08:00
parent 723558ff22
commit a476a4240c
11 changed files with 1873 additions and 1 deletions
+12 -1
View File
@@ -4,11 +4,13 @@ import { Command } from 'commander';
import { Agent } from './core/agent.js';
import { TerminalUI } from './ui/terminal.js';
import { loadConfig, initConfig } from './utils/config.js';
import { toolRegistry, todoManager, initTaskContext, updateTaskDescription } from './tools/index.js';
import { toolRegistry, todoManager, initTaskContext, updateTaskDescription, updateSkillDescription } from './tools/index.js';
import { getPermissionManager, promptPermission } from './permission/index.js';
import { SessionManager } from './session/index.js';
import { agentRegistry } from './agent/index.js';
import { initLSP, shutdownLSP } from './lsp/index.js';
import { getCommandRegistry } from './commands/index.js';
import { getSkillRegistry } from './skills/index.js';
import {
printServerList,
installServer,
@@ -127,6 +129,15 @@ program.action(async () => {
initTaskContext(config, sessionManager);
updateTaskDescription();
// 初始化 Skill 注册表
const skillRegistry = getSkillRegistry();
await skillRegistry.initialize(process.cwd());
updateSkillDescription();
// 初始化 Command 注册表
const commandRegistry = getCommandRegistry();
await commandRegistry.initialize(process.cwd());
// 显示会话恢复信息
const session = sessionManager.getSession();
if (session && session.messages.length > 0) {