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