Skip to content

Commit d4a6014

Browse files
fix: 修复 BriefTool 循环依赖导致 isBriefEnabled 未定义
将模块顶层 require() 改为懒加载函数 getBriefToolModule(), 延迟到实际调用时才加载模块,避免循环依赖时模块尚未完成初始化。
1 parent 897c186 commit d4a6014

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/constants/prompts.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,11 @@ const BRIEF_PROACTIVE_SECTION: string | null =
8282
require('@claude-code-best/builtin-tools/tools/BriefTool/prompt.js') as typeof import('@claude-code-best/builtin-tools/tools/BriefTool/prompt.js')
8383
).BRIEF_PROACTIVE_SECTION
8484
: null
85-
const briefToolModule =
86-
feature('KAIROS') || feature('KAIROS_BRIEF')
85+
function getBriefToolModule() {
86+
return feature('KAIROS') || feature('KAIROS_BRIEF')
8787
? (require('@claude-code-best/builtin-tools/tools/BriefTool/BriefTool.js') as typeof import('@claude-code-best/builtin-tools/tools/BriefTool/BriefTool.js'))
8888
: null
89+
}
8990
const DISCOVER_SKILLS_TOOL_NAME: string | null = feature(
9091
'EXPERIMENTAL_SKILL_SEARCH',
9192
)
@@ -800,7 +801,7 @@ function getBriefSection(): string | null {
800801
// Whenever the tool is available, the model is told to use it. The
801802
// /brief toggle and --brief flag now only control the isBriefOnly
802803
// display filter — they no longer gate model-facing behavior.
803-
if (!briefToolModule?.isBriefEnabled()) return null
804+
if (!getBriefToolModule()?.isBriefEnabled()) return null
804805
// When proactive is active, getProactiveSection() already appends the
805806
// section inline. Skip here to avoid duplicating it in the system prompt.
806807
if (
@@ -864,5 +865,5 @@ Do not narrate each step, list every file you read, or explain routine actions.
864865
865866
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:
866867
- **Unfocused**: The user is away. Lean heavily into autonomous action — make decisions, explore, commit, push. Only pause for genuinely irreversible or high-risk actions.
867-
- **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}` : ''}`
868+
- **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}` : ''}`
868869
}

0 commit comments

Comments
 (0)