Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,19 @@
# Copy this file to .env and add your actual API key
ANTHROPIC_API_KEY=your-anthropic-api-key-here

# API Provider Configuration
# Options: "anthropic" (default) or "openrouter"
API_PROVIDER=anthropic

# API Key - Works for both Anthropic and OpenRouter
# For Anthropic: Get your key at https://console.anthropic.com/
# For OpenRouter: Get your key at https://openrouter.ai/keys
ANTHROPIC_API_KEY=your-api-key-here

# Model Configuration
# For Anthropic (when API_PROVIDER=anthropic):
ANTHROPIC_MODEL=claude-sonnet-4-20250514

# For OpenRouter (when API_PROVIDER=openrouter):
# Available models: anthropic/claude-3.5-sonnet, anthropic/claude-3-opus, etc.
# See https://openrouter.ai/models for full list
OPENROUTER_MODEL=anthropic/claude-3.5-sonnet
16 changes: 16 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[flake8]
max-line-length = 100
extend-ignore = E203, E266, E501, W503
exclude =
.git,
__pycache__,
.venv,
venv,
.eggs,
*.egg,
dist,
build,
chroma_db
max-complexity = 10
per-file-ignores =
__init__.py:F401
90 changes: 90 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: CI/CD Pipeline

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
quality-checks:
name: Code Quality & Tests
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python 3.13
uses: actions/setup-python@v5
with:
python-version: '3.13'

- name: Install uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true

- name: Install dependencies
run: |
uv sync

- name: Run Black (formatting check)
run: |
uv run black --check backend/ *.py
continue-on-error: false

- name: Run isort (import sorting check)
run: |
uv run isort --check-only backend/ *.py
continue-on-error: false

- name: Run flake8 (linting)
run: |
uv run flake8 backend/ *.py
continue-on-error: false

- name: Run mypy (type checking)
run: |
uv run mypy backend/ *.py
continue-on-error: true # Allow type checking to fail without blocking

- name: Run pytest (tests with coverage)
run: |
# Set API provider based on available secrets
if [ -n "${{ secrets.ANTHROPIC_API_KEY }}" ]; then
export API_PROVIDER=anthropic
export ANTHROPIC_API_KEY="${{ secrets.ANTHROPIC_API_KEY }}"
elif [ -n "${{ secrets.OPENROUTER_API_KEY }}" ]; then
export API_PROVIDER=openrouter
export ANTHROPIC_API_KEY="${{ secrets.OPENROUTER_API_KEY }}"
export OPENROUTER_MODEL="anthropic/claude-3.5-sonnet"
fi

uv run pytest backend/tests/ -v --cov=backend --cov-report=term-missing --cov-report=xml

- name: Upload coverage reports
uses: codecov/codecov-action@v4
if: always()
with:
file: ./coverage.xml
fail_ci_if_error: false
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

summary:
name: CI Summary
runs-on: ubuntu-latest
needs: [quality-checks]
if: always()

steps:
- name: Check CI Status
run: |
if [ "${{ needs.quality-checks.result }}" == "success" ]; then
echo "✅ All quality checks and tests passed!"
exit 0
else
echo "❌ Some checks failed. Please review the logs above."
exit 1
fi
57 changes: 57 additions & 0 deletions .github/workflows/claude-code-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Claude Code Review

on:
pull_request:
types: [opened, synchronize]
# Optional: Only run on specific file changes
# paths:
# - "src/**/*.ts"
# - "src/**/*.tsx"
# - "src/**/*.js"
# - "src/**/*.jsx"

jobs:
claude-review:
# Optional: Filter by PR author
# if: |
# github.event.pull_request.user.login == 'external-contributor' ||
# github.event.pull_request.user.login == 'new-developer' ||
# github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR'

runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
issues: read
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Run Claude Code Review
id: claude-review
uses: anthropics/claude-code-action@v1
with:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
prompt: |
REPO: ${{ github.repository }}
PR NUMBER: ${{ github.event.pull_request.number }}
Please review this pull request and provide feedback on:
- Code quality and best practices
- Potential bugs or issues
- Performance considerations
- Security concerns
- Test coverage
Use the repository's CLAUDE.md for guidance on style and conventions. Be constructive and helpful in your feedback.
Use `gh pr comment` with your Bash tool to leave your review as a comment on the PR.
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
# or https://code.claude.com/docs/en/cli-reference for available options
claude_args: '--allowed-tools "Bash(gh issue view:*),Bash(gh search:*),Bash(gh issue list:*),Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr list:*)"'

124 changes: 124 additions & 0 deletions .github/workflows/claude-code.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
name: Claude Code

on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]

permissions:
contents: write
pull-requests: write
issues: write

jobs:
claude-code:
# Only run on comments that mention @claude code
if: |
github.event.comment.body != null &&
contains(github.event.comment.body, '@claude code')
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get PR branch
id: get-branch
if: github.event.issue.pull_request
run: |
PR_NUMBER=${{ github.event.issue.number }}
BRANCH=$(gh pr view $PR_NUMBER --json headRefName --jq '.headRefName')
echo "branch=$BRANCH" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Checkout PR branch
if: github.event.issue.pull_request
run: |
git fetch origin ${{ steps.get-branch.outputs.branch }}
git checkout ${{ steps.get-branch.outputs.branch }}

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'

- name: Install uv
uses: astral-sh/setup-uv@v4

- name: Install dependencies
run: uv sync

- name: Extract task from comment
id: extract-task
run: |
COMMENT_BODY="${{ github.event.comment.body }}"
# Remove @claude code prefix and extract the actual task
TASK=$(echo "$COMMENT_BODY" | sed 's/@claude code//g' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
echo "task=$TASK" >> $GITHUB_OUTPUT

- name: Add reaction to comment
run: |
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
/repos/${{ github.repository }}/issues/comments/${{ github.event.comment.id }}/reactions \
-f content='eyes'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Post processing status
run: |
gh pr comment ${{ github.event.issue.number }} \
--body "🤖 Claude Code is processing your request: \`${{ steps.extract-task.outputs.task }}\`"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Run Claude Code task
id: claude-task
run: |
# Set API provider based on available secrets
if [ -n "${{ secrets.ANTHROPIC_API_KEY }}" ]; then
export API_PROVIDER=anthropic
export ANTHROPIC_API_KEY="${{ secrets.ANTHROPIC_API_KEY }}"
elif [ -n "${{ secrets.OPENROUTER_API_KEY }}" ]; then
export API_PROVIDER=openrouter
export ANTHROPIC_API_KEY="${{ secrets.OPENROUTER_API_KEY }}"
export OPENROUTER_MODEL="anthropic/claude-3.5-sonnet"
fi

# This is a placeholder - you would integrate with Claude Code CLI here
echo "Task: ${{ steps.extract-task.outputs.task }}"
echo "Using API Provider: ${API_PROVIDER:-none}"
echo "Note: Full Claude Code integration requires additional setup"

- name: Commit and push changes
if: success()
run: |
git config user.name "Claude Code Bot"
git config user.email "claude-code-bot@users.noreply.github.com"

if [[ -n $(git status -s) ]]; then
git add .
git commit -m "🤖 Claude Code: ${{ steps.extract-task.outputs.task }}"
git push

gh pr comment ${{ github.event.issue.number }} \
--body "✅ Changes have been committed to this PR"
else
gh pr comment ${{ github.event.issue.number }} \
--body "ℹ️ No changes were made"
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Handle errors
if: failure()
run: |
gh pr comment ${{ github.event.issue.number }} \
--body "❌ Claude Code encountered an error processing your request. Please check the workflow logs for details."
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Loading