From 7a92545b9c722c79d582451e6fbe5954e3976855 Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Mon, 6 Jul 2026 01:33:38 +0200 Subject: [PATCH] feat(coding-agent): include analysis summary in issue comment --- .github/workflows/issue-analysis.yml | 47 ++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/.github/workflows/issue-analysis.yml b/.github/workflows/issue-analysis.yml index b0f5c407..f62cb356 100644 --- a/.github/workflows/issue-analysis.yml +++ b/.github/workflows/issue-analysis.yml @@ -275,11 +275,51 @@ jobs: GIST_URL: ${{ steps.gist.outputs.url }} GIST_ID: ${{ steps.gist.outputs.id }} SHARE_URL: ${{ steps.gist.outputs.share_url }} + SESSION_JSONL: ${{ runner.temp }}/pi-out/session.jsonl with: script: | + const fs = require('fs'); + + function extractLastAgentMessage(sessionPath) { + const lines = fs.readFileSync(sessionPath, 'utf8').split(/\r?\n/).filter(Boolean); + let lastText = ''; + + for (const line of lines) { + let entry; + try { + entry = JSON.parse(line); + } catch { + continue; + } + + if (entry.type !== 'message' || entry.message?.role !== 'assistant') continue; + + const content = entry.message.content; + const parts = []; + if (typeof content === 'string') { + parts.push(content); + } else if (Array.isArray(content)) { + for (const block of content) { + if (block?.type === 'text' && typeof block.text === 'string') { + parts.push(block.text); + } + } + } + + const text = parts.join('\n\n').trim(); + if (text) lastText = text; + } + + if (!lastText) return '_No assistant output found._'; + const maxLength = 55000; + if (lastText.length <= maxLength) return lastText; + return `${lastText.slice(0, maxLength)}\n\n_[truncated]_`; + } + const gistUrl = process.env.GIST_URL; const gistId = process.env.GIST_ID; const shareUrl = process.env.SHARE_URL; + const lastAgentMessage = extractLastAgentMessage(process.env.SESSION_JSONL); const body = [ 'Pi issue analysis finished.', '', @@ -291,6 +331,13 @@ jobs: '```sh', `pi "/ir ${gistId}"`, '```', + '', + '
', + 'Agent analysis summary', + '', + lastAgentMessage, + '', + '
', ].join('\n'); await github.rest.issues.createComment({