Fix: 修正Cursor Console 不支援中文問題

fixes #12
fixes #10
This commit is contained in:
siage 2025-04-28 12:18:59 +08:00
parent 1f8d9c8352
commit 00943e1736
4 changed files with 26 additions and 24 deletions

View File

@ -53,12 +53,12 @@ import {
async function main() { async function main() {
try { try {
console.log("啟動蝦米任務管理器服務..."); console.log("Starting Shrimp Task Manager service...");
// 創建MCP服務器 // 創建MCP服務器
const server = new Server( const server = new Server(
{ {
name: "蝦米任務管理器", name: "Shrimp Task Manager",
version: "1.0.0", version: "1.0.0",
}, },
{ {
@ -331,7 +331,7 @@ async function main() {
case "init_project_rules": case "init_project_rules":
return await initProjectRules(); return await initProjectRules();
default: default:
throw new Error(`工具 ${request.params.name} 不存在`); throw new Error(`Tool ${request.params.name} does not exist`);
} }
} catch (error) { } catch (error) {
console.error("Error executing tool:", error); console.error("Error executing tool:", error);
@ -341,7 +341,7 @@ async function main() {
content: [ content: [
{ {
type: "text", 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(); const transport = new StdioServerTransport();
await server.connect(transport); await server.connect(transport);
console.log("蝦米任務管理器服務已啟動"); console.log("Shrimp Task Manager service started");
} catch (error) { } catch (error) {
console.error("啟動服務失敗:", error); console.error("Failed to start service:", error);
process.exit(1); process.exit(1);
} }
} }

View File

@ -129,7 +129,9 @@ export async function updateTask(
if (disallowedFields.length > 0) { if (disallowedFields.length > 0) {
console.warn( console.warn(
`警告:嘗試更新已完成任務的非法欄位: ${disallowedFields.join(", ")}` `Warning: Attempted to update illegal fields on a completed task: ${disallowedFields.join(
", "
)}`
); );
return null; return null;
} }
@ -388,11 +390,11 @@ export async function batchCreateOrUpdateTasks(
existingTasks[existingTaskIndex].status === TaskStatus.COMPLETED existingTasks[existingTaskIndex].status === TaskStatus.COMPLETED
) { ) {
console.warn( console.warn(
`警告:嘗試更新已完成的任務 "${taskData.name}",操作被忽略` `Warning: Attempted to update completed task "${taskData.name}", operation ignored`
); );
} else { } else {
console.warn( 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)!; dependencyTaskId = taskNameToIdMap.get(dependencyName)!;
} else { } else {
console.warn( console.warn(
`警告:任務 "${taskData.name}" 引用了未知的依賴任務 "${dependencyName}",此依賴將被忽略` `Warning: Task "${taskData.name}" references unknown dependency task "${dependencyName}", dependency ignored`
); );
continue; // 跳過此依賴 continue; // 跳過此依賴
} }
@ -460,7 +462,7 @@ export async function batchCreateOrUpdateTasks(
); );
if (!idExists) { if (!idExists) {
console.warn( console.warn(
`警告:任務 "${taskData.name}" 引用了未知的依賴任務ID "${dependencyTaskId}",此依賴將被忽略` `Warning: Task "${taskData.name}" references unknown dependency task ID "${dependencyTaskId}", dependency ignored`
); );
continue; // 跳過此依賴 continue; // 跳過此依賴
} }
@ -745,7 +747,7 @@ export async function clearAllTasks(): Promise<{
backupFile: backupFileName, backupFile: backupFileName,
}; };
} catch (error) { } catch (error) {
console.error("清除所有任務時發生錯誤:", error); console.error("Error occurred while clearing all tasks:", error);
return { return {
success: false, success: false,
message: `清除任務時發生錯誤: ${ message: `清除任務時發生錯誤: ${
@ -861,7 +863,7 @@ export async function searchTasksWithCommand(
memoryTasks.push(...filteredTasks); memoryTasks.push(...filteredTasks);
} catch (error: unknown) { } catch (error: unknown) {
console.error(`讀取檔案 ${filePath} 時發生錯誤:`, error); console.error(`Error reading file ${filePath}:`, error);
} }
} }
} }
@ -870,12 +872,12 @@ export async function searchTasksWithCommand(
// 只有當錯誤代碼不是1(沒有匹配)時才記錄錯誤 // 只有當錯誤代碼不是1(沒有匹配)時才記錄錯誤
const err = error as { code?: number }; const err = error as { code?: number };
if (err.code !== 1) { if (err.code !== 1) {
console.error("執行搜尋指令時發生錯誤:", error); console.error("Error executing search command:", error);
} }
} }
} }
} catch (error: unknown) { } catch (error: unknown) {
console.error("搜尋記憶資料夾時發生錯誤:", error); console.error("Error searching memory directory:", error);
} }
// 從當前任務中過濾符合條件的任務 // 從當前任務中過濾符合條件的任務

View File

@ -93,7 +93,7 @@ export async function planTask({
(task) => task.status !== TaskStatus.COMPLETED (task) => task.status !== TaskStatus.COMPLETED
); );
} catch (error) { } catch (error) {
console.error("載入現有任務時發生錯誤:", error); console.error("Error loading existing tasks:", error);
} }
} }
@ -402,7 +402,7 @@ export async function splitTasks({
try { try {
allTasks = await getAllTasks(); allTasks = await getAllTasks();
} catch (error) { } catch (error) {
console.error("獲取所有任務時發生錯誤:", error); console.error("Error retrieving all tasks:", error);
allTasks = [...createdTasks]; // 如果獲取失敗,至少使用剛創建的任務 allTasks = [...createdTasks]; // 如果獲取失敗,至少使用剛創建的任務
} }
@ -429,7 +429,7 @@ export async function splitTasks({
}, },
}; };
} catch (error) { } catch (error) {
console.error("執行任務拆分時發生錯誤:", error); console.error("Error executing task split:", error);
return { return {
content: [ content: [
@ -622,8 +622,9 @@ export async function executeTask({
? relatedFilesResult ? relatedFilesResult
: relatedFilesResult.summary || ""; : relatedFilesResult.summary || "";
} catch (error) { } catch (error) {
console.error("載入相關文件時發生錯誤:", error); console.error("Error loading related files:", error);
relatedFilesSummary = "載入相關文件時發生錯誤,請手動查看文件。"; relatedFilesSummary =
"Error loading related files, please check the files manually.";
} }
} }
@ -644,7 +645,7 @@ export async function executeTask({
], ],
}; };
} catch (error) { } catch (error) {
console.error("執行任務時發生錯誤:", error); console.error("Error executing task:", error);
return { return {
content: [ content: [
{ {
@ -1121,7 +1122,7 @@ export async function queryTask({
], ],
}; };
} catch (error) { } catch (error) {
console.error("查詢任務時發生錯誤:", error); console.error("Error querying tasks:", error);
return { return {
content: [ content: [
{ {
@ -1186,7 +1187,7 @@ export async function getTaskDetail({
], ],
}; };
} catch (error) { } catch (error) {
console.error("取得任務詳情時發生錯誤:", error); console.error("Error retrieving task details:", error);
// 使用prompt生成器獲取錯誤訊息 // 使用prompt生成器獲取錯誤訊息
const errorPrompt = getGetTaskDetailPrompt({ const errorPrompt = getGetTaskDetailPrompt({

View File

@ -36,6 +36,5 @@ export async function ensureRulesFileExists(): Promise<void> {
"# 開發守則\n\n請在此文件中定義專案規範。", "# 開發守則\n\n請在此文件中定義專案規範。",
"utf-8" "utf-8"
); );
console.log(`已在 ${dataRulesPath} 創建空規則文件`);
} }
} }