mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-01-23 23:14:13 +08:00
Compare commits
1 Commits
ashwin-ant
...
ashwin/sti
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7925dd1804 |
2
.github/workflows/issue-triage.yml
vendored
2
.github/workflows/issue-triage.yml
vendored
@@ -32,7 +32,7 @@ jobs:
|
|||||||
"--rm",
|
"--rm",
|
||||||
"-e",
|
"-e",
|
||||||
"GITHUB_PERSONAL_ACCESS_TOKEN",
|
"GITHUB_PERSONAL_ACCESS_TOKEN",
|
||||||
"ghcr.io/github/github-mcp-server:sha-721fd3e"
|
"ghcr.io/github/github-mcp-server:sha-6d69797"
|
||||||
],
|
],
|
||||||
"env": {
|
"env": {
|
||||||
"GITHUB_PERSONAL_ACCESS_TOKEN": "${{ secrets.GITHUB_TOKEN }}"
|
"GITHUB_PERSONAL_ACCESS_TOKEN": "${{ secrets.GITHUB_TOKEN }}"
|
||||||
|
|||||||
25
FAQ.md
25
FAQ.md
@@ -51,29 +51,14 @@ allowed_tools: "Bash(git rebase:*)" # Use with caution
|
|||||||
|
|
||||||
Claude doesn't create PRs by default. Instead, it pushes commits to a branch and provides a link to a pre-filled PR submission page. This approach ensures your repository's branch protection rules are still adhered to and gives you final control over PR creation.
|
Claude doesn't create PRs by default. Instead, it pushes commits to a branch and provides a link to a pre-filled PR submission page. This approach ensures your repository's branch protection rules are still adhered to and gives you final control over PR creation.
|
||||||
|
|
||||||
### Can Claude see my GitHub Actions CI results?
|
### Why can't Claude run my tests or see CI results?
|
||||||
|
|
||||||
Yes! Claude can access GitHub Actions workflow runs, job logs, and test results on the PR where it's tagged. To enable this:
|
Claude cannot access GitHub Actions logs, test results, or other CI/CD outputs by default. It only has access to the repository files. If you need Claude to see test results, you can either:
|
||||||
|
|
||||||
1. Add `actions: read` permission to your workflow:
|
1. Instruct Claude to run tests before making commits
|
||||||
|
2. Copy and paste CI results into a comment for Claude to analyze
|
||||||
|
|
||||||
```yaml
|
This limitation exists for security reasons but may be reconsidered in the future based on user feedback.
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
pull-requests: write
|
|
||||||
issues: write
|
|
||||||
actions: read
|
|
||||||
```
|
|
||||||
|
|
||||||
2. Configure the action with additional permissions:
|
|
||||||
```yaml
|
|
||||||
- uses: anthropics/claude-code-action@beta
|
|
||||||
with:
|
|
||||||
additional_permissions: |
|
|
||||||
actions: read
|
|
||||||
```
|
|
||||||
|
|
||||||
Claude will then be able to analyze CI failures and help debug workflow issues. For running tests locally before commits, you can still instruct Claude to do so in your request.
|
|
||||||
|
|
||||||
### Why does Claude only update one comment instead of creating new ones?
|
### Why does Claude only update one comment instead of creating new ones?
|
||||||
|
|
||||||
|
|||||||
83
README.md
83
README.md
@@ -30,9 +30,7 @@ This command will guide you through setting up the GitHub app and required secre
|
|||||||
**Requirements**: You must be a repository admin to complete these steps.
|
**Requirements**: You must be a repository admin to complete these steps.
|
||||||
|
|
||||||
1. Install the Claude GitHub app to your repository: https://github.com/apps/claude
|
1. Install the Claude GitHub app to your repository: https://github.com/apps/claude
|
||||||
2. Add authentication to your repository secrets ([Learn how to use secrets in GitHub Actions](https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions)):
|
2. Add `ANTHROPIC_API_KEY` to your repository secrets ([Learn how to use secrets in GitHub Actions](https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions))
|
||||||
- Either `ANTHROPIC_API_KEY` for API key authentication
|
|
||||||
- Or `CLAUDE_CODE_OAUTH_TOKEN` for OAuth token authentication (Pro and Max users can generate this by running `claude setup-token` locally)
|
|
||||||
3. Copy the workflow file from [`examples/claude.yml`](./examples/claude.yml) into your repository's `.github/workflows/`
|
3. Copy the workflow file from [`examples/claude.yml`](./examples/claude.yml) into your repository's `.github/workflows/`
|
||||||
|
|
||||||
## 📚 FAQ
|
## 📚 FAQ
|
||||||
@@ -62,8 +60,6 @@ jobs:
|
|||||||
- uses: anthropics/claude-code-action@beta
|
- uses: anthropics/claude-code-action@beta
|
||||||
with:
|
with:
|
||||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||||
# Or use OAuth token instead:
|
|
||||||
# claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
|
|
||||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
# Optional: add custom trigger phrase (default: @claude)
|
# Optional: add custom trigger phrase (default: @claude)
|
||||||
# trigger_phrase: "/claude"
|
# trigger_phrase: "/claude"
|
||||||
@@ -85,31 +81,30 @@ jobs:
|
|||||||
|
|
||||||
## Inputs
|
## Inputs
|
||||||
|
|
||||||
| Input | Description | Required | Default |
|
| Input | Description | Required | Default |
|
||||||
| ------------------------- | -------------------------------------------------------------------------------------------------------------------- | -------- | --------- |
|
| ------------------------ | -------------------------------------------------------------------------------------------------------------------- | -------- | --------- |
|
||||||
| `anthropic_api_key` | Anthropic API key (required for direct API, not needed for Bedrock/Vertex) | No\* | - |
|
| `anthropic_api_key` | Anthropic API key (required for direct API, not needed for Bedrock/Vertex) | No\* | - |
|
||||||
| `claude_code_oauth_token` | Claude Code OAuth token (alternative to anthropic_api_key) | No\* | - |
|
| `direct_prompt` | Direct prompt for Claude to execute automatically without needing a trigger (for automated workflows) | No | - |
|
||||||
| `direct_prompt` | Direct prompt for Claude to execute automatically without needing a trigger (for automated workflows) | No | - |
|
| `base_branch` | The base branch to use for creating new branches (e.g., 'main', 'develop') | No | - |
|
||||||
| `base_branch` | The base branch to use for creating new branches (e.g., 'main', 'develop') | No | - |
|
| `max_turns` | Maximum number of conversation turns Claude can take (limits back-and-forth exchanges) | No | - |
|
||||||
| `max_turns` | Maximum number of conversation turns Claude can take (limits back-and-forth exchanges) | No | - |
|
| `timeout_minutes` | Timeout in minutes for execution | No | `30` |
|
||||||
| `timeout_minutes` | Timeout in minutes for execution | No | `30` |
|
| `use_sticky_comment` | Use just one comment to deliver PR comments (only applies for pull_request event workflows) | No | `false` |
|
||||||
| `use_sticky_comment` | Use just one comment to deliver PR comments (only applies for pull_request event workflows) | No | `false` |
|
| `github_token` | GitHub token for Claude to operate with. **Only include this if you're connecting a custom GitHub app of your own!** | No | - |
|
||||||
| `github_token` | GitHub token for Claude to operate with. **Only include this if you're connecting a custom GitHub app of your own!** | No | - |
|
| `model` | Model to use (provider-specific format required for Bedrock/Vertex) | No | - |
|
||||||
| `model` | Model to use (provider-specific format required for Bedrock/Vertex) | No | - |
|
| `fallback_model` | Enable automatic fallback to specified model when primary model is unavailable | No | - |
|
||||||
| `fallback_model` | Enable automatic fallback to specified model when primary model is unavailable | No | - |
|
| `anthropic_model` | **DEPRECATED**: Use `model` instead. Kept for backward compatibility. | No | - |
|
||||||
| `anthropic_model` | **DEPRECATED**: Use `model` instead. Kept for backward compatibility. | No | - |
|
| `use_bedrock` | Use Amazon Bedrock with OIDC authentication instead of direct Anthropic API | No | `false` |
|
||||||
| `use_bedrock` | Use Amazon Bedrock with OIDC authentication instead of direct Anthropic API | No | `false` |
|
| `use_vertex` | Use Google Vertex AI with OIDC authentication instead of direct Anthropic API | No | `false` |
|
||||||
| `use_vertex` | Use Google Vertex AI with OIDC authentication instead of direct Anthropic API | No | `false` |
|
| `allowed_tools` | Additional tools for Claude to use (the base GitHub tools will always be included) | No | "" |
|
||||||
| `allowed_tools` | Additional tools for Claude to use (the base GitHub tools will always be included) | No | "" |
|
| `disallowed_tools` | Tools that Claude should never use | No | "" |
|
||||||
| `disallowed_tools` | Tools that Claude should never use | No | "" |
|
| `custom_instructions` | Additional custom instructions to include in the prompt for Claude | No | "" |
|
||||||
| `custom_instructions` | Additional custom instructions to include in the prompt for Claude | No | "" |
|
| `mcp_config` | Additional MCP configuration (JSON string) that merges with the built-in GitHub MCP servers | No | "" |
|
||||||
| `mcp_config` | Additional MCP configuration (JSON string) that merges with the built-in GitHub MCP servers | No | "" |
|
| `assignee_trigger` | The assignee username that triggers the action (e.g. @claude). Only used for issue assignment | No | - |
|
||||||
| `assignee_trigger` | The assignee username that triggers the action (e.g. @claude). Only used for issue assignment | No | - |
|
| `label_trigger` | The label name that triggers the action when applied to an issue (e.g. "claude") | No | - |
|
||||||
| `label_trigger` | The label name that triggers the action when applied to an issue (e.g. "claude") | No | - |
|
| `trigger_phrase` | The trigger phrase to look for in comments, issue/PR bodies, and issue titles | No | `@claude` |
|
||||||
| `trigger_phrase` | The trigger phrase to look for in comments, issue/PR bodies, and issue titles | No | `@claude` |
|
| `branch_prefix` | The prefix to use for Claude branches (defaults to 'claude/', use 'claude-' for dash format) | No | `claude/` |
|
||||||
| `branch_prefix` | The prefix to use for Claude branches (defaults to 'claude/', use 'claude-' for dash format) | No | `claude/` |
|
| `claude_env` | Custom environment variables to pass to Claude Code execution (YAML format) | No | "" |
|
||||||
| `claude_env` | Custom environment variables to pass to Claude Code execution (YAML format) | No | "" |
|
| `additional_permissions` | Additional permissions to enable. Currently supports 'actions: read' for viewing workflow results | No | "" |
|
||||||
| `additional_permissions` | Additional permissions to enable. Currently supports 'actions: read' for viewing workflow results | No | "" |
|
|
||||||
|
|
||||||
\*Required when using direct Anthropic API (default and when not using Bedrock or Vertex)
|
\*Required when using direct Anthropic API (default and when not using Bedrock or Vertex)
|
||||||
|
|
||||||
@@ -335,7 +330,6 @@ This action is built on top of [`anthropics/claude-code-base-action`](https://gi
|
|||||||
- When triggered on an **issue**: Always creates a new branch for the work
|
- When triggered on an **issue**: Always creates a new branch for the work
|
||||||
- When triggered on an **open PR**: Always pushes directly to the existing PR branch
|
- When triggered on an **open PR**: Always pushes directly to the existing PR branch
|
||||||
- When triggered on a **closed PR**: Creates a new branch since the original is no longer active
|
- When triggered on a **closed PR**: Creates a new branch since the original is no longer active
|
||||||
- **View GitHub Actions Results**: Can access workflow runs, job logs, and test results on the PR where it's tagged when `actions: read` permission is configured (see [Additional Permissions for CI/CD Integration](#additional-permissions-for-cicd-integration))
|
|
||||||
|
|
||||||
### What Claude Cannot Do
|
### What Claude Cannot Do
|
||||||
|
|
||||||
@@ -344,6 +338,7 @@ This action is built on top of [`anthropics/claude-code-base-action`](https://gi
|
|||||||
- **Post Multiple Comments**: Claude only acts by updating its initial comment
|
- **Post Multiple Comments**: Claude only acts by updating its initial comment
|
||||||
- **Execute Commands Outside Its Context**: Claude only has access to the repository and PR/issue context it's triggered in
|
- **Execute Commands Outside Its Context**: Claude only has access to the repository and PR/issue context it's triggered in
|
||||||
- **Run Arbitrary Bash Commands**: By default, Claude cannot execute Bash commands unless explicitly allowed using the `allowed_tools` configuration
|
- **Run Arbitrary Bash Commands**: By default, Claude cannot execute Bash commands unless explicitly allowed using the `allowed_tools` configuration
|
||||||
|
- **View CI/CD Results**: Cannot access CI systems, test results, or build logs unless an additional tool or MCP server is configured
|
||||||
- **Perform Branch Operations**: Cannot merge branches, rebase, or perform other git operations beyond pushing commits
|
- **Perform Branch Operations**: Cannot merge branches, rebase, or perform other git operations beyond pushing commits
|
||||||
|
|
||||||
## Advanced Configuration
|
## Advanced Configuration
|
||||||
@@ -609,21 +604,18 @@ The [Claude Code GitHub app](https://github.com/apps/claude) requires these perm
|
|||||||
|
|
||||||
All commits made by Claude through this action are automatically signed with commit signatures. This ensures the authenticity and integrity of commits, providing a verifiable trail of changes made by the action.
|
All commits made by Claude through this action are automatically signed with commit signatures. This ensures the authenticity and integrity of commits, providing a verifiable trail of changes made by the action.
|
||||||
|
|
||||||
### ⚠️ Authentication Protection
|
### ⚠️ ANTHROPIC_API_KEY Protection
|
||||||
|
|
||||||
**CRITICAL: Never hardcode your Anthropic API key or OAuth token in workflow files!**
|
**CRITICAL: Never hardcode your Anthropic API key in workflow files!**
|
||||||
|
|
||||||
Your authentication credentials must always be stored in GitHub secrets to prevent unauthorized access:
|
Your ANTHROPIC_API_KEY must always be stored in GitHub secrets to prevent unauthorized access:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# CORRECT ✅
|
# CORRECT ✅
|
||||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||||
# OR
|
|
||||||
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
|
|
||||||
|
|
||||||
# NEVER DO THIS ❌
|
# NEVER DO THIS ❌
|
||||||
anthropic_api_key: "sk-ant-api03-..." # Exposed and vulnerable!
|
anthropic_api_key: "sk-ant-api03-..." # Exposed and vulnerable!
|
||||||
claude_code_oauth_token: "oauth_token_..." # Exposed and vulnerable!
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Setting Up GitHub Secrets
|
### Setting Up GitHub Secrets
|
||||||
@@ -631,18 +623,17 @@ claude_code_oauth_token: "oauth_token_..." # Exposed and vulnerable!
|
|||||||
1. Go to your repository's Settings
|
1. Go to your repository's Settings
|
||||||
2. Click on "Secrets and variables" → "Actions"
|
2. Click on "Secrets and variables" → "Actions"
|
||||||
3. Click "New repository secret"
|
3. Click "New repository secret"
|
||||||
4. For authentication, choose one:
|
4. Name: `ANTHROPIC_API_KEY`
|
||||||
- API Key: Name: `ANTHROPIC_API_KEY`, Value: Your Anthropic API key (starting with `sk-ant-`)
|
5. Value: Your Anthropic API key (starting with `sk-ant-`)
|
||||||
- OAuth Token: Name: `CLAUDE_CODE_OAUTH_TOKEN`, Value: Your Claude Code OAuth token (Pro and Max users can generate this by running `claude setup-token` locally)
|
6. Click "Add secret"
|
||||||
5. Click "Add secret"
|
|
||||||
|
|
||||||
### Best Practices for Authentication
|
### Best Practices for ANTHROPIC_API_KEY
|
||||||
|
|
||||||
1. ✅ Always use `${{ secrets.ANTHROPIC_API_KEY }}` or `${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}` in workflows
|
1. ✅ Always use `${{ secrets.ANTHROPIC_API_KEY }}` in workflows
|
||||||
2. ✅ Never commit API keys or tokens to version control
|
2. ✅ Never commit API keys to version control
|
||||||
3. ✅ Regularly rotate your API keys and tokens
|
3. ✅ Regularly rotate your API keys
|
||||||
4. ✅ Use environment secrets for organization-wide access
|
4. ✅ Use environment secrets for organization-wide access
|
||||||
5. ❌ Never share API keys or tokens in pull requests or issues
|
5. ❌ Never share API keys in pull requests or issues
|
||||||
6. ❌ Avoid logging workflow variables that might contain keys
|
6. ❌ Avoid logging workflow variables that might contain keys
|
||||||
|
|
||||||
## Security Best Practices
|
## Security Best Practices
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ Thank you for trying out the beta of our GitHub Action! This document outlines o
|
|||||||
- **Cross-repo support** - Enable Claude to work across multiple repositories in a single session
|
- **Cross-repo support** - Enable Claude to work across multiple repositories in a single session
|
||||||
- **Ability to modify workflow files** - Let Claude update GitHub Actions workflows and other CI configuration files
|
- **Ability to modify workflow files** - Let Claude update GitHub Actions workflows and other CI configuration files
|
||||||
- **Support for workflow_dispatch and repository_dispatch events** - Dispatch Claude on events triggered via API from other workflows or from other services
|
- **Support for workflow_dispatch and repository_dispatch events** - Dispatch Claude on events triggered via API from other workflows or from other services
|
||||||
- ~**Ability to disable commit signing**~ - Option to turn off GPG signing for environments where it's not required. This will enable Claude to use normal `git` bash commands for committing. This will likely become the default behavior once added.
|
- **Ability to disable commit signing** - Option to turn off GPG signing for environments where it's not required. This will enable Claude to use normal `git` bash commands for committing. This will likely become the default behavior once added.
|
||||||
- **Better code review behavior** - Support inline comments on specific lines, provide higher quality reviews with more actionable feedback
|
- **Better code review behavior** - Support inline comments on specific lines, provide higher quality reviews with more actionable feedback
|
||||||
- **Support triggering @claude from bot users** - Allow automation and bot accounts to invoke Claude
|
- **Support triggering @claude from bot users** - Allow automation and bot accounts to invoke Claude
|
||||||
- **Customizable base prompts** - Full control over Claude's initial context with template variables like `$PR_COMMENTS`, `$PR_FILES`, etc. Users can replace our default prompt entirely while still accessing key contextual data
|
- **Customizable base prompts** - Full control over Claude's initial context with template variables like `$PR_COMMENTS`, `$PR_FILES`, etc. Users can replace our default prompt entirely while still accessing key contextual data
|
||||||
|
|||||||
13
action.yml
13
action.yml
@@ -65,9 +65,6 @@ inputs:
|
|||||||
anthropic_api_key:
|
anthropic_api_key:
|
||||||
description: "Anthropic API key (required for direct API, not needed for Bedrock/Vertex)"
|
description: "Anthropic API key (required for direct API, not needed for Bedrock/Vertex)"
|
||||||
required: false
|
required: false
|
||||||
claude_code_oauth_token:
|
|
||||||
description: "Claude Code OAuth token (alternative to anthropic_api_key)"
|
|
||||||
required: false
|
|
||||||
github_token:
|
github_token:
|
||||||
description: "GitHub token with repo and pull request permissions (optional if using GitHub App)"
|
description: "GitHub token with repo and pull request permissions (optional if using GitHub App)"
|
||||||
required: false
|
required: false
|
||||||
@@ -92,10 +89,6 @@ inputs:
|
|||||||
description: "Use just one comment to deliver issue/PR comments"
|
description: "Use just one comment to deliver issue/PR comments"
|
||||||
required: false
|
required: false
|
||||||
default: "false"
|
default: "false"
|
||||||
use_commit_signing:
|
|
||||||
description: "Enable commit signing using GitHub's commit signature verification. When false, Claude uses standard git commands"
|
|
||||||
required: false
|
|
||||||
default: "false"
|
|
||||||
|
|
||||||
outputs:
|
outputs:
|
||||||
execution_file:
|
execution_file:
|
||||||
@@ -137,12 +130,11 @@ runs:
|
|||||||
USE_STICKY_COMMENT: ${{ inputs.use_sticky_comment }}
|
USE_STICKY_COMMENT: ${{ inputs.use_sticky_comment }}
|
||||||
ACTIONS_TOKEN: ${{ github.token }}
|
ACTIONS_TOKEN: ${{ github.token }}
|
||||||
ADDITIONAL_PERMISSIONS: ${{ inputs.additional_permissions }}
|
ADDITIONAL_PERMISSIONS: ${{ inputs.additional_permissions }}
|
||||||
USE_COMMIT_SIGNING: ${{ inputs.use_commit_signing }}
|
|
||||||
|
|
||||||
- name: Run Claude Code
|
- name: Run Claude Code
|
||||||
id: claude-code
|
id: claude-code
|
||||||
if: steps.prepare.outputs.contains_trigger == 'true'
|
if: steps.prepare.outputs.contains_trigger == 'true'
|
||||||
uses: anthropics/claude-code-base-action@3560d21b41bd19b1d3ac6c9000af378903d8df0e # v0.0.32
|
uses: anthropics/claude-code-base-action@a835717b36becf75584224421f4094aae288cad7 # v0.0.31
|
||||||
with:
|
with:
|
||||||
prompt_file: ${{ runner.temp }}/claude-prompts/claude-prompt.txt
|
prompt_file: ${{ runner.temp }}/claude-prompts/claude-prompt.txt
|
||||||
allowed_tools: ${{ env.ALLOWED_TOOLS }}
|
allowed_tools: ${{ env.ALLOWED_TOOLS }}
|
||||||
@@ -155,13 +147,11 @@ runs:
|
|||||||
use_bedrock: ${{ inputs.use_bedrock }}
|
use_bedrock: ${{ inputs.use_bedrock }}
|
||||||
use_vertex: ${{ inputs.use_vertex }}
|
use_vertex: ${{ inputs.use_vertex }}
|
||||||
anthropic_api_key: ${{ inputs.anthropic_api_key }}
|
anthropic_api_key: ${{ inputs.anthropic_api_key }}
|
||||||
claude_code_oauth_token: ${{ inputs.claude_code_oauth_token }}
|
|
||||||
claude_env: ${{ inputs.claude_env }}
|
claude_env: ${{ inputs.claude_env }}
|
||||||
env:
|
env:
|
||||||
# Model configuration
|
# Model configuration
|
||||||
ANTHROPIC_MODEL: ${{ inputs.model || inputs.anthropic_model }}
|
ANTHROPIC_MODEL: ${{ inputs.model || inputs.anthropic_model }}
|
||||||
GITHUB_TOKEN: ${{ steps.prepare.outputs.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ steps.prepare.outputs.GITHUB_TOKEN }}
|
||||||
NODE_VERSION: ${{ env.NODE_VERSION }}
|
|
||||||
|
|
||||||
# Provider configuration
|
# Provider configuration
|
||||||
ANTHROPIC_BASE_URL: ${{ env.ANTHROPIC_BASE_URL }}
|
ANTHROPIC_BASE_URL: ${{ env.ANTHROPIC_BASE_URL }}
|
||||||
@@ -206,7 +196,6 @@ runs:
|
|||||||
PREPARE_SUCCESS: ${{ steps.prepare.outcome == 'success' }}
|
PREPARE_SUCCESS: ${{ steps.prepare.outcome == 'success' }}
|
||||||
PREPARE_ERROR: ${{ steps.prepare.outputs.prepare_error || '' }}
|
PREPARE_ERROR: ${{ steps.prepare.outputs.prepare_error || '' }}
|
||||||
USE_STICKY_COMMENT: ${{ inputs.use_sticky_comment }}
|
USE_STICKY_COMMENT: ${{ inputs.use_sticky_comment }}
|
||||||
USE_COMMIT_SIGNING: ${{ inputs.use_commit_signing }}
|
|
||||||
|
|
||||||
- name: Display Claude Code Report
|
- name: Display Claude Code Report
|
||||||
if: steps.prepare.outputs.contains_trigger == 'true' && steps.claude-code.outputs.execution_file != ''
|
if: steps.prepare.outputs.contains_trigger == 'true' && steps.claude-code.outputs.execution_file != ''
|
||||||
|
|||||||
@@ -33,6 +33,4 @@ jobs:
|
|||||||
uses: anthropics/claude-code-action@beta
|
uses: anthropics/claude-code-action@beta
|
||||||
with:
|
with:
|
||||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||||
# Or use OAuth token instead:
|
|
||||||
# claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
|
|
||||||
timeout_minutes: "60"
|
timeout_minutes: "60"
|
||||||
|
|||||||
@@ -30,40 +30,18 @@ const BASE_ALLOWED_TOOLS = [
|
|||||||
"LS",
|
"LS",
|
||||||
"Read",
|
"Read",
|
||||||
"Write",
|
"Write",
|
||||||
|
"mcp__github_file_ops__commit_files",
|
||||||
|
"mcp__github_file_ops__delete_files",
|
||||||
|
"mcp__github_file_ops__update_claude_comment",
|
||||||
];
|
];
|
||||||
const DISALLOWED_TOOLS = ["WebSearch", "WebFetch"];
|
const DISALLOWED_TOOLS = ["WebSearch", "WebFetch"];
|
||||||
|
|
||||||
export function buildAllowedToolsString(
|
export function buildAllowedToolsString(
|
||||||
customAllowedTools?: string[],
|
customAllowedTools?: string[],
|
||||||
includeActionsTools: boolean = false,
|
includeActionsTools: boolean = false,
|
||||||
useCommitSigning: boolean = false,
|
|
||||||
): string {
|
): string {
|
||||||
let baseTools = [...BASE_ALLOWED_TOOLS];
|
let baseTools = [...BASE_ALLOWED_TOOLS];
|
||||||
|
|
||||||
// Always include the comment update tool from the comment server
|
|
||||||
baseTools.push("mcp__github_comment__update_claude_comment");
|
|
||||||
|
|
||||||
// Add commit signing tools if enabled
|
|
||||||
if (useCommitSigning) {
|
|
||||||
baseTools.push(
|
|
||||||
"mcp__github_file_ops__commit_files",
|
|
||||||
"mcp__github_file_ops__delete_files",
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
// When not using commit signing, add specific Bash git commands only
|
|
||||||
baseTools.push(
|
|
||||||
"Bash(git add:*)",
|
|
||||||
"Bash(git commit:*)",
|
|
||||||
"Bash(git push:*)",
|
|
||||||
"Bash(git status:*)",
|
|
||||||
"Bash(git diff:*)",
|
|
||||||
"Bash(git log:*)",
|
|
||||||
"Bash(git rm:*)",
|
|
||||||
"Bash(git config user.name:*)",
|
|
||||||
"Bash(git config user.email:*)",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add GitHub Actions MCP tools if enabled
|
// Add GitHub Actions MCP tools if enabled
|
||||||
if (includeActionsTools) {
|
if (includeActionsTools) {
|
||||||
baseTools.push(
|
baseTools.push(
|
||||||
@@ -402,68 +380,9 @@ export function getEventTypeAndContext(envVars: PreparedContext): {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCommitInstructions(
|
|
||||||
eventData: EventData,
|
|
||||||
githubData: FetchDataResult,
|
|
||||||
context: PreparedContext,
|
|
||||||
useCommitSigning: boolean,
|
|
||||||
): string {
|
|
||||||
const coAuthorLine =
|
|
||||||
(githubData.triggerDisplayName ?? context.triggerUsername !== "Unknown")
|
|
||||||
? `Co-authored-by: ${githubData.triggerDisplayName ?? context.triggerUsername} <${context.triggerUsername}@users.noreply.github.com>`
|
|
||||||
: "";
|
|
||||||
|
|
||||||
if (useCommitSigning) {
|
|
||||||
if (eventData.isPR && !eventData.claudeBranch) {
|
|
||||||
return `
|
|
||||||
- Push directly using mcp__github_file_ops__commit_files to the existing branch (works for both new and existing files).
|
|
||||||
- Use mcp__github_file_ops__commit_files to commit files atomically in a single commit (supports single or multiple files).
|
|
||||||
- When pushing changes with this tool and the trigger user is not "Unknown", include a Co-authored-by trailer in the commit message.
|
|
||||||
- Use: "${coAuthorLine}"`;
|
|
||||||
} else {
|
|
||||||
return `
|
|
||||||
- You are already on the correct branch (${eventData.claudeBranch || "the PR branch"}). Do not create a new branch.
|
|
||||||
- Push changes directly to the current branch using mcp__github_file_ops__commit_files (works for both new and existing files)
|
|
||||||
- Use mcp__github_file_ops__commit_files to commit files atomically in a single commit (supports single or multiple files).
|
|
||||||
- When pushing changes and the trigger user is not "Unknown", include a Co-authored-by trailer in the commit message.
|
|
||||||
- Use: "${coAuthorLine}"`;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Non-signing instructions
|
|
||||||
if (eventData.isPR && !eventData.claudeBranch) {
|
|
||||||
return `
|
|
||||||
- Use git commands via the Bash tool to commit and push your changes:
|
|
||||||
- Stage files: Bash(git add <files>)
|
|
||||||
- Commit with a descriptive message: Bash(git commit -m "<message>")
|
|
||||||
${
|
|
||||||
coAuthorLine
|
|
||||||
? `- When committing and the trigger user is not "Unknown", include a Co-authored-by trailer:
|
|
||||||
Bash(git commit -m "<message>\\n\\n${coAuthorLine}")`
|
|
||||||
: ""
|
|
||||||
}
|
|
||||||
- Push to the remote: Bash(git push origin HEAD)`;
|
|
||||||
} else {
|
|
||||||
const branchName = eventData.claudeBranch || eventData.baseBranch;
|
|
||||||
return `
|
|
||||||
- You are already on the correct branch (${eventData.claudeBranch || "the PR branch"}). Do not create a new branch.
|
|
||||||
- Use git commands via the Bash tool to commit and push your changes:
|
|
||||||
- Stage files: Bash(git add <files>)
|
|
||||||
- Commit with a descriptive message: Bash(git commit -m "<message>")
|
|
||||||
${
|
|
||||||
coAuthorLine
|
|
||||||
? `- When committing and the trigger user is not "Unknown", include a Co-authored-by trailer:
|
|
||||||
Bash(git commit -m "<message>\\n\\n${coAuthorLine}")`
|
|
||||||
: ""
|
|
||||||
}
|
|
||||||
- Push to the remote: Bash(git push origin ${branchName})`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function generatePrompt(
|
export function generatePrompt(
|
||||||
context: PreparedContext,
|
context: PreparedContext,
|
||||||
githubData: FetchDataResult,
|
githubData: FetchDataResult,
|
||||||
useCommitSigning: boolean,
|
|
||||||
): string {
|
): string {
|
||||||
const {
|
const {
|
||||||
contextData,
|
contextData,
|
||||||
@@ -552,9 +471,9 @@ ${sanitizeContent(context.directPrompt)}
|
|||||||
: ""
|
: ""
|
||||||
}
|
}
|
||||||
${`<comment_tool_info>
|
${`<comment_tool_info>
|
||||||
IMPORTANT: You have been provided with the mcp__github_comment__update_claude_comment tool to update your comment. This tool automatically handles both issue and PR comments.
|
IMPORTANT: You have been provided with the mcp__github_file_ops__update_claude_comment tool to update your comment. This tool automatically handles both issue and PR comments.
|
||||||
|
|
||||||
Tool usage example for mcp__github_comment__update_claude_comment:
|
Tool usage example for mcp__github_file_ops__update_claude_comment:
|
||||||
{
|
{
|
||||||
"body": "Your comment text here"
|
"body": "Your comment text here"
|
||||||
}
|
}
|
||||||
@@ -573,7 +492,7 @@ Follow these steps:
|
|||||||
1. Create a Todo List:
|
1. Create a Todo List:
|
||||||
- Use your GitHub comment to maintain a detailed task list based on the request.
|
- Use your GitHub comment to maintain a detailed task list based on the request.
|
||||||
- Format todos as a checklist (- [ ] for incomplete, - [x] for complete).
|
- Format todos as a checklist (- [ ] for incomplete, - [x] for complete).
|
||||||
- Update the comment using mcp__github_comment__update_claude_comment with each task completion.
|
- Update the comment using mcp__github_file_ops__update_claude_comment with each task completion.
|
||||||
|
|
||||||
2. Gather Context:
|
2. Gather Context:
|
||||||
- Analyze the pre-fetched data provided above.
|
- Analyze the pre-fetched data provided above.
|
||||||
@@ -604,16 +523,29 @@ ${context.directPrompt ? ` - DIRECT INSTRUCTION: A direct instruction was prov
|
|||||||
- Look for bugs, security issues, performance problems, and other issues
|
- Look for bugs, security issues, performance problems, and other issues
|
||||||
- Suggest improvements for readability and maintainability
|
- Suggest improvements for readability and maintainability
|
||||||
- Check for best practices and coding standards
|
- Check for best practices and coding standards
|
||||||
- Reference specific code sections with file paths and line numbers${eventData.isPR ? `\n - AFTER reading files and analyzing code, you MUST call mcp__github_comment__update_claude_comment to post your review` : ""}
|
- Reference specific code sections with file paths and line numbers${eventData.isPR ? "\n - AFTER reading files and analyzing code, you MUST call mcp__github_file_ops__update_claude_comment to post your review" : ""}
|
||||||
- Formulate a concise, technical, and helpful response based on the context.
|
- Formulate a concise, technical, and helpful response based on the context.
|
||||||
- Reference specific code with inline formatting or code blocks.
|
- Reference specific code with inline formatting or code blocks.
|
||||||
- Include relevant file paths and line numbers when applicable.
|
- Include relevant file paths and line numbers when applicable.
|
||||||
- ${eventData.isPR ? `IMPORTANT: Submit your review feedback by updating the Claude comment using mcp__github_comment__update_claude_comment. This will be displayed as your PR review.` : `Remember that this feedback must be posted to the GitHub comment using mcp__github_comment__update_claude_comment.`}
|
- ${eventData.isPR ? "IMPORTANT: Submit your review feedback by updating the Claude comment using mcp__github_file_ops__update_claude_comment. This will be displayed as your PR review." : "Remember that this feedback must be posted to the GitHub comment using mcp__github_file_ops__update_claude_comment."}
|
||||||
|
|
||||||
B. For Straightforward Changes:
|
B. For Straightforward Changes:
|
||||||
- Use file system tools to make the change locally.
|
- Use file system tools to make the change locally.
|
||||||
- If you discover related tasks (e.g., updating tests), add them to the todo list.
|
- If you discover related tasks (e.g., updating tests), add them to the todo list.
|
||||||
- Mark each subtask as completed as you progress.${getCommitInstructions(eventData, githubData, context, useCommitSigning)}
|
- Mark each subtask as completed as you progress.
|
||||||
|
${
|
||||||
|
eventData.isPR && !eventData.claudeBranch
|
||||||
|
? `
|
||||||
|
- Push directly using mcp__github_file_ops__commit_files to the existing branch (works for both new and existing files).
|
||||||
|
- Use mcp__github_file_ops__commit_files to commit files atomically in a single commit (supports single or multiple files).
|
||||||
|
- When pushing changes with this tool and the trigger user is not "Unknown", include a Co-authored-by trailer in the commit message.
|
||||||
|
- Use: "Co-authored-by: ${githubData.triggerDisplayName ?? context.triggerUsername} <${context.triggerUsername}@users.noreply.github.com>"`
|
||||||
|
: `
|
||||||
|
- You are already on the correct branch (${eventData.claudeBranch || "the PR branch"}). Do not create a new branch.
|
||||||
|
- Push changes directly to the current branch using mcp__github_file_ops__commit_files (works for both new and existing files)
|
||||||
|
- Use mcp__github_file_ops__commit_files to commit files atomically in a single commit (supports single or multiple files).
|
||||||
|
- When pushing changes and the trigger user is not "Unknown", include a Co-authored-by trailer in the commit message.
|
||||||
|
- Use: "Co-authored-by: ${githubData.triggerDisplayName ?? context.triggerUsername} <${context.triggerUsername}@users.noreply.github.com>"
|
||||||
${
|
${
|
||||||
eventData.claudeBranch
|
eventData.claudeBranch
|
||||||
? `- Provide a URL to create a PR manually in this format:
|
? `- Provide a URL to create a PR manually in this format:
|
||||||
@@ -631,6 +563,7 @@ ${context.directPrompt ? ` - DIRECT INSTRUCTION: A direct instruction was prov
|
|||||||
- The signature: "Generated with [Claude Code](https://claude.ai/code)"
|
- The signature: "Generated with [Claude Code](https://claude.ai/code)"
|
||||||
- Just include the markdown link with text "Create a PR" - do not add explanatory text before it like "You can create a PR using this link"`
|
- Just include the markdown link with text "Create a PR" - do not add explanatory text before it like "You can create a PR using this link"`
|
||||||
: ""
|
: ""
|
||||||
|
}`
|
||||||
}
|
}
|
||||||
|
|
||||||
C. For Complex Changes:
|
C. For Complex Changes:
|
||||||
@@ -646,31 +579,20 @@ ${context.directPrompt ? ` - DIRECT INSTRUCTION: A direct instruction was prov
|
|||||||
- Always update the GitHub comment to reflect the current todo state.
|
- Always update the GitHub comment to reflect the current todo state.
|
||||||
- When all todos are completed, remove the spinner and add a brief summary of what was accomplished, and what was not done.
|
- When all todos are completed, remove the spinner and add a brief summary of what was accomplished, and what was not done.
|
||||||
- Note: If you see previous Claude comments with headers like "**Claude finished @user's task**" followed by "---", do not include this in your comment. The system adds this automatically.
|
- Note: If you see previous Claude comments with headers like "**Claude finished @user's task**" followed by "---", do not include this in your comment. The system adds this automatically.
|
||||||
- If you changed any files locally, you must update them in the remote branch via ${useCommitSigning ? "mcp__github_file_ops__commit_files" : "git commands (add, commit, push)"} before saying that you're done.
|
- If you changed any files locally, you must update them in the remote branch via mcp__github_file_ops__commit_files before saying that you're done.
|
||||||
${eventData.claudeBranch ? `- If you created anything in your branch, your comment must include the PR URL with prefilled title and body mentioned above.` : ""}
|
${eventData.claudeBranch ? `- If you created anything in your branch, your comment must include the PR URL with prefilled title and body mentioned above.` : ""}
|
||||||
|
|
||||||
Important Notes:
|
Important Notes:
|
||||||
- All communication must happen through GitHub PR comments.
|
- All communication must happen through GitHub PR comments.
|
||||||
- Never create new comments. Only update the existing comment using mcp__github_comment__update_claude_comment.
|
- Never create new comments. Only update the existing comment using mcp__github_file_ops__update_claude_comment.
|
||||||
- This includes ALL responses: code reviews, answers to questions, progress updates, and final results.${eventData.isPR ? `\n- PR CRITICAL: After reading files and forming your response, you MUST post it by calling mcp__github_comment__update_claude_comment. Do NOT just respond with a normal response, the user will not see it.` : ""}
|
- This includes ALL responses: code reviews, answers to questions, progress updates, and final results.${eventData.isPR ? "\n- PR CRITICAL: After reading files and forming your response, you MUST post it by calling mcp__github_file_ops__update_claude_comment. Do NOT just respond with a normal response, the user will not see it." : ""}
|
||||||
- You communicate exclusively by editing your single comment - not through any other means.
|
- You communicate exclusively by editing your single comment - not through any other means.
|
||||||
- Use this spinner HTML when work is in progress: <img src="https://github.com/user-attachments/assets/5ac382c7-e004-429b-8e35-7feb3e8f9c6f" width="14px" height="14px" style="vertical-align: middle; margin-left: 4px;" />
|
- Use this spinner HTML when work is in progress: <img src="https://github.com/user-attachments/assets/5ac382c7-e004-429b-8e35-7feb3e8f9c6f" width="14px" height="14px" style="vertical-align: middle; margin-left: 4px;" />
|
||||||
${eventData.isPR && !eventData.claudeBranch ? `- Always push to the existing branch when triggered on a PR.` : `- IMPORTANT: You are already on the correct branch (${eventData.claudeBranch || "the created branch"}). Never create new branches when triggered on issues or closed/merged PRs.`}
|
${eventData.isPR && !eventData.claudeBranch ? `- Always push to the existing branch when triggered on a PR.` : `- IMPORTANT: You are already on the correct branch (${eventData.claudeBranch || "the created branch"}). Never create new branches when triggered on issues or closed/merged PRs.`}
|
||||||
${
|
- Use mcp__github_file_ops__commit_files for making commits (works for both new and existing files, single or multiple). Use mcp__github_file_ops__delete_files for deleting files (supports deleting single or multiple files atomically), or mcp__github__delete_file for deleting a single file. Edit files locally, and the tool will read the content from the same path on disk.
|
||||||
useCommitSigning
|
|
||||||
? `- Use mcp__github_file_ops__commit_files for making commits (works for both new and existing files, single or multiple). Use mcp__github_file_ops__delete_files for deleting files (supports deleting single or multiple files atomically), or mcp__github__delete_file for deleting a single file. Edit files locally, and the tool will read the content from the same path on disk.
|
|
||||||
Tool usage examples:
|
Tool usage examples:
|
||||||
- mcp__github_file_ops__commit_files: {"files": ["path/to/file1.js", "path/to/file2.py"], "message": "feat: add new feature"}
|
- mcp__github_file_ops__commit_files: {"files": ["path/to/file1.js", "path/to/file2.py"], "message": "feat: add new feature"}
|
||||||
- mcp__github_file_ops__delete_files: {"files": ["path/to/old.js"], "message": "chore: remove deprecated file"}`
|
- mcp__github_file_ops__delete_files: {"files": ["path/to/old.js"], "message": "chore: remove deprecated file"}
|
||||||
: `- Use git commands via the Bash tool for version control (you have access to specific git commands only):
|
|
||||||
- Stage files: Bash(git add <files>)
|
|
||||||
- Commit changes: Bash(git commit -m "<message>")
|
|
||||||
- Push to remote: Bash(git push origin <branch>) (NEVER force push)
|
|
||||||
- Delete files: Bash(git rm <files>) followed by commit and push
|
|
||||||
- Check status: Bash(git status)
|
|
||||||
- View diff: Bash(git diff)
|
|
||||||
- Configure git user: Bash(git config user.name "...") and Bash(git config user.email "...")`
|
|
||||||
}
|
|
||||||
- Display the todo list as a checklist in the GitHub comment and mark things off as you go.
|
- Display the todo list as a checklist in the GitHub comment and mark things off as you go.
|
||||||
- REPOSITORY SETUP INSTRUCTIONS: The repository's CLAUDE.md file(s) contain critical repo-specific setup instructions, development guidelines, and preferences. Always read and follow these files, particularly the root CLAUDE.md, as they provide essential context for working with the codebase effectively.
|
- REPOSITORY SETUP INSTRUCTIONS: The repository's CLAUDE.md file(s) contain critical repo-specific setup instructions, development guidelines, and preferences. Always read and follow these files, particularly the root CLAUDE.md, as they provide essential context for working with the codebase effectively.
|
||||||
- Use h3 headers (###) for section titles in your comments, not h1 headers (#).
|
- Use h3 headers (###) for section titles in your comments, not h1 headers (#).
|
||||||
@@ -741,11 +663,7 @@ export async function createPrompt(
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Generate the prompt
|
// Generate the prompt
|
||||||
const promptContent = generatePrompt(
|
const promptContent = generatePrompt(preparedContext, githubData);
|
||||||
preparedContext,
|
|
||||||
githubData,
|
|
||||||
context.inputs.useCommitSigning,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Log the final prompt to console
|
// Log the final prompt to console
|
||||||
console.log("===== FINAL PROMPT =====");
|
console.log("===== FINAL PROMPT =====");
|
||||||
@@ -765,7 +683,6 @@ export async function createPrompt(
|
|||||||
const allAllowedTools = buildAllowedToolsString(
|
const allAllowedTools = buildAllowedToolsString(
|
||||||
context.inputs.allowedTools,
|
context.inputs.allowedTools,
|
||||||
hasActionsReadPermission,
|
hasActionsReadPermission,
|
||||||
context.inputs.useCommitSigning,
|
|
||||||
);
|
);
|
||||||
const allDisallowedTools = buildDisallowedToolsString(
|
const allDisallowedTools = buildDisallowedToolsString(
|
||||||
context.inputs.disallowedTools,
|
context.inputs.disallowedTools,
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import { checkWritePermissions } from "../github/validation/permissions";
|
|||||||
import { createInitialComment } from "../github/operations/comments/create-initial";
|
import { createInitialComment } from "../github/operations/comments/create-initial";
|
||||||
import { setupBranch } from "../github/operations/branch";
|
import { setupBranch } from "../github/operations/branch";
|
||||||
import { updateTrackingComment } from "../github/operations/comments/update-with-branch";
|
import { updateTrackingComment } from "../github/operations/comments/update-with-branch";
|
||||||
import { configureGitAuth } from "../github/operations/git-config";
|
|
||||||
import { prepareMcpConfig } from "../mcp/install-mcp-server";
|
import { prepareMcpConfig } from "../mcp/install-mcp-server";
|
||||||
import { createPrompt } from "../create-prompt";
|
import { createPrompt } from "../create-prompt";
|
||||||
import { createOctokit } from "../github/api/client";
|
import { createOctokit } from "../github/api/client";
|
||||||
@@ -52,8 +51,7 @@ async function run() {
|
|||||||
await checkHumanActor(octokit.rest, context);
|
await checkHumanActor(octokit.rest, context);
|
||||||
|
|
||||||
// Step 6: Create initial tracking comment
|
// Step 6: Create initial tracking comment
|
||||||
const commentData = await createInitialComment(octokit.rest, context);
|
const commentId = await createInitialComment(octokit.rest, context);
|
||||||
const commentId = commentData.id;
|
|
||||||
|
|
||||||
// Step 7: Fetch GitHub data (once for both branch setup and prompt creation)
|
// Step 7: Fetch GitHub data (once for both branch setup and prompt creation)
|
||||||
const githubData = await fetchGitHubData({
|
const githubData = await fetchGitHubData({
|
||||||
@@ -77,17 +75,7 @@ async function run() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 10: Configure git authentication if not using commit signing
|
// Step 10: Create prompt file
|
||||||
if (!context.inputs.useCommitSigning) {
|
|
||||||
try {
|
|
||||||
await configureGitAuth(githubToken, context, commentData.user);
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Failed to configure git authentication:", error);
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Step 11: Create prompt file
|
|
||||||
await createPrompt(
|
await createPrompt(
|
||||||
commentId,
|
commentId,
|
||||||
branchInfo.baseBranch,
|
branchInfo.baseBranch,
|
||||||
@@ -96,7 +84,7 @@ async function run() {
|
|||||||
context,
|
context,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Step 12: Get MCP configuration
|
// Step 11: Get MCP configuration
|
||||||
const additionalMcpConfig = process.env.MCP_CONFIG || "";
|
const additionalMcpConfig = process.env.MCP_CONFIG || "";
|
||||||
const mcpConfig = await prepareMcpConfig({
|
const mcpConfig = await prepareMcpConfig({
|
||||||
githubToken,
|
githubToken,
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import {
|
|||||||
isPullRequestReviewCommentEvent,
|
isPullRequestReviewCommentEvent,
|
||||||
} from "../github/context";
|
} from "../github/context";
|
||||||
import { GITHUB_SERVER_URL } from "../github/api/config";
|
import { GITHUB_SERVER_URL } from "../github/api/config";
|
||||||
import { checkAndCommitOrDeleteBranch } from "../github/operations/branch-cleanup";
|
import { checkAndDeleteEmptyBranch } from "../github/operations/branch-cleanup";
|
||||||
import { updateClaudeComment } from "../github/operations/comments/update-claude-comment";
|
import { updateClaudeComment } from "../github/operations/comments/update-claude-comment";
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
@@ -88,16 +88,13 @@ async function run() {
|
|||||||
const currentBody = comment.body ?? "";
|
const currentBody = comment.body ?? "";
|
||||||
|
|
||||||
// Check if we need to add branch link for new branches
|
// Check if we need to add branch link for new branches
|
||||||
const useCommitSigning = process.env.USE_COMMIT_SIGNING === "true";
|
const { shouldDeleteBranch, branchLink } = await checkAndDeleteEmptyBranch(
|
||||||
const { shouldDeleteBranch, branchLink } =
|
octokit,
|
||||||
await checkAndCommitOrDeleteBranch(
|
owner,
|
||||||
octokit,
|
repo,
|
||||||
owner,
|
claudeBranch,
|
||||||
repo,
|
baseBranch,
|
||||||
claudeBranch,
|
);
|
||||||
baseBranch,
|
|
||||||
useCommitSigning,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Check if we need to add PR URL when we have a new branch
|
// Check if we need to add PR URL when we have a new branch
|
||||||
let prLink = "";
|
let prLink = "";
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ export type ParsedGitHubContext = {
|
|||||||
branchPrefix: string;
|
branchPrefix: string;
|
||||||
useStickyComment: boolean;
|
useStickyComment: boolean;
|
||||||
additionalPermissions: Map<string, string>;
|
additionalPermissions: Map<string, string>;
|
||||||
useCommitSigning: boolean;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -69,7 +68,6 @@ export function parseGitHubContext(): ParsedGitHubContext {
|
|||||||
additionalPermissions: parseAdditionalPermissions(
|
additionalPermissions: parseAdditionalPermissions(
|
||||||
process.env.ADDITIONAL_PERMISSIONS ?? "",
|
process.env.ADDITIONAL_PERMISSIONS ?? "",
|
||||||
),
|
),
|
||||||
useCommitSigning: process.env.USE_COMMIT_SIGNING === "true",
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,12 @@
|
|||||||
import type { Octokits } from "../api/client";
|
import type { Octokits } from "../api/client";
|
||||||
import { GITHUB_SERVER_URL } from "../api/config";
|
import { GITHUB_SERVER_URL } from "../api/config";
|
||||||
import { $ } from "bun";
|
|
||||||
|
|
||||||
export async function checkAndCommitOrDeleteBranch(
|
export async function checkAndDeleteEmptyBranch(
|
||||||
octokit: Octokits,
|
octokit: Octokits,
|
||||||
owner: string,
|
owner: string,
|
||||||
repo: string,
|
repo: string,
|
||||||
claudeBranch: string | undefined,
|
claudeBranch: string | undefined,
|
||||||
baseBranch: string,
|
baseBranch: string,
|
||||||
useCommitSigning: boolean,
|
|
||||||
): Promise<{ shouldDeleteBranch: boolean; branchLink: string }> {
|
): Promise<{ shouldDeleteBranch: boolean; branchLink: string }> {
|
||||||
let branchLink = "";
|
let branchLink = "";
|
||||||
let shouldDeleteBranch = false;
|
let shouldDeleteBranch = false;
|
||||||
@@ -23,58 +21,12 @@ export async function checkAndCommitOrDeleteBranch(
|
|||||||
basehead: `${baseBranch}...${claudeBranch}`,
|
basehead: `${baseBranch}...${claudeBranch}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
// If there are no commits, check for uncommitted changes if not using commit signing
|
// If there are no commits, mark branch for deletion
|
||||||
if (comparison.total_commits === 0) {
|
if (comparison.total_commits === 0) {
|
||||||
if (!useCommitSigning) {
|
console.log(
|
||||||
console.log(
|
`Branch ${claudeBranch} has no commits from Claude, will delete it`,
|
||||||
`Branch ${claudeBranch} has no commits from Claude, checking for uncommitted changes...`,
|
);
|
||||||
);
|
shouldDeleteBranch = true;
|
||||||
|
|
||||||
// Check for uncommitted changes using git status
|
|
||||||
try {
|
|
||||||
const gitStatus = await $`git status --porcelain`.quiet();
|
|
||||||
const hasUncommittedChanges =
|
|
||||||
gitStatus.stdout.toString().trim().length > 0;
|
|
||||||
|
|
||||||
if (hasUncommittedChanges) {
|
|
||||||
console.log("Found uncommitted changes, committing them...");
|
|
||||||
|
|
||||||
// Add all changes
|
|
||||||
await $`git add -A`;
|
|
||||||
|
|
||||||
// Commit with a descriptive message
|
|
||||||
const runId = process.env.GITHUB_RUN_ID || "unknown";
|
|
||||||
const commitMessage = `Auto-commit: Save uncommitted changes from Claude\n\nRun ID: ${runId}`;
|
|
||||||
await $`git commit -m ${commitMessage}`;
|
|
||||||
|
|
||||||
// Push the changes
|
|
||||||
await $`git push origin ${claudeBranch}`;
|
|
||||||
|
|
||||||
console.log(
|
|
||||||
"✅ Successfully committed and pushed uncommitted changes",
|
|
||||||
);
|
|
||||||
|
|
||||||
// Set branch link since we now have commits
|
|
||||||
const branchUrl = `${GITHUB_SERVER_URL}/${owner}/${repo}/tree/${claudeBranch}`;
|
|
||||||
branchLink = `\n[View branch](${branchUrl})`;
|
|
||||||
} else {
|
|
||||||
console.log(
|
|
||||||
"No uncommitted changes found, marking branch for deletion",
|
|
||||||
);
|
|
||||||
shouldDeleteBranch = true;
|
|
||||||
}
|
|
||||||
} catch (gitError) {
|
|
||||||
console.error("Error checking/committing changes:", gitError);
|
|
||||||
// If we can't check git status, assume the branch might have changes
|
|
||||||
const branchUrl = `${GITHUB_SERVER_URL}/${owner}/${repo}/tree/${claudeBranch}`;
|
|
||||||
branchLink = `\n[View branch](${branchUrl})`;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
console.log(
|
|
||||||
`Branch ${claudeBranch} has no commits from Claude, will delete it`,
|
|
||||||
);
|
|
||||||
shouldDeleteBranch = true;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// Only add branch link if there are commits
|
// Only add branch link if there are commits
|
||||||
const branchUrl = `${GITHUB_SERVER_URL}/${owner}/${repo}/tree/${claudeBranch}`;
|
const branchUrl = `${GITHUB_SERVER_URL}/${owner}/${repo}/tree/${claudeBranch}`;
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ import {
|
|||||||
} from "../../context";
|
} from "../../context";
|
||||||
import type { Octokit } from "@octokit/rest";
|
import type { Octokit } from "@octokit/rest";
|
||||||
|
|
||||||
const CLAUDE_APP_BOT_ID = 209825114;
|
|
||||||
|
|
||||||
export async function createInitialComment(
|
export async function createInitialComment(
|
||||||
octokit: Octokit,
|
octokit: Octokit,
|
||||||
context: ParsedGitHubContext,
|
context: ParsedGitHubContext,
|
||||||
@@ -38,15 +36,16 @@ export async function createInitialComment(
|
|||||||
repo,
|
repo,
|
||||||
issue_number: context.entityNumber,
|
issue_number: context.entityNumber,
|
||||||
});
|
});
|
||||||
const existingComment = comments.data.find((comment) => {
|
console.log("users");
|
||||||
const idMatch = comment.user?.id === CLAUDE_APP_BOT_ID;
|
comments.data.forEach((comment) => {
|
||||||
const botNameMatch =
|
console.log(comment.user);
|
||||||
comment.user?.type === "Bot" &&
|
|
||||||
comment.user?.login.toLowerCase().includes("claude");
|
|
||||||
const bodyMatch = comment.body === initialBody;
|
|
||||||
|
|
||||||
return idMatch || botNameMatch || bodyMatch;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const existingComment = comments.data.find(
|
||||||
|
(comment) =>
|
||||||
|
comment.user?.login.indexOf("claude[bot]") !== -1 ||
|
||||||
|
comment.body === initialBody,
|
||||||
|
);
|
||||||
if (existingComment) {
|
if (existingComment) {
|
||||||
response = await octokit.rest.issues.updateComment({
|
response = await octokit.rest.issues.updateComment({
|
||||||
owner,
|
owner,
|
||||||
@@ -86,7 +85,7 @@ export async function createInitialComment(
|
|||||||
const githubOutput = process.env.GITHUB_OUTPUT!;
|
const githubOutput = process.env.GITHUB_OUTPUT!;
|
||||||
appendFileSync(githubOutput, `claude_comment_id=${response.data.id}\n`);
|
appendFileSync(githubOutput, `claude_comment_id=${response.data.id}\n`);
|
||||||
console.log(`✅ Created initial comment with ID: ${response.data.id}`);
|
console.log(`✅ Created initial comment with ID: ${response.data.id}`);
|
||||||
return response.data;
|
return response.data.id;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error in initial comment:", error);
|
console.error("Error in initial comment:", error);
|
||||||
|
|
||||||
@@ -102,7 +101,7 @@ export async function createInitialComment(
|
|||||||
const githubOutput = process.env.GITHUB_OUTPUT!;
|
const githubOutput = process.env.GITHUB_OUTPUT!;
|
||||||
appendFileSync(githubOutput, `claude_comment_id=${response.data.id}\n`);
|
appendFileSync(githubOutput, `claude_comment_id=${response.data.id}\n`);
|
||||||
console.log(`✅ Created fallback comment with ID: ${response.data.id}`);
|
console.log(`✅ Created fallback comment with ID: ${response.data.id}`);
|
||||||
return response.data;
|
return response.data.id;
|
||||||
} catch (fallbackError) {
|
} catch (fallbackError) {
|
||||||
console.error("Error creating fallback comment:", fallbackError);
|
console.error("Error creating fallback comment:", fallbackError);
|
||||||
throw fallbackError;
|
throw fallbackError;
|
||||||
|
|||||||
@@ -1,56 +0,0 @@
|
|||||||
#!/usr/bin/env bun
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Configure git authentication for non-signing mode
|
|
||||||
* Sets up git user and authentication to work with GitHub App tokens
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { $ } from "bun";
|
|
||||||
import type { ParsedGitHubContext } from "../context";
|
|
||||||
import { GITHUB_SERVER_URL } from "../api/config";
|
|
||||||
|
|
||||||
type GitUser = {
|
|
||||||
login: string;
|
|
||||||
id: number;
|
|
||||||
};
|
|
||||||
|
|
||||||
export async function configureGitAuth(
|
|
||||||
githubToken: string,
|
|
||||||
context: ParsedGitHubContext,
|
|
||||||
user: GitUser | null,
|
|
||||||
) {
|
|
||||||
console.log("Configuring git authentication for non-signing mode");
|
|
||||||
|
|
||||||
// Configure git user based on the comment creator
|
|
||||||
console.log("Configuring git user...");
|
|
||||||
if (user) {
|
|
||||||
const botName = user.login;
|
|
||||||
const botId = user.id;
|
|
||||||
console.log(`Setting git user as ${botName}...`);
|
|
||||||
await $`git config user.name "${botName}"`;
|
|
||||||
await $`git config user.email "${botId}+${botName}@users.noreply.github.com"`;
|
|
||||||
console.log(`✓ Set git user as ${botName}`);
|
|
||||||
} else {
|
|
||||||
console.log("No user data in comment, using default bot user");
|
|
||||||
await $`git config user.name "github-actions[bot]"`;
|
|
||||||
await $`git config user.email "41898282+github-actions[bot]@users.noreply.github.com"`;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove the authorization header that actions/checkout sets
|
|
||||||
console.log("Removing existing git authentication headers...");
|
|
||||||
try {
|
|
||||||
await $`git config --unset-all http.${GITHUB_SERVER_URL}/.extraheader`;
|
|
||||||
console.log("✓ Removed existing authentication headers");
|
|
||||||
} catch (e) {
|
|
||||||
console.log("No existing authentication headers to remove");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update the remote URL to include the token for authentication
|
|
||||||
console.log("Updating remote URL with authentication...");
|
|
||||||
const serverUrl = new URL(GITHUB_SERVER_URL);
|
|
||||||
const remoteUrl = `https://x-access-token:${githubToken}@${serverUrl.host}/${context.repository.owner}/${context.repository.repo}.git`;
|
|
||||||
await $`git remote set-url origin ${remoteUrl}`;
|
|
||||||
console.log("✓ Updated remote URL with authentication token");
|
|
||||||
|
|
||||||
console.log("Git authentication configured successfully");
|
|
||||||
}
|
|
||||||
@@ -1,98 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
// GitHub Comment MCP Server - Minimal server that only provides comment update functionality
|
|
||||||
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
||||||
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
||||||
import { z } from "zod";
|
|
||||||
import { GITHUB_API_URL } from "../github/api/config";
|
|
||||||
import { Octokit } from "@octokit/rest";
|
|
||||||
import { updateClaudeComment } from "../github/operations/comments/update-claude-comment";
|
|
||||||
|
|
||||||
// Get repository information from environment variables
|
|
||||||
const REPO_OWNER = process.env.REPO_OWNER;
|
|
||||||
const REPO_NAME = process.env.REPO_NAME;
|
|
||||||
|
|
||||||
if (!REPO_OWNER || !REPO_NAME) {
|
|
||||||
console.error(
|
|
||||||
"Error: REPO_OWNER and REPO_NAME environment variables are required",
|
|
||||||
);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
const server = new McpServer({
|
|
||||||
name: "GitHub Comment Server",
|
|
||||||
version: "0.0.1",
|
|
||||||
});
|
|
||||||
|
|
||||||
server.tool(
|
|
||||||
"update_claude_comment",
|
|
||||||
"Update the Claude comment with progress and results (automatically handles both issue and PR comments)",
|
|
||||||
{
|
|
||||||
body: z.string().describe("The updated comment content"),
|
|
||||||
},
|
|
||||||
async ({ body }) => {
|
|
||||||
try {
|
|
||||||
const githubToken = process.env.GITHUB_TOKEN;
|
|
||||||
const claudeCommentId = process.env.CLAUDE_COMMENT_ID;
|
|
||||||
const eventName = process.env.GITHUB_EVENT_NAME;
|
|
||||||
|
|
||||||
if (!githubToken) {
|
|
||||||
throw new Error("GITHUB_TOKEN environment variable is required");
|
|
||||||
}
|
|
||||||
if (!claudeCommentId) {
|
|
||||||
throw new Error("CLAUDE_COMMENT_ID environment variable is required");
|
|
||||||
}
|
|
||||||
|
|
||||||
const owner = REPO_OWNER;
|
|
||||||
const repo = REPO_NAME;
|
|
||||||
const commentId = parseInt(claudeCommentId, 10);
|
|
||||||
|
|
||||||
const octokit = new Octokit({
|
|
||||||
auth: githubToken,
|
|
||||||
baseUrl: GITHUB_API_URL,
|
|
||||||
});
|
|
||||||
|
|
||||||
const isPullRequestReviewComment =
|
|
||||||
eventName === "pull_request_review_comment";
|
|
||||||
|
|
||||||
const result = await updateClaudeComment(octokit, {
|
|
||||||
owner,
|
|
||||||
repo,
|
|
||||||
commentId,
|
|
||||||
body,
|
|
||||||
isPullRequestReviewComment,
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
|
||||||
content: [
|
|
||||||
{
|
|
||||||
type: "text",
|
|
||||||
text: JSON.stringify(result, null, 2),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
} catch (error) {
|
|
||||||
const errorMessage =
|
|
||||||
error instanceof Error ? error.message : String(error);
|
|
||||||
return {
|
|
||||||
content: [
|
|
||||||
{
|
|
||||||
type: "text",
|
|
||||||
text: `Error: ${errorMessage}`,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
error: errorMessage,
|
|
||||||
isError: true,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
async function runServer() {
|
|
||||||
const transport = new StdioServerTransport();
|
|
||||||
await server.connect(transport);
|
|
||||||
process.on("exit", () => {
|
|
||||||
server.close();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
runServer().catch(console.error);
|
|
||||||
@@ -7,6 +7,8 @@ import { readFile } from "fs/promises";
|
|||||||
import { join } from "path";
|
import { join } from "path";
|
||||||
import fetch from "node-fetch";
|
import fetch from "node-fetch";
|
||||||
import { GITHUB_API_URL } from "../github/api/config";
|
import { GITHUB_API_URL } from "../github/api/config";
|
||||||
|
import { Octokit } from "@octokit/rest";
|
||||||
|
import { updateClaudeComment } from "../github/operations/comments/update-claude-comment";
|
||||||
import { retryWithBackoff } from "../utils/retry";
|
import { retryWithBackoff } from "../utils/retry";
|
||||||
|
|
||||||
type GitHubRef = {
|
type GitHubRef = {
|
||||||
@@ -533,6 +535,70 @@ server.tool(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
server.tool(
|
||||||
|
"update_claude_comment",
|
||||||
|
"Update the Claude comment with progress and results (automatically handles both issue and PR comments)",
|
||||||
|
{
|
||||||
|
body: z.string().describe("The updated comment content"),
|
||||||
|
},
|
||||||
|
async ({ body }) => {
|
||||||
|
try {
|
||||||
|
const githubToken = process.env.GITHUB_TOKEN;
|
||||||
|
const claudeCommentId = process.env.CLAUDE_COMMENT_ID;
|
||||||
|
const eventName = process.env.GITHUB_EVENT_NAME;
|
||||||
|
|
||||||
|
if (!githubToken) {
|
||||||
|
throw new Error("GITHUB_TOKEN environment variable is required");
|
||||||
|
}
|
||||||
|
if (!claudeCommentId) {
|
||||||
|
throw new Error("CLAUDE_COMMENT_ID environment variable is required");
|
||||||
|
}
|
||||||
|
|
||||||
|
const owner = REPO_OWNER;
|
||||||
|
const repo = REPO_NAME;
|
||||||
|
const commentId = parseInt(claudeCommentId, 10);
|
||||||
|
|
||||||
|
const octokit = new Octokit({
|
||||||
|
auth: githubToken,
|
||||||
|
baseUrl: GITHUB_API_URL,
|
||||||
|
});
|
||||||
|
|
||||||
|
const isPullRequestReviewComment =
|
||||||
|
eventName === "pull_request_review_comment";
|
||||||
|
|
||||||
|
const result = await updateClaudeComment(octokit, {
|
||||||
|
owner,
|
||||||
|
repo,
|
||||||
|
commentId,
|
||||||
|
body,
|
||||||
|
isPullRequestReviewComment,
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
content: [
|
||||||
|
{
|
||||||
|
type: "text",
|
||||||
|
text: JSON.stringify(result, null, 2),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
const errorMessage =
|
||||||
|
error instanceof Error ? error.message : String(error);
|
||||||
|
return {
|
||||||
|
content: [
|
||||||
|
{
|
||||||
|
type: "text",
|
||||||
|
text: `Error: ${errorMessage}`,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
error: errorMessage,
|
||||||
|
isError: true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
async function runServer() {
|
async function runServer() {
|
||||||
const transport = new StdioServerTransport();
|
const transport = new StdioServerTransport();
|
||||||
await server.connect(transport);
|
await server.connect(transport);
|
||||||
|
|||||||
@@ -67,47 +67,28 @@ export async function prepareMcpConfig(
|
|||||||
);
|
);
|
||||||
|
|
||||||
const baseMcpConfig: { mcpServers: Record<string, unknown> } = {
|
const baseMcpConfig: { mcpServers: Record<string, unknown> } = {
|
||||||
mcpServers: {},
|
mcpServers: {
|
||||||
};
|
github_file_ops: {
|
||||||
|
command: "bun",
|
||||||
// Always include comment server for updating Claude comments
|
args: [
|
||||||
baseMcpConfig.mcpServers.github_comment = {
|
"run",
|
||||||
command: "bun",
|
`${process.env.GITHUB_ACTION_PATH}/src/mcp/github-file-ops-server.ts`,
|
||||||
args: [
|
],
|
||||||
"run",
|
env: {
|
||||||
`${process.env.GITHUB_ACTION_PATH}/src/mcp/github-comment-server.ts`,
|
GITHUB_TOKEN: githubToken,
|
||||||
],
|
REPO_OWNER: owner,
|
||||||
env: {
|
REPO_NAME: repo,
|
||||||
GITHUB_TOKEN: githubToken,
|
BRANCH_NAME: branch,
|
||||||
REPO_OWNER: owner,
|
REPO_DIR: process.env.GITHUB_WORKSPACE || process.cwd(),
|
||||||
REPO_NAME: repo,
|
...(claudeCommentId && { CLAUDE_COMMENT_ID: claudeCommentId }),
|
||||||
...(claudeCommentId && { CLAUDE_COMMENT_ID: claudeCommentId }),
|
GITHUB_EVENT_NAME: process.env.GITHUB_EVENT_NAME || "",
|
||||||
GITHUB_EVENT_NAME: process.env.GITHUB_EVENT_NAME || "",
|
IS_PR: process.env.IS_PR || "false",
|
||||||
GITHUB_API_URL: GITHUB_API_URL,
|
GITHUB_API_URL: GITHUB_API_URL,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
// Include file ops server when commit signing is enabled
|
|
||||||
if (context.inputs.useCommitSigning) {
|
|
||||||
baseMcpConfig.mcpServers.github_file_ops = {
|
|
||||||
command: "bun",
|
|
||||||
args: [
|
|
||||||
"run",
|
|
||||||
`${process.env.GITHUB_ACTION_PATH}/src/mcp/github-file-ops-server.ts`,
|
|
||||||
],
|
|
||||||
env: {
|
|
||||||
GITHUB_TOKEN: githubToken,
|
|
||||||
REPO_OWNER: owner,
|
|
||||||
REPO_NAME: repo,
|
|
||||||
BRANCH_NAME: branch,
|
|
||||||
REPO_DIR: process.env.GITHUB_WORKSPACE || process.cwd(),
|
|
||||||
GITHUB_EVENT_NAME: process.env.GITHUB_EVENT_NAME || "",
|
|
||||||
IS_PR: process.env.IS_PR || "false",
|
|
||||||
GITHUB_API_URL: GITHUB_API_URL,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only add CI server if we have actions:read permission and we're in a PR context
|
// Only add CI server if we have actions:read permission and we're in a PR context
|
||||||
const hasActionsReadPermission =
|
const hasActionsReadPermission =
|
||||||
context.inputs.additionalPermissions.get("actions") === "read";
|
context.inputs.additionalPermissions.get("actions") === "read";
|
||||||
@@ -153,7 +134,7 @@ export async function prepareMcpConfig(
|
|||||||
"--rm",
|
"--rm",
|
||||||
"-e",
|
"-e",
|
||||||
"GITHUB_PERSONAL_ACCESS_TOKEN",
|
"GITHUB_PERSONAL_ACCESS_TOKEN",
|
||||||
"ghcr.io/github/github-mcp-server:sha-721fd3e", // https://github.com/github/github-mcp-server/releases/tag/v0.6.0
|
"ghcr.io/github/github-mcp-server:sha-6d69797", // https://github.com/github/github-mcp-server/releases/tag/v0.5.0
|
||||||
],
|
],
|
||||||
env: {
|
env: {
|
||||||
GITHUB_PERSONAL_ACCESS_TOKEN: githubToken,
|
GITHUB_PERSONAL_ACCESS_TOKEN: githubToken,
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { describe, test, expect, beforeEach, afterEach, spyOn } from "bun:test";
|
import { describe, test, expect, beforeEach, afterEach, spyOn } from "bun:test";
|
||||||
import { checkAndCommitOrDeleteBranch } from "../src/github/operations/branch-cleanup";
|
import { checkAndDeleteEmptyBranch } from "../src/github/operations/branch-cleanup";
|
||||||
import type { Octokits } from "../src/github/api/client";
|
import type { Octokits } from "../src/github/api/client";
|
||||||
import { GITHUB_SERVER_URL } from "../src/github/api/config";
|
import { GITHUB_SERVER_URL } from "../src/github/api/config";
|
||||||
|
|
||||||
describe("checkAndCommitOrDeleteBranch", () => {
|
describe("checkAndDeleteEmptyBranch", () => {
|
||||||
let consoleLogSpy: any;
|
let consoleLogSpy: any;
|
||||||
let consoleErrorSpy: any;
|
let consoleErrorSpy: any;
|
||||||
|
|
||||||
@@ -43,13 +43,12 @@ describe("checkAndCommitOrDeleteBranch", () => {
|
|||||||
|
|
||||||
test("should return no branch link and not delete when branch is undefined", async () => {
|
test("should return no branch link and not delete when branch is undefined", async () => {
|
||||||
const mockOctokit = createMockOctokit();
|
const mockOctokit = createMockOctokit();
|
||||||
const result = await checkAndCommitOrDeleteBranch(
|
const result = await checkAndDeleteEmptyBranch(
|
||||||
mockOctokit,
|
mockOctokit,
|
||||||
"owner",
|
"owner",
|
||||||
"repo",
|
"repo",
|
||||||
undefined,
|
undefined,
|
||||||
"main",
|
"main",
|
||||||
false,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(result.shouldDeleteBranch).toBe(false);
|
expect(result.shouldDeleteBranch).toBe(false);
|
||||||
@@ -57,15 +56,14 @@ describe("checkAndCommitOrDeleteBranch", () => {
|
|||||||
expect(consoleLogSpy).not.toHaveBeenCalled();
|
expect(consoleLogSpy).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should mark branch for deletion when commit signing is enabled and no commits", async () => {
|
test("should delete branch and return no link when branch has no commits", async () => {
|
||||||
const mockOctokit = createMockOctokit({ total_commits: 0 });
|
const mockOctokit = createMockOctokit({ total_commits: 0 });
|
||||||
const result = await checkAndCommitOrDeleteBranch(
|
const result = await checkAndDeleteEmptyBranch(
|
||||||
mockOctokit,
|
mockOctokit,
|
||||||
"owner",
|
"owner",
|
||||||
"repo",
|
"repo",
|
||||||
"claude/issue-123-20240101_123456",
|
"claude/issue-123-20240101_123456",
|
||||||
"main",
|
"main",
|
||||||
true, // commit signing enabled
|
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(result.shouldDeleteBranch).toBe(true);
|
expect(result.shouldDeleteBranch).toBe(true);
|
||||||
@@ -73,17 +71,19 @@ describe("checkAndCommitOrDeleteBranch", () => {
|
|||||||
expect(consoleLogSpy).toHaveBeenCalledWith(
|
expect(consoleLogSpy).toHaveBeenCalledWith(
|
||||||
"Branch claude/issue-123-20240101_123456 has no commits from Claude, will delete it",
|
"Branch claude/issue-123-20240101_123456 has no commits from Claude, will delete it",
|
||||||
);
|
);
|
||||||
|
expect(consoleLogSpy).toHaveBeenCalledWith(
|
||||||
|
"✅ Deleted empty branch: claude/issue-123-20240101_123456",
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should not delete branch and return link when branch has commits", async () => {
|
test("should not delete branch and return link when branch has commits", async () => {
|
||||||
const mockOctokit = createMockOctokit({ total_commits: 3 });
|
const mockOctokit = createMockOctokit({ total_commits: 3 });
|
||||||
const result = await checkAndCommitOrDeleteBranch(
|
const result = await checkAndDeleteEmptyBranch(
|
||||||
mockOctokit,
|
mockOctokit,
|
||||||
"owner",
|
"owner",
|
||||||
"repo",
|
"repo",
|
||||||
"claude/issue-123-20240101_123456",
|
"claude/issue-123-20240101_123456",
|
||||||
"main",
|
"main",
|
||||||
false,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(result.shouldDeleteBranch).toBe(false);
|
expect(result.shouldDeleteBranch).toBe(false);
|
||||||
@@ -109,13 +109,12 @@ describe("checkAndCommitOrDeleteBranch", () => {
|
|||||||
},
|
},
|
||||||
} as any as Octokits;
|
} as any as Octokits;
|
||||||
|
|
||||||
const result = await checkAndCommitOrDeleteBranch(
|
const result = await checkAndDeleteEmptyBranch(
|
||||||
mockOctokit,
|
mockOctokit,
|
||||||
"owner",
|
"owner",
|
||||||
"repo",
|
"repo",
|
||||||
"claude/issue-123-20240101_123456",
|
"claude/issue-123-20240101_123456",
|
||||||
"main",
|
"main",
|
||||||
false,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(result.shouldDeleteBranch).toBe(false);
|
expect(result.shouldDeleteBranch).toBe(false);
|
||||||
@@ -132,13 +131,12 @@ describe("checkAndCommitOrDeleteBranch", () => {
|
|||||||
const deleteError = new Error("Delete failed");
|
const deleteError = new Error("Delete failed");
|
||||||
const mockOctokit = createMockOctokit({ total_commits: 0 }, deleteError);
|
const mockOctokit = createMockOctokit({ total_commits: 0 }, deleteError);
|
||||||
|
|
||||||
const result = await checkAndCommitOrDeleteBranch(
|
const result = await checkAndDeleteEmptyBranch(
|
||||||
mockOctokit,
|
mockOctokit,
|
||||||
"owner",
|
"owner",
|
||||||
"repo",
|
"repo",
|
||||||
"claude/issue-123-20240101_123456",
|
"claude/issue-123-20240101_123456",
|
||||||
"main",
|
"main",
|
||||||
true, // commit signing enabled - will try to delete
|
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(result.shouldDeleteBranch).toBe(true);
|
expect(result.shouldDeleteBranch).toBe(true);
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ describe("generatePrompt", () => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const prompt = generatePrompt(envVars, mockGitHubData, false);
|
const prompt = generatePrompt(envVars, mockGitHubData);
|
||||||
|
|
||||||
expect(prompt).toContain("You are Claude, an AI assistant");
|
expect(prompt).toContain("You are Claude, an AI assistant");
|
||||||
expect(prompt).toContain("<event_type>GENERAL_COMMENT</event_type>");
|
expect(prompt).toContain("<event_type>GENERAL_COMMENT</event_type>");
|
||||||
@@ -161,7 +161,7 @@ describe("generatePrompt", () => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const prompt = generatePrompt(envVars, mockGitHubData, false);
|
const prompt = generatePrompt(envVars, mockGitHubData);
|
||||||
|
|
||||||
expect(prompt).toContain("<event_type>PR_REVIEW</event_type>");
|
expect(prompt).toContain("<event_type>PR_REVIEW</event_type>");
|
||||||
expect(prompt).toContain("<is_pr>true</is_pr>");
|
expect(prompt).toContain("<is_pr>true</is_pr>");
|
||||||
@@ -187,7 +187,7 @@ describe("generatePrompt", () => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const prompt = generatePrompt(envVars, mockGitHubData, false);
|
const prompt = generatePrompt(envVars, mockGitHubData);
|
||||||
|
|
||||||
expect(prompt).toContain("<event_type>ISSUE_CREATED</event_type>");
|
expect(prompt).toContain("<event_type>ISSUE_CREATED</event_type>");
|
||||||
expect(prompt).toContain(
|
expect(prompt).toContain(
|
||||||
@@ -215,7 +215,7 @@ describe("generatePrompt", () => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const prompt = generatePrompt(envVars, mockGitHubData, false);
|
const prompt = generatePrompt(envVars, mockGitHubData);
|
||||||
|
|
||||||
expect(prompt).toContain("<event_type>ISSUE_ASSIGNED</event_type>");
|
expect(prompt).toContain("<event_type>ISSUE_ASSIGNED</event_type>");
|
||||||
expect(prompt).toContain(
|
expect(prompt).toContain(
|
||||||
@@ -242,7 +242,7 @@ describe("generatePrompt", () => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const prompt = generatePrompt(envVars, mockGitHubData, false);
|
const prompt = generatePrompt(envVars, mockGitHubData);
|
||||||
|
|
||||||
expect(prompt).toContain("<event_type>ISSUE_LABELED</event_type>");
|
expect(prompt).toContain("<event_type>ISSUE_LABELED</event_type>");
|
||||||
expect(prompt).toContain(
|
expect(prompt).toContain(
|
||||||
@@ -269,7 +269,7 @@ describe("generatePrompt", () => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const prompt = generatePrompt(envVars, mockGitHubData, false);
|
const prompt = generatePrompt(envVars, mockGitHubData);
|
||||||
|
|
||||||
expect(prompt).toContain("<direct_prompt>");
|
expect(prompt).toContain("<direct_prompt>");
|
||||||
expect(prompt).toContain("Fix the bug in the login form");
|
expect(prompt).toContain("Fix the bug in the login form");
|
||||||
@@ -292,7 +292,7 @@ describe("generatePrompt", () => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const prompt = generatePrompt(envVars, mockGitHubData, false);
|
const prompt = generatePrompt(envVars, mockGitHubData);
|
||||||
|
|
||||||
expect(prompt).toContain("<event_type>PULL_REQUEST</event_type>");
|
expect(prompt).toContain("<event_type>PULL_REQUEST</event_type>");
|
||||||
expect(prompt).toContain("<is_pr>true</is_pr>");
|
expect(prompt).toContain("<is_pr>true</is_pr>");
|
||||||
@@ -317,7 +317,7 @@ describe("generatePrompt", () => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const prompt = generatePrompt(envVars, mockGitHubData, false);
|
const prompt = generatePrompt(envVars, mockGitHubData);
|
||||||
|
|
||||||
expect(prompt).toContain("CUSTOM INSTRUCTIONS:\nAlways use TypeScript");
|
expect(prompt).toContain("CUSTOM INSTRUCTIONS:\nAlways use TypeScript");
|
||||||
});
|
});
|
||||||
@@ -339,12 +339,11 @@ describe("generatePrompt", () => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const prompt = generatePrompt(envVars, mockGitHubData, false);
|
const prompt = generatePrompt(envVars, mockGitHubData);
|
||||||
|
|
||||||
expect(prompt).toContain("<trigger_username>johndoe</trigger_username>");
|
expect(prompt).toContain("<trigger_username>johndoe</trigger_username>");
|
||||||
// With commit signing disabled, co-author info appears in git commit instructions
|
|
||||||
expect(prompt).toContain(
|
expect(prompt).toContain(
|
||||||
"Co-authored-by: johndoe <johndoe@users.noreply.github.com>",
|
'Use: "Co-authored-by: johndoe <johndoe@users.noreply.github.com>"',
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -361,10 +360,12 @@ describe("generatePrompt", () => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const prompt = generatePrompt(envVars, mockGitHubData, false);
|
const prompt = generatePrompt(envVars, mockGitHubData);
|
||||||
|
|
||||||
// Should contain PR-specific instructions (git commands when not using signing)
|
// Should contain PR-specific instructions
|
||||||
expect(prompt).toContain("git push");
|
expect(prompt).toContain(
|
||||||
|
"Push directly using mcp__github_file_ops__commit_files to the existing branch",
|
||||||
|
);
|
||||||
expect(prompt).toContain(
|
expect(prompt).toContain(
|
||||||
"Always push to the existing branch when triggered on a PR",
|
"Always push to the existing branch when triggered on a PR",
|
||||||
);
|
);
|
||||||
@@ -392,7 +393,7 @@ describe("generatePrompt", () => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const prompt = generatePrompt(envVars, mockGitHubData, false);
|
const prompt = generatePrompt(envVars, mockGitHubData);
|
||||||
|
|
||||||
// Should contain Issue-specific instructions
|
// Should contain Issue-specific instructions
|
||||||
expect(prompt).toContain(
|
expect(prompt).toContain(
|
||||||
@@ -431,7 +432,7 @@ describe("generatePrompt", () => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const prompt = generatePrompt(envVars, mockGitHubData, false);
|
const prompt = generatePrompt(envVars, mockGitHubData);
|
||||||
|
|
||||||
// Should contain the actual branch name with timestamp
|
// Should contain the actual branch name with timestamp
|
||||||
expect(prompt).toContain(
|
expect(prompt).toContain(
|
||||||
@@ -461,7 +462,7 @@ describe("generatePrompt", () => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const prompt = generatePrompt(envVars, mockGitHubData, false);
|
const prompt = generatePrompt(envVars, mockGitHubData);
|
||||||
|
|
||||||
// Should contain branch-specific instructions like issues
|
// Should contain branch-specific instructions like issues
|
||||||
expect(prompt).toContain(
|
expect(prompt).toContain(
|
||||||
@@ -499,10 +500,12 @@ describe("generatePrompt", () => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const prompt = generatePrompt(envVars, mockGitHubData, false);
|
const prompt = generatePrompt(envVars, mockGitHubData);
|
||||||
|
|
||||||
// Should contain open PR instructions (git commands when not using signing)
|
// Should contain open PR instructions
|
||||||
expect(prompt).toContain("git push");
|
expect(prompt).toContain(
|
||||||
|
"Push directly using mcp__github_file_ops__commit_files to the existing branch",
|
||||||
|
);
|
||||||
expect(prompt).toContain(
|
expect(prompt).toContain(
|
||||||
"Always push to the existing branch when triggered on a PR",
|
"Always push to the existing branch when triggered on a PR",
|
||||||
);
|
);
|
||||||
@@ -530,7 +533,7 @@ describe("generatePrompt", () => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const prompt = generatePrompt(envVars, mockGitHubData, false);
|
const prompt = generatePrompt(envVars, mockGitHubData);
|
||||||
|
|
||||||
// Should contain new branch instructions
|
// Should contain new branch instructions
|
||||||
expect(prompt).toContain(
|
expect(prompt).toContain(
|
||||||
@@ -558,7 +561,7 @@ describe("generatePrompt", () => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const prompt = generatePrompt(envVars, mockGitHubData, false);
|
const prompt = generatePrompt(envVars, mockGitHubData);
|
||||||
|
|
||||||
// Should contain new branch instructions
|
// Should contain new branch instructions
|
||||||
expect(prompt).toContain(
|
expect(prompt).toContain(
|
||||||
@@ -586,7 +589,7 @@ describe("generatePrompt", () => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const prompt = generatePrompt(envVars, mockGitHubData, false);
|
const prompt = generatePrompt(envVars, mockGitHubData);
|
||||||
|
|
||||||
// Should contain new branch instructions
|
// Should contain new branch instructions
|
||||||
expect(prompt).toContain(
|
expect(prompt).toContain(
|
||||||
@@ -595,61 +598,6 @@ describe("generatePrompt", () => {
|
|||||||
expect(prompt).toContain("Create a PR](https://github.com/");
|
expect(prompt).toContain("Create a PR](https://github.com/");
|
||||||
expect(prompt).toContain("Reference to the original PR");
|
expect(prompt).toContain("Reference to the original PR");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should include git commands when useCommitSigning is false", () => {
|
|
||||||
const envVars: PreparedContext = {
|
|
||||||
repository: "owner/repo",
|
|
||||||
claudeCommentId: "12345",
|
|
||||||
triggerPhrase: "@claude",
|
|
||||||
eventData: {
|
|
||||||
eventName: "issue_comment",
|
|
||||||
commentId: "67890",
|
|
||||||
isPR: true,
|
|
||||||
prNumber: "123",
|
|
||||||
commentBody: "@claude fix the bug",
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const prompt = generatePrompt(envVars, mockGitHubData, false);
|
|
||||||
|
|
||||||
// Should have git command instructions
|
|
||||||
expect(prompt).toContain("Use git commands via the Bash tool");
|
|
||||||
expect(prompt).toContain("git add");
|
|
||||||
expect(prompt).toContain("git commit");
|
|
||||||
expect(prompt).toContain("git push");
|
|
||||||
|
|
||||||
// Should use the minimal comment tool
|
|
||||||
expect(prompt).toContain("mcp__github_comment__update_claude_comment");
|
|
||||||
|
|
||||||
// Should not have commit signing tool references
|
|
||||||
expect(prompt).not.toContain("mcp__github_file_ops__commit_files");
|
|
||||||
});
|
|
||||||
|
|
||||||
test("should include commit signing tools when useCommitSigning is true", () => {
|
|
||||||
const envVars: PreparedContext = {
|
|
||||||
repository: "owner/repo",
|
|
||||||
claudeCommentId: "12345",
|
|
||||||
triggerPhrase: "@claude",
|
|
||||||
eventData: {
|
|
||||||
eventName: "issue_comment",
|
|
||||||
commentId: "67890",
|
|
||||||
isPR: true,
|
|
||||||
prNumber: "123",
|
|
||||||
commentBody: "@claude fix the bug",
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const prompt = generatePrompt(envVars, mockGitHubData, true);
|
|
||||||
|
|
||||||
// Should have commit signing tool instructions
|
|
||||||
expect(prompt).toContain("mcp__github_file_ops__commit_files");
|
|
||||||
expect(prompt).toContain("mcp__github_file_ops__delete_files");
|
|
||||||
// Comment tool should always be from comment server, not file ops
|
|
||||||
expect(prompt).toContain("mcp__github_comment__update_claude_comment");
|
|
||||||
|
|
||||||
// Should not have git command instructions
|
|
||||||
expect(prompt).not.toContain("Use git commands via the Bash tool");
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("getEventTypeAndContext", () => {
|
describe("getEventTypeAndContext", () => {
|
||||||
@@ -741,7 +689,7 @@ describe("getEventTypeAndContext", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("buildAllowedToolsString", () => {
|
describe("buildAllowedToolsString", () => {
|
||||||
test("should return correct tools for regular events (default no signing)", () => {
|
test("should return issue comment tool for regular events", () => {
|
||||||
const result = buildAllowedToolsString();
|
const result = buildAllowedToolsString();
|
||||||
|
|
||||||
// The base tools should be in the result
|
// The base tools should be in the result
|
||||||
@@ -751,20 +699,15 @@ describe("buildAllowedToolsString", () => {
|
|||||||
expect(result).toContain("LS");
|
expect(result).toContain("LS");
|
||||||
expect(result).toContain("Read");
|
expect(result).toContain("Read");
|
||||||
expect(result).toContain("Write");
|
expect(result).toContain("Write");
|
||||||
|
expect(result).toContain("mcp__github_file_ops__update_claude_comment");
|
||||||
// Default is no commit signing, so should have specific Bash git commands
|
expect(result).not.toContain("mcp__github__update_issue_comment");
|
||||||
expect(result).toContain("Bash(git add:*)");
|
expect(result).not.toContain("mcp__github__update_pull_request_comment");
|
||||||
expect(result).toContain("Bash(git commit:*)");
|
expect(result).toContain("mcp__github_file_ops__commit_files");
|
||||||
expect(result).toContain("Bash(git push:*)");
|
expect(result).toContain("mcp__github_file_ops__delete_files");
|
||||||
expect(result).toContain("mcp__github_comment__update_claude_comment");
|
|
||||||
|
|
||||||
// Should not have commit signing tools
|
|
||||||
expect(result).not.toContain("mcp__github_file_ops__commit_files");
|
|
||||||
expect(result).not.toContain("mcp__github_file_ops__delete_files");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should return correct tools with default parameters", () => {
|
test("should return PR comment tool for inline review comments", () => {
|
||||||
const result = buildAllowedToolsString([], false, false);
|
const result = buildAllowedToolsString();
|
||||||
|
|
||||||
// The base tools should be in the result
|
// The base tools should be in the result
|
||||||
expect(result).toContain("Edit");
|
expect(result).toContain("Edit");
|
||||||
@@ -773,15 +716,11 @@ describe("buildAllowedToolsString", () => {
|
|||||||
expect(result).toContain("LS");
|
expect(result).toContain("LS");
|
||||||
expect(result).toContain("Read");
|
expect(result).toContain("Read");
|
||||||
expect(result).toContain("Write");
|
expect(result).toContain("Write");
|
||||||
|
expect(result).toContain("mcp__github_file_ops__update_claude_comment");
|
||||||
// Should have specific Bash git commands for non-signing mode
|
expect(result).not.toContain("mcp__github__update_issue_comment");
|
||||||
expect(result).toContain("Bash(git add:*)");
|
expect(result).not.toContain("mcp__github__update_pull_request_comment");
|
||||||
expect(result).toContain("Bash(git commit:*)");
|
expect(result).toContain("mcp__github_file_ops__commit_files");
|
||||||
expect(result).toContain("mcp__github_comment__update_claude_comment");
|
expect(result).toContain("mcp__github_file_ops__delete_files");
|
||||||
|
|
||||||
// Should not have commit signing tools
|
|
||||||
expect(result).not.toContain("mcp__github_file_ops__commit_files");
|
|
||||||
expect(result).not.toContain("mcp__github_file_ops__delete_files");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should append custom tools when provided", () => {
|
test("should append custom tools when provided", () => {
|
||||||
@@ -834,79 +773,6 @@ describe("buildAllowedToolsString", () => {
|
|||||||
expect(result).toContain("mcp__github_ci__get_workflow_run_details");
|
expect(result).toContain("mcp__github_ci__get_workflow_run_details");
|
||||||
expect(result).toContain("mcp__github_ci__download_job_log");
|
expect(result).toContain("mcp__github_ci__download_job_log");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should include commit signing tools when useCommitSigning is true", () => {
|
|
||||||
const result = buildAllowedToolsString([], false, true);
|
|
||||||
|
|
||||||
// Base tools should be present
|
|
||||||
expect(result).toContain("Edit");
|
|
||||||
expect(result).toContain("Glob");
|
|
||||||
expect(result).toContain("Grep");
|
|
||||||
expect(result).toContain("LS");
|
|
||||||
expect(result).toContain("Read");
|
|
||||||
expect(result).toContain("Write");
|
|
||||||
|
|
||||||
// Commit signing tools should be included
|
|
||||||
expect(result).toContain("mcp__github_file_ops__commit_files");
|
|
||||||
expect(result).toContain("mcp__github_file_ops__delete_files");
|
|
||||||
// Comment tool should always be from github_comment server
|
|
||||||
expect(result).toContain("mcp__github_comment__update_claude_comment");
|
|
||||||
|
|
||||||
// Bash should NOT be included when using commit signing (except in comment tool name)
|
|
||||||
expect(result).not.toContain("Bash(");
|
|
||||||
});
|
|
||||||
|
|
||||||
test("should include specific Bash git commands when useCommitSigning is false", () => {
|
|
||||||
const result = buildAllowedToolsString([], false, false);
|
|
||||||
|
|
||||||
// Base tools should be present
|
|
||||||
expect(result).toContain("Edit");
|
|
||||||
expect(result).toContain("Glob");
|
|
||||||
expect(result).toContain("Grep");
|
|
||||||
expect(result).toContain("LS");
|
|
||||||
expect(result).toContain("Read");
|
|
||||||
expect(result).toContain("Write");
|
|
||||||
|
|
||||||
// Specific Bash git commands should be included
|
|
||||||
expect(result).toContain("Bash(git add:*)");
|
|
||||||
expect(result).toContain("Bash(git commit:*)");
|
|
||||||
expect(result).toContain("Bash(git push:*)");
|
|
||||||
expect(result).toContain("Bash(git status:*)");
|
|
||||||
expect(result).toContain("Bash(git diff:*)");
|
|
||||||
expect(result).toContain("Bash(git log:*)");
|
|
||||||
expect(result).toContain("Bash(git rm:*)");
|
|
||||||
expect(result).toContain("Bash(git config user.name:*)");
|
|
||||||
expect(result).toContain("Bash(git config user.email:*)");
|
|
||||||
|
|
||||||
// Comment tool from minimal server should be included
|
|
||||||
expect(result).toContain("mcp__github_comment__update_claude_comment");
|
|
||||||
|
|
||||||
// Commit signing tools should NOT be included
|
|
||||||
expect(result).not.toContain("mcp__github_file_ops__commit_files");
|
|
||||||
expect(result).not.toContain("mcp__github_file_ops__delete_files");
|
|
||||||
});
|
|
||||||
|
|
||||||
test("should handle all combinations of options", () => {
|
|
||||||
const customTools = ["CustomTool1", "CustomTool2"];
|
|
||||||
const result = buildAllowedToolsString(customTools, true, false);
|
|
||||||
|
|
||||||
// Base tools should be present
|
|
||||||
expect(result).toContain("Edit");
|
|
||||||
expect(result).toContain("Bash(git add:*)");
|
|
||||||
|
|
||||||
// Custom tools should be included
|
|
||||||
expect(result).toContain("CustomTool1");
|
|
||||||
expect(result).toContain("CustomTool2");
|
|
||||||
|
|
||||||
// GitHub Actions tools should be included
|
|
||||||
expect(result).toContain("mcp__github_ci__get_ci_status");
|
|
||||||
|
|
||||||
// Comment tool from minimal server should be included
|
|
||||||
expect(result).toContain("mcp__github_comment__update_claude_comment");
|
|
||||||
|
|
||||||
// Commit signing tools should NOT be included
|
|
||||||
expect(result).not.toContain("mcp__github_file_ops__commit_files");
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("buildDisallowedToolsString", () => {
|
describe("buildDisallowedToolsString", () => {
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ describe("prepareMcpConfig", () => {
|
|||||||
branchPrefix: "",
|
branchPrefix: "",
|
||||||
useStickyComment: false,
|
useStickyComment: false,
|
||||||
additionalPermissions: new Map(),
|
additionalPermissions: new Map(),
|
||||||
useCommitSigning: false,
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -45,22 +44,6 @@ describe("prepareMcpConfig", () => {
|
|||||||
entityNumber: 456,
|
entityNumber: 456,
|
||||||
};
|
};
|
||||||
|
|
||||||
const mockContextWithSigning: ParsedGitHubContext = {
|
|
||||||
...mockContext,
|
|
||||||
inputs: {
|
|
||||||
...mockContext.inputs,
|
|
||||||
useCommitSigning: true,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const mockPRContextWithSigning: ParsedGitHubContext = {
|
|
||||||
...mockPRContext,
|
|
||||||
inputs: {
|
|
||||||
...mockPRContext.inputs,
|
|
||||||
useCommitSigning: true,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
consoleInfoSpy = spyOn(core, "info").mockImplementation(() => {});
|
consoleInfoSpy = spyOn(core, "info").mockImplementation(() => {});
|
||||||
consoleWarningSpy = spyOn(core, "warning").mockImplementation(() => {});
|
consoleWarningSpy = spyOn(core, "warning").mockImplementation(() => {});
|
||||||
@@ -82,7 +65,7 @@ describe("prepareMcpConfig", () => {
|
|||||||
processExitSpy.mockRestore();
|
processExitSpy.mockRestore();
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should return comment server when commit signing is disabled", async () => {
|
test("should return base config when no additional config is provided and no allowed_tools", async () => {
|
||||||
const result = await prepareMcpConfig({
|
const result = await prepareMcpConfig({
|
||||||
githubToken: "test-token",
|
githubToken: "test-token",
|
||||||
owner: "test-owner",
|
owner: "test-owner",
|
||||||
@@ -95,37 +78,6 @@ describe("prepareMcpConfig", () => {
|
|||||||
const parsed = JSON.parse(result);
|
const parsed = JSON.parse(result);
|
||||||
expect(parsed.mcpServers).toBeDefined();
|
expect(parsed.mcpServers).toBeDefined();
|
||||||
expect(parsed.mcpServers.github).not.toBeDefined();
|
expect(parsed.mcpServers.github).not.toBeDefined();
|
||||||
expect(parsed.mcpServers.github_file_ops).not.toBeDefined();
|
|
||||||
expect(parsed.mcpServers.github_comment).toBeDefined();
|
|
||||||
expect(parsed.mcpServers.github_comment.env.GITHUB_TOKEN).toBe(
|
|
||||||
"test-token",
|
|
||||||
);
|
|
||||||
expect(parsed.mcpServers.github_comment.env.REPO_OWNER).toBe("test-owner");
|
|
||||||
expect(parsed.mcpServers.github_comment.env.REPO_NAME).toBe("test-repo");
|
|
||||||
});
|
|
||||||
|
|
||||||
test("should return file ops server when commit signing is enabled", async () => {
|
|
||||||
const contextWithSigning = {
|
|
||||||
...mockContext,
|
|
||||||
inputs: {
|
|
||||||
...mockContext.inputs,
|
|
||||||
useCommitSigning: true,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const result = await prepareMcpConfig({
|
|
||||||
githubToken: "test-token",
|
|
||||||
owner: "test-owner",
|
|
||||||
repo: "test-repo",
|
|
||||||
branch: "test-branch",
|
|
||||||
allowedTools: [],
|
|
||||||
context: contextWithSigning,
|
|
||||||
});
|
|
||||||
|
|
||||||
const parsed = JSON.parse(result);
|
|
||||||
expect(parsed.mcpServers).toBeDefined();
|
|
||||||
expect(parsed.mcpServers.github).not.toBeDefined();
|
|
||||||
expect(parsed.mcpServers.github_comment).toBeDefined();
|
|
||||||
expect(parsed.mcpServers.github_file_ops).toBeDefined();
|
expect(parsed.mcpServers.github_file_ops).toBeDefined();
|
||||||
expect(parsed.mcpServers.github_file_ops.env.GITHUB_TOKEN).toBe(
|
expect(parsed.mcpServers.github_file_ops.env.GITHUB_TOKEN).toBe(
|
||||||
"test-token",
|
"test-token",
|
||||||
@@ -153,22 +105,13 @@ describe("prepareMcpConfig", () => {
|
|||||||
const parsed = JSON.parse(result);
|
const parsed = JSON.parse(result);
|
||||||
expect(parsed.mcpServers).toBeDefined();
|
expect(parsed.mcpServers).toBeDefined();
|
||||||
expect(parsed.mcpServers.github).toBeDefined();
|
expect(parsed.mcpServers.github).toBeDefined();
|
||||||
expect(parsed.mcpServers.github_comment).toBeDefined();
|
expect(parsed.mcpServers.github_file_ops).toBeDefined();
|
||||||
expect(parsed.mcpServers.github_file_ops).not.toBeDefined();
|
|
||||||
expect(parsed.mcpServers.github.env.GITHUB_PERSONAL_ACCESS_TOKEN).toBe(
|
expect(parsed.mcpServers.github.env.GITHUB_PERSONAL_ACCESS_TOKEN).toBe(
|
||||||
"test-token",
|
"test-token",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should not include github MCP server when only file_ops tools are allowed", async () => {
|
test("should not include github MCP server when only file_ops tools are allowed", async () => {
|
||||||
const contextWithSigning = {
|
|
||||||
...mockContext,
|
|
||||||
inputs: {
|
|
||||||
...mockContext.inputs,
|
|
||||||
useCommitSigning: true,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const result = await prepareMcpConfig({
|
const result = await prepareMcpConfig({
|
||||||
githubToken: "test-token",
|
githubToken: "test-token",
|
||||||
owner: "test-owner",
|
owner: "test-owner",
|
||||||
@@ -178,7 +121,7 @@ describe("prepareMcpConfig", () => {
|
|||||||
"mcp__github_file_ops__commit_files",
|
"mcp__github_file_ops__commit_files",
|
||||||
"mcp__github_file_ops__update_claude_comment",
|
"mcp__github_file_ops__update_claude_comment",
|
||||||
],
|
],
|
||||||
context: contextWithSigning,
|
context: mockContext,
|
||||||
});
|
});
|
||||||
|
|
||||||
const parsed = JSON.parse(result);
|
const parsed = JSON.parse(result);
|
||||||
@@ -187,7 +130,7 @@ describe("prepareMcpConfig", () => {
|
|||||||
expect(parsed.mcpServers.github_file_ops).toBeDefined();
|
expect(parsed.mcpServers.github_file_ops).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should include comment server when no GitHub tools are allowed and signing disabled", async () => {
|
test("should include file_ops server even when no GitHub tools are allowed", async () => {
|
||||||
const result = await prepareMcpConfig({
|
const result = await prepareMcpConfig({
|
||||||
githubToken: "test-token",
|
githubToken: "test-token",
|
||||||
owner: "test-owner",
|
owner: "test-owner",
|
||||||
@@ -200,8 +143,7 @@ describe("prepareMcpConfig", () => {
|
|||||||
const parsed = JSON.parse(result);
|
const parsed = JSON.parse(result);
|
||||||
expect(parsed.mcpServers).toBeDefined();
|
expect(parsed.mcpServers).toBeDefined();
|
||||||
expect(parsed.mcpServers.github).not.toBeDefined();
|
expect(parsed.mcpServers.github).not.toBeDefined();
|
||||||
expect(parsed.mcpServers.github_file_ops).not.toBeDefined();
|
expect(parsed.mcpServers.github_file_ops).toBeDefined();
|
||||||
expect(parsed.mcpServers.github_comment).toBeDefined();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should return base config when additional config is empty string", async () => {
|
test("should return base config when additional config is empty string", async () => {
|
||||||
@@ -218,7 +160,7 @@ describe("prepareMcpConfig", () => {
|
|||||||
const parsed = JSON.parse(result);
|
const parsed = JSON.parse(result);
|
||||||
expect(parsed.mcpServers).toBeDefined();
|
expect(parsed.mcpServers).toBeDefined();
|
||||||
expect(parsed.mcpServers.github).not.toBeDefined();
|
expect(parsed.mcpServers.github).not.toBeDefined();
|
||||||
expect(parsed.mcpServers.github_comment).toBeDefined();
|
expect(parsed.mcpServers.github_file_ops).toBeDefined();
|
||||||
expect(consoleWarningSpy).not.toHaveBeenCalled();
|
expect(consoleWarningSpy).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -236,7 +178,7 @@ describe("prepareMcpConfig", () => {
|
|||||||
const parsed = JSON.parse(result);
|
const parsed = JSON.parse(result);
|
||||||
expect(parsed.mcpServers).toBeDefined();
|
expect(parsed.mcpServers).toBeDefined();
|
||||||
expect(parsed.mcpServers.github).not.toBeDefined();
|
expect(parsed.mcpServers.github).not.toBeDefined();
|
||||||
expect(parsed.mcpServers.github_comment).toBeDefined();
|
expect(parsed.mcpServers.github_file_ops).toBeDefined();
|
||||||
expect(consoleWarningSpy).not.toHaveBeenCalled();
|
expect(consoleWarningSpy).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -263,7 +205,7 @@ describe("prepareMcpConfig", () => {
|
|||||||
"mcp__github__create_issue",
|
"mcp__github__create_issue",
|
||||||
"mcp__github_file_ops__commit_files",
|
"mcp__github_file_ops__commit_files",
|
||||||
],
|
],
|
||||||
context: mockContextWithSigning,
|
context: mockContext,
|
||||||
});
|
});
|
||||||
|
|
||||||
const parsed = JSON.parse(result);
|
const parsed = JSON.parse(result);
|
||||||
@@ -301,7 +243,7 @@ describe("prepareMcpConfig", () => {
|
|||||||
"mcp__github__create_issue",
|
"mcp__github__create_issue",
|
||||||
"mcp__github_file_ops__commit_files",
|
"mcp__github_file_ops__commit_files",
|
||||||
],
|
],
|
||||||
context: mockContextWithSigning,
|
context: mockContext,
|
||||||
});
|
});
|
||||||
|
|
||||||
const parsed = JSON.parse(result);
|
const parsed = JSON.parse(result);
|
||||||
@@ -339,7 +281,7 @@ describe("prepareMcpConfig", () => {
|
|||||||
branch: "test-branch",
|
branch: "test-branch",
|
||||||
additionalMcpConfig: additionalConfig,
|
additionalMcpConfig: additionalConfig,
|
||||||
allowedTools: [],
|
allowedTools: [],
|
||||||
context: mockContextWithSigning,
|
context: mockContext,
|
||||||
});
|
});
|
||||||
|
|
||||||
const parsed = JSON.parse(result);
|
const parsed = JSON.parse(result);
|
||||||
@@ -359,7 +301,7 @@ describe("prepareMcpConfig", () => {
|
|||||||
branch: "test-branch",
|
branch: "test-branch",
|
||||||
additionalMcpConfig: invalidJson,
|
additionalMcpConfig: invalidJson,
|
||||||
allowedTools: [],
|
allowedTools: [],
|
||||||
context: mockContextWithSigning,
|
context: mockContext,
|
||||||
});
|
});
|
||||||
|
|
||||||
const parsed = JSON.parse(result);
|
const parsed = JSON.parse(result);
|
||||||
@@ -380,7 +322,7 @@ describe("prepareMcpConfig", () => {
|
|||||||
branch: "test-branch",
|
branch: "test-branch",
|
||||||
additionalMcpConfig: nonObjectJson,
|
additionalMcpConfig: nonObjectJson,
|
||||||
allowedTools: [],
|
allowedTools: [],
|
||||||
context: mockContextWithSigning,
|
context: mockContext,
|
||||||
});
|
});
|
||||||
|
|
||||||
const parsed = JSON.parse(result);
|
const parsed = JSON.parse(result);
|
||||||
@@ -404,7 +346,7 @@ describe("prepareMcpConfig", () => {
|
|||||||
branch: "test-branch",
|
branch: "test-branch",
|
||||||
additionalMcpConfig: nullJson,
|
additionalMcpConfig: nullJson,
|
||||||
allowedTools: [],
|
allowedTools: [],
|
||||||
context: mockContextWithSigning,
|
context: mockContext,
|
||||||
});
|
});
|
||||||
|
|
||||||
const parsed = JSON.parse(result);
|
const parsed = JSON.parse(result);
|
||||||
@@ -428,7 +370,7 @@ describe("prepareMcpConfig", () => {
|
|||||||
branch: "test-branch",
|
branch: "test-branch",
|
||||||
additionalMcpConfig: arrayJson,
|
additionalMcpConfig: arrayJson,
|
||||||
allowedTools: [],
|
allowedTools: [],
|
||||||
context: mockContextWithSigning,
|
context: mockContext,
|
||||||
});
|
});
|
||||||
|
|
||||||
const parsed = JSON.parse(result);
|
const parsed = JSON.parse(result);
|
||||||
@@ -475,7 +417,7 @@ describe("prepareMcpConfig", () => {
|
|||||||
branch: "test-branch",
|
branch: "test-branch",
|
||||||
additionalMcpConfig: additionalConfig,
|
additionalMcpConfig: additionalConfig,
|
||||||
allowedTools: [],
|
allowedTools: [],
|
||||||
context: mockContextWithSigning,
|
context: mockContext,
|
||||||
});
|
});
|
||||||
|
|
||||||
const parsed = JSON.parse(result);
|
const parsed = JSON.parse(result);
|
||||||
@@ -497,7 +439,7 @@ describe("prepareMcpConfig", () => {
|
|||||||
repo: "test-repo",
|
repo: "test-repo",
|
||||||
branch: "test-branch",
|
branch: "test-branch",
|
||||||
allowedTools: [],
|
allowedTools: [],
|
||||||
context: mockContextWithSigning,
|
context: mockContext,
|
||||||
});
|
});
|
||||||
|
|
||||||
const parsed = JSON.parse(result);
|
const parsed = JSON.parse(result);
|
||||||
@@ -518,7 +460,7 @@ describe("prepareMcpConfig", () => {
|
|||||||
repo: "test-repo",
|
repo: "test-repo",
|
||||||
branch: "test-branch",
|
branch: "test-branch",
|
||||||
allowedTools: [],
|
allowedTools: [],
|
||||||
context: mockContextWithSigning,
|
context: mockContext,
|
||||||
});
|
});
|
||||||
|
|
||||||
const parsed = JSON.parse(result);
|
const parsed = JSON.parse(result);
|
||||||
@@ -536,7 +478,6 @@ describe("prepareMcpConfig", () => {
|
|||||||
inputs: {
|
inputs: {
|
||||||
...mockPRContext.inputs,
|
...mockPRContext.inputs,
|
||||||
additionalPermissions: new Map([["actions", "read"]]),
|
additionalPermissions: new Map([["actions", "read"]]),
|
||||||
useCommitSigning: true,
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -565,7 +506,7 @@ describe("prepareMcpConfig", () => {
|
|||||||
repo: "test-repo",
|
repo: "test-repo",
|
||||||
branch: "test-branch",
|
branch: "test-branch",
|
||||||
allowedTools: [],
|
allowedTools: [],
|
||||||
context: mockContextWithSigning,
|
context: mockContext,
|
||||||
});
|
});
|
||||||
|
|
||||||
const parsed = JSON.parse(result);
|
const parsed = JSON.parse(result);
|
||||||
@@ -583,7 +524,7 @@ describe("prepareMcpConfig", () => {
|
|||||||
repo: "test-repo",
|
repo: "test-repo",
|
||||||
branch: "test-branch",
|
branch: "test-branch",
|
||||||
allowedTools: [],
|
allowedTools: [],
|
||||||
context: mockPRContextWithSigning,
|
context: mockPRContext,
|
||||||
});
|
});
|
||||||
|
|
||||||
const parsed = JSON.parse(result);
|
const parsed = JSON.parse(result);
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ const defaultInputs = {
|
|||||||
branchPrefix: "claude/",
|
branchPrefix: "claude/",
|
||||||
useStickyComment: false,
|
useStickyComment: false,
|
||||||
additionalPermissions: new Map<string, string>(),
|
additionalPermissions: new Map<string, string>(),
|
||||||
useCommitSigning: false,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const defaultRepository = {
|
const defaultRepository = {
|
||||||
|
|||||||
@@ -70,7 +70,6 @@ describe("checkWritePermissions", () => {
|
|||||||
branchPrefix: "claude/",
|
branchPrefix: "claude/",
|
||||||
useStickyComment: false,
|
useStickyComment: false,
|
||||||
additionalPermissions: new Map(),
|
additionalPermissions: new Map(),
|
||||||
useCommitSigning: false,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ describe("checkContainsTrigger", () => {
|
|||||||
branchPrefix: "claude/",
|
branchPrefix: "claude/",
|
||||||
useStickyComment: false,
|
useStickyComment: false,
|
||||||
additionalPermissions: new Map(),
|
additionalPermissions: new Map(),
|
||||||
useCommitSigning: false,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
expect(checkContainsTrigger(context)).toBe(true);
|
expect(checkContainsTrigger(context)).toBe(true);
|
||||||
@@ -69,7 +68,6 @@ describe("checkContainsTrigger", () => {
|
|||||||
branchPrefix: "claude/",
|
branchPrefix: "claude/",
|
||||||
useStickyComment: false,
|
useStickyComment: false,
|
||||||
additionalPermissions: new Map(),
|
additionalPermissions: new Map(),
|
||||||
useCommitSigning: false,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
expect(checkContainsTrigger(context)).toBe(false);
|
expect(checkContainsTrigger(context)).toBe(false);
|
||||||
@@ -284,7 +282,6 @@ describe("checkContainsTrigger", () => {
|
|||||||
branchPrefix: "claude/",
|
branchPrefix: "claude/",
|
||||||
useStickyComment: false,
|
useStickyComment: false,
|
||||||
additionalPermissions: new Map(),
|
additionalPermissions: new Map(),
|
||||||
useCommitSigning: false,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
expect(checkContainsTrigger(context)).toBe(true);
|
expect(checkContainsTrigger(context)).toBe(true);
|
||||||
@@ -316,7 +313,6 @@ describe("checkContainsTrigger", () => {
|
|||||||
branchPrefix: "claude/",
|
branchPrefix: "claude/",
|
||||||
useStickyComment: false,
|
useStickyComment: false,
|
||||||
additionalPermissions: new Map(),
|
additionalPermissions: new Map(),
|
||||||
useCommitSigning: false,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
expect(checkContainsTrigger(context)).toBe(true);
|
expect(checkContainsTrigger(context)).toBe(true);
|
||||||
@@ -348,7 +344,6 @@ describe("checkContainsTrigger", () => {
|
|||||||
branchPrefix: "claude/",
|
branchPrefix: "claude/",
|
||||||
useStickyComment: false,
|
useStickyComment: false,
|
||||||
additionalPermissions: new Map(),
|
additionalPermissions: new Map(),
|
||||||
useCommitSigning: false,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
expect(checkContainsTrigger(context)).toBe(false);
|
expect(checkContainsTrigger(context)).toBe(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user