mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-03 08:53:36 +00:00
fix: Address PR feedback for structured output fallback
- Throw error immediately when JSON extraction fails in generate-features-from-spec.ts to avoid redundant parsing attempt (feedback from Gemini Code Assist review) - Emit spec_regeneration_error event before throwing for consistency - Fix TypeScript cast in sync-spec.ts by using double cast through unknown 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -286,9 +286,20 @@ Your entire response should be valid JSON starting with { and ending with }. No
|
|||||||
contentForParsing = JSON.stringify(extracted);
|
contentForParsing = JSON.stringify(extracted);
|
||||||
logger.info('✅ Pre-extracted JSON from text response');
|
logger.info('✅ Pre-extracted JSON from text response');
|
||||||
} else {
|
} else {
|
||||||
// Fall back to raw text (let parseAndCreateFeatures try its extraction)
|
// If pre-extraction fails, we know the next step will also fail.
|
||||||
contentForParsing = rawText;
|
// Throw an error here to avoid redundant parsing and make the failure point clearer.
|
||||||
logger.warn('⚠️ Could not pre-extract JSON, passing raw text to parser');
|
logger.error(
|
||||||
|
'❌ Could not extract features JSON from model response. Full response text was:\n' +
|
||||||
|
rawText
|
||||||
|
);
|
||||||
|
const errorMessage =
|
||||||
|
'Failed to parse features from model response: No valid JSON with a "features" array found.';
|
||||||
|
events.emit('spec-regeneration:event', {
|
||||||
|
type: 'spec_regeneration_error',
|
||||||
|
error: errorMessage,
|
||||||
|
projectPath: projectPath,
|
||||||
|
});
|
||||||
|
throw new Error(errorMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -261,7 +261,7 @@ CRITICAL INSTRUCTIONS:
|
|||||||
|
|
||||||
if (techResult.structured_output) {
|
if (techResult.structured_output) {
|
||||||
// Use structured output from Claude/Codex models
|
// Use structured output from Claude/Codex models
|
||||||
const structured = techResult.structured_output as TechStackExtractionResult;
|
const structured = techResult.structured_output as unknown as TechStackExtractionResult;
|
||||||
if (Array.isArray(structured.technologies)) {
|
if (Array.isArray(structured.technologies)) {
|
||||||
parsedTechnologies = structured.technologies;
|
parsedTechnologies = structured.technologies;
|
||||||
logger.info('✅ Received structured output for tech analysis');
|
logger.info('✅ Received structured output for tech analysis');
|
||||||
|
|||||||
Reference in New Issue
Block a user