Tiedostot kulkevat agentilta toiselle: korjaukset päivittyvät, QA saa korjatun koodin
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) <noreply@anthropic.com>
This commit is contained in:
@@ -801,34 +801,50 @@ OUTPUT FORMAT:
|
|||||||
const review = await kpnRun(tst.model, tstPrompt);
|
const review = await kpnRun(tst.model, tstPrompt);
|
||||||
stepN++;
|
stepN++;
|
||||||
|
|
||||||
// Korjausluuppi (jos tarpeen)
|
// Korjausluuppi (jos tarpeen) — korjatut tiedostot päivitetään files-objektiin
|
||||||
if (review && !review.toLowerCase().includes('lgtm')) {
|
if (review && !review.toLowerCase().includes('lgtm')) {
|
||||||
termLog(`\n<span style="color:#d29922;font-weight:bold">[${stepN}] ${esc(cdr.name)}</span> — korjaukset`);
|
termLog(`\n<span style="color:#d29922;font-weight:bold">[${stepN}] ${esc(cdr.name)}</span> — korjaukset`);
|
||||||
highlightAgent('coder');
|
highlightAgent('coder');
|
||||||
explainStep('Korjausluuppi', `${tst.name} löysi ongelmia. ${cdr.name} saa palautteen ja korjaa koodin.`);
|
explainStep('Korjausluuppi', `${tst.name} löysi ongelmia. ${cdr.name} korjaa ja palauttaa päivitetyt tiedostot.`);
|
||||||
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.`);
|
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++;
|
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];
|
const qaAgent = agents.qa || Object.values(agents)[3];
|
||||||
if (qaAgent) {
|
if (qaAgent) {
|
||||||
termLog(`\n<span style="color:#d2a8ff;font-weight:bold">[${stepN}] ${esc(qaAgent.name)}</span> — testit`);
|
termLog(`\n<span style="color:#d2a8ff;font-weight:bold">[${stepN}] ${esc(qaAgent.name)}</span> — testit`);
|
||||||
highlightAgent('qa');
|
highlightAgent('qa');
|
||||||
explainStep('Testit', `${qaAgent.name} kirjoittaa pytest-testit kaikille endpointeille.`);
|
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${allCode}\n\nWrite a complete test_main.py file with TestClient.`;
|
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);
|
const tests = await kpnRun(qaAgent.model, qaPrompt);
|
||||||
if (tests) files['test_main.py'] = tests;
|
if (tests) files['test_main.py'] = tests;
|
||||||
stepN++;
|
stepN++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// DevOps: Dockerfile
|
// DevOps: Dockerfile (saa kaikki tiedostot mukaan lukien testit)
|
||||||
|
const allFilesNow = Object.keys(files).join(', ');
|
||||||
termLog(`\n<span style="color:var(--accent);font-weight:bold">[${stepN}] ${esc(tst.name)}</span> — Dockerfile`);
|
termLog(`\n<span style="color:var(--accent);font-weight:bold">[${stepN}] ${esc(tst.name)}</span> — Dockerfile`);
|
||||||
highlightAgent('tester');
|
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' : '') +
|
const dockerPrompt = (tst.prompt ? tst.prompt+'\n\n' : '') +
|
||||||
`Write a Dockerfile for this Python FastAPI project.\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` +
|
`Requirements:\n` +
|
||||||
`- Use python:3.12-slim as base\n` +
|
`- Use python:3.12-slim as base\n` +
|
||||||
`- Install uv: COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv\n` +
|
`- Install uv: COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv\n` +
|
||||||
|
|||||||
Reference in New Issue
Block a user