From cb16f3526545ca48ce1de14fa3ec5624b5ad87c9 Mon Sep 17 00:00:00 2001 From: Jaakko Vanhala Date: Fri, 10 Apr 2026 07:44:01 +0300 Subject: [PATCH] =?UTF-8?q?Tiedostot=20kulkevat=20agentilta=20toiselle:=20?= =?UTF-8?q?korjaukset=20p=C3=A4ivittyv=C3=A4t,=20QA=20saa=20korjatun=20koo?= =?UTF-8?q?din?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Kontekstiketju nyt: 1. Data → models.py 2. Koodari → schemas.py (saa models.py kontekstina) 3. Koodari → main.py (saa models.py + schemas.py) 4. Koodari → pyproject.toml 5. DevOps → review (saa kaikki tiedostot) 6. Koodari → korjaukset → parsitaan takaisin files-objektiin (--- filename ---) 7. QA → testit (saa KORJATUT tiedostot, ei alkuperäisiä) 8. DevOps → Dockerfile (saa kaikki tiedostot + testit) 9. Tarkkailija → README (saa kaiken) Aiemmin: korjaukset menivät terminaaliin mutta eivät päivittyneet files-objektiin. Nyt: korjattu koodi parsitaan --- filename --- -erottimilla takaisin. Co-Authored-By: Claude Opus 4.6 (1M context) --- network-poc/frontend/src/pages/index.astro | 34 ++++++++++++++++------ 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/network-poc/frontend/src/pages/index.astro b/network-poc/frontend/src/pages/index.astro index 050bfa3..50b9cea 100644 --- a/network-poc/frontend/src/pages/index.astro +++ b/network-poc/frontend/src/pages/index.astro @@ -801,34 +801,50 @@ OUTPUT FORMAT: const review = await kpnRun(tst.model, tstPrompt); stepN++; - // Korjausluuppi (jos tarpeen) + // Korjausluuppi (jos tarpeen) — korjatut tiedostot päivitetään files-objektiin if (review && !review.toLowerCase().includes('lgtm')) { termLog(`\n[${stepN}] ${esc(cdr.name)} — korjaukset`); highlightAgent('coder'); - explainStep('Korjausluuppi', `${tst.name} löysi ongelmia. ${cdr.name} saa palautteen ja korjaa koodin.`); - await kpnRun(cdr.model, `${cdr.prompt ? cdr.prompt+'\n\n' : ''}Fix these issues:\n${review}\n\nCurrent code:\n${allCode}\n\nWrite the corrected files.`); + explainStep('Korjausluuppi', `${tst.name} löysi ongelmia. ${cdr.name} korjaa ja palauttaa päivitetyt tiedostot.`); + const fixPrompt = `${cdr.prompt ? cdr.prompt+'\n\n' : ''}Fix these issues:\n${review}\n\nCurrent code:\n${allCode}\n\nWrite ALL corrected files. Start each file with: --- filename.py ---`; + const fixedCode = await kpnRun(cdr.model, fixPrompt); + // Parsitaan korjatut tiedostot takaisin files-objektiin + if (fixedCode) { + const fixedParts = fixedCode.split(/^---\s*(\S+)\s*---$/m); + for (let j = 1; j < fixedParts.length; j += 2) { + const fname = fixedParts[j].trim(); + const fcode = (fixedParts[j+1] || '').trim(); + if (fname && fcode && files[fname] !== undefined) { + files[fname] = fcode; + } + } + } stepN++; } - // QA: testit + // Päivitetään allCode korjausten jälkeen + const updatedCode = Object.entries(files).map(([n,c]) => `--- ${n} ---\n${c}`).join('\n\n'); + + // QA: testit (saa korjatut tiedostot) const qaAgent = agents.qa || Object.values(agents)[3]; if (qaAgent) { termLog(`\n[${stepN}] ${esc(qaAgent.name)} — testit`); highlightAgent('qa'); - explainStep('Testit', `${qaAgent.name} kirjoittaa pytest-testit kaikille endpointeille.`); - const qaPrompt = (qaAgent.prompt ? qaAgent.prompt+'\n\n' : '') + `Write pytest tests for this project:\n\n${allCode}\n\nWrite a complete test_main.py file with TestClient.`; + explainStep('Testit', `${qaAgent.name} kirjoittaa pytest-testit korjatulle koodille.`); + const qaPrompt = (qaAgent.prompt ? qaAgent.prompt+'\n\n' : '') + `Write pytest tests for this project:\n\n${updatedCode}\n\nWrite a complete test_main.py file with TestClient.`; const tests = await kpnRun(qaAgent.model, qaPrompt); if (tests) files['test_main.py'] = tests; stepN++; } - // DevOps: Dockerfile + // DevOps: Dockerfile (saa kaikki tiedostot mukaan lukien testit) + const allFilesNow = Object.keys(files).join(', '); termLog(`\n[${stepN}] ${esc(tst.name)} — Dockerfile`); highlightAgent('tester'); - explainStep('Dockerfile', `${tst.name} generoi Docker-kontin joka pakkaa projektin ajettavaksi.`); + explainStep('Dockerfile', `${tst.name} generoi Docker-kontin kaikista ${Object.keys(files).length} tiedostosta: ${allFilesNow}`); const dockerPrompt = (tst.prompt ? tst.prompt+'\n\n' : '') + `Write a Dockerfile for this Python FastAPI project.\n\n` + - `Project files: ${Object.keys(files).join(', ')}\n\n` + + `Project files: ${allFilesNow}\n\n` + `Requirements:\n` + `- Use python:3.12-slim as base\n` + `- Install uv: COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv\n` +