From 3ee32e5f73652e15ab4eba392b9475777d9c8ff6 Mon Sep 17 00:00:00 2001 From: siage Date: Tue, 15 Apr 2025 20:50:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=92=B0=E5=A2=83=E8=AE=8A?= =?UTF-8?q?=E6=95=B8=20`ENABLE=5FTHOUGHT=5FCHAIN`=20=E4=BB=A5=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=E4=BB=BB=E5=8B=99=E8=A6=8F=E5=8A=83=E4=B8=AD=E7=9A=84?= =?UTF-8?q?=E6=80=9D=E8=80=83=E6=A8=A1=E5=BC=8F=EF=BC=8C=E4=B8=A6=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E7=9B=B8=E9=97=9C=E6=96=87=E6=AA=94=E4=BB=A5=E8=AA=AA?= =?UTF-8?q?=E6=98=8E=E5=85=B6=E5=8A=9F=E8=83=BD=E8=88=87=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=EF=BC=8C=E6=8F=90=E5=8D=87=E7=94=A8=E6=88=B6?= =?UTF-8?q?=E5=9C=A8=E4=BB=BB=E5=8B=99=E5=88=86=E6=9E=90=E9=81=8E=E7=A8=8B?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E9=9D=88=E6=B4=BB=E6=80=A7=E8=88=87=E6=95=88?= =?UTF-8?q?=E7=8E=87=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.example | 3 +++ README.md | 8 +++++++- docs/zh/README.md | 8 +++++++- src/index.ts | 2 -- src/prompts/generators/planTask.ts | 13 ++++++++++--- src/prompts/templates/planTask.ts | 10 +++++++--- src/tools/thoughtChainTools.ts | 12 +++++++++--- 7 files changed, 43 insertions(+), 13 deletions(-) diff --git a/.env.example b/.env.example index d3a75da..0a3205c 100644 --- a/.env.example +++ b/.env.example @@ -8,6 +8,9 @@ # Task data storage directory (absolute path) DATA_DIR= +# Enable thought chain +ENABLE_THOUGHT_CHAIN=true + # ============================ # Prompt Customization # ============================ diff --git a/README.md b/README.md index 79a4406..ca10b5a 100644 --- a/README.md +++ b/README.md @@ -153,7 +153,8 @@ Shrimp Task Manager supports customizing prompt behavior through environment var "env": { "DATA_DIR": "/path/to/project/data", "MCP_PROMPT_PLAN_TASK": "Custom planning guidance...", - "MCP_PROMPT_EXECUTE_TASK_APPEND": "Additional execution instructions..." + "MCP_PROMPT_EXECUTE_TASK_APPEND": "Additional execution instructions...", + "ENABLE_THOUGHT_CHAIN": "true" } } } @@ -165,6 +166,11 @@ There are two customization methods: - **Override Mode** (`MCP_PROMPT_[FUNCTION_NAME]`): Completely replace the default prompt - **Append Mode** (`MCP_PROMPT_[FUNCTION_NAME]_APPEND`): Add content to the existing prompt +Additionally, there are other system configuration variables: + +- **DATA_DIR**: Specifies the directory where task data is stored +- **ENABLE_THOUGHT_CHAIN**: Controls the thinking model in task planning workflow. When set to `true` (default), the system guides users to use the `process_thought` tool for step-by-step reasoning. When set to `false`, the system directly uses `analyze_task` to submit analysis results, skipping the detailed thinking process. + For detailed instructions on customizing prompts, including supported parameters and examples, see the [Prompt Customization Guide](docs/en/prompt-customization.md). ## 💡 System Prompt Guidance diff --git a/docs/zh/README.md b/docs/zh/README.md index 823c5c4..4bc709b 100644 --- a/docs/zh/README.md +++ b/docs/zh/README.md @@ -153,7 +153,8 @@ npm run build "env": { "DATA_DIR": "/path/to/project/data", "MCP_PROMPT_PLAN_TASK": "自定義規劃指導...", - "MCP_PROMPT_EXECUTE_TASK_APPEND": "附加執行說明..." + "MCP_PROMPT_EXECUTE_TASK_APPEND": "附加執行說明...", + "ENABLE_THOUGHT_CHAIN": "true" } } } @@ -165,6 +166,11 @@ npm run build - **覆蓋模式**(`MCP_PROMPT_[FUNCTION_NAME]`):完全替換預設提示詞 - **追加模式**(`MCP_PROMPT_[FUNCTION_NAME]_APPEND`):在現有提示詞基礎上增加內容 +此外,還有其他系統配置變數: + +- **DATA_DIR**:指定任務數據存儲的目錄 +- **ENABLE_THOUGHT_CHAIN**:控制任務規劃工作流中的思考模式。當設置為 `true`(預設值)時,系統引導用戶使用 `process_thought` 工具進行逐步推理。當設置為 `false` 時,系統直接使用 `analyze_task` 提交分析結果,跳過詳細的思考過程。 + 有關自定義提示詞的詳細說明,包括支援的參數和範例,請參閱[提示詞自定義指南](prompt-customization.md)。 ## 💡 系統提示詞指導 diff --git a/src/index.ts b/src/index.ts index b9e82bc..e2961bd 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,8 +4,6 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js" import { z } from "zod"; import { RelatedFileType } from "./types/index.js"; -console.log(process.env.DATA_DIR || "沒設定"); - // 導入工具函數 import { planTask, diff --git a/src/prompts/generators/planTask.ts b/src/prompts/generators/planTask.ts index 084e86b..5a48205 100644 --- a/src/prompts/generators/planTask.ts +++ b/src/prompts/generators/planTask.ts @@ -182,9 +182,16 @@ export function getPlanTaskPrompt(params: PlanTaskPromptParams): string { basePrompt += templates.nextStepsTemplate; basePrompt += templates.nextStepsContent1; basePrompt += templates.nextStepsContent1Detail; - basePrompt += templates.nextStepsContent2; - basePrompt += templates.nextStepsContent2Detail1; - basePrompt += templates.nextStepsContent2Detail2; + + if (process.env.ENABLE_THOUGHT_CHAIN !== "false") { + basePrompt += templates.nextStepsThoughtTemplate; + basePrompt += templates.nextStepsThoughtDetail1; + basePrompt += templates.nextStepsThoughtDetail2; + } else { + basePrompt += templates.nextStepsContent2; + basePrompt += templates.nextStepsContent2Detail1; + basePrompt += templates.nextStepsContent2Detail2; + } // 載入可能的自定義 prompt return loadPrompt(basePrompt, "PLAN_TASK"); diff --git a/src/prompts/templates/planTask.ts b/src/prompts/templates/planTask.ts index a47948a..fb33fe4 100644 --- a/src/prompts/templates/planTask.ts +++ b/src/prompts/templates/planTask.ts @@ -90,6 +90,10 @@ export const infoCollectionGuideItems3 = `3. **網路搜索** - 當出現你不 export const nextStepsTemplate = `## 下一步\n\n`; export const nextStepsContent1 = `**第一步:根據任務描述決定是否查詢記憶**\n`; export const nextStepsContent1Detail = `- 判斷任務是否屬於必查情境,若是,請先使用「query_task」查詢過往記錄;否則,可直接進行分析。\n\n`; -export const nextStepsContent2 = `**第二步:使用「process_thought」思考答案:\n`; -export const nextStepsContent2Detail1 = `1. **思考過程** - 逐步推理過程,包括假設、驗證和調整\n`; -export const nextStepsContent2Detail2 = `2. 如果不需要思考更多,請使用「analyze_task」提交分析結果\n`; +export const nextStepsContent2 = `**第二步:使用 analyze_task 提交分析結果**\n`; +export const nextStepsContent2Detail1 = `1. **任務摘要** - 目標、範圍、挑戰和限制條件\n`; +export const nextStepsContent2Detail2 = `2. **初步解答構想** - 可行的技術方案和實施計劃\n`; + +export const nextStepsThoughtTemplate = `**第二步:使用「process_thought」思考答案:\n`; +export const nextStepsThoughtDetail1 = `1. **思考過程** - 逐步推理過程,包括假設、驗證和調整\n`; +export const nextStepsThoughtDetail2 = `2. 請務必先使用「process_thought」工具思考,禁止直接回答\n`; diff --git a/src/tools/thoughtChainTools.ts b/src/tools/thoughtChainTools.ts index a6013c5..f4b1557 100644 --- a/src/tools/thoughtChainTools.ts +++ b/src/tools/thoughtChainTools.ts @@ -31,9 +31,15 @@ const thoughtDataSchema = z.object({ message: "思維階段不能為空,請提供有效的思考階段", }) .describe("思維階段"), - tags: z.array(z.string()).optional().describe("思維標籤"), - axioms_used: z.array(z.string()).optional().describe("使用的公理"), - assumptions_challenged: z.array(z.string()).optional().describe("挑戰的假設"), + tags: z.array(z.string()).optional().describe("思維標籤,是一個陣列字串"), + axioms_used: z + .array(z.string()) + .optional() + .describe("使用的公理,是一個陣列字串"), + assumptions_challenged: z + .array(z.string()) + .optional() + .describe("挑戰的假設,是一個陣列字串"), }); /**