Files
nofx/decision
ZhouYongyou 1ca4b80add feat(decision): add validateJSONFormat to catch common AI errors
Adds comprehensive JSON validation before parsing to catch common AI output errors:
1. Format validation: Ensures JSON starts with [{ (decision array)
2. Range symbol detection: Rejects ~ symbols (e.g., "leverage: 3~5")
3. Thousands separator detection: Rejects commas in numbers (e.g., "98,000")
Execution order (critical for fullwidth character fix):
1. Extract JSON from response
2. fixMissingQuotes - normalize fullwidth → halfwidth 
3. validateJSONFormat - check for common errors 
4. Parse JSON
This validation layer provides early error detection and clearer error messages
for debugging AI response issues.
Added helper function:
- min(a, b int) int - returns smaller of two integers
Co-Authored-By: tinkle-community <tinklefund@gmail.com>
2025-11-04 23:04:22 +08:00
..