mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-03 21:03:08 +00:00
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:
@@ -198,11 +198,14 @@ export class AgentService {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Load project context files (CLAUDE.md, CODE_QUALITY.md, etc.)
|
// Load project context files (CLAUDE.md, CODE_QUALITY.md, etc.)
|
||||||
// Note: When autoLoadClaudeMd is enabled, SDK handles CLAUDE.md loading via settingSources
|
// Note: When autoLoadClaudeMd is enabled, skip loading CLAUDE.md here since SDK handles it
|
||||||
const { formattedPrompt: contextFilesPrompt } = await loadContextFiles({
|
// to avoid duplication. The SDK's settingSources will load CLAUDE.md from standard locations.
|
||||||
projectPath: effectiveWorkDir,
|
const { formattedPrompt: contextFilesPrompt } = autoLoadClaudeMd
|
||||||
fsModule: secureFs as Parameters<typeof loadContextFiles>[0]['fsModule'],
|
? { formattedPrompt: '' }
|
||||||
});
|
: await loadContextFiles({
|
||||||
|
projectPath: effectiveWorkDir,
|
||||||
|
fsModule: secureFs as Parameters<typeof loadContextFiles>[0]['fsModule'],
|
||||||
|
});
|
||||||
|
|
||||||
// Build combined system prompt with base prompt and context files
|
// Build combined system prompt with base prompt and context files
|
||||||
const baseSystemPrompt = this.getSystemPrompt();
|
const baseSystemPrompt = this.getSystemPrompt();
|
||||||
|
|||||||
@@ -559,13 +559,24 @@ export class AutoModeService {
|
|||||||
// Update feature status to in_progress
|
// Update feature status to in_progress
|
||||||
await this.updateFeatureStatus(projectPath, featureId, 'in_progress');
|
await this.updateFeatureStatus(projectPath, featureId, 'in_progress');
|
||||||
|
|
||||||
|
// Load autoLoadClaudeMd setting to determine context loading strategy
|
||||||
|
const autoLoadClaudeMd = await getAutoLoadClaudeMdSetting(
|
||||||
|
projectPath,
|
||||||
|
this.settingsService,
|
||||||
|
'[AutoMode]'
|
||||||
|
);
|
||||||
|
|
||||||
// Build the prompt - use continuation prompt if provided (for recovery after plan approval)
|
// Build the prompt - use continuation prompt if provided (for recovery after plan approval)
|
||||||
let prompt: string;
|
let prompt: string;
|
||||||
// Load project context files (CLAUDE.md, CODE_QUALITY.md, etc.) - passed as system prompt
|
// Load project context files (CLAUDE.md, CODE_QUALITY.md, etc.) - passed as system prompt
|
||||||
const { formattedPrompt: contextFilesPrompt } = await loadContextFiles({
|
// Note: When autoLoadClaudeMd is enabled, skip loading CLAUDE.md here since SDK handles it
|
||||||
projectPath,
|
// to avoid duplication. The SDK's settingSources will load CLAUDE.md from standard locations.
|
||||||
fsModule: secureFs as Parameters<typeof loadContextFiles>[0]['fsModule'],
|
const { formattedPrompt: contextFilesPrompt } = autoLoadClaudeMd
|
||||||
});
|
? { formattedPrompt: '' }
|
||||||
|
: await loadContextFiles({
|
||||||
|
projectPath,
|
||||||
|
fsModule: secureFs as Parameters<typeof loadContextFiles>[0]['fsModule'],
|
||||||
|
});
|
||||||
|
|
||||||
if (options?.continuationPrompt) {
|
if (options?.continuationPrompt) {
|
||||||
// Continuation prompt is used when recovering from a plan approval
|
// Continuation prompt is used when recovering from a plan approval
|
||||||
@@ -612,6 +623,7 @@ export class AutoModeService {
|
|||||||
planningMode: feature.planningMode,
|
planningMode: feature.planningMode,
|
||||||
requirePlanApproval: feature.requirePlanApproval,
|
requirePlanApproval: feature.requirePlanApproval,
|
||||||
systemPrompt: contextFilesPrompt || undefined,
|
systemPrompt: contextFilesPrompt || undefined,
|
||||||
|
autoLoadClaudeMd,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -754,11 +766,22 @@ export class AutoModeService {
|
|||||||
// No previous context
|
// No previous context
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load project context files (CLAUDE.md, CODE_QUALITY.md, etc.) - passed as system prompt
|
// Load autoLoadClaudeMd setting to determine context loading strategy
|
||||||
const { formattedPrompt: contextFilesPrompt } = await loadContextFiles({
|
const autoLoadClaudeMd = await getAutoLoadClaudeMdSetting(
|
||||||
projectPath,
|
projectPath,
|
||||||
fsModule: secureFs as Parameters<typeof loadContextFiles>[0]['fsModule'],
|
this.settingsService,
|
||||||
});
|
'[AutoMode]'
|
||||||
|
);
|
||||||
|
|
||||||
|
// Load project context files (CLAUDE.md, CODE_QUALITY.md, etc.) - passed as system prompt
|
||||||
|
// 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,
|
||||||
|
fsModule: secureFs as Parameters<typeof loadContextFiles>[0]['fsModule'],
|
||||||
|
});
|
||||||
|
|
||||||
// Build complete prompt with feature info, previous context, and follow-up instructions
|
// Build complete prompt with feature info, previous context, and follow-up instructions
|
||||||
let fullPrompt = `## Follow-up on Feature Implementation
|
let fullPrompt = `## Follow-up on Feature Implementation
|
||||||
@@ -887,6 +910,7 @@ Address the follow-up instructions above. Review the previous work and make the
|
|||||||
planningMode: 'skip', // Follow-ups don't require approval
|
planningMode: 'skip', // Follow-ups don't require approval
|
||||||
previousContent: previousContext || undefined,
|
previousContent: previousContext || undefined,
|
||||||
systemPrompt: contextFilesPrompt || undefined,
|
systemPrompt: contextFilesPrompt || undefined,
|
||||||
|
autoLoadClaudeMd,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -1729,6 +1753,7 @@ This helps parse your summary correctly in the output logs.`;
|
|||||||
requirePlanApproval?: boolean;
|
requirePlanApproval?: boolean;
|
||||||
previousContent?: string;
|
previousContent?: string;
|
||||||
systemPrompt?: string;
|
systemPrompt?: string;
|
||||||
|
autoLoadClaudeMd?: boolean;
|
||||||
}
|
}
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const finalProjectPath = options?.projectPath || projectPath;
|
const finalProjectPath = options?.projectPath || projectPath;
|
||||||
@@ -1802,11 +1827,11 @@ This mock response was generated because AUTOMAKER_MOCK_AGENT=true was set.
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load autoLoadClaudeMd setting (project setting takes precedence over global)
|
// Load autoLoadClaudeMd setting (project setting takes precedence over global)
|
||||||
const autoLoadClaudeMd = await getAutoLoadClaudeMdSetting(
|
// Use provided value if available, otherwise load from settings
|
||||||
finalProjectPath,
|
const autoLoadClaudeMd =
|
||||||
this.settingsService,
|
options?.autoLoadClaudeMd !== undefined
|
||||||
'[AutoMode]'
|
? options.autoLoadClaudeMd
|
||||||
);
|
: await getAutoLoadClaudeMdSetting(finalProjectPath, this.settingsService, '[AutoMode]');
|
||||||
|
|
||||||
// Build SDK options using centralized configuration for feature implementation
|
// Build SDK options using centralized configuration for feature implementation
|
||||||
const sdkOptions = createAutoModeOptions({
|
const sdkOptions = createAutoModeOptions({
|
||||||
|
|||||||
Reference in New Issue
Block a user