| 1 | name: Agent task labels |
| 2 | |
| 3 | on: |
| 4 | issues: |
| 5 | types: [opened] |
| 6 | |
| 7 | permissions: |
| 8 | issues: write |
| 9 | contents: read |
| 10 | |
| 11 | jobs: |
| 12 | labels: |
| 13 | runs-on: ubuntu-latest |
| 14 | steps: |
| 15 | - name: Add area hints to agent tasks |
| 16 | uses: actions/github-script@v9 |
| 17 | with: |
| 18 | script: | |
| 19 | const issue = context.payload.issue; |
| 20 | if (!issue) return; |
| 21 | |
| 22 | const labels = new Set((issue.labels || []).map(label => label.name)); |
| 23 | if (!labels.has('agent-ready')) { |
| 24 | core.info(`#${issue.number} is not an agent task; leaving it unchanged.`); |
| 25 | return; |
| 26 | } |
| 27 | |
| 28 | // Milestones are the canonical release roadmap and are assigned |
| 29 | // explicitly during triage. Never infer one from a title or label: |
| 30 | // old version labels must remain harmless historical metadata. |
| 31 | const title = (issue.title || '').toLowerCase(); |
| 32 | const body = (issue.body || '').toLowerCase(); |
| 33 | const text = `${title}\n${body}`; |
| 34 | |
| 35 | if (/\bworkflow\b|whaleflow|workflow-runtime/.test(text)) labels.add('workflow-runtime'); |
| 36 | // `tui` means "touches the terminal UI layer", not "mentions the TUI |
| 37 | // in passing". A bare \btui\b over-fired on every issue that merely |
| 38 | // referenced the UI — the v0.9.2 localization issues all describe TUI |
| 39 | // locale packs in prose and were labelled on that alone. |
| 40 | // |
| 41 | // Anchor on signals that survive the single-binary refactor (#4747): |
| 42 | // the crate path and the rendering framework stay put when |
| 43 | // codewhale-tui is lib-ized, whereas the `codewhale-tui` *binary* |
| 44 | // name goes away. Do not reintroduce a bare word match here. |
| 45 | if (/crates\/tui\b|ratatui|\bcodewhale-tui\b/.test(text)) labels.add('tui'); |
| 46 | if (/fleet|subagent|sub-agent/.test(text)) labels.add('subagents'); |
| 47 | if (/catalog|openrouter|model.?picker|provider.?lake/.test(text)) labels.add('reliability'); |
| 48 | |
| 49 | const existing = await github.paginate(github.rest.issues.listLabelsForRepo, { |
| 50 | owner: context.repo.owner, |
| 51 | repo: context.repo.repo, |
| 52 | per_page: 100, |
| 53 | }); |
| 54 | const existingNames = new Set(existing.map(label => label.name)); |
| 55 | const currentNames = new Set((issue.labels || []).map(label => label.name)); |
| 56 | const toAdd = [...labels].filter( |
| 57 | name => existingNames.has(name) && !currentNames.has(name) |
| 58 | ); |
| 59 | if (toAdd.length === 0) return; |
| 60 | |
| 61 | await github.rest.issues.addLabels({ |
| 62 | owner: context.repo.owner, |
| 63 | repo: context.repo.repo, |
| 64 | issue_number: issue.number, |
| 65 | labels: toAdd, |
| 66 | }); |
| 67 |