新增環境變數 ENABLE_THOUGHT_CHAIN 以控制任務規劃中的思考模式,並更新相關文檔以說明其功能與使用方式,提升用戶在任務分析過程中的靈活性與效率。

This commit is contained in:
siage 2025-04-15 20:50:29 +08:00
parent 34f46a57d0
commit 3ee32e5f73
7 changed files with 43 additions and 13 deletions

View File

@ -8,6 +8,9 @@
# Task data storage directory (absolute path) # Task data storage directory (absolute path)
DATA_DIR= DATA_DIR=
# Enable thought chain
ENABLE_THOUGHT_CHAIN=true
# ============================ # ============================
# Prompt Customization # Prompt Customization
# ============================ # ============================

View File

@ -153,7 +153,8 @@ Shrimp Task Manager supports customizing prompt behavior through environment var
"env": { "env": {
"DATA_DIR": "/path/to/project/data", "DATA_DIR": "/path/to/project/data",
"MCP_PROMPT_PLAN_TASK": "Custom planning guidance...", "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 - **Override Mode** (`MCP_PROMPT_[FUNCTION_NAME]`): Completely replace the default prompt
- **Append Mode** (`MCP_PROMPT_[FUNCTION_NAME]_APPEND`): Add content to the existing 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). For detailed instructions on customizing prompts, including supported parameters and examples, see the [Prompt Customization Guide](docs/en/prompt-customization.md).
## 💡 System Prompt Guidance ## 💡 System Prompt Guidance

View File

@ -153,7 +153,8 @@ npm run build
"env": { "env": {
"DATA_DIR": "/path/to/project/data", "DATA_DIR": "/path/to/project/data",
"MCP_PROMPT_PLAN_TASK": "自定義規劃指導...", "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]`):完全替換預設提示詞
- **追加模式**`MCP_PROMPT_[FUNCTION_NAME]_APPEND`):在現有提示詞基礎上增加內容 - **追加模式**`MCP_PROMPT_[FUNCTION_NAME]_APPEND`):在現有提示詞基礎上增加內容
此外,還有其他系統配置變數:
- **DATA_DIR**:指定任務數據存儲的目錄
- **ENABLE_THOUGHT_CHAIN**:控制任務規劃工作流中的思考模式。當設置為 `true`(預設值)時,系統引導用戶使用 `process_thought` 工具進行逐步推理。當設置為 `false` 時,系統直接使用 `analyze_task` 提交分析結果,跳過詳細的思考過程。
有關自定義提示詞的詳細說明,包括支援的參數和範例,請參閱[提示詞自定義指南](prompt-customization.md)。 有關自定義提示詞的詳細說明,包括支援的參數和範例,請參閱[提示詞自定義指南](prompt-customization.md)。
## 💡 系統提示詞指導 ## 💡 系統提示詞指導

View File

@ -4,8 +4,6 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
import { z } from "zod"; import { z } from "zod";
import { RelatedFileType } from "./types/index.js"; import { RelatedFileType } from "./types/index.js";
console.log(process.env.DATA_DIR || "沒設定");
// 導入工具函數 // 導入工具函數
import { import {
planTask, planTask,

View File

@ -182,9 +182,16 @@ export function getPlanTaskPrompt(params: PlanTaskPromptParams): string {
basePrompt += templates.nextStepsTemplate; basePrompt += templates.nextStepsTemplate;
basePrompt += templates.nextStepsContent1; basePrompt += templates.nextStepsContent1;
basePrompt += templates.nextStepsContent1Detail; basePrompt += templates.nextStepsContent1Detail;
basePrompt += templates.nextStepsContent2;
basePrompt += templates.nextStepsContent2Detail1; if (process.env.ENABLE_THOUGHT_CHAIN !== "false") {
basePrompt += templates.nextStepsContent2Detail2; basePrompt += templates.nextStepsThoughtTemplate;
basePrompt += templates.nextStepsThoughtDetail1;
basePrompt += templates.nextStepsThoughtDetail2;
} else {
basePrompt += templates.nextStepsContent2;
basePrompt += templates.nextStepsContent2Detail1;
basePrompt += templates.nextStepsContent2Detail2;
}
// 載入可能的自定義 prompt // 載入可能的自定義 prompt
return loadPrompt(basePrompt, "PLAN_TASK"); return loadPrompt(basePrompt, "PLAN_TASK");

View File

@ -90,6 +90,10 @@ export const infoCollectionGuideItems3 = `3. **網路搜索** - 當出現你不
export const nextStepsTemplate = `## 下一步\n\n`; export const nextStepsTemplate = `## 下一步\n\n`;
export const nextStepsContent1 = `**第一步:根據任務描述決定是否查詢記憶**\n`; export const nextStepsContent1 = `**第一步:根據任務描述決定是否查詢記憶**\n`;
export const nextStepsContent1Detail = `- 判斷任務是否屬於必查情境若是請先使用「query_task」查詢過往記錄否則可直接進行分析。\n\n`; export const nextStepsContent1Detail = `- 判斷任務是否屬於必查情境若是請先使用「query_task」查詢過往記錄否則可直接進行分析。\n\n`;
export const nextStepsContent2 = `**第二步使用「process_thought」思考答案\n`; export const nextStepsContent2 = `**第二步:使用 analyze_task 提交分析結果**\n`;
export const nextStepsContent2Detail1 = `1. **思考過程** - 逐步推理過程,包括假設、驗證和調整\n`; export const nextStepsContent2Detail1 = `1. **任務摘要** - 目標、範圍、挑戰和限制條件\n`;
export const nextStepsContent2Detail2 = `2. 如果不需要思考更多請使用「analyze_task」提交分析結果\n`; export const nextStepsContent2Detail2 = `2. **初步解答構想** - 可行的技術方案和實施計劃\n`;
export const nextStepsThoughtTemplate = `**第二步使用「process_thought」思考答案\n`;
export const nextStepsThoughtDetail1 = `1. **思考過程** - 逐步推理過程,包括假設、驗證和調整\n`;
export const nextStepsThoughtDetail2 = `2. 請務必先使用「process_thought」工具思考禁止直接回答\n`;

View File

@ -31,9 +31,15 @@ const thoughtDataSchema = z.object({
message: "思維階段不能為空,請提供有效的思考階段", message: "思維階段不能為空,請提供有效的思考階段",
}) })
.describe("思維階段"), .describe("思維階段"),
tags: z.array(z.string()).optional().describe("思維標籤"), tags: z.array(z.string()).optional().describe("思維標籤,是一個陣列字串"),
axioms_used: z.array(z.string()).optional().describe("使用的公理"), axioms_used: z
assumptions_challenged: z.array(z.string()).optional().describe("挑戰的假設"), .array(z.string())
.optional()
.describe("使用的公理,是一個陣列字串"),
assumptions_challenged: z
.array(z.string())
.optional()
.describe("挑戰的假設,是一個陣列字串"),
}); });
/** /**