Compare commits

..

3 Commits

Author SHA1 Message Date
Ralph Khreish
3592736451 Merge remote-tracking branch 'origin/next' into fix/set-task-status 2025-05-16 15:43:56 +02:00
shenysun
e5ed10275e fix: update import path 2025-05-16 14:05:34 +08:00
shenysun
97bf01a0ac fix: error handling of task status settings 2025-05-15 21:18:30 +08:00
5 changed files with 52 additions and 24 deletions

View File

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

View File

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

View File

@@ -5,6 +5,7 @@
import { findNextTask } from '../../../../scripts/modules/task-manager.js';
import { readJSON } from '../../../../scripts/modules/utils.js';
import { getCachedOrExecute } from '../../tools/utils.js';
import {
enableSilentMode,
disableSilentMode
@@ -34,6 +35,9 @@ 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
const coreNextTaskAction = async () => {
try {
@@ -114,11 +118,18 @@ export async function nextTaskDirect(args, log) {
// Use the caching utility
try {
const result = await coreNextTaskAction();
log.info(`nextTaskDirect completed.`);
return result;
const result = await getCachedOrExecute({
cacheKey,
actionFn: coreNextTaskAction,
log
});
log.info(`nextTaskDirect completed. From cache: ${result.fromCache}`);
return result; // Returns { success, data/error, fromCache }
} catch (error) {
log.error(`Unexpected error during nextTask: ${error.message}`);
// Catch unexpected errors from getCachedOrExecute itself
log.error(
`Unexpected error during getCachedOrExecute for nextTask: ${error.message}`
);
return {
success: false,
error: {

View File

@@ -4,6 +4,11 @@
*/
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';
/**