Repository navigation
Expand file tree
/
Copy pathgithub-action.yml
More file actions
78 lines (69 loc) · 2.69 KB
/
Copy pathgithub-action.yml
File metadata and controls
78 lines (69 loc) · 2.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: Facet tool surface on PR
# Drop this into .github/workflows/facet-surface.yml
# On each PR, routes MCP tools for the PR's task and posts the planned surface
# as a comment — gives your code-review bot the right tool subset automatically.
on:
pull_request:
types: [opened, synchronize]
jobs:
facet-surface:
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: read
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: Get PR task description
id: pr
env:
PR_TITLE: ${{ github.event.pull_request.title }}
PR_BODY: ${{ github.event.pull_request.body }}
run: |
TASK="${PR_TITLE}: ${PR_BODY}"
echo "task=${TASK}" >> $GITHUB_OUTPUT
- name: Route tool surface for PR task
id: surface
run: |
# Run facet plan with your manifest file (update path as needed)
RESULT=$(npx -y @kioie/facet plan "${{ steps.pr.outputs.task }}" \
--manifest ./tools.json \
--budget 6000 \
--json)
echo "result<<EOF" >> $GITHUB_OUTPUT
echo "$RESULT" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Post tool surface as PR comment
uses: actions/github-script@v7
with:
script: |
const result = JSON.parse(`${{ steps.surface.outputs.result }}`);
const selected = result.selected
.map(t => `- \`${t.name}\``)
.join('\n');
const deferred = result.deferred
.slice(0, 8)
.map(t => `\`${t.name}\``)
.join(', ');
const savings = result.savingsPercent.toFixed(0);
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: [
'## Facet tool surface',
'',
`**Task:** ${result.task}`,
`**Tokens:** ${result.tokensAfter.toLocaleString()} / ${result.tokensBefore.toLocaleString()} (${savings}% saved)`,
`**Selected:** ${result.selected.length} tools · **Deferred:** ${result.deferred.length} tools`,
'',
'### Selected tools',
selected,
'',
`**Deferred:** ${deferred}${result.deferred.length > 8 ? ` +${result.deferred.length - 8} more` : ''}`,
'',
'*Generated by [Facet](https://github.com/kioie/facet) — task-aware MCP tool surface routing*'
].join('\n')
});