import { handleSave, handleLoad, handleList, handleDelete, handleCleanup, handleAddNote, handleGetContext, handleDocHealth, } from './manage-context/handlers.js';
import { compactError } from './output-formatter.js';
// ---------------------------------------------------------------------------
// Main handler
// ---------------------------------------------------------------------------
export async function handleManageContext(params) {
    const { projectId, action, key, content, ttlDays, tags, specId, filterByTag, filterBySpecId } = params;
    switch (action) {
        case 'save': {
            if (!key) {
                return compactError("Parameter 'key' is required for save action");
            }
            if (!content) {
                return compactError("Parameter 'content' is required for save action");
            }
            return handleSave(projectId, key, content, ttlDays, tags, specId);
        }
        case 'load': {
            if (!key) {
                return compactError("Parameter 'key' is required for load action");
            }
            return handleLoad(projectId, key);
        }
        case 'list':
            return handleList(projectId, filterByTag, filterBySpecId);
        case 'delete': {
            if (!key) {
                return compactError("Parameter 'key' is required for delete action");
            }
            return handleDelete(projectId, key);
        }
        case 'cleanup':
            return handleCleanup(projectId);
        case 'add-note': {
            if (!key) {
                return compactError("Parameter 'key' is required for add-note action");
            }
            if (!content) {
                return compactError("Parameter 'content' is required for add-note action");
            }
            return handleAddNote(projectId, key, content, tags ?? [], specId);
        }
        case 'get-context':
            return handleGetContext(projectId);
        case 'doc-health':
            return handleDocHealth(projectId);
        default:
            return compactError(`Unknown action: ${String(action)}`);
    }
}
//# sourceMappingURL=manage-context.js.map