diff --git a/.claude/settings.json b/.claude/settings.json new file mode 100644 index 0000000..29f0ffc --- /dev/null +++ b/.claude/settings.json @@ -0,0 +1,14 @@ +{ + "permissions": { + "allow": [ + "Bash(*)", + "Edit", + "MultiEdit", + "NotebookEdit", + "FileEdit", + "WebFetch", + "WebSearch", + "Write" + ] + } +} diff --git a/.github/actions/claude-code-action/action.yml b/.github/actions/claude-code-action/action.yml index bb08c05..7616989 100644 --- a/.github/actions/claude-code-action/action.yml +++ b/.github/actions/claude-code-action/action.yml @@ -7,10 +7,13 @@ inputs: required: true anthropic_api_key: description: "Anthropic API key" - required: true + required: false cborg_api_key: description: "CBORG API key" - required: true + required: false + claude_code_oauth_token: + description: "Claude Code OAuth token" + required: false prompt: description: "The prompt to send to Claude Code" required: false @@ -90,6 +93,7 @@ runs: shell: bash id: prepare_prompt run: | + # Check if either prompt or prompt_file is provided if [ -z "${{ inputs.prompt }}" ] && [ -z "${{ inputs.prompt_file }}" ]; then echo "::error::Neither 'prompt' nor 'prompt_file' was provided. At least one is required." @@ -125,6 +129,14 @@ runs: shell: bash id: run_claude run: | + + if [ ! -z "${{ inputs.claude_code_oauth_token }}" ]; then + echo CLAUDE AUTH TOKEN IS NOT SET + else + echo CLAUDE AUTH TOKEN IS SET + export ANTHROPIC_API_KEY= + fi + ALLOWED_TOOLS_ARG="" if [ ! -z "${{ inputs.allowed_tools }}" ]; then ALLOWED_TOOLS_ARG="--allowedTools ${{ inputs.allowed_tools }}" @@ -135,7 +147,7 @@ runs: if [ -z "${{ inputs.output_file }}" ]; then # Run Claude Code and output to console - timeout $timeout_seconds claude \ + claude \ -p \ --verbose \ --output-format stream-json \ @@ -143,7 +155,7 @@ runs: ${{ inputs.allowed_tools != '' && format('--allowedTools "{0}"', inputs.allowed_tools) || '' }} else # Run Claude Code and tee output to console and file - timeout $timeout_seconds claude \ + claude \ -p \ --verbose \ --output-format stream-json \ @@ -160,8 +172,9 @@ runs: fi env: - ANTHROPIC_API_KEY: "." - ANTHROPIC_AUTH_TOKEN: ${{ inputs.cborg_api_key }} + ANTHROPIC_API_KEY: ${{ inputs.anthropic_api_key }} + # ANTHROPIC_AUTH_TOKEN: ${{ inputs.cborg_api_key }} + CLAUDE_CODE_OAUTH_TOKEN: ${{ inputs.claude_code_oauth_token }} GITHUB_TOKEN: ${{ inputs.github_token }} - ANTHROPIC_BASE_URL: "https://api.cborg.lbl.gov" - DISABLE_NON_ESSENTIAL_MODEL_CALLS: "1" + # ANTHROPIC_BASE_URL: "https://api.cborg.lbl.gov" + # DISABLE_NON_ESSENTIAL_MODEL_CALLS: "1" diff --git a/.github/actions/claude-issue-summarize-action/action.yml b/.github/actions/claude-issue-summarize-action/action.yml index b497d17..896af91 100644 --- a/.github/actions/claude-issue-summarize-action/action.yml +++ b/.github/actions/claude-issue-summarize-action/action.yml @@ -8,10 +8,13 @@ inputs: default: "5" anthropic_api_key: description: "Anthropic API key" - required: true + required: false cborg_api_key: description: "CBORG API key" - required: true + required: false + claude_code_oauth_token: + description: "Claude Code OAuth token" + required: false github_token: description: "GitHub token with repo and issues permissions" required: true @@ -22,7 +25,7 @@ runs: - name: Checkout repository code uses: actions/checkout@v4 with: - fetch-depth: 0 + ref: ${{ github.ref }} - name: Create prompt file shell: bash @@ -70,5 +73,6 @@ runs: install_artl_mcp: "true" timeout_minutes: ${{ inputs.timeout_minutes }} anthropic_api_key: ${{ inputs.anthropic_api_key }} + claude_code_oauth_token: ${{ inputs.claude_code_oauth_token }} cborg_api_key: ${{ inputs.cborg_api_key }} github_token: ${{ inputs.github_token }} diff --git a/.github/actions/claude-issue-triage-action/action.yml b/.github/actions/claude-issue-triage-action/action.yml index 22fcd82..caaad89 100644 --- a/.github/actions/claude-issue-triage-action/action.yml +++ b/.github/actions/claude-issue-triage-action/action.yml @@ -8,7 +8,10 @@ inputs: default: "5" anthropic_api_key: description: "Anthropic API key" - required: true + required: false + claude_code_oauth_token: + description: "Claude Code OAuth token" + required: false cborg_api_key: description: "CBORG API key" required: true @@ -22,7 +25,7 @@ runs: - name: Checkout repository code uses: actions/checkout@v4 with: - fetch-depth: 0 + ref: ${{ github.ref }} - name: Create prompt file shell: bash @@ -87,5 +90,6 @@ runs: install_github_mcp: "true" timeout_minutes: ${{ inputs.timeout_minutes }} anthropic_api_key: ${{ inputs.anthropic_api_key }} + claude_code_oauth_token: ${{ inputs.claude_code_oauth_token }} cborg_api_key: ${{ inputs.cborg_api_key }} github_token: ${{ inputs.github_token }} diff --git a/.github/workflows/claude-code-review.yml b/.github/workflows/claude-code-review.yml index a12225a..5bf8ce5 100644 --- a/.github/workflows/claude-code-review.yml +++ b/.github/workflows/claude-code-review.yml @@ -37,9 +37,9 @@ jobs: with: claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} - # Optional: Specify model (defaults to Claude Sonnet 4, uncomment for Claude Opus 4.1) - # model: "claude-opus-4-1-20250805" - + # Optional: Specify model (defaults to Claude Sonnet 4, uncomment for Claude Opus 4) + # model: "claude-opus-4-20250514" + # Direct prompt for automated review (no @claude mention needed) direct_prompt: | Please review this pull request and provide feedback on: diff --git a/.github/workflows/claude-issue-summarize.yml b/.github/workflows/claude-issue-summarize.yml index da5e536..710195f 100644 --- a/.github/workflows/claude-issue-summarize.yml +++ b/.github/workflows/claude-issue-summarize.yml @@ -15,11 +15,13 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 + with: + ref: ${{ github.ref }} - name: Run Claude Issue summarize uses: ./.github/actions/claude-issue-summarize-action with: anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} + claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} cborg_api_key: ${{ secrets.CBORG_API_KEY }} github_token: ${{ secrets.GITHUB_TOKEN }} - install_artl_mcp: "true" diff --git a/.github/workflows/claude-issue-triage.yml b/.github/workflows/claude-issue-triage.yml index 276fdff..ddec43e 100644 --- a/.github/workflows/claude-issue-triage.yml +++ b/.github/workflows/claude-issue-triage.yml @@ -15,10 +15,13 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 - + with: + ref: ${{ github.ref }} + - name: Run Claude Issue Triage uses: ./.github/actions/claude-issue-triage-action with: anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} + claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} cborg_api_key: ${{ secrets.CBORG_API_KEY }} github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/dragon-ai.yml b/.github/workflows/dragon-ai.yml index ea27378..584bb43 100644 --- a/.github/workflows/dragon-ai.yml +++ b/.github/workflows/dragon-ai.yml @@ -21,7 +21,11 @@ jobs: result: ${{ steps.check.outputs.result }} steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 + # this seems to be necessary to ensure actions uses the latest; see + # https://github.com/actions/checkout/issues/439 + with: + ref: ${{ github.ref }} - name: Check for qualifying mention id: check @@ -97,9 +101,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: - fetch-depth: 0 + ref: ${{ github.ref }} token: ${{ secrets.PAT_FOR_PR }} # Use PAT for checkout to allow committing later - name: Configure Git @@ -119,22 +123,12 @@ jobs: run: | npm install -g @anthropic-ai/claude-code - - - name: Set up environment - run: | - echo "BRANCH_NAME=dragon_ai_agent_${{ fromJSON(needs.check-mention.outputs.result).itemNumber }}" >> $GITHUB_ENV - # Safely write prompt to file - mkdir -p /tmp/claude-input - echo "${{ fromJSON(needs.check-mention.outputs.result).prompt }}" > /tmp/claude-input/prompt.txt - - - name: Set up Anthropic API key and GitHub token - env: - ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} - GH_TOKEN: ${{ secrets.PAT_FOR_PR }} # Kept PAT as requested + + - name: Add tools to PATH run: | - echo "ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY" >> $GITHUB_ENV - echo "GH_TOKEN=$GH_TOKEN" >> $GITHUB_ENV - echo "LOGFIRE_SEND_TO_LOGFIRE=false" >> $GITHUB_ENV + echo "${{ env.TOOLS_DIR }}" >> $GITHUB_PATH + ls -alt ${{ github.workspace }} + ls -alt ${{ env.TOOLS_DIR }} - name: Install uv uses: astral-sh/setup-uv@v5 @@ -143,8 +137,18 @@ jobs: run: | uv venv source .venv/bin/activate - + + - name: Set up environment + run: | + # Safely write prompt to file + mkdir -p /tmp/claude-input + echo "${{ fromJSON(needs.check-mention.outputs.result).prompt }}" > /tmp/claude-input/prompt.txt + - name: Create structured Claude prompt + env: + CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} + ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} + GH_TOKEN: ${{ secrets.PAT_FOR_PR }} run: | cat > /tmp/claude-input/claude_prompt.txt << EOL You are @dragon-ai-agent. @@ -171,13 +175,16 @@ jobs: - name: Run Claude Code in headless mode id: claude-response + env: + CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - # Python env - source .venv/bin/activate + + export PATH="${{ env.TOOLS_DIR }}:$PATH" # Run Claude with proper permissions claude -p "$(cat /tmp/claude-input/claude_prompt.txt)" \ + --permission-mode bypassPermissions \ --output-format stream-json \ - --allowedTools "Bash(git:*)" "Bash(gh:*)" "FileSystem(*)" \ --verbose diff --git a/README.md b/README.md index f430b87..d83b9fe 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,34 @@ CBORG_API_KEY ### Setup -After setting up env vars: +After running copier and setting up environment variables, run the following command to complete the AI integration setup: + + +```bash +just -f ai.just setup-ai +``` + +This command performs two main setup tasks: + +1. **AI Agent Configuration** (`setup-ai-instructions`): + - Creates `CLAUDE.md` symlink to `AGENTS.md` for Claude Code instructions + - Creates `.goosehints` symlink to `AGENTS.md` for Goose agent instructions + - Creates `.github/copilot-instructions.md` symlink to `AGENTS.md` for GitHub Copilot instructions + +2. **GitHub Repository Setup** (`setup-gh`): + - Adds repository topics for discoverability (`monarchinitiative,ai4curation`) + - Configures repository secrets from your environment variables (PAT_FOR_PR, ANTHROPIC_API_KEY, etc.) + +# FAQ + +## `claude-review.yml` fails PR check on first run + +This is normal: see this comment in the action logs: + +``` +Error: Failed to setup GitHub token: Error: Workflow validation failed. The workflow file must exist and have identical content to the version on the repository's default branch. If you're seeing this on a PR when you first add a code review workflow file to your repository, this is normal and you should ignore this error. + +If you instead wish to use this action with a custom GitHub token or custom GitHub app, provide a `github_token` in the `uses` section of the app in your workflow yml file. +Error: Process completed with exit code 1. +``` -`just -f ai.just setup-ai` diff --git a/copier.yaml b/copier.yaml index 0381c09..a568214 100644 --- a/copier.yaml +++ b/copier.yaml @@ -31,7 +31,7 @@ project_slug: {% endif %} github_handle: - help: github username of the author. Will be assigned as a-controller + help: github username of the author. Will be assigned as ai-controller type: str default: "cmungall" @@ -86,7 +86,7 @@ _message_after_copy: | 3. if your project is already on GitHub, and your keys are set as env vars, then run: - `just setup-ai` + `just -f ai.just setup-ai` diff --git a/template/.github/actions/claude-code-action/action.yml b/template/.github/actions/claude-code-action/action.yml index bb08c05..7616989 100644 --- a/template/.github/actions/claude-code-action/action.yml +++ b/template/.github/actions/claude-code-action/action.yml @@ -7,10 +7,13 @@ inputs: required: true anthropic_api_key: description: "Anthropic API key" - required: true + required: false cborg_api_key: description: "CBORG API key" - required: true + required: false + claude_code_oauth_token: + description: "Claude Code OAuth token" + required: false prompt: description: "The prompt to send to Claude Code" required: false @@ -90,6 +93,7 @@ runs: shell: bash id: prepare_prompt run: | + # Check if either prompt or prompt_file is provided if [ -z "${{ inputs.prompt }}" ] && [ -z "${{ inputs.prompt_file }}" ]; then echo "::error::Neither 'prompt' nor 'prompt_file' was provided. At least one is required." @@ -125,6 +129,14 @@ runs: shell: bash id: run_claude run: | + + if [ ! -z "${{ inputs.claude_code_oauth_token }}" ]; then + echo CLAUDE AUTH TOKEN IS NOT SET + else + echo CLAUDE AUTH TOKEN IS SET + export ANTHROPIC_API_KEY= + fi + ALLOWED_TOOLS_ARG="" if [ ! -z "${{ inputs.allowed_tools }}" ]; then ALLOWED_TOOLS_ARG="--allowedTools ${{ inputs.allowed_tools }}" @@ -135,7 +147,7 @@ runs: if [ -z "${{ inputs.output_file }}" ]; then # Run Claude Code and output to console - timeout $timeout_seconds claude \ + claude \ -p \ --verbose \ --output-format stream-json \ @@ -143,7 +155,7 @@ runs: ${{ inputs.allowed_tools != '' && format('--allowedTools "{0}"', inputs.allowed_tools) || '' }} else # Run Claude Code and tee output to console and file - timeout $timeout_seconds claude \ + claude \ -p \ --verbose \ --output-format stream-json \ @@ -160,8 +172,9 @@ runs: fi env: - ANTHROPIC_API_KEY: "." - ANTHROPIC_AUTH_TOKEN: ${{ inputs.cborg_api_key }} + ANTHROPIC_API_KEY: ${{ inputs.anthropic_api_key }} + # ANTHROPIC_AUTH_TOKEN: ${{ inputs.cborg_api_key }} + CLAUDE_CODE_OAUTH_TOKEN: ${{ inputs.claude_code_oauth_token }} GITHUB_TOKEN: ${{ inputs.github_token }} - ANTHROPIC_BASE_URL: "https://api.cborg.lbl.gov" - DISABLE_NON_ESSENTIAL_MODEL_CALLS: "1" + # ANTHROPIC_BASE_URL: "https://api.cborg.lbl.gov" + # DISABLE_NON_ESSENTIAL_MODEL_CALLS: "1" diff --git a/template/.github/actions/claude-issue-summarize-action/action.yml b/template/.github/actions/claude-issue-summarize-action/action.yml index b497d17..896af91 100644 --- a/template/.github/actions/claude-issue-summarize-action/action.yml +++ b/template/.github/actions/claude-issue-summarize-action/action.yml @@ -8,10 +8,13 @@ inputs: default: "5" anthropic_api_key: description: "Anthropic API key" - required: true + required: false cborg_api_key: description: "CBORG API key" - required: true + required: false + claude_code_oauth_token: + description: "Claude Code OAuth token" + required: false github_token: description: "GitHub token with repo and issues permissions" required: true @@ -22,7 +25,7 @@ runs: - name: Checkout repository code uses: actions/checkout@v4 with: - fetch-depth: 0 + ref: ${{ github.ref }} - name: Create prompt file shell: bash @@ -70,5 +73,6 @@ runs: install_artl_mcp: "true" timeout_minutes: ${{ inputs.timeout_minutes }} anthropic_api_key: ${{ inputs.anthropic_api_key }} + claude_code_oauth_token: ${{ inputs.claude_code_oauth_token }} cborg_api_key: ${{ inputs.cborg_api_key }} github_token: ${{ inputs.github_token }} diff --git a/template/.github/actions/claude-issue-triage-action/action.yml b/template/.github/actions/claude-issue-triage-action/action.yml index 22fcd82..caaad89 100644 --- a/template/.github/actions/claude-issue-triage-action/action.yml +++ b/template/.github/actions/claude-issue-triage-action/action.yml @@ -8,7 +8,10 @@ inputs: default: "5" anthropic_api_key: description: "Anthropic API key" - required: true + required: false + claude_code_oauth_token: + description: "Claude Code OAuth token" + required: false cborg_api_key: description: "CBORG API key" required: true @@ -22,7 +25,7 @@ runs: - name: Checkout repository code uses: actions/checkout@v4 with: - fetch-depth: 0 + ref: ${{ github.ref }} - name: Create prompt file shell: bash @@ -87,5 +90,6 @@ runs: install_github_mcp: "true" timeout_minutes: ${{ inputs.timeout_minutes }} anthropic_api_key: ${{ inputs.anthropic_api_key }} + claude_code_oauth_token: ${{ inputs.claude_code_oauth_token }} cborg_api_key: ${{ inputs.cborg_api_key }} github_token: ${{ inputs.github_token }} diff --git a/template/.github/workflows/claude-code-review.yml b/template/.github/workflows/claude-code-review.yml index a12225a..5bf8ce5 100644 --- a/template/.github/workflows/claude-code-review.yml +++ b/template/.github/workflows/claude-code-review.yml @@ -37,9 +37,9 @@ jobs: with: claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} - # Optional: Specify model (defaults to Claude Sonnet 4, uncomment for Claude Opus 4.1) - # model: "claude-opus-4-1-20250805" - + # Optional: Specify model (defaults to Claude Sonnet 4, uncomment for Claude Opus 4) + # model: "claude-opus-4-20250514" + # Direct prompt for automated review (no @claude mention needed) direct_prompt: | Please review this pull request and provide feedback on: diff --git a/template/.github/workflows/claude-issue-summarize.yml b/template/.github/workflows/claude-issue-summarize.yml index da5e536..710195f 100644 --- a/template/.github/workflows/claude-issue-summarize.yml +++ b/template/.github/workflows/claude-issue-summarize.yml @@ -15,11 +15,13 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 + with: + ref: ${{ github.ref }} - name: Run Claude Issue summarize uses: ./.github/actions/claude-issue-summarize-action with: anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} + claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} cborg_api_key: ${{ secrets.CBORG_API_KEY }} github_token: ${{ secrets.GITHUB_TOKEN }} - install_artl_mcp: "true" diff --git a/template/.github/workflows/claude-issue-triage.yml b/template/.github/workflows/claude-issue-triage.yml index 276fdff..ddec43e 100644 --- a/template/.github/workflows/claude-issue-triage.yml +++ b/template/.github/workflows/claude-issue-triage.yml @@ -15,10 +15,13 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 - + with: + ref: ${{ github.ref }} + - name: Run Claude Issue Triage uses: ./.github/actions/claude-issue-triage-action with: anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} + claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} cborg_api_key: ${{ secrets.CBORG_API_KEY }} github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/template/.github/workflows/claude.yml b/template/.github/workflows/claude.yml index 6181f3b..e1d4a43 100644 --- a/template/.github/workflows/claude.yml +++ b/template/.github/workflows/claude.yml @@ -1,8 +1,3 @@ -# Claude Code GitHub action -# --- -# This github action is from the copier template in https://github.com/ai4curation/github-ai-integrations, donated by the Monarch Initiative -# For more documentation, see https://ai4curation.github.io/aidocs/how-tos/set-up-github-actions/ -# Author: Chris Mungall (@cmungall) name: Claude Code on: diff --git a/template/.github/workflows/dragon-ai.yml b/template/.github/workflows/dragon-ai.yml index f7fba5e..584bb43 100644 --- a/template/.github/workflows/dragon-ai.yml +++ b/template/.github/workflows/dragon-ai.yml @@ -1,8 +1,3 @@ -# DRAGON-AI GitHub action -# --- -# This github action is from the copier template in https://github.com/ai4curation/github-ai-integrations, donated by the Monarch Initiative -# For more documentation, see https://ai4curation.github.io/aidocs/how-tos/set-up-github-actions/ -# Author: Chris Mungall (@cmungall) name: Dragon AI Agent GitHub Mentions env: @@ -26,7 +21,11 @@ jobs: result: ${{ steps.check.outputs.result }} steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 + # this seems to be necessary to ensure actions uses the latest; see + # https://github.com/actions/checkout/issues/439 + with: + ref: ${{ github.ref }} - name: Check for qualifying mention id: check @@ -102,9 +101,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: - fetch-depth: 0 + ref: ${{ github.ref }} token: ${{ secrets.PAT_FOR_PR }} # Use PAT for checkout to allow committing later - name: Configure Git @@ -124,22 +123,12 @@ jobs: run: | npm install -g @anthropic-ai/claude-code - - - name: Set up environment - run: | - echo "BRANCH_NAME=dragon_ai_agent_${{ fromJSON(needs.check-mention.outputs.result).itemNumber }}" >> $GITHUB_ENV - # Safely write prompt to file - mkdir -p /tmp/claude-input - echo "${{ fromJSON(needs.check-mention.outputs.result).prompt }}" > /tmp/claude-input/prompt.txt - - - name: Set up Anthropic API key and GitHub token - env: - ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} - GH_TOKEN: ${{ secrets.PAT_FOR_PR }} # Kept PAT as requested + + - name: Add tools to PATH run: | - echo "ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY" >> $GITHUB_ENV - echo "GH_TOKEN=$GH_TOKEN" >> $GITHUB_ENV - echo "LOGFIRE_SEND_TO_LOGFIRE=false" >> $GITHUB_ENV + echo "${{ env.TOOLS_DIR }}" >> $GITHUB_PATH + ls -alt ${{ github.workspace }} + ls -alt ${{ env.TOOLS_DIR }} - name: Install uv uses: astral-sh/setup-uv@v5 @@ -148,8 +137,18 @@ jobs: run: | uv venv source .venv/bin/activate - + + - name: Set up environment + run: | + # Safely write prompt to file + mkdir -p /tmp/claude-input + echo "${{ fromJSON(needs.check-mention.outputs.result).prompt }}" > /tmp/claude-input/prompt.txt + - name: Create structured Claude prompt + env: + CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} + ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} + GH_TOKEN: ${{ secrets.PAT_FOR_PR }} run: | cat > /tmp/claude-input/claude_prompt.txt << EOL You are @dragon-ai-agent. @@ -176,13 +175,16 @@ jobs: - name: Run Claude Code in headless mode id: claude-response + env: + CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - # Python env - source .venv/bin/activate + + export PATH="${{ env.TOOLS_DIR }}:$PATH" # Run Claude with proper permissions claude -p "$(cat /tmp/claude-input/claude_prompt.txt)" \ + --permission-mode bypassPermissions \ --output-format stream-json \ - --allowedTools "Bash(git:*)" "Bash(gh:*)" "FileSystem(*)" \ --verbose diff --git a/template/ai.just b/template/ai.just index dc76eac..c675bda 100644 --- a/template/ai.just +++ b/template/ai.just @@ -19,13 +19,13 @@ gh-add-topics: gh-add-secrets: #!/usr/bin/env bash set -euo pipefail - + # Function to set secret if env var exists set_secret_if_exists() { local secret_name="$1" local gh_var="GH_$secret_name" local plain_var="$secret_name" - + if [ -n "${!gh_var:-}" ]; then echo "Setting $secret_name from $gh_var" gh secret set "$secret_name" --body "${!gh_var}" @@ -36,7 +36,7 @@ gh-add-secrets: echo "Skipping $secret_name (neither $gh_var nor $plain_var is set)" fi } - + # Set each secret if the corresponding env var exists set_secret_if_exists "PAT_FOR_PR" set_secret_if_exists "ANTHROPIC_API_KEY" @@ -44,3 +44,6 @@ gh-add-secrets: set_secret_if_exists "CBORG_API_KEY" set_secret_if_exists "CLAUDE_CODE_OAUTH_TOKEN" +gh-invite-dragon-ai: + gh api repos/:owner/:repo/collaborators/dragon-ai-agent --method PUT --field permission=write > /dev/null +