Gap-Driven Repo Implementation
Use when: project has conceptual gaps, need to find and adapt existing implementations rather than write from scratch.
Workflow
Gap Analysis
- Review available project docs
- Map existing capabilities vs. stated goals
- List missing modules with one-line descriptions
GitHub Search (parallel queries)
- Use curl to GitHub API:
https://api.github.com/search/repositories?q=...&sort=stars&order=desc&per_page=5
- Save JSON to temp files, parse with Python
- Search strategies:
- Exact concept terms:
"hidden semi markov regime python"
- Broader combo:
"hmm regime detection python finance"
- Related methods:
"wasserstein clustering python", "particle filter regime"
- Check repo structure via API
- Download key files via raw.githubusercontent.com
Repo Evaluation Criteria
- Stars (4+ for academic, 10+ for production)
- Has README + working code + ideally paper/PDF
- Code quality: type hints, docstrings, tests
- License compatibility (Apache 2.0 / MIT preferred)
- Can core logic be isolated from framework deps?
Translation to Target Language
- Extract pure algorithmic core
- Strip framework deps, reimplement minimal equivalents
- Map source language patterns to target idioms
- For Rust: use enums/structs properly, avoid dynamic typing
Integration
- Create module directory with types.rs, engine.rs, mod.rs
- Write tests for each public function
- Register in lib.rs
- Document formulas in module docstrings
Test-Driven Fixes
- Run tests after each module
- Fix compilation errors before moving on
- If assertion too strict, relax to essential properties
Pitfalls
- Don't clone large repos — use raw.githubusercontent.com for individual files
- GitHub API may return 0 results with overly specific queries — try broader terms
- Python code often has implicit deps — identify and reimplement from scratch
- Strict mathematical properties may not hold in approximations
Heuristic-Algorithm Adaptation Notes
When the target is an existing solver/bot and the user asks to improve success rate from external links:
Inspect the current local evaluator/search first.
- Identify whether failure is coming from shallow search, weak heuristic weights, bad move ordering, or target-specific runtime issues.
- Do not blindly port an entire upstream project if only the scoring core is weak.
Prefer extracting the decisive core, not the packaging.
- Read raw source or rendered code snippets from linked repos/pages.
- Ignore upstream UI, worker, build, or platform glue unless the target actually needs it.
- For browser userscripts, a pure-JS heuristic/search upgrade is often the fastest reliable landing zone; WASM/worker ports are optional later.
For 2048-style solvers, the highest-value borrowed ideas are usually evaluation terms, not just deeper search.
- snake-path / gradient weighting
- empty-cell reward
- monotonicity
- smoothness
- merge potential
- corner / edge anchoring for the max tile
- memoized search state
- deterministic move ordering (often favoring left/up before right/down)
- bounded chance-node sampling to keep runtime tractable
Integrate surgically.
- Replace or patch only the local solver module.
- Preserve the surrounding API/UI surface unless the references prove the interface itself is the bottleneck.
- After integration, verify that old symbols/call sites still line up.
Example
ict-engine: Found gaps in regime duration, multi-scale resonance, liquidity.
Searched GitHub, found wess_hmm (Wasserstein+HMM) and MSM_python.
Ported to Rust: 12 files, 285 tests passing, 3 new modules.
Output: GAP_REMEDIATION_PLAN.md with formulas and integration plan.
1---2name: gap-driven-repo-implmn3description: Identify project gaps, search GitHub for reference implementations, translate/adapt to target language, integrate with tests4---56# Gap-Driven Repo Implementation78Use when: project has conceptual gaps, need to find and adapt existing implementations rather than write from scratch.910## Workflow11121. **Gap Analysis**13 - Review available project docs14 - Map existing capabilities vs. stated goals15 - List missing modules with one-line descriptions16172. **GitHub Search** (parallel queries)18 - Use curl to GitHub API: `https://api.github.com/search/repositories?q=...&sort=stars&order=desc&per_page=5`19 - Save JSON to temp files, parse with Python20 - Search strategies:21 - Exact concept terms: `"hidden semi markov regime python"`22 - Broader combo: `"hmm regime detection python finance"`23 - Related methods: `"wasserstein clustering python"`, `"particle filter regime"`24 - Check repo structure via API25 - Download key files via raw.githubusercontent.com26273. **Repo Evaluation Criteria**28 - Stars (4+ for academic, 10+ for production)29 - Has README + working code + ideally paper/PDF30 - Code quality: type hints, docstrings, tests31 - License compatibility (Apache 2.0 / MIT preferred)32 - Can core logic be isolated from framework deps?33344. **Translation to Target Language**35 - Extract pure algorithmic core36 - Strip framework deps, reimplement minimal equivalents37 - Map source language patterns to target idioms38 - For Rust: use enums/structs properly, avoid dynamic typing39405. **Integration**41 - Create module directory with types.rs, engine.rs, mod.rs42 - Write tests for each public function43 - Register in lib.rs44 - Document formulas in module docstrings45466. **Test-Driven Fixes**47 - Run tests after each module48 - Fix compilation errors before moving on49 - If assertion too strict, relax to essential properties5051## Pitfalls5253- Don't clone large repos — use raw.githubusercontent.com for individual files54- GitHub API may return 0 results with overly specific queries — try broader terms55- Python code often has implicit deps — identify and reimplement from scratch56- Strict mathematical properties may not hold in approximations5758## Heuristic-Algorithm Adaptation Notes5960When the target is an existing solver/bot and the user asks to improve success rate from external links:61621. Inspect the current local evaluator/search first.63 - Identify whether failure is coming from shallow search, weak heuristic weights, bad move ordering, or target-specific runtime issues.64 - Do not blindly port an entire upstream project if only the scoring core is weak.65662. Prefer extracting the decisive core, not the packaging.67 - Read raw source or rendered code snippets from linked repos/pages.68 - Ignore upstream UI, worker, build, or platform glue unless the target actually needs it.69 - For browser userscripts, a pure-JS heuristic/search upgrade is often the fastest reliable landing zone; WASM/worker ports are optional later.70713. For 2048-style solvers, the highest-value borrowed ideas are usually evaluation terms, not just deeper search.72 - snake-path / gradient weighting73 - empty-cell reward74 - monotonicity75 - smoothness76 - merge potential77 - corner / edge anchoring for the max tile78 - memoized search state79 - deterministic move ordering (often favoring left/up before right/down)80 - bounded chance-node sampling to keep runtime tractable81824. Integrate surgically.83 - Replace or patch only the local solver module.84 - Preserve the surrounding API/UI surface unless the references prove the interface itself is the bottleneck.85 - After integration, verify that old symbols/call sites still line up.8687## Example8889ict-engine: Found gaps in regime duration, multi-scale resonance, liquidity.90Searched GitHub, found wess_hmm (Wasserstein+HMM) and MSM_python.91Ported to Rust: 12 files, 285 tests passing, 3 new modules.92Output: GAP_REMEDIATION_PLAN.md with formulas and integration plan.