refactor: centralizar ACTION_ALIASES y SCOPE_ALIASES en commands/shared

Co-authored-by: aider (openrouter/openai/gpt-5) <aider@aider.chat>
main
brobert 4 days ago
parent 7dd390b04e
commit a89ec3f875

@ -13,6 +13,7 @@ import { Metrics } from './metrics';
import { ResponseQueue } from './response-queue'; import { ResponseQueue } from './response-queue';
import { randomTokenBase64Url, sha256Hex } from '../utils/crypto'; import { randomTokenBase64Url, sha256Hex } from '../utils/crypto';
import { route as routeCommand } from './commands'; import { route as routeCommand } from './commands';
import { ACTION_ALIASES, SCOPE_ALIASES } from './commands/shared';
import { parseNueva } from './commands/parsers/nueva'; import { parseNueva } from './commands/parsers/nueva';
type CommandContext = { type CommandContext = {
@ -53,39 +54,6 @@ export class CommandService {
const trimmed = (context.message || '').trim(); const trimmed = (context.message || '').trim();
const tokens = trimmed.split(/\s+/); const tokens = trimmed.split(/\s+/);
const rawAction = (tokens[1] || '').toLowerCase(); const rawAction = (tokens[1] || '').toLowerCase();
const ACTION_ALIASES: Record<string, string> = {
'n': 'nueva',
'nueva': 'nueva',
'crear': 'nueva',
'+': 'nueva',
'ver': 'ver',
'mostrar': 'ver',
'listar': 'ver',
'ls': 'ver',
'mias': 'ver',
'mías': 'ver',
'todas': 'ver',
'todos': 'ver',
'x': 'completar',
'hecho': 'completar',
'completar': 'completar',
'done': 'completar',
'tomar': 'tomar',
'claim': 'tomar',
'asumir': 'tomar',
'asumo': 'tomar',
'soltar': 'soltar',
'unassign': 'soltar',
'dejar': 'soltar',
'liberar': 'soltar',
'renunciar': 'soltar',
'ayuda': 'ayuda',
'help': 'ayuda',
'info': 'ayuda',
'?': 'ayuda',
'config': 'configurar',
'configurar': 'configurar'
};
const action = ACTION_ALIASES[rawAction] || rawAction; const action = ACTION_ALIASES[rawAction] || rawAction;
// Métrica: uso de alias (info/mias/todas) // Métrica: uso de alias (info/mias/todas)
try { try {
@ -181,15 +149,6 @@ export class CommandService {
// Listar pendientes // Listar pendientes
if (action === 'ver') { if (action === 'ver') {
const scopeRaw = (tokens[2] || '').toLowerCase(); const scopeRaw = (tokens[2] || '').toLowerCase();
const SCOPE_ALIASES: Record<string, 'mis' | 'todos'> = {
'todo': 'todos',
'todos': 'todos',
'todas': 'todos',
'mis': 'mis',
'mias': 'mis',
'mías': 'mis',
'yo': 'mis',
};
const scope = scopeRaw const scope = scopeRaw
? (SCOPE_ALIASES[scopeRaw] || scopeRaw) ? (SCOPE_ALIASES[scopeRaw] || scopeRaw)
: ((rawAction === 'mias' || rawAction === 'mías') ? 'mis' : ((rawAction === 'todas' || rawAction === 'todos') ? 'todos' : 'todos')); : ((rawAction === 'mias' || rawAction === 'mías') ? 'mis' : ((rawAction === 'todas' || rawAction === 'todos') ? 'todos' : 'todos'));
@ -1322,40 +1281,6 @@ Puedes interactuar escribiéndome por privado:
// Clasificación explícita del outcome (evita lógica en server) // Clasificación explícita del outcome (evita lógica en server)
const tokens = msg.split(/\s+/); const tokens = msg.split(/\s+/);
const rawAction = (tokens[1] || '').toLowerCase(); const rawAction = (tokens[1] || '').toLowerCase();
const ACTION_ALIASES: Record<string, string> = {
'n': 'nueva',
'nueva': 'nueva',
'crear': 'nueva',
'+': 'nueva',
'ver': 'ver',
'mostrar': 'ver',
'listar': 'ver',
'ls': 'ver',
'mias': 'ver',
'mías': 'ver',
'todas': 'ver',
'todos': 'ver',
'x': 'completar',
'hecho': 'completar',
'completar': 'completar',
'done': 'completar',
'tomar': 'tomar',
'claim': 'tomar',
'asumir': 'tomar',
'asumo': 'tomar',
'soltar': 'soltar',
'unassign': 'soltar',
'dejar': 'soltar',
'liberar': 'soltar',
'renunciar': 'soltar',
'ayuda': 'ayuda',
'help': 'ayuda',
'info': 'ayuda',
'?': 'ayuda',
'config': 'configurar',
'configurar': 'configurar',
'web': 'web'
};
const action = ACTION_ALIASES[rawAction] || rawAction; const action = ACTION_ALIASES[rawAction] || rawAction;
// Casos explícitos considerados éxito // Casos explícitos considerados éxito

Loading…
Cancel
Save