Skip to content

Commit dcfa692

Browse files
authored
Merge branch 'main' into fix-can-use-tool-stream-closed
2 parents 13a458c + 5005816 commit dcfa692

67 files changed

Lines changed: 18538 additions & 595 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/commands/label-issue.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
allowed-tools: Bash(./scripts/gh.sh:*),Bash(./scripts/edit-issue-labels.sh:*)
3+
description: Apply labels to GitHub issues
4+
---
5+
6+
You're an issue triage assistant for GitHub issues. Your task is to analyze the issue and select appropriate labels from the provided list.
7+
8+
IMPORTANT: Don't post any comments or messages to the issue. Your only action should be to apply labels.
9+
10+
Issue Information:
11+
12+
- REPO: ${{ github.repository }}
13+
- ISSUE_NUMBER: ${{ github.event.issue.number }}
14+
15+
TASK OVERVIEW:
16+
17+
1. First, fetch the list of labels available in this repository by running: `./scripts/gh.sh label list`. Run exactly this command with nothing else.
18+
19+
2. Next, use gh wrapper commands to get context about the issue:
20+
21+
- Use `./scripts/gh.sh issue view ${{ github.event.issue.number }}` to retrieve the current issue's details
22+
- Use `./scripts/gh.sh search issues` to find similar issues that might provide context for proper categorization
23+
- `./scripts/gh.sh` is a wrapper for `gh` CLI. Example commands:
24+
- `./scripts/gh.sh label list` — fetch all available labels
25+
- `./scripts/gh.sh issue view 123` — view issue details
26+
- `./scripts/gh.sh issue view 123 --comments` — view with comments
27+
- `./scripts/gh.sh search issues "query" --limit 10` — search for issues
28+
- `./scripts/edit-issue-labels.sh` — apply labels to the issue
29+
30+
3. Analyze the issue content, considering:
31+
32+
- The issue title and description
33+
- The type of issue (bug report, feature request, question, etc.)
34+
- Technical areas mentioned
35+
- Severity or priority indicators
36+
- User impact
37+
- Components affected
38+
39+
4. Select appropriate labels from the available labels list provided above:
40+
41+
- Choose labels that accurately reflect the issue's nature
42+
- Be specific but comprehensive
43+
- IMPORTANT: Add a priority label (P1, P2, or P3) based on the label descriptions from ./scripts/gh.sh label list
44+
- Consider platform labels (android, ios) if applicable
45+
- If you find similar issues using ./scripts/gh.sh search, consider using a "duplicate" label if appropriate. Only do so if the issue is a duplicate of another OPEN issue.
46+
47+
5. Apply the selected labels:
48+
- Use `./scripts/edit-issue-labels.sh --add-label LABEL1 --add-label LABEL2` to apply your selected labels (issue number is read from the workflow event)
49+
- DO NOT post any comments explaining your decision
50+
- DO NOT communicate directly with users
51+
- If no labels are clearly applicable, do not apply any labels
52+
53+
IMPORTANT GUIDELINES:
54+
55+
- Be thorough in your analysis
56+
- Only select labels from the provided list above
57+
- DO NOT post any comments to the issue
58+
- Your ONLY action should be to apply labels using ./scripts/edit-issue-labels.sh
59+
- It's okay to not add any labels if none are clearly applicable
60+
61+
---
Lines changed: 9 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Claude Issue Triage
2-
2+
description: Run Claude Code for issue triage in GitHub Actions
33
on:
44
issues:
55
types: [opened]
@@ -15,93 +15,15 @@ jobs:
1515
steps:
1616
- name: Checkout repository
1717
uses: actions/checkout@v4
18-
19-
- name: Create triage prompt
20-
run: |
21-
mkdir -p /tmp/claude-prompts
22-
cat > /tmp/claude-prompts/triage-prompt.txt << 'EOF'
23-
You're an issue triage assistant for GitHub issues. Your task is to analyze the issue and select appropriate labels from the provided list.
24-
25-
IMPORTANT: Don't post any comments or messages to the issue. Your only action should be to apply labels.
26-
27-
Issue Information:
28-
- REPO: ${{ github.repository }}
29-
- ISSUE_NUMBER: ${{ github.event.issue.number }}
30-
31-
TASK OVERVIEW:
32-
33-
1. First, fetch the list of labels available in this repository by running: `gh label list`. Run exactly this command with nothing else.
34-
35-
2. Next, use the GitHub tools to get context about the issue:
36-
- You have access to these tools:
37-
- mcp__github__get_issue: Use this to retrieve the current issue's details including title, description, and existing labels
38-
- mcp__github__get_issue_comments: Use this to read any discussion or additional context provided in the comments
39-
- mcp__github__update_issue: Use this to apply labels to the issue (do not use this for commenting)
40-
- mcp__github__search_issues: Use this to find similar issues that might provide context for proper categorization and to identify potential duplicate issues
41-
- mcp__github__list_issues: Use this to understand patterns in how other issues are labeled
42-
- Start by using mcp__github__get_issue to get the issue details
43-
44-
3. Analyze the issue content, considering:
45-
- The issue title and description
46-
- The type of issue (bug report, feature request, question, etc.)
47-
- Technical areas mentioned
48-
- Severity or priority indicators
49-
- User impact
50-
- Components affected
51-
52-
4. Select appropriate labels from the available labels list provided above:
53-
- Choose labels that accurately reflect the issue's nature
54-
- Be specific but comprehensive
55-
- Select priority labels if you can determine urgency (high-priority, med-priority, or low-priority)
56-
- Consider platform labels (android, ios) if applicable
57-
- If you find similar issues using mcp__github__search_issues, consider using a "duplicate" label if appropriate. Only do so if the issue is a duplicate of another OPEN issue.
58-
59-
5. Apply the selected labels:
60-
- Use mcp__github__update_issue to apply your selected labels
61-
- DO NOT post any comments explaining your decision
62-
- DO NOT communicate directly with users
63-
- If no labels are clearly applicable, do not apply any labels
64-
65-
IMPORTANT GUIDELINES:
66-
- Be thorough in your analysis
67-
- Only select labels from the provided list above
68-
- DO NOT post any comments to the issue
69-
- Your ONLY action should be to apply labels using mcp__github__update_issue
70-
- It's okay to not add any labels if none are clearly applicable
71-
EOF
72-
73-
- name: Setup GitHub MCP Server
74-
run: |
75-
mkdir -p /tmp/mcp-config
76-
cat > /tmp/mcp-config/mcp-servers.json << 'EOF'
77-
{
78-
"mcpServers": {
79-
"github": {
80-
"command": "docker",
81-
"args": [
82-
"run",
83-
"-i",
84-
"--rm",
85-
"-e",
86-
"GITHUB_PERSONAL_ACCESS_TOKEN",
87-
"ghcr.io/github/github-mcp-server:sha-7aced2b"
88-
],
89-
"env": {
90-
"GITHUB_PERSONAL_ACCESS_TOKEN": "${{ secrets.GITHUB_TOKEN }}"
91-
}
92-
}
93-
}
94-
}
95-
EOF
18+
with:
19+
fetch-depth: 0
9620

9721
- name: Run Claude Code for Issue Triage
98-
uses: anthropics/claude-code-base-action@v1
99-
timeout-minutes: 5
22+
uses: anthropics/claude-code-action@v1
23+
env:
24+
CLAUDE_CODE_SCRIPT_CAPS: '{"edit-issue-labels.sh":2}'
10025
with:
101-
prompt_file: /tmp/claude-prompts/triage-prompt.txt
26+
prompt: "/label-issue REPO: ${{ github.repository }} ISSUE_NUMBER: ${{ github.event.issue.number }}"
10227
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
103-
claude_args: |
104-
--allowed-tools "Bash(gh label list),mcp__github__get_issue,mcp__github__get_issue_comments,mcp__github__update_issue,mcp__github__search_issues,mcp__github__list_issues"
105-
--mcp-config /tmp/mcp-config/mcp-servers.json
106-
env:
107-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
allowed_non_write_users: "*" # Required for issue triage workflow, if users without repo write access create issues
29+
github_token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/claude.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,16 @@ jobs:
4545
with:
4646
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
4747

48-
claude_args: --model claude-opus-4-6
49-
5048
# Optional: Customize the trigger phrase (default: @claude)
5149
# trigger_phrase: "/claude"
52-
50+
5351
# Optional: Trigger when specific user is assigned to an issue
5452
# assignee_trigger: "claude-bot"
55-
56-
# Allow Claude to run linters, typecheckers, and tests
57-
claude_args: |
58-
--allowed-tools "Bash(python -m ruff check:*),Bash(python -m ruff format:*),Bash(python -m mypy:*),Bash(python -m pytest:*)"
5953

60-
# Optional: Add custom instructions for Claude to customize its behavior for your project
61-
# claude_args: --system-prompt "Follow our coding standards"
54+
# CLI args: model selection + allowed tools for lint/typecheck/tests.
55+
# Add further flags (e.g. --system-prompt "...") to this block rather
56+
# than a second claude_args key — duplicate YAML keys are rejected by
57+
# GitHub Actions.
58+
claude_args: |
59+
--model claude-opus-4-6
60+
--allowed-tools "Bash(python -m ruff check:*),Bash(python -m ruff format:*),Bash(python -m mypy:*),Bash(python -m pytest:*)"

.github/workflows/pypi-quota-check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838

3939
- name: Post to Slack
4040
if: steps.quota.outputs.alert == 'true' && github.event_name != 'pull_request'
41-
uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # 2.1.1
41+
uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1 (sha-pinned)
4242
with:
4343
method: chat.postMessage
4444
token: ${{ secrets.SLACK_BOT_TOKEN }}

.github/workflows/slack-issue-notification.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- name: Post to Slack
12-
uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # 2.1.1
12+
uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1 (sha-pinned)
1313
with:
1414
method: chat.postMessage
1515
token: ${{ secrets.SLACK_BOT_TOKEN }}

.github/workflows/test.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
python -m pytest tests/ -v --cov=claude_agent_sdk --cov-report=xml
3232
3333
- name: Upload coverage to Codecov
34-
uses: codecov/codecov-action@v4
34+
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.0 (sha-pinned)
3535
with:
3636
file: ./coverage.xml
3737
fail_ci_if_error: false
@@ -141,20 +141,22 @@ jobs:
141141
if: runner.os == 'Linux'
142142
env:
143143
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
144+
PYTHONUNBUFFERED: "1"
144145
run: |
145146
python examples/quick_start.py
146-
timeout 120 python examples/streaming_mode.py all
147+
timeout 300 python examples/streaming_mode.py all
147148
timeout 120 python examples/hooks.py PreToolUse
148149
timeout 120 python examples/hooks.py DecisionFields
149150
150151
- name: Run example scripts (Windows)
151152
if: runner.os == 'Windows'
152153
env:
153154
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
155+
PYTHONUNBUFFERED: "1"
154156
run: |
155157
python examples/quick_start.py
156158
$job = Start-Job { python examples/streaming_mode.py all }
157-
Wait-Job $job -Timeout 120 | Out-Null
159+
Wait-Job $job -Timeout 300 | Out-Null
158160
Stop-Job $job
159161
Receive-Job $job
160162

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ env/
2828
.venv
2929
uv.lock
3030

31+
# Local env files (live-backend test credentials etc.)
32+
.env
33+
.env.*
34+
3135
# IDEs
3236
.vscode/
3337
.idea/
@@ -49,3 +53,4 @@ htmlcov/
4953
.dmypy.json
5054
dmypy.json
5155
.pyre/
56+
.claude/worktrees/

0 commit comments

Comments
 (0)