mirror of
https://github.com/cjo4m06/mcp-shrimp-task-manager.git
synced 2025-07-26 07:52:25 +08:00
parent
1f8d9c8352
commit
00943e1736
12
src/index.ts
12
src/index.ts
@ -53,12 +53,12 @@ import {
|
||||
|
||||
async function main() {
|
||||
try {
|
||||
console.log("啟動蝦米任務管理器服務...");
|
||||
console.log("Starting Shrimp Task Manager service...");
|
||||
|
||||
// 創建MCP服務器
|
||||
const server = new Server(
|
||||
{
|
||||
name: "蝦米任務管理器",
|
||||
name: "Shrimp Task Manager",
|
||||
version: "1.0.0",
|
||||
},
|
||||
{
|
||||
@ -331,7 +331,7 @@ async function main() {
|
||||
case "init_project_rules":
|
||||
return await initProjectRules();
|
||||
default:
|
||||
throw new Error(`工具 ${request.params.name} 不存在`);
|
||||
throw new Error(`Tool ${request.params.name} does not exist`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error executing tool:", error);
|
||||
@ -341,7 +341,7 @@ async function main() {
|
||||
content: [
|
||||
{
|
||||
type: "text",
|
||||
text: `發生錯誤: ${errorMsg} \n 請嘗試修正錯誤並重新嘗試呼叫工具`,
|
||||
text: `Error occurred: ${errorMsg} \n Please try correcting the error and calling the tool again`,
|
||||
},
|
||||
],
|
||||
};
|
||||
@ -353,9 +353,9 @@ async function main() {
|
||||
const transport = new StdioServerTransport();
|
||||
await server.connect(transport);
|
||||
|
||||
console.log("蝦米任務管理器服務已啟動");
|
||||
console.log("Shrimp Task Manager service started");
|
||||
} catch (error) {
|
||||
console.error("啟動服務失敗:", error);
|
||||
console.error("Failed to start service:", error);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -129,7 +129,9 @@ export async function updateTask(
|
||||
|
||||
if (disallowedFields.length > 0) {
|
||||
console.warn(
|
||||
`警告:嘗試更新已完成任務的非法欄位: ${disallowedFields.join(", ")}`
|
||||
`Warning: Attempted to update illegal fields on a completed task: ${disallowedFields.join(
|
||||
", "
|
||||
)}`
|
||||
);
|
||||
return null;
|
||||
}
|
||||
@ -388,11 +390,11 @@ export async function batchCreateOrUpdateTasks(
|
||||
existingTasks[existingTaskIndex].status === TaskStatus.COMPLETED
|
||||
) {
|
||||
console.warn(
|
||||
`警告:嘗試更新已完成的任務 "${taskData.name}",操作被忽略`
|
||||
`Warning: Attempted to update completed task "${taskData.name}", operation ignored`
|
||||
);
|
||||
} else {
|
||||
console.warn(
|
||||
`警告:嘗試更新不存在的任務 "${taskData.name}",操作被忽略`
|
||||
`Warning: Attempted to update non-existent task "${taskData.name}", operation ignored`
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -449,7 +451,7 @@ export async function batchCreateOrUpdateTasks(
|
||||
dependencyTaskId = taskNameToIdMap.get(dependencyName)!;
|
||||
} else {
|
||||
console.warn(
|
||||
`警告:任務 "${taskData.name}" 引用了未知的依賴任務 "${dependencyName}",此依賴將被忽略`
|
||||
`Warning: Task "${taskData.name}" references unknown dependency task "${dependencyName}", dependency ignored`
|
||||
);
|
||||
continue; // 跳過此依賴
|
||||
}
|
||||
@ -460,7 +462,7 @@ export async function batchCreateOrUpdateTasks(
|
||||
);
|
||||
if (!idExists) {
|
||||
console.warn(
|
||||
`警告:任務 "${taskData.name}" 引用了未知的依賴任務ID "${dependencyTaskId}",此依賴將被忽略`
|
||||
`Warning: Task "${taskData.name}" references unknown dependency task ID "${dependencyTaskId}", dependency ignored`
|
||||
);
|
||||
continue; // 跳過此依賴
|
||||
}
|
||||
@ -745,7 +747,7 @@ export async function clearAllTasks(): Promise<{
|
||||
backupFile: backupFileName,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error("清除所有任務時發生錯誤:", error);
|
||||
console.error("Error occurred while clearing all tasks:", error);
|
||||
return {
|
||||
success: false,
|
||||
message: `清除任務時發生錯誤: ${
|
||||
@ -861,7 +863,7 @@ export async function searchTasksWithCommand(
|
||||
|
||||
memoryTasks.push(...filteredTasks);
|
||||
} catch (error: unknown) {
|
||||
console.error(`讀取檔案 ${filePath} 時發生錯誤:`, error);
|
||||
console.error(`Error reading file ${filePath}:`, error);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -870,12 +872,12 @@ export async function searchTasksWithCommand(
|
||||
// 只有當錯誤代碼不是1(沒有匹配)時才記錄錯誤
|
||||
const err = error as { code?: number };
|
||||
if (err.code !== 1) {
|
||||
console.error("執行搜尋指令時發生錯誤:", error);
|
||||
console.error("Error executing search command:", error);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error: unknown) {
|
||||
console.error("搜尋記憶資料夾時發生錯誤:", error);
|
||||
console.error("Error searching memory directory:", error);
|
||||
}
|
||||
|
||||
// 從當前任務中過濾符合條件的任務
|
||||
|
@ -93,7 +93,7 @@ export async function planTask({
|
||||
(task) => task.status !== TaskStatus.COMPLETED
|
||||
);
|
||||
} catch (error) {
|
||||
console.error("載入現有任務時發生錯誤:", error);
|
||||
console.error("Error loading existing tasks:", error);
|
||||
}
|
||||
}
|
||||
|
||||
@ -402,7 +402,7 @@ export async function splitTasks({
|
||||
try {
|
||||
allTasks = await getAllTasks();
|
||||
} catch (error) {
|
||||
console.error("獲取所有任務時發生錯誤:", error);
|
||||
console.error("Error retrieving all tasks:", error);
|
||||
allTasks = [...createdTasks]; // 如果獲取失敗,至少使用剛創建的任務
|
||||
}
|
||||
|
||||
@ -429,7 +429,7 @@ export async function splitTasks({
|
||||
},
|
||||
};
|
||||
} catch (error) {
|
||||
console.error("執行任務拆分時發生錯誤:", error);
|
||||
console.error("Error executing task split:", error);
|
||||
|
||||
return {
|
||||
content: [
|
||||
@ -622,8 +622,9 @@ export async function executeTask({
|
||||
? relatedFilesResult
|
||||
: relatedFilesResult.summary || "";
|
||||
} catch (error) {
|
||||
console.error("載入相關文件時發生錯誤:", error);
|
||||
relatedFilesSummary = "載入相關文件時發生錯誤,請手動查看文件。";
|
||||
console.error("Error loading related files:", error);
|
||||
relatedFilesSummary =
|
||||
"Error loading related files, please check the files manually.";
|
||||
}
|
||||
}
|
||||
|
||||
@ -644,7 +645,7 @@ export async function executeTask({
|
||||
],
|
||||
};
|
||||
} catch (error) {
|
||||
console.error("執行任務時發生錯誤:", error);
|
||||
console.error("Error executing task:", error);
|
||||
return {
|
||||
content: [
|
||||
{
|
||||
@ -1121,7 +1122,7 @@ export async function queryTask({
|
||||
],
|
||||
};
|
||||
} catch (error) {
|
||||
console.error("查詢任務時發生錯誤:", error);
|
||||
console.error("Error querying tasks:", error);
|
||||
return {
|
||||
content: [
|
||||
{
|
||||
@ -1186,7 +1187,7 @@ export async function getTaskDetail({
|
||||
],
|
||||
};
|
||||
} catch (error) {
|
||||
console.error("取得任務詳情時發生錯誤:", error);
|
||||
console.error("Error retrieving task details:", error);
|
||||
|
||||
// 使用prompt生成器獲取錯誤訊息
|
||||
const errorPrompt = getGetTaskDetailPrompt({
|
||||
|
@ -36,6 +36,5 @@ export async function ensureRulesFileExists(): Promise<void> {
|
||||
"# 開發守則\n\n請在此文件中定義專案規範。",
|
||||
"utf-8"
|
||||
);
|
||||
console.log(`已在 ${dataRulesPath} 創建空規則文件`);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user