Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 17 additions & 34 deletions .flue/workflows/issue-triage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,10 @@ const fixResultSchema = v.object({
});

const labelResultSchema = v.object({
priority: v.pipe(
v.nullable(v.string()),
v.description(
'Exactly one priority label name (e.g. "P4: important"), or null if unable to determine priority',
),
),
packages: v.pipe(
labels: v.pipe(
v.array(v.string()),
v.description(
'One or more package label names (e.g. ["pkg: astro", "pkg: react"]). Empty array if unable to determine package.',
'The labels to apply to the issue (e.g. ["- P1: chore", "pkg: react"]). Array must contain one "priority" label.',
),
),
});
Expand Down Expand Up @@ -143,7 +137,7 @@ Return only "yes" or "no" inside the ---RESULT_START--- / ---RESULT_END--- block

await flue.shell(`gh issue comment ${issueNumber} --body-file -`, {
stdin: comment,
env: { GH_TOKEN: flue.secrets.GITHUB_TOKEN },
env: { GH_TOKEN: flue.secrets.FREDKBOT_GITHUB_TOKEN },
});

if (reproduceResult.reproducible) {
Expand All @@ -163,34 +157,31 @@ Return only "yes" or "no" inside the ---RESULT_START--- / ---RESULT_END--- block
.map((line) => JSON.parse(line) as { name: string; description: string });

// Filter to priority labels (P followed by a digit) and package labels (pkg: prefix)
const priorityLabels = allLabels.filter((l) => /^P\d/.test(l.name));
const priorityLabels = allLabels.filter((l) => /^- P\d/.test(l.name));
const packageLabels = allLabels.filter((l) => l.name.startsWith('pkg:'));
const candidateLabels = [...priorityLabels, ...packageLabels];

const labelResult = await flue.prompt(
`Label the following GitHub issue based on our Triage Report which summarizes what we learned in our attempt to reproduce, diagnose, and fix the issue.

Select the most appropriate labels from the list below. Use the label descriptions to guide your decision, combined with the triage report's cause and impact analysis.

### Rules
- Select exactly ONE priority label based on the severity and impact of the bug. Pay close attention to the "Cause" and "Impact" sections of the triage report.
- You must select ONE priorty label! If you are not sure, just use your best judgement based on the label descriptions and the findings of the triage report.
- Select exactly ONE priority label based on the label description and the severity and impact of the bug. Pay close attention to the "Cause" and "Impact" sections of the triage report.
- You must select ONE priority label! If you are not sure, just use your best judgement based on the label descriptions and the findings of the triage report.
- Select 0-3 package labels based on where where the issue lives (or most likely lives) in the monorepo. The triage report's diagnosis should make it clear. If you cannot confidently determine the affected package(s), return an empty array for packages.
- Return the exact label names as they appear above — do not modify them.

### Priority Labels (select exactly one)
${priorityLabels.map((l) => `- **${l.name}**: ${l.description || '(no description)'}`).join('\n')}
${priorityLabels.map((l) => `- "${l.name}": ${l.description || '(no description)'}`).join('\n')}

### Package Labels (select zero or more)
${packageLabels.map((l) => `- **${l.name}**: ${l.description || '(no description)'}`).join('\n')}
${packageLabels.map((l) => `- "${l.name}": ${l.description || '(no description)'}`).join('\n')}

---

<issue format="md">
# ${issue.title}

${issue.body}
</issue>
<github-issue format="json">
${issueJson}
</github-issue>

<triage-report format="md">
${comment}
Expand All @@ -199,13 +190,10 @@ ${comment}
{ result: labelResultSchema },
);

const labelsToAdd = [
...(labelResult.priority ? [labelResult.priority] : []),
...labelResult.packages,
].filter((name) => candidateLabels.some((l) => l.name === name));

if (labelsToAdd.length > 0) {
const labelFlags = labelsToAdd.map((l) => `--add-label ${JSON.stringify(l)}`).join(' ');
if (labelResult.labels.length > 0) {
const labelFlags = labelResult.labels
.map((l) => `--add-label ${JSON.stringify(l)}`)
.join(' ');
await flue.shell(`gh issue edit ${issueNumber} ${labelFlags}`, {
env: { GH_TOKEN: flue.secrets.GITHUB_TOKEN },
});
Expand All @@ -218,13 +206,8 @@ ${comment}
env: { GH_TOKEN: flue.secrets.GITHUB_TOKEN },
});
} else {
// Not reproducible: add "needs repro" and remove "needs triage".
// We handle both labels here (instead of just adding "needs repro") to avoid
// the issue-labeled.yml workflow posting a duplicate auto-comment.
await flue.shell(
`gh issue edit ${issueNumber} --add-label "needs repro" --remove-label "needs triage"`,
{ env: { GH_TOKEN: flue.secrets.GITHUB_TOKEN } },
);
// Not reproducible: do nothing. The "needs triage" label stays on the issue
// so that it can continue to be worked on and triaged by the humans.
}
return { reproduceResult, diagnoseResult, fixResult, isPushed };
}
1 change: 1 addition & 0 deletions .github/workflows/issue-triage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ jobs:
- name: Run workflow
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FREDKBOT_GITHUB_TOKEN: ${{ secrets.FREDKBOT_GITHUB_TOKEN }}
ANTHROPIC_API_KEY: ${{ secrets.CI_ANTHROPIC_API_KEY }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
run: |
Expand Down
Loading