Compare commits

...

3 Commits

Author SHA1 Message Date
Ralph Khreish
22ce57b221 chore: add changeset 2025-05-16 22:23:12 +02:00
Ralph Khreish
8a23ba9b2c chore: remove cached function 2025-05-16 22:19:45 +02:00
Ralph Khreish
0393e0fb14 fix: remove cache from list-tasks and next-task mcp calls 2025-05-16 21:45:56 +02:00
5 changed files with 24 additions and 52 deletions

View File

@@ -0,0 +1,7 @@
---
'task-master-ai': patch
---
Remove caching layer from MCP direct functions for task listing, next task, and complexity report
- Fixes issues users where having where they were getting stale data

View File

@@ -8,7 +8,6 @@ import {
enableSilentMode, enableSilentMode,
disableSilentMode disableSilentMode
} from '../../../../scripts/modules/utils.js'; } from '../../../../scripts/modules/utils.js';
import { getCachedOrExecute } from '../../tools/utils.js';
/** /**
* Direct function wrapper for displaying the complexity report with error handling and caching. * Direct function wrapper for displaying the complexity report with error handling and caching.
@@ -86,30 +85,20 @@ export async function complexityReportDirect(args, log) {
// Use the caching utility // Use the caching utility
try { try {
const result = await getCachedOrExecute({ const result = await coreActionFn();
cacheKey, log.info('complexityReportDirect completed');
actionFn: coreActionFn, return result;
log
});
log.info(
`complexityReportDirect completed. From cache: ${result.fromCache}`
);
return result; // Returns { success, data/error, fromCache }
} catch (error) { } catch (error) {
// Catch unexpected errors from getCachedOrExecute itself
// Ensure silent mode is disabled // Ensure silent mode is disabled
disableSilentMode(); disableSilentMode();
log.error( log.error(`Unexpected error during complexityReport: ${error.message}`);
`Unexpected error during getCachedOrExecute for complexityReport: ${error.message}`
);
return { return {
success: false, success: false,
error: { error: {
code: 'UNEXPECTED_ERROR', code: 'UNEXPECTED_ERROR',
message: error.message message: error.message
}, }
fromCache: false
}; };
} }
} catch (error) { } catch (error) {

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

@@ -5,7 +5,6 @@
import { findNextTask } from '../../../../scripts/modules/task-manager.js'; import { findNextTask } from '../../../../scripts/modules/task-manager.js';
import { readJSON } from '../../../../scripts/modules/utils.js'; import { readJSON } from '../../../../scripts/modules/utils.js';
import { getCachedOrExecute } from '../../tools/utils.js';
import { import {
enableSilentMode, enableSilentMode,
disableSilentMode disableSilentMode
@@ -35,9 +34,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 +114,11 @@ 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, return result;
log
});
log.info(`nextTaskDirect completed. From cache: ${result.fromCache}`);
return result; // Returns { success, data/error, fromCache }
} catch (error) { } catch (error) {
// Catch unexpected errors from getCachedOrExecute itself log.error(`Unexpected error during nextTask: ${error.message}`);
log.error(
`Unexpected error during getCachedOrExecute for nextTask: ${error.message}`
);
return { return {
success: false, success: false,
error: { error: {

View File

@@ -4,11 +4,6 @@
*/ */
import { findTaskById, readJSON } from '../../../../scripts/modules/utils.js'; import { findTaskById, readJSON } from '../../../../scripts/modules/utils.js';
import { getCachedOrExecute } from '../../tools/utils.js';
import {
enableSilentMode,
disableSilentMode
} from '../../../../scripts/modules/utils.js';
import { findTasksJsonPath } from '../utils/path-utils.js'; import { findTasksJsonPath } from '../utils/path-utils.js';
/** /**