From 98c3deb2b63413248a7fb63cbe460c3099007b76 Mon Sep 17 00:00:00 2001 From: claude-code-best Date: Fri, 22 May 2026 21:04:17 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20BriefTool=20?= =?UTF-8?q?=E5=BE=AA=E7=8E=AF=E4=BE=9D=E8=B5=96=E5=AF=BC=E8=87=B4=20isBrie?= =?UTF-8?q?fEnabled=20=E6=9C=AA=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将模块顶层 require() 改为懒加载函数 getBriefToolModule(), 延迟到实际调用时才加载模块,避免循环依赖时模块尚未完成初始化。 (cherry picked from commit d4a601475f195f2eabee660de428a8f1fcd86e7e) --- src/constants/prompts.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/constants/prompts.ts b/src/constants/prompts.ts index c85554219..433ac04f2 100644 --- a/src/constants/prompts.ts +++ b/src/constants/prompts.ts @@ -63,7 +63,6 @@ import { getAntModelOverrideConfig } from '../utils/model/antModels.js' import { isMcpInstructionsDeltaEnabled } from '../utils/mcpInstructionsDelta.js' import { BRIEF_PROACTIVE_SECTION as BRIEF_PROACTIVE_SECTION_VALUE } from '../tools/BriefTool/prompt.js' import * as proactiveModuleValue from '../proactive/index.js' -import * as briefToolModuleValue from '../tools/BriefTool/BriefTool.js' import { DISCOVER_SKILLS_TOOL_NAME as DISCOVER_SKILLS_TOOL_NAME_VALUE } from '../tools/DiscoverSkillsTool/prompt.js' import * as skillSearchFeatureCheckValue from '../services/skillSearch/featureCheck.js' @@ -81,10 +80,11 @@ const BRIEF_PROACTIVE_SECTION: string | null = feature('KAIROS') || feature('KAIROS_BRIEF') ? BRIEF_PROACTIVE_SECTION_VALUE : null -const briefToolModule = - feature('KAIROS') || feature('KAIROS_BRIEF') - ? briefToolModuleValue +function getBriefToolModule() { + return feature('KAIROS') || feature('KAIROS_BRIEF') + ? (require('../tools/BriefTool/BriefTool.js') as typeof import('../tools/BriefTool/BriefTool.js')) : null +} const DISCOVER_SKILLS_TOOL_NAME: string | null = feature( 'EXPERIMENTAL_SKILL_SEARCH', ) @@ -846,7 +846,7 @@ function getBriefSection(): string | null { // Whenever the tool is available, the model is told to use it. The // /brief toggle and --brief flag now only control the isBriefOnly // display filter — they no longer gate model-facing behavior. - if (!briefToolModule?.isBriefEnabled()) return null + if (!getBriefToolModule()?.isBriefEnabled()) return null // When proactive is active, getProactiveSection() already appends the // section inline. Skip here to avoid duplicating it in the system prompt. if ( @@ -910,5 +910,5 @@ Do not narrate each step, list every file you read, or explain routine actions. The user context may include a \`terminalFocus\` field indicating whether the user's terminal is focused or unfocused. Use this to calibrate how autonomous you are: - **Unfocused**: The user is away. Lean heavily into autonomous action — make decisions, explore, commit, push. Only pause for genuinely irreversible or high-risk actions. -- **Focused**: The user is watching. Be more collaborative — surface choices, ask before committing to large changes, and keep your output concise so it's easy to follow in real time.${BRIEF_PROACTIVE_SECTION && briefToolModule?.isBriefEnabled() ? `\n\n${BRIEF_PROACTIVE_SECTION}` : ''}` +- **Focused**: The user is watching. Be more collaborative — surface choices, ask before committing to large changes, and keep your output concise so it's easy to follow in real time.${BRIEF_PROACTIVE_SECTION && getBriefToolModule()?.isBriefEnabled() ? `\n\n${BRIEF_PROACTIVE_SECTION}` : ''}` }