mirror of
https://github.com/cjo4m06/mcp-shrimp-task-manager.git
synced 2025-07-26 07:52:25 +08:00
移除多處不必要的錯誤日誌輸出,避免 Cursor 報錯
This commit is contained in:
parent
bf5f3678ba
commit
552eed82ad
20
src/index.ts
20
src/index.ts
@ -71,7 +71,6 @@ async function main() {
|
||||
|
||||
// 發送 SSE 事件的輔助函數
|
||||
function sendSseUpdate() {
|
||||
console.log("Tasks changed, sending update to clients...");
|
||||
sseClients.forEach((client) => {
|
||||
// 檢查客戶端是否仍然連接
|
||||
if (!client.writableEnded) {
|
||||
@ -102,7 +101,6 @@ async function main() {
|
||||
const tasksData = await fsPromises.readFile(TASKS_FILE_PATH, "utf-8");
|
||||
res.json(JSON.parse(tasksData));
|
||||
} catch (error) {
|
||||
console.error("Error reading tasks.json:", error);
|
||||
// 確保檔案不存在時返回空任務列表
|
||||
if ((error as NodeJS.ErrnoException).code === "ENOENT") {
|
||||
res.json({ tasks: [] });
|
||||
@ -153,18 +151,8 @@ async function main() {
|
||||
sendSseUpdate();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
console.warn(
|
||||
`${TASKS_FILE_PATH} does not exist. File watching not started. It will start if the file is created later by the application.`
|
||||
);
|
||||
// 可以考慮在這裡也設置一個 watcher 監聽目錄創建或檔案創建
|
||||
}
|
||||
} catch (watchError) {
|
||||
console.error(
|
||||
`Error setting up file watch on ${TASKS_FILE_PATH}:`,
|
||||
watchError
|
||||
);
|
||||
}
|
||||
} catch (watchError) {}
|
||||
});
|
||||
|
||||
// 將 URL 寫入 ebGUI.md
|
||||
@ -172,9 +160,7 @@ async function main() {
|
||||
const websiteUrl = `[Task Manager UI](http://localhost:${port})`;
|
||||
const websiteFilePath = path.join(DATA_DIR, "WebGUI.md");
|
||||
await fsPromises.writeFile(websiteFilePath, websiteUrl, "utf-8");
|
||||
} catch (error) {
|
||||
console.error("Error writing website URL to file:", error);
|
||||
}
|
||||
} catch (error) {}
|
||||
|
||||
// 設置進程終止事件處理 (確保移除 watcher)
|
||||
const shutdownHandler = async () => {
|
||||
@ -470,7 +456,6 @@ async function main() {
|
||||
throw new Error(`Tool ${request.params.name} does not exist`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error executing tool:", error);
|
||||
const errorMsg =
|
||||
error instanceof Error ? error.message : String(error);
|
||||
return {
|
||||
@ -491,7 +476,6 @@ async function main() {
|
||||
|
||||
console.log("Shrimp Task Manager service started");
|
||||
} catch (error) {
|
||||
console.error("Failed to start service:", error);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -128,11 +128,6 @@ export async function updateTask(
|
||||
);
|
||||
|
||||
if (disallowedFields.length > 0) {
|
||||
console.warn(
|
||||
`Warning: Attempted to update illegal fields on a completed task: ${disallowedFields.join(
|
||||
", "
|
||||
)}`
|
||||
);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -383,20 +378,6 @@ export async function batchCreateOrUpdateTasks(
|
||||
|
||||
// 從tasksToKeep中移除此任務,因為它已經被更新並添加到newTasks中了
|
||||
tasksToKeep = tasksToKeep.filter((task) => task.id !== existingTaskId);
|
||||
} else {
|
||||
// 如果任務已完成或找不到,則跳過更新,可能在控制台輸出警告
|
||||
if (
|
||||
existingTaskIndex !== -1 &&
|
||||
existingTasks[existingTaskIndex].status === TaskStatus.COMPLETED
|
||||
) {
|
||||
console.warn(
|
||||
`Warning: Attempted to update completed task "${taskData.name}", operation ignored`
|
||||
);
|
||||
} else {
|
||||
console.warn(
|
||||
`Warning: Attempted to update non-existent task "${taskData.name}", operation ignored`
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 創建新任務
|
||||
@ -450,9 +431,6 @@ export async function batchCreateOrUpdateTasks(
|
||||
if (taskNameToIdMap.has(dependencyName)) {
|
||||
dependencyTaskId = taskNameToIdMap.get(dependencyName)!;
|
||||
} else {
|
||||
console.warn(
|
||||
`Warning: Task "${taskData.name}" references unknown dependency task "${dependencyName}", dependency ignored`
|
||||
);
|
||||
continue; // 跳過此依賴
|
||||
}
|
||||
} else {
|
||||
@ -461,9 +439,6 @@ export async function batchCreateOrUpdateTasks(
|
||||
(task) => task.id === dependencyTaskId
|
||||
);
|
||||
if (!idExists) {
|
||||
console.warn(
|
||||
`Warning: Task "${taskData.name}" references unknown dependency task ID "${dependencyTaskId}", dependency ignored`
|
||||
);
|
||||
continue; // 跳過此依賴
|
||||
}
|
||||
}
|
||||
@ -747,7 +722,6 @@ export async function clearAllTasks(): Promise<{
|
||||
backupFile: backupFileName,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error("Error occurred while clearing all tasks:", error);
|
||||
return {
|
||||
success: false,
|
||||
message: `清除任務時發生錯誤: ${
|
||||
@ -789,7 +763,6 @@ export async function searchTasksWithCommand(
|
||||
// 如果有搜尋命令,執行它
|
||||
if (cmd) {
|
||||
try {
|
||||
console.log(`Executing command: ${cmd}`);
|
||||
const { stdout } = await execPromise(cmd, {
|
||||
maxBuffer: 1024 * 1024 * 10,
|
||||
});
|
||||
@ -862,23 +835,12 @@ export async function searchTasksWithCommand(
|
||||
});
|
||||
|
||||
memoryTasks.push(...filteredTasks);
|
||||
} catch (error: unknown) {
|
||||
console.error(`Error reading file ${filePath}:`, error);
|
||||
}
|
||||
} catch (error: unknown) {}
|
||||
}
|
||||
}
|
||||
} catch (error: unknown) {
|
||||
// grep沒有找到匹配項時會返回錯誤,但這不是真正的錯誤
|
||||
// 只有當錯誤代碼不是1(沒有匹配)時才記錄錯誤
|
||||
const err = error as { code?: number };
|
||||
if (err.code !== 1) {
|
||||
console.error("Error executing search command:", error);
|
||||
}
|
||||
}
|
||||
} catch (error: unknown) {}
|
||||
}
|
||||
} catch (error: unknown) {
|
||||
console.error("Error searching memory directory:", error);
|
||||
}
|
||||
} catch (error: unknown) {}
|
||||
|
||||
// 從當前任務中過濾符合條件的任務
|
||||
const filteredCurrentTasks = filterCurrentTasks(currentTasks, query, isId);
|
||||
|
@ -92,9 +92,7 @@ export async function planTask({
|
||||
pendingTasks = allTasks.filter(
|
||||
(task) => task.status !== TaskStatus.COMPLETED
|
||||
);
|
||||
} catch (error) {
|
||||
console.error("Error loading existing tasks:", error);
|
||||
}
|
||||
} catch (error) {}
|
||||
}
|
||||
|
||||
// 使用prompt生成器獲取最終prompt
|
||||
@ -402,7 +400,6 @@ export async function splitTasks({
|
||||
try {
|
||||
allTasks = await getAllTasks();
|
||||
} catch (error) {
|
||||
console.error("Error retrieving all tasks:", error);
|
||||
allTasks = [...createdTasks]; // 如果獲取失敗,至少使用剛創建的任務
|
||||
}
|
||||
|
||||
@ -429,8 +426,6 @@ export async function splitTasks({
|
||||
},
|
||||
};
|
||||
} catch (error) {
|
||||
console.error("Error executing task split:", error);
|
||||
|
||||
return {
|
||||
content: [
|
||||
{
|
||||
@ -622,7 +617,6 @@ export async function executeTask({
|
||||
? relatedFilesResult
|
||||
: relatedFilesResult.summary || "";
|
||||
} catch (error) {
|
||||
console.error("Error loading related files:", error);
|
||||
relatedFilesSummary =
|
||||
"Error loading related files, please check the files manually.";
|
||||
}
|
||||
@ -645,7 +639,6 @@ export async function executeTask({
|
||||
],
|
||||
};
|
||||
} catch (error) {
|
||||
console.error("Error executing task:", error);
|
||||
return {
|
||||
content: [
|
||||
{
|
||||
@ -1122,7 +1115,6 @@ export async function queryTask({
|
||||
],
|
||||
};
|
||||
} catch (error) {
|
||||
console.error("Error querying tasks:", error);
|
||||
return {
|
||||
content: [
|
||||
{
|
||||
@ -1187,8 +1179,6 @@ export async function getTaskDetail({
|
||||
],
|
||||
};
|
||||
} catch (error) {
|
||||
console.error("Error retrieving task details:", error);
|
||||
|
||||
// 使用prompt生成器獲取錯誤訊息
|
||||
const errorPrompt = getGetTaskDetailPrompt({
|
||||
taskId,
|
||||
|
Loading…
x
Reference in New Issue
Block a user