Skip to content
Closed
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
104 changes: 100 additions & 4 deletions .github/workflows/claude.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,27 @@ jobs:
with:
fetch-depth: 0
token: ${{ steps.claude-token.outputs.token }}
path: fcvm

- uses: actions/checkout@v4
with:
repository: ejc3/fuse-backend-rs
ref: master
path: fuse-backend-rs

- uses: actions/checkout@v4
with:
repository: ejc3/fuser
ref: master
path: fuser

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy

- name: Install build dependencies
run: sudo apt-get update && sudo apt-get install -y libfuse3-dev libclang-dev clang

- uses: actions/setup-node@v4
with:
Expand All @@ -169,9 +190,10 @@ jobs:
version: 9

- name: Install dependencies
run: cd scripts/claude-assistant && pnpm install
run: cd fcvm/scripts/claude-assistant && pnpm install

- name: Run Claude review
working-directory: fcvm
env:
GH_TOKEN: ${{ steps.claude-token.outputs.token }}
CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
Expand All @@ -183,6 +205,8 @@ jobs:
BASE_BRANCH: ${{ github.event.pull_request.base.ref }}
RUN_ID: ${{ github.run_id }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
FUSE_BACKEND_RS: ${{ github.workspace }}/fuse-backend-rs
FUSER: ${{ github.workspace }}/fuser
run: |
cd scripts/claude-assistant && pnpm exec tsx index.ts 2>&1 | tee /tmp/claude-output.log
# Verify completion marker exists (detects if process was killed mid-execution)
Expand Down Expand Up @@ -219,6 +243,27 @@ jobs:
fetch-depth: 0
ref: refs/pull/${{ github.event.issue.number }}/head
token: ${{ steps.claude-token.outputs.token }}
path: fcvm

- uses: actions/checkout@v4
with:
repository: ejc3/fuse-backend-rs
ref: master
path: fuse-backend-rs

- uses: actions/checkout@v4
with:
repository: ejc3/fuser
ref: master
path: fuser

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy

- name: Install build dependencies
run: sudo apt-get update && sudo apt-get install -y libfuse3-dev libclang-dev clang

- uses: actions/setup-node@v4
with:
Expand All @@ -229,7 +274,7 @@ jobs:
version: 9

- name: Install dependencies
run: cd scripts/claude-assistant && pnpm install
run: cd fcvm/scripts/claude-assistant && pnpm install

- name: Get PR info
id: pr
Expand All @@ -242,6 +287,7 @@ jobs:
GH_TOKEN: ${{ steps.claude-token.outputs.token }}

- name: Run Claude review
working-directory: fcvm
env:
GH_TOKEN: ${{ steps.claude-token.outputs.token }}
CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
Expand All @@ -253,6 +299,8 @@ jobs:
BASE_BRANCH: ${{ steps.pr.outputs.base_branch }}
RUN_ID: ${{ github.run_id }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
FUSE_BACKEND_RS: ${{ github.workspace }}/fuse-backend-rs
FUSER: ${{ github.workspace }}/fuser
run: |
cd scripts/claude-assistant && pnpm exec tsx index.ts 2>&1 | tee /tmp/claude-output.log
if ! grep -q "CLAUDE_ASSISTANT_COMPLETE" /tmp/claude-output.log; then
Expand Down Expand Up @@ -287,6 +335,27 @@ jobs:
with:
fetch-depth: 0
token: ${{ steps.claude-token.outputs.token }}
path: fcvm

- uses: actions/checkout@v4
with:
repository: ejc3/fuse-backend-rs
ref: master
path: fuse-backend-rs

- uses: actions/checkout@v4
with:
repository: ejc3/fuser
ref: master
path: fuser

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy

- name: Install build dependencies
run: sudo apt-get update && sudo apt-get install -y libfuse3-dev libclang-dev clang

- uses: actions/setup-node@v4
with:
Expand All @@ -297,7 +366,7 @@ jobs:
version: 9

- name: Install dependencies
run: cd scripts/claude-assistant && pnpm install
run: cd fcvm/scripts/claude-assistant && pnpm install

- name: Get PR info
id: pr
Expand All @@ -317,6 +386,7 @@ jobs:
fi

- name: Run Claude respond
working-directory: fcvm
env:
GH_TOKEN: ${{ steps.claude-token.outputs.token }}
CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
Expand All @@ -329,6 +399,8 @@ jobs:
RUN_ID: ${{ github.run_id }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
COMMENT_BODY: ${{ github.event.comment.body }}
FUSE_BACKEND_RS: ${{ github.workspace }}/fuse-backend-rs
FUSER: ${{ github.workspace }}/fuser
run: |
cd scripts/claude-assistant && pnpm exec tsx index.ts 2>&1 | tee /tmp/claude-output.log
if ! grep -q "CLAUDE_ASSISTANT_COMPLETE" /tmp/claude-output.log; then
Expand Down Expand Up @@ -365,6 +437,27 @@ jobs:
ref: ${{ github.event.workflow_run.head_sha }}
fetch-depth: 0
token: ${{ steps.claude-token.outputs.token }}
path: fcvm

- uses: actions/checkout@v4
with:
repository: ejc3/fuse-backend-rs
ref: master
path: fuse-backend-rs

- uses: actions/checkout@v4
with:
repository: ejc3/fuser
ref: master
path: fuser

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy

- name: Install build dependencies
run: sudo apt-get update && sudo apt-get install -y libfuse3-dev libclang-dev clang

- uses: actions/setup-node@v4
with:
Expand All @@ -375,9 +468,10 @@ jobs:
version: 9

- name: Install dependencies
run: cd scripts/claude-assistant && pnpm install
run: cd fcvm/scripts/claude-assistant && pnpm install

- name: Run Claude CI fix
working-directory: fcvm
env:
GH_TOKEN: ${{ steps.claude-token.outputs.token }}
CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
Expand All @@ -392,6 +486,8 @@ jobs:
FAILED_RUN_ID: ${{ github.event.workflow_run.id }}
FAILED_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }}
WORKFLOW_NAME: ${{ github.event.workflow_run.name }}
FUSE_BACKEND_RS: ${{ github.workspace }}/fuse-backend-rs
FUSER: ${{ github.workspace }}/fuser
run: |
cd scripts/claude-assistant && pnpm exec tsx index.ts 2>&1 | tee /tmp/claude-output.log
if ! grep -q "CLAUDE_ASSISTANT_COMPLETE" /tmp/claude-output.log; then
Expand Down
60 changes: 59 additions & 1 deletion scripts/claude-assistant/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { tmpdir } from "os";

// Configurable limits with sensible defaults
const MAX_LOG_SIZE = parseInt(process.env.CLAUDE_MAX_LOG_SIZE ?? "100000", 10);
const MAX_TURNS = parseInt(process.env.CLAUDE_MAX_TURNS ?? "50", 10);
const MAX_TURNS = parseInt(process.env.CLAUDE_MAX_TURNS ?? "75", 10);

// Branch naming convention for Claude-generated fix branches
const FIX_BRANCH_PREFIX = "claude/fix-";
Expand Down Expand Up @@ -229,6 +229,57 @@ All GitHub operations target **PR #${ctx.prNumber}** in **${ctx.repository}**.

---

## STEP 0: WAIT FOR CI TO PASS

**Before doing anything else**, wait for CI checks to pass.

### 0a. Check Lint status first (fast check)
\`\`\`bash
gh api repos/${ctx.repository}/commits/${ctx.headSha}/check-runs --jq '.check_runs[] | select(.name == "Lint") | {name: .name, status: .status, conclusion: .conclusion}'
\`\`\`

### 0b. If Lint passes, check overall PR status
\`\`\`bash
gh pr checks ${ctx.prNumber} --repo ${ctx.repository}
\`\`\`

**Rules:**
- If **Lint failed**: Stop immediately. Post comment: "Lint failed - please fix before I can review."
- If **any check failed**: Stop. Post comment noting which check failed.
- If **checks are still running**: Wait 30 seconds, then check again. Repeat until all pass/fail or 15 minutes elapsed.
- If **all checks pass**: Proceed to Step 1.

**Do NOT proceed with the review until CI passes.** Reviewing code that doesn't pass CI is a waste of time.

---

## CRITICAL: IF YOU MAKE CHANGES

When you edit files and create a fix PR:

### 1. Run lint locally BEFORE committing
\`\`\`bash
cargo fmt --check
cargo clippy --all-targets -- -D warnings
\`\`\`

If lint fails, fix the issues before committing. **NEVER push code that doesn't pass lint.**

### 2. After pushing, verify your PR passes CI
\`\`\`bash
gh pr checks <your-pr-number> --repo ${ctx.repository} --watch
\`\`\`

If CI fails on your PR:
- Read the failure logs
- Fix the issue
- Commit and push again
- Repeat until CI passes

**Your fix PR must pass CI before you're done.** Do not leave broken PRs.

---

## STEP 1: UNDERSTAND THE FULL SCOPE

### 1a. Get PR context (title, description, comments)
Expand Down Expand Up @@ -303,6 +354,13 @@ _Review by Claude | [Run](${ctx.runUrl})_"
### 5a. Edit files
Make the minimum changes needed to fix the issues.

**IMPORTANT: Edit files directly in the repo. NEVER:**
- Copy files to /tmp and edit there
- Create temp files and copy back
- Use intermediate files

Just use the Edit tool directly on the source files.

### 5b. Commit
\`\`\`bash
git add -A
Expand Down