Skip to content

Commit 27c4d2d

Browse files
committed
fix(ci): align Claude Assistant with PraisonAIUI; use GH_TOKEN for chained @claude/@copilot comments
Made-with: Cursor
1 parent 3c698b4 commit 27c4d2d

File tree

3 files changed

+72
-54
lines changed

3 files changed

+72
-54
lines changed

.github/workflows/auto-pr-comment.yml

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,19 @@ jobs:
2121
- name: Post Copilot review request
2222
uses: actions/github-script@v7
2323
with:
24-
github-token: ${{ secrets.GITHUB_TOKEN }}
24+
github-token: ${{ secrets.GH_TOKEN }}
2525
script: |
2626
const comments = await github.rest.issues.listComments({
2727
issue_number: context.issue.number,
2828
owner: context.repo.owner,
29-
repo: context.repo.repo
29+
repo: context.repo.repo,
30+
per_page: 100
3031
});
31-
if (comments.data.some(c => c.user.login === 'github-actions[bot]' && c.body.includes('@copilot'))) {
32+
if (comments.data.some(c => c.body && c.body.includes('@copilot') && c.body.includes('thorough review'))) {
3233
console.log('Copilot already triggered, skipping');
3334
return;
3435
}
35-
github.rest.issues.createComment({
36+
await github.rest.issues.createComment({
3637
issue_number: context.issue.number,
3738
owner: context.repo.owner,
3839
repo: context.repo.repo,
@@ -50,19 +51,21 @@ jobs:
5051
- name: Post Copilot review request (fallback)
5152
uses: actions/github-script@v7
5253
with:
53-
github-token: ${{ secrets.GITHUB_TOKEN }}
54+
github-token: ${{ secrets.GH_TOKEN }}
5455
script: |
56+
const issue_number = context.payload.pull_request?.number ?? context.issue?.number;
5557
const comments = await github.rest.issues.listComments({
56-
issue_number: context.issue.number,
58+
issue_number,
5759
owner: context.repo.owner,
58-
repo: context.repo.repo
60+
repo: context.repo.repo,
61+
per_page: 100
5962
});
60-
if (comments.data.some(c => c.user.login === 'github-actions[bot]' && c.body.includes('@copilot'))) {
63+
if (comments.data.some(c => c.body && c.body.includes('@copilot') && c.body.includes('thorough review'))) {
6164
console.log('Copilot already triggered, skipping');
6265
return;
6366
}
64-
github.rest.issues.createComment({
65-
issue_number: context.issue.number,
67+
await github.rest.issues.createComment({
68+
issue_number,
6669
owner: context.repo.owner,
6770
repo: context.repo.repo,
6871
body: '@copilot Do a thorough review of this PR. Read ALL existing reviewer comments first.\n\n1. **Bloat check**: Minimal and focused?\n2. **Security**: Hardcoded secrets?\n3. **Performance**: Heavy imports?\n4. **Tests**: Coverage?\n5. **Code quality**: DRY, naming, errors?'

.github/workflows/chain-claude-after-copilot.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,22 @@ jobs:
1616
- name: Post Claude final review + fix request
1717
uses: actions/github-script@v7
1818
with:
19-
github-token: ${{ secrets.GITHUB_TOKEN }}
19+
github-token: ${{ secrets.GH_TOKEN }}
2020
script: |
21-
github.rest.issues.createComment({
22-
issue_number: context.issue.number,
21+
const issue_number = context.payload.pull_request?.number ?? context.issue?.number;
22+
const comments = await github.rest.issues.listComments({
23+
issue_number,
24+
owner: context.repo.owner,
25+
repo: context.repo.repo,
26+
per_page: 100
27+
});
28+
if (comments.data.some(c => c.body && /@claude\b/i.test(c.body))) {
29+
console.log('@claude already requested, skipping');
30+
return;
31+
}
32+
await github.rest.issues.createComment({
33+
issue_number,
2334
owner: context.repo.owner,
2435
repo: context.repo.repo,
2536
body: '@claude You are the FINAL reviewer. Read ALL comments above from Qodo, Coderabbit, and Copilot.\n\n**Phase 1: Review**\n1. Code follows existing tool patterns (see lumalabs_tool.py)?\n2. Lazy imports for optional deps?\n3. All options as function parameters?\n4. Proper error handling?\n\n**Phase 2: Fix valid issues**\n5. Implement fixes from other reviewers\n6. Push to THIS branch\n\n**Phase 3: Verdict**\n7. Approve or request changes'
26-
})
37+
});

.github/workflows/claude.yml

Lines changed: 44 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,79 +3,84 @@ name: Claude Assistant
33
on:
44
issue_comment:
55
types: [created]
6-
pull_request_review_comment:
7-
types: [created]
86
issues:
9-
types: [assigned, labeled]
10-
pull_request_review:
11-
types: [submitted]
7+
types: [labeled]
8+
9+
permissions:
10+
contents: write
11+
pull-requests: write
12+
issues: write
13+
actions: read
14+
id-token: write
1215

1316
jobs:
1417
claude-response:
1518
env:
16-
ISSUE_NUMBER_RESOLVED: ${{ github.event.issue.number || github.event.pull_request.number }}
19+
ISSUE_NUMBER_RESOLVED: ${{ github.event.issue.number }}
1720
if: |
18-
(github.event.action != 'labeled' || github.event.label.name == 'claude') &&
19-
(github.event_name != 'issue_comment' || contains(github.event.comment.body, '@claude')) &&
2021
(
21-
!contains(github.actor, '[bot]') ||
22-
github.actor == 'github-actions[bot]' ||
23-
github.actor == 'praisonai-triage-agent[bot]'
24-
) &&
25-
github.actor != 'dependabot[bot]' &&
26-
github.actor != 'cursor[bot]' &&
27-
github.actor != 'renovate[bot]'
22+
github.event_name == 'issue_comment' &&
23+
contains(github.event.comment.body, '@claude') &&
24+
github.actor != 'dependabot[bot]' &&
25+
github.actor != 'cursor[bot]' &&
26+
github.actor != 'renovate[bot]'
27+
) || (
28+
github.event_name == 'issues' &&
29+
github.event.action == 'labeled' &&
30+
github.event.label.name == 'claude'
31+
)
2832
runs-on: ubuntu-latest
29-
permissions:
30-
contents: write
31-
pull-requests: write
32-
issues: write
33-
actions: read
3433
steps:
3534
- name: Checkout repository
3635
uses: actions/checkout@v4
3736
with:
3837
fetch-depth: 0
38+
token: ${{ secrets.GITHUB_TOKEN }}
39+
ref: ${{ github.event.issue.pull_request && format('refs/pull/{0}/head', github.event.issue.number) || github.event.repository.default_branch }}
3940

40-
- uses: anthropics/claude-code-action@beta
41+
- name: Run Claude Code Action
42+
uses: anthropics/claude-code-action@beta
4143
env:
4244
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4345
with:
44-
allowed_bots: 'praisonai-triage-agent[bot]'
4546
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
4647
github_token: ${{ secrets.GITHUB_TOKEN }}
4748
trigger_phrase: "@claude"
4849
label_trigger: "claude"
50+
allowed_bots: "praisonai-triage-agent[bot]"
51+
timeout_minutes: "30"
4952
direct_prompt: |
50-
You are implementing changes in the praisonai-tools repository (Python tools for PraisonAI).
53+
You are implementing changes in MervinPraison/PraisonAI-Tools (Python tools for PraisonAI). Follow README.md and existing patterns under `praisonai_tools/`.
54+
55+
Primary scope: `praisonai_tools/`, `tests/`, `examples/`, `docs/`. Do not change `praisonaiagents` in this repo (it is not vendored here).
5156
5257
STEP 0 — GIT & GITHUB CLI:
5358
git config --global user.name "github-actions[bot]"
5459
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
5560
gh auth setup-git
5661
57-
STEP 1 — ISSUE:
58-
Read the issue/PR context. Scope: implement or fix tools under `praisonai_tools/`.
59-
60-
STEP 2 — IMPLEMENT (tool patterns):
61-
- Use `praisonai_tools/tools/lumalabs_tool.py` as a structural reference where applicable
62-
- BaseTool + `@tool` patterns, lazy imports for optional deps, env via constructor or os.getenv
63-
- Clear errors; export new tools from `praisonai_tools/tools/__init__.py` when adding a tool
64-
- Sanity check: python -c "import ast; ast.parse(open('path/to/file.py').read()); print('OK')"
62+
STEP 1 — ISSUE / PR:
63+
Read the issue (or PR) and all comments. Implement what is described with minimal, focused changes.
6564
66-
STEP 3 — BRANCH (one name, reuse in STEP 5):
67-
BRANCH="claude/issue-${{ env.ISSUE_NUMBER_RESOLVED }}-$(date +%Y%m%d)"
65+
STEP 2 — BRANCH (single name; reuse in STEP 4):
66+
BRANCH="claude/issue-${{ env.ISSUE_NUMBER_RESOLVED }}-$(date +%Y%m%d-%H%M%S)"
6867
git checkout -b "$BRANCH"
6968
70-
STEP 4 — TEST / VERIFY:
71-
Run targeted tests or imports relevant to your edits.
69+
STEP 3 — TEST / VERIFY:
70+
Run targeted pytest or smoke checks relevant to your edits (e.g. pytest tests/unit -q).
7271
73-
STEP 5 — COMMIT, PUSH, OPEN PR (mandatory if you produced commits):
72+
STEP 4 — COMMIT, PUSH, OPEN PR (mandatory if you produced commits):
7473
git add -A
75-
git commit -m "fix: <short summary> (fixes #${{ env.ISSUE_NUMBER_RESOLVED }})"
74+
git commit -m "feat: <short summary> (fixes #${{ env.ISSUE_NUMBER_RESOLVED }})"
7675
git push -u origin "$BRANCH"
77-
gh pr create --base main --head "$BRANCH" --title "fix: <short title>" --body "Fixes #${{ env.ISSUE_NUMBER_RESOLVED }}"
78-
Do not stop after push only. Do not ask a human to open the PR. Finish only when `gh pr create` prints a PR URL; on failure, read the error and retry after fixing (auth, duplicate PR, head branch).
76+
REPO="${{ github.repository }}"
77+
COUNT=$(gh pr list --repo "$REPO" --head "$BRANCH" --json number --jq 'length')
78+
if [ "$COUNT" -gt 0 ]; then
79+
gh pr list --repo "$REPO" --head "$BRANCH" --json url --jq '.[0].url'
80+
else
81+
gh pr create --repo "$REPO" --base main --head "$BRANCH" --title "feat: <short title>" --body "Fixes #${{ env.ISSUE_NUMBER_RESOLVED }}"
82+
fi
83+
CRITICAL: Do not stop after `git push`. You MUST complete `gh pr create` (or print the existing PR URL from the step above) and post that URL on the issue. Never ask a human to open the PR manually.
7984
8085
allowed_tools: |
8186
Bash(git:*)
@@ -94,4 +99,3 @@ jobs:
9499
mcp__github__get_issue
95100
mcp__github__get_issue_comments
96101
mcp__github__update_issue
97-
timeout_minutes: 30

0 commit comments

Comments
 (0)