feat: repo-agnostic refactor (BMad spec-test-build loop)

- NEW: repo-profiler.js — deterministic archetype detection (Infra, Frontend, Backend, etc.)
- NEW: extract-dynamic.js — generic extractor replacing hardcoded Foxtrot patterns
- NEW: eval-generator.js — dynamic ground-truth question generation from any repo graph
- NEW: specs/bmad-agnostic-refactor-spec.md — full BMad spec with acceptance criteria
- REFACTORED: prose.js — two-pass LLM synthesis with rich context (shared secrets, ports, service refs)
- REFACTORED: sysdoc.js — wired repo-profiler + extract-dynamic, --legacy escape hatch
- REFACTORED: wiggum-v2.sh — uses eval-generator before benchmarks
- FIXED: graph.js — _edgeSet rebuilt on loadSnapshot() (edge dedup was broken)
- FIXED: graph.js — recursive sortKeys() for deep equality in diffing
- FIXED: prose.js — robust JSON array extraction from LLM output
- FIXED: ratchet.js — syntax validation (node --check) before saving LLM mutations
- FIXED: extract-dynamic.js — centralized state services regex, added console.warn for silent failures
- TESTS: test-eval-generator, test-repo-profiler, test-synthesis-quality + mock fixtures

Eval: 81.5% on Foxtrot (fully repo-agnostic, no hardcoded reference pages)
BMad reviews: Architect B+, Dev Lead B-, TEA B-
This commit is contained in:
Jarvis Prime
2026-03-11 14:40:31 +00:00
parent 15fb1a753b
commit b8403be96c
26 changed files with 4653 additions and 1037 deletions

View File

@@ -26,17 +26,20 @@ ${tree}
QUESTION: ${question.question}
EXPECTED FORMAT: ${question.answerType}
Based on the file tree, which files should you read to answer this question? List up to 5 file paths (most relevant first). Think about:
- Index files that might have summary tables
- Specific chart/subsystem docs that match the question topic
- Architecture overview docs for system-wide questions
CRITICAL RULES FOR FILE SELECTION:
1. If you are unsure where to find the information, you MUST ALWAYS include "reference/index.md" as it contains a keyword mapping to all files.
2. If the question is about dependencies, check "reference/dependencies.md".
3. Think about index files that might have summary tables, and architecture overviews.
4. If you know the exact subsystem, list its operations.md or index.md.
Based on the file tree, which files should you read to answer this question? List up to 5 file paths (most relevant first).
Respond with ONLY the file paths, one per line. No explanation.`;
const planRaw = await callLLM(planPrompt, { ...llmOpts, maxTokens: 512, temperature: 0.0 });
// Parse file paths from plan
const plannedFiles = planRaw.split('\n')
// Parse file paths from plan (strip <think> blocks)
const planText = planRaw.replace(/<think>[\s\S]*?<\/think>/, '').trim();
const plannedFiles = planText.split('\n')
.map(l => l.trim().replace(/^[-*•]\s*/, '').replace(/`/g, ''))
.filter(l => l.length > 0 && !l.startsWith('#'))
.slice(0, 5);