refactor: enhance context loading strategy in AgentService and AutoModeService

- Updated both services to conditionally load CLAUDE.md based on the autoLoadClaudeMd setting, preventing duplication.
- Improved clarity in comments regarding the loading process of context files.
- Ensured consistent retrieval of the autoLoadClaudeMd setting across different methods.
This commit is contained in:
Kacper
2025-12-24 22:59:57 +01:00
parent 99a19cb2a2
commit 077dd31b4f
2 changed files with 46 additions and 18 deletions

View File

@@ -198,11 +198,14 @@ export class AgentService {
);
// Load project context files (CLAUDE.md, CODE_QUALITY.md, etc.)
// Note: When autoLoadClaudeMd is enabled, SDK handles CLAUDE.md loading via settingSources
const { formattedPrompt: contextFilesPrompt } = await loadContextFiles({
projectPath: effectiveWorkDir,
fsModule: secureFs as Parameters<typeof loadContextFiles>[0]['fsModule'],
});
// Note: When autoLoadClaudeMd is enabled, skip loading CLAUDE.md here since SDK handles it
// to avoid duplication. The SDK's settingSources will load CLAUDE.md from standard locations.
const { formattedPrompt: contextFilesPrompt } = autoLoadClaudeMd
? { formattedPrompt: '' }
: await loadContextFiles({
projectPath: effectiveWorkDir,
fsModule: secureFs as Parameters<typeof loadContextFiles>[0]['fsModule'],
});
// Build combined system prompt with base prompt and context files
const baseSystemPrompt = this.getSystemPrompt();