agent-Specialization/cli/legacy-ink-src/commands.ts
JOJO d97c1423b1 feat(cli): rewrite CLI on opentui with Gateway host Bearer channel
- replace Ink implementation with opentui + React 19 (old version kept at cli/legacy-ink-src/ for field reference)
- all traffic goes through Gateway host Bearer token; workspace bound via X-Astrion-Workspace-Id header
- auto-spawn server only when no instance is alive (never kill/restart running ones); stale server without token is detected
- astrion launcher (bin/astrion, symlink-aware, --version/--help fast-exit)
- slash menu panels (session/model/mode/permission/path/context/approvals...) with shared selector component
- backend: host workspace list/create dual-channel endpoints, host token generated at startup
- i18n reads OS locale at startup (zh/en)

Co-authored-by: Astrion powered by Kimi-K3 <astrion-agent@users.noreply.github.com>
2026-09-11 17:27:53 +08:00

29 lines
1.7 KiB
TypeScript

import type { SlashCommand } from './types.js';
export const slashCommands: SlashCommand[] = [
{ name: '/new', description: '新建对话', kind: 'immediate' },
{ name: '/resume', description: '查看对话列表并切换对话', kind: 'picker' },
{ name: '/model', description: '切换模型与思考模式', kind: 'picker' },
{ name: '/versioning', description: '管理版本控制', aliases: ['/version'], kind: 'picker' },
{ name: '/permission', description: '切换权限模式', aliases: ['/perm'], kind: 'picker' },
{ name: '/execution', description: '切换执行环境', aliases: ['/exec', '/env'], kind: 'picker' },
{ name: '/workspace', description: '选择或切换工作区', kind: 'picker' },
{ name: '/compact', description: '压缩当前对话上下文', kind: 'immediate' },
{ name: '/tools', description: '启用或禁用工具', aliases: ['/tool'], kind: 'picker' },
{ name: '/path', description: '管理路径授权', kind: 'form' },
{ name: '/skill', description: '选择本轮要使用的 skill', kind: 'picker' },
{ name: '/status', description: '查看当前状态', kind: 'panel' },
{ name: '/help', description: '查看命令帮助', kind: 'panel' },
{ name: '/clear', description: '清空当前 CLI 显示', kind: 'immediate' },
{ name: '/exit', description: '退出 CLI', kind: 'immediate' },
];
export function filterCommands(query: string): SlashCommand[] {
const normalized = query.trim().toLowerCase();
if (!normalized || normalized === '/') return slashCommands;
return slashCommands.filter((command) => {
const candidates = [command.name, ...(command.aliases || [])];
return candidates.some((name) => name.toLowerCase().startsWith(normalized) || name.toLowerCase().includes(normalized));
});
}