capsule-ai-cli
Version:
The AI Model Orchestrator - Intelligent multi-model workflows with device-locked licensing
77 lines • 2.24 kB
JavaScript
import { helpCommand } from './help.js';
import { newCommand } from './new.js';
import { clearCommand } from './clear.js';
import { exitCommand } from './exit.js';
import { modelCommand } from './model.js';
import { providerCommand } from './provider.js';
import { keysCommand } from './keys.js';
import { activateCommand } from './activate.js';
import { localCommand } from './local.js';
import { contextCommand } from './context.js';
import { statsCommand } from './stats.js';
import { compactCommand } from './compact.js';
import { costCommand } from './cost.js';
import { deleteCommand } from './delete.js';
import { benchmarkCommand } from './benchmark.js';
import { orchestratorCommand } from './orchestrator.js';
import { taskCommand } from './task.js';
const commands = [
helpCommand,
newCommand,
clearCommand,
exitCommand,
modelCommand,
providerCommand,
localCommand,
keysCommand,
activateCommand,
contextCommand,
statsCommand,
compactCommand,
costCommand,
deleteCommand,
benchmarkCommand,
orchestratorCommand,
taskCommand,
];
export const commandRegistry = {};
commands.forEach(cmd => {
commandRegistry[cmd.name] = cmd;
if (cmd.alias) {
cmd.alias.forEach(alias => {
commandRegistry[alias] = cmd;
});
}
});
export function getAllCommands() {
const uniqueCommands = new Map();
Object.values(commandRegistry).forEach(cmd => {
if (!uniqueCommands.has(cmd.name)) {
uniqueCommands.set(cmd.name, cmd);
}
});
return Array.from(uniqueCommands.values());
}
export function parseCommand(input) {
const trimmed = input.trim();
if (!trimmed.startsWith('/')) {
throw new Error('Not a command');
}
const parts = trimmed.slice(1).split(/\s+/);
return {
command: parts[0] || '',
args: parts.slice(1)
};
}
export async function executeCommand(input) {
const { command, args } = parseCommand(input);
const cmd = commandRegistry[command];
if (!cmd) {
return {
success: false,
message: `Unknown command: /${command}`
};
}
return await cmd.execute(args);
}
//# sourceMappingURL=index.js.map