diff --git a/.github/workflows/ticket-refinement.yml b/.github/workflows/ticket-refinement.yml index ec95497..7f7088d 100644 --- a/.github/workflows/ticket-refinement.yml +++ b/.github/workflows/ticket-refinement.yml @@ -14,7 +14,7 @@ jobs: git checkout ${{ github.event.repository.default_branch }} - name: Run AI Formatter - run: npx -y @ztimson/ai-agents@latest format .github/issue_templates/ai-refinement.md + run: npx -y @ztimson/ai-agents@latest format .github/issue_template/ai-refinement.md env: AI_HOST: anthropic AI_MODEL: claude-sonnet-4-5 diff --git a/src/refine.mjs b/src/refine.mjs index 83b1a1b..96fafbd 100644 --- a/src/refine.mjs +++ b/src/refine.mjs @@ -11,7 +11,7 @@ dotenv.config({path: '.env.local', override: true, quiet: true}); (async () => { let p = process.argv[process.argv.length - 1]; - if(p === 'review' || p.endsWith('review.mjs')) p = null; + if(p === 'refine' || p.endsWith('refine.mjs')) p = null; if(!/(\/|[A-Z]:)/.test(p)) p = path.join(process.cwd(), p); if(!p || !fs.existsSync(p)) throw new Error('Please provide a template'); @@ -81,10 +81,14 @@ ${template.trim()} \`\`\` Output ONLY the formatted ticket, no explanation.` - }); + }) - const messages = await ai.language.ask(`Title: ${issueData.title}\n\nDescription:\n${issueData.body || 'No description provided'}`); - const content = messages.pop().content; + const messages = await ai.language.ask(`Title: ${issueData.title}\n\nDescription:\n${issueData.body || 'No description provided'}`).catch(() => []);; + const content = messages?.pop()?.content; + if(!content) { + console.log('Invalid response from AI'); + return process.exit(1); + } const title = /^# (.+)$/m.exec(content)?.[1] || issueData.title; const typeMatch = /^## Type:\s*(.+)$/m.exec(content); const type = typeMatch?.[1]?.split('/')[0]?.trim() || 'Unassigned'; @@ -98,7 +102,7 @@ Output ONLY the formatted ticket, no explanation.` body: JSON.stringify({ title, body, - labels: [`Type/${type[0].toUpperCase() + type.slice(1).toLowerCase()}`] + labels: type?.length ? [`Kind/${type[0].toUpperCase() + type.slice(1).toLowerCase()}`] : [] }) }); if(!updateRes.ok) throw new Error(`${updateRes.status} ${await updateRes.text()}`); diff --git a/src/review.mjs b/src/review.mjs index 502a94f..b05b2ae 100644 --- a/src/review.mjs +++ b/src/review.mjs @@ -37,7 +37,7 @@ dotenv.config({path: '.env.local', override: true, quiet: true, debug: false}); ...options, model: [host, model], path: process.env['path'] || os.tmpdir(), - system: `You are a code reviewer. Analyze the git diff and use the \`recommend\` tool for EACH issue you find. You must call \`recommend\` exactly once for every bug or improvement opportunity directly related to changes. Ignore formatting recommendations. After making all recommendations, provide one brief bullet-point summary.`, + system: `You are a code reviewer. Analyze the git diff and use the \`recommend\` tool for EACH issue you find. You must call \`recommend\` exactly once for every bug or improvement opportunity directly related to changes. Ignore formatting recommendations. After making all recommendations, provide some concluding remarks about the overall state of the changes.`, tools: [{ name: 'read_file', description: 'Read contents of a file',