mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-02 20:43:36 +00:00
refactor: streamline auto-load CLAUDE.md setting retrieval
- Removed the private method for getting the autoLoadClaudeMd setting from AgentService and AutoModeService. - Updated both services to utilize the new settings helper for retrieving the autoLoadClaudeMd setting, improving code reusability and clarity. - Adjusted error handling in the settings helper to throw errors instead of returning false when the settings service is unavailable.
This commit is contained in:
@@ -17,6 +17,7 @@ import { ProviderFactory } from '../providers/provider-factory.js';
|
||||
import { createChatOptions, validateWorkingDirectory } from '../lib/sdk-options.js';
|
||||
import { PathNotAllowedError } from '@automaker/platform';
|
||||
import type { SettingsService } from './settings-service.js';
|
||||
import { getAutoLoadClaudeMdSetting } from '../lib/settings-helpers.js';
|
||||
|
||||
interface Message {
|
||||
id: string;
|
||||
@@ -190,7 +191,11 @@ export class AgentService {
|
||||
const effectiveWorkDir = workingDirectory || session.workingDirectory;
|
||||
|
||||
// Load autoLoadClaudeMd setting (project setting takes precedence over global)
|
||||
const autoLoadClaudeMd = await this.getAutoLoadClaudeMdSetting(effectiveWorkDir);
|
||||
const autoLoadClaudeMd = await getAutoLoadClaudeMdSetting(
|
||||
effectiveWorkDir,
|
||||
this.settingsService,
|
||||
'[AgentService]'
|
||||
);
|
||||
|
||||
// Load project context files (CLAUDE.md, CODE_QUALITY.md, etc.)
|
||||
// Note: When autoLoadClaudeMd is enabled, SDK handles CLAUDE.md loading via settingSources
|
||||
@@ -604,37 +609,6 @@ You have full access to the codebase and can:
|
||||
- Execute tests and builds`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the autoLoadClaudeMd setting, with project settings taking precedence over global.
|
||||
* Returns false if settings service is not available.
|
||||
*/
|
||||
private async getAutoLoadClaudeMdSetting(projectPath: string): Promise<boolean> {
|
||||
if (!this.settingsService) {
|
||||
console.log('[AgentService] SettingsService not available, autoLoadClaudeMd disabled');
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
// Check project settings first (takes precedence)
|
||||
const projectSettings = await this.settingsService.getProjectSettings(projectPath);
|
||||
if (projectSettings.autoLoadClaudeMd !== undefined) {
|
||||
console.log(
|
||||
`[AgentService] autoLoadClaudeMd from project settings: ${projectSettings.autoLoadClaudeMd}`
|
||||
);
|
||||
return projectSettings.autoLoadClaudeMd;
|
||||
}
|
||||
|
||||
// Fall back to global settings
|
||||
const globalSettings = await this.settingsService.getGlobalSettings();
|
||||
const result = globalSettings.autoLoadClaudeMd ?? false;
|
||||
console.log(`[AgentService] autoLoadClaudeMd from global settings: ${result}`);
|
||||
return result;
|
||||
} catch (error) {
|
||||
console.error('[AgentService] Failed to load autoLoadClaudeMd setting:', error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private generateId(): string {
|
||||
return `msg_${Date.now()}_${Math.random().toString(36).substring(2, 11)}`;
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import {
|
||||
} from '../lib/sdk-options.js';
|
||||
import { FeatureLoader } from './feature-loader.js';
|
||||
import type { SettingsService } from './settings-service.js';
|
||||
import { getAutoLoadClaudeMdSetting } from '../lib/settings-helpers.js';
|
||||
|
||||
const execAsync = promisify(exec);
|
||||
|
||||
@@ -1100,7 +1101,11 @@ Format your response as a structured markdown document.`;
|
||||
const provider = ProviderFactory.getProviderForModel(analysisModel);
|
||||
|
||||
// Load autoLoadClaudeMd setting
|
||||
const autoLoadClaudeMd = await this.getAutoLoadClaudeMdSetting(projectPath);
|
||||
const autoLoadClaudeMd = await getAutoLoadClaudeMdSetting(
|
||||
projectPath,
|
||||
this.settingsService,
|
||||
'[AutoMode]'
|
||||
);
|
||||
|
||||
// Use createCustomOptions for centralized SDK configuration with CLAUDE.md support
|
||||
const sdkOptions = createCustomOptions({
|
||||
@@ -1797,7 +1802,11 @@ This mock response was generated because AUTOMAKER_MOCK_AGENT=true was set.
|
||||
}
|
||||
|
||||
// Load autoLoadClaudeMd setting (project setting takes precedence over global)
|
||||
const autoLoadClaudeMd = await this.getAutoLoadClaudeMdSetting(finalProjectPath);
|
||||
const autoLoadClaudeMd = await getAutoLoadClaudeMdSetting(
|
||||
finalProjectPath,
|
||||
this.settingsService,
|
||||
'[AutoMode]'
|
||||
);
|
||||
|
||||
// Build SDK options using centralized configuration for feature implementation
|
||||
const sdkOptions = createAutoModeOptions({
|
||||
@@ -2515,35 +2524,4 @@ Begin implementing task ${task.id} now.`;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the autoLoadClaudeMd setting, with project settings taking precedence over global.
|
||||
* Returns false if settings service is not available.
|
||||
*/
|
||||
private async getAutoLoadClaudeMdSetting(projectPath: string): Promise<boolean> {
|
||||
if (!this.settingsService) {
|
||||
console.log('[AutoMode] SettingsService not available, autoLoadClaudeMd disabled');
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
// Check project settings first (takes precedence)
|
||||
const projectSettings = await this.settingsService.getProjectSettings(projectPath);
|
||||
if (projectSettings.autoLoadClaudeMd !== undefined) {
|
||||
console.log(
|
||||
`[AutoMode] autoLoadClaudeMd from project settings: ${projectSettings.autoLoadClaudeMd}`
|
||||
);
|
||||
return projectSettings.autoLoadClaudeMd;
|
||||
}
|
||||
|
||||
// Fall back to global settings
|
||||
const globalSettings = await this.settingsService.getGlobalSettings();
|
||||
const result = globalSettings.autoLoadClaudeMd ?? false;
|
||||
console.log(`[AutoMode] autoLoadClaudeMd from global settings: ${result}`);
|
||||
return result;
|
||||
} catch (error) {
|
||||
console.error('[AutoMode] Failed to load autoLoadClaudeMd setting:', error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user