|
| 1 | +name: Model PR Adjustments |
| 2 | + |
| 3 | +on: |
| 4 | + issue_comment: |
| 5 | + types: [created] |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: write |
| 9 | + pull-requests: write |
| 10 | + issues: read |
| 11 | + |
| 12 | +env: |
| 13 | + ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} |
| 14 | + |
| 15 | +jobs: |
| 16 | + adjust: |
| 17 | + if: | |
| 18 | + github.event.issue.pull_request && |
| 19 | + contains(github.event.issue.labels.*.name, 'models') && |
| 20 | + startsWith(github.event.comment.body, '/models ') |
| 21 | + runs-on: depot-ubuntu-24.04-16 |
| 22 | + timeout-minutes: 10 |
| 23 | + steps: |
| 24 | + - name: Get PR branch |
| 25 | + id: pr |
| 26 | + run: | |
| 27 | + PR_DATA=$(gh api repos/${{ github.repository }}/pulls/${{ github.event.issue.number }}) |
| 28 | + echo "ref=$(echo "$PR_DATA" | jq -r '.head.ref')" >> "$GITHUB_OUTPUT" |
| 29 | + echo "sha=$(echo "$PR_DATA" | jq -r '.head.sha')" >> "$GITHUB_OUTPUT" |
| 30 | + env: |
| 31 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 32 | + |
| 33 | + - uses: actions/checkout@v4 |
| 34 | + with: |
| 35 | + ref: ${{ steps.pr.outputs.ref }} |
| 36 | + fetch-depth: 0 |
| 37 | + |
| 38 | + - name: Install Claude Code |
| 39 | + run: npm install -g @anthropic-ai/claude-code |
| 40 | + |
| 41 | + - name: Parse instruction |
| 42 | + id: instruction |
| 43 | + run: | |
| 44 | + COMMENT=$(cat <<'COMMENT_EOF' |
| 45 | + ${{ github.event.comment.body }} |
| 46 | + COMMENT_EOF |
| 47 | + ) |
| 48 | + # Strip the /models prefix |
| 49 | + INSTRUCTION="${COMMENT#/models }" |
| 50 | + echo "instruction<<EOF" >> "$GITHUB_OUTPUT" |
| 51 | + echo "$INSTRUCTION" >> "$GITHUB_OUTPUT" |
| 52 | + echo "EOF" >> "$GITHUB_OUTPUT" |
| 53 | +
|
| 54 | + - name: React to comment |
| 55 | + run: | |
| 56 | + gh api repos/${{ github.repository }}/issues/comments/${{ github.event.comment.id }}/reactions \ |
| 57 | + -f content=eyes |
| 58 | + env: |
| 59 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 60 | + |
| 61 | + - name: Apply adjustment |
| 62 | + id: adjust |
| 63 | + run: | |
| 64 | + PROMPT="$(cat <<'PROMPT_EOF' |
| 65 | + You are making a targeted adjustment to AI model configuration files for the Botpress cognitive service. |
| 66 | +
|
| 67 | + ## Context |
| 68 | +
|
| 69 | + Provider config files live in: packages/cognitive/src/features/providers/{provider}/{provider}.config.ts |
| 70 | + The schema is in: packages/cognitive/src/features/model-selection/schemas.models.ts |
| 71 | +
|
| 72 | + Providers: openai, anthropic, google-ai, groq, cerebras, xai, openrouter, fireworks-ai |
| 73 | +
|
| 74 | + ## Rules |
| 75 | +
|
| 76 | + - ONLY modify files matching packages/cognitive/src/features/providers/*/*.config.ts |
| 77 | + - Follow the exact existing TypeScript patterns (numeric separators, field order, etc.) |
| 78 | + - Do NOT remove the mock provider config |
| 79 | + - When removing a model, actually remove it from the array — do not just mark it deprecated (unless the instruction says to deprecate it) |
| 80 | + - When updating pricing, only change the cost fields |
| 81 | + - When adding a model, place it in the correct position (newest first) and include ALL required fields |
| 82 | +
|
| 83 | + ## Instruction from reviewer |
| 84 | +
|
| 85 | + INSTRUCTION_PLACEHOLDER |
| 86 | +
|
| 87 | + ## Output |
| 88 | +
|
| 89 | + After applying changes, write a SHORT summary (2-3 lines) of what you changed to /tmp/adjustment-summary.txt |
| 90 | + PROMPT_EOF |
| 91 | + )" |
| 92 | +
|
| 93 | + PROMPT="${PROMPT//INSTRUCTION_PLACEHOLDER/${{ steps.instruction.outputs.instruction }}}" |
| 94 | +
|
| 95 | + claude --print \ |
| 96 | + --model claude-sonnet-4-6 \ |
| 97 | + --max-turns 15 \ |
| 98 | + --allowedTools "Read,Edit,Glob,Grep" \ |
| 99 | + "$PROMPT" | tee /tmp/claude-output.txt |
| 100 | +
|
| 101 | + if git diff --quiet; then |
| 102 | + echo "has_changes=false" >> "$GITHUB_OUTPUT" |
| 103 | + else |
| 104 | + echo "has_changes=true" >> "$GITHUB_OUTPUT" |
| 105 | + fi |
| 106 | +
|
| 107 | + - name: Commit and push |
| 108 | + if: steps.adjust.outputs.has_changes == 'true' |
| 109 | + run: | |
| 110 | + git config user.name "github-actions[bot]" |
| 111 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 112 | + git add packages/cognitive/src/features/providers/ |
| 113 | + SUMMARY="apply model adjustment" |
| 114 | + if [ -f /tmp/adjustment-summary.txt ]; then |
| 115 | + SUMMARY=$(head -1 /tmp/adjustment-summary.txt) |
| 116 | + fi |
| 117 | + git commit -m "chore(cognitive): $SUMMARY" |
| 118 | + git push |
| 119 | +
|
| 120 | + - name: Reply to comment |
| 121 | + if: always() |
| 122 | + run: | |
| 123 | + if [ "${{ steps.adjust.outputs.has_changes }}" = "true" ]; then |
| 124 | + BODY="Applied the adjustment and pushed a new commit." |
| 125 | + if [ -f /tmp/adjustment-summary.txt ]; then |
| 126 | + SUMMARY=$(cat /tmp/adjustment-summary.txt) |
| 127 | + BODY="$BODY"$'\n\n'"**Changes:**"$'\n'"$SUMMARY" |
| 128 | + fi |
| 129 | + else |
| 130 | + BODY="No changes were needed for this instruction. The config files already match, or the instruction could not be applied." |
| 131 | + if [ -f /tmp/claude-output.txt ]; then |
| 132 | + # Include last 10 lines of Claude output for context |
| 133 | + TAIL=$(tail -10 /tmp/claude-output.txt) |
| 134 | + BODY="$BODY"$'\n\n'"<details><summary>Claude output</summary>"$'\n\n'"\`\`\`"$'\n'"$TAIL"$'\n'"\`\`\`"$'\n'"</details>" |
| 135 | + fi |
| 136 | + fi |
| 137 | + gh api repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments \ |
| 138 | + -f body="$BODY" |
| 139 | + env: |
| 140 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 141 | + |
| 142 | + - name: React success/failure |
| 143 | + if: always() |
| 144 | + run: | |
| 145 | + if [ "${{ steps.adjust.outputs.has_changes }}" = "true" ]; then |
| 146 | + REACTION="rocket" |
| 147 | + else |
| 148 | + REACTION="confused" |
| 149 | + fi |
| 150 | + gh api repos/${{ github.repository }}/issues/comments/${{ github.event.comment.id }}/reactions \ |
| 151 | + -f content="$REACTION" |
| 152 | + env: |
| 153 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments