Files
nofx/decision
ZhouYongyou 5afd417a5d feat(decision): sync robust JSON extraction & limit candidates from z-dev
## Synced from z-dev
### 1. Robust JSON Extraction (from aa63298)
- Add regexp import
- Add removeInvisibleRunes() - removes zero-width chars & BOM
- Add compactArrayOpen() - normalizes '[ {' to '[{'
- Rewrite extractDecisions():
  * Priority 1: Extract from ```json code blocks
  * Priority 2: Regex find array
  * Multi-layer defense: 7 layers total
### 2. Enhanced Validation
- validateJSONFormat now uses regex ^\[\s*\{ (allows any whitespace)
- More tolerant than string prefix check
### 3. Limit Candidate Coins (from f1e981b)
- calculateMaxCandidates now enforces proper limits:
  * 0 positions: max 30 candidates
  * 1 position: max 25 candidates
  * 2 positions: max 20 candidates
  * 3+ positions: max 15 candidates
- Prevents Prompt bloat when users configure many coins
## Coverage
Now handles:
-  Pure JSON
-  ```json code blocks
-  Thinking chain混合
-  Fullwidth characters (16種)
-  CJK characters
-  Zero-width characters
-  All whitespace combinations
Estimated coverage: **99.9%**
Co-Authored-By: tinkle-community <tinklefund@gmail.com>
2025-11-05 00:27:47 +08:00
..