fix: remove cache from list-tasks and next-task mcp calls

This commit is contained in:
Ralph Khreish
2025-05-16 21:45:56 +02:00
parent da317f2607
commit 0393e0fb14
2 changed files with 11 additions and 28 deletions

View File

@@ -4,7 +4,6 @@
*/ */
import { listTasks } from '../../../../scripts/modules/task-manager.js'; import { listTasks } from '../../../../scripts/modules/task-manager.js';
import { getCachedOrExecute } from '../../tools/utils.js';
import { import {
enableSilentMode, enableSilentMode,
disableSilentMode disableSilentMode
@@ -36,7 +35,6 @@ export async function listTasksDirect(args, log) {
// Use the explicit tasksJsonPath for cache key // Use the explicit tasksJsonPath for cache key
const statusFilter = status || 'all'; const statusFilter = status || 'all';
const withSubtasksFilter = withSubtasks || false; const withSubtasksFilter = withSubtasks || false;
const cacheKey = `listTasks:${tasksJsonPath}:${statusFilter}:${withSubtasksFilter}`;
// Define the action function to be executed on cache miss // Define the action function to be executed on cache miss
const coreListTasksAction = async () => { const coreListTasksAction = async () => {
@@ -88,25 +86,19 @@ export async function listTasksDirect(args, log) {
} }
}; };
// Use the caching utility
try { try {
const result = await getCachedOrExecute({ const result = await coreListTasksAction();
cacheKey, log.info('listTasksDirect completed');
actionFn: coreListTasksAction, return result;
log
});
log.info(`listTasksDirect completed. From cache: ${result.fromCache}`);
return result; // Returns { success, data/error, fromCache }
} catch (error) { } catch (error) {
// Catch unexpected errors from getCachedOrExecute itself (though unlikely) log.error(`Unexpected error during listTasks: ${error.message}`);
log.error(
`Unexpected error during getCachedOrExecute for listTasks: ${error.message}`
);
console.error(error.stack); console.error(error.stack);
return { return {
success: false, success: false,
error: { code: 'CACHE_UTIL_ERROR', message: error.message }, error: {
fromCache: false code: 'UNEXPECTED_ERROR',
message: error.message
}
}; };
} }
} }

View File

@@ -35,9 +35,6 @@ export async function nextTaskDirect(args, log) {
}; };
} }
// Generate cache key using the provided task path
const cacheKey = `nextTask:${tasksJsonPath}`;
// Define the action function to be executed on cache miss // Define the action function to be executed on cache miss
const coreNextTaskAction = async () => { const coreNextTaskAction = async () => {
try { try {
@@ -118,18 +115,12 @@ export async function nextTaskDirect(args, log) {
// Use the caching utility // Use the caching utility
try { try {
const result = await getCachedOrExecute({ const result = await coreNextTaskAction();
cacheKey, log.info(`nextTaskDirect completed.`);
actionFn: coreNextTaskAction,
log
});
log.info(`nextTaskDirect completed. From cache: ${result.fromCache}`);
return result; // Returns { success, data/error, fromCache } return result; // Returns { success, data/error, fromCache }
} catch (error) { } catch (error) {
// Catch unexpected errors from getCachedOrExecute itself // Catch unexpected errors from getCachedOrExecute itself
log.error( log.error(`Unexpected error during nextTask: ${error.message}`);
`Unexpected error during getCachedOrExecute for nextTask: ${error.message}`
);
return { return {
success: false, success: false,
error: { error: {