diff --git a/.github/workflows/claude-documentation-fixer.yml b/.github/workflows/claude-documentation-fixer.yml index d522174223..9cec53fe0b 100644 --- a/.github/workflows/claude-documentation-fixer.yml +++ b/.github/workflows/claude-documentation-fixer.yml @@ -3,23 +3,14 @@ name: Documentation Fixer on: issue_comment: types: [created] - pull_request_review_comment: - types: [created] jobs: claude-response: runs-on: ubuntu-latest if: | - ( - github.event_name == 'issue_comment' && - github.event.issue.pull_request && - contains(github.event.comment.body, '@claude') && - github.event.comment.user.login != 'github-actions[bot]' - ) || ( - github.event_name == 'pull_request_review_comment' && - contains(github.event.comment.body, '@claude') && - github.event.comment.user.login != 'github-actions[bot]' - ) + github.event.issue.pull_request && + contains(github.event.comment.body, '@claude') && + github.event.comment.user.login != 'github-actions[bot]' permissions: contents: write pull-requests: write @@ -32,11 +23,7 @@ jobs: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - if [ "${{ github.event_name }}" = "issue_comment" ]; then - PR_NUMBER="${{ github.event.issue.number }}" - else - PR_NUMBER="${{ github.event.pull_request.number }}" - fi + PR_NUMBER="${{ github.event.issue.number }}" PR_DATA=$(gh pr view $PR_NUMBER --repo ${{ github.repository }} --json headRefName,isCrossRepository) echo "number=$PR_NUMBER" >> "$GITHUB_OUTPUT" echo "branch=$(echo "$PR_DATA" | jq -r '.headRefName')" >> "$GITHUB_OUTPUT" @@ -57,69 +44,37 @@ jobs: ref: ${{ steps.pr-info.outputs.branch }} fetch-depth: 0 - - name: Build prompt for review comment reply - id: build-prompt - if: steps.pr-info.outputs.is_fork == 'false' && github.event_name == 'pull_request_review_comment' - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - COMMENT_BODY: ${{ github.event.comment.body }} - FILE_PATH: ${{ github.event.comment.path }} - LINE: ${{ github.event.comment.line }} - IN_REPLY_TO: ${{ github.event.comment.in_reply_to_id }} - run: | - if [ -n "$IN_REPLY_TO" ] && [ "$IN_REPLY_TO" != "0" ]; then - PARENT_BODY=$(gh api repos/${{ github.repository }}/pulls/comments/$IN_REPLY_TO --jq '.body') - else - PARENT_BODY="$COMMENT_BODY" - fi + - name: Checkout system prompt repository + if: steps.pr-info.outputs.is_fork == 'false' + uses: actions/checkout@v4 + with: + repository: netwrix-eng/internal-agents + token: ${{ secrets.PRIVATE_AGENTS_REPO }} + path: system-prompt-repo + ref: builds + sparse-checkout: | + engineering/technical_writing/system-prompt.md + sparse-checkout-cone-mode: false + - name: Read system prompt + id: read-prompt + if: steps.pr-info.outputs.is_fork == 'false' + run: | { echo "prompt<'. Add this suggestion to the list and rewrite the comment using exactly this format (replacing N with the updated count and updating the list):" - echo "" - echo " " - echo " **Batched suggestions: N**" - echo " Comment \`@claude apply batch\` on this PR to apply all of them." - echo "" - echo " | # | File | Line | Suggested change |" - echo " |---|------|------|------------------|" - echo " | 1 | \`path/to/file.md\` | 12 | suggested text |" - echo " | 2 | \`path/to/file.md\` | 34 | suggested text |" - echo "" - echo " Then post a reply to the inline comment thread: 'Added to batch (N total). Comment \`@claude apply batch\` on this PR to apply all batched suggestions.'" + cat system-prompt-repo/engineering/technical_writing/system-prompt.md + echo "" # Forces a newline to prevent EOF delimiter errors echo "EOF" } >> "$GITHUB_OUTPUT" - - name: Apply fixes (PR comment) - if: steps.pr-info.outputs.is_fork == 'false' && github.event_name == 'issue_comment' - uses: anthropics/claude-code-action@v1 - with: - anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} - github_token: ${{ secrets.GITHUB_TOKEN }} - show_full_output: true - claude_args: | - --model claude-sonnet-4-5-20250929 - --allowedTools "Read,Write,Edit,Bash(gh pr view:*),Bash(gh pr diff:*),Bash(gh pr comment:*),Bash(gh api:*),Bash(git config:*),Bash(git add:*),Bash(git commit:*),Bash(git push:*),Bash(git status:*),Bash(git diff:*)" - - - name: Apply fixes (review comment reply) - if: steps.pr-info.outputs.is_fork == 'false' && github.event_name == 'pull_request_review_comment' + - name: Apply fixes + if: steps.pr-info.outputs.is_fork == 'false' uses: anthropics/claude-code-action@v1 with: anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} github_token: ${{ secrets.GITHUB_TOKEN }} show_full_output: true - prompt: ${{ steps.build-prompt.outputs.prompt }} claude_args: | --model claude-sonnet-4-5-20250929 - --allowedTools "Read,Write,Edit,Bash(gh pr view:*),Bash(gh pr diff:*),Bash(gh pr comment:*),Bash(gh api:*),Bash(git config:*),Bash(git add:*),Bash(git commit:*),Bash(git push:*),Bash(git status:*),Bash(git diff:*)" + --allowedTools "Read,Write,Edit,Bash(gh pr view:*),Bash(gh pr diff:*),Bash(gh pr comment:*),Bash(git config:*),Bash(git add:*),Bash(git commit:*),Bash(git push:*),Bash(git status:*),Bash(git diff:*)" + --append-system-prompt "${{ steps.read-prompt.outputs.prompt }}" diff --git a/.github/workflows/claude-documentation-reviewer.yml b/.github/workflows/claude-documentation-reviewer.yml index b3952a56a2..a1de3b41a8 100644 --- a/.github/workflows/claude-documentation-reviewer.yml +++ b/.github/workflows/claude-documentation-reviewer.yml @@ -89,25 +89,16 @@ jobs: Follow these steps in order: - 1. Use the Read tool to read each file in full. Do not look at the PR diff yet. + 1. Use `gh pr diff ${{ github.event.pull_request.number }}` to get the lines that were added or modified in this PR. - 2. Identify ALL issues in the document per your instructions. + 2. Review ONLY the added or modified lines from the diff for issues per your instructions. Do not report issues on lines that were not changed. - 3. Use `gh pr diff ${{ github.event.pull_request.number }}` to get the list of lines that were added or modified in this PR. - - 4. Categorize each issue from step 2 as either: - - Issues in PR changes: the issue is on a line that was added or modified in this PR - - Preexisting issues: the issue exists on a line that was not changed by this PR - - You MUST write your complete review to `/tmp/review-summary.md` — always, even if there are no issues. Use this exact structure — two sections, each containing a flat list of issues in the format from your instructions, with no subheadings, groupings, or extra nesting: + 3. You MUST write your complete review to `/tmp/review-summary.md` — always, even if there are no issues. Use this exact structure — a flat list of issues in the format from your instructions, with no subheadings, groupings, or extra nesting: ## Issues in PR changes - ## Preexisting issues - - - Then fix ALL issues directly in the files using the Write and Edit tools. Do not post a PR comment. Do not commit or push. + 4. Fix ALL issues directly in the files using the Write and Edit tools. Do not post a PR comment. Do not commit or push. claude_args: | --model claude-sonnet-4-5-20250929 @@ -132,24 +123,15 @@ jobs: FOOTER = ( "\n---\n\n" - "To apply individual fixes, reply to the inline comments on this review" - " with `@claude apply suggestion`.\n" - "To batch fixes, reply with `@claude add suggestion to batch` on each inline comment," - " then comment `@claude apply batch` on this PR when ready.\n" - "To fix issues in bulk, reply with `@claude` here, followed by your instructions" - " (e.g. `@claude fix all issues` or `@claude fix only the spelling errors`" - " or `@claude fix all other existing issues`" - " or `@claude fix all linting issues`)." - " You can use this option to fix preexisting issues.\n\n" + "To apply suggested fixes to the updated documentation, individually or in bulk, comment `@claude`" + " on this PR followed by your instructions (`@claude fix all issues`" + " or `@claude fix all linting issues` or `@claude fix only the spelling errors`).\n\n" + "To review and fix other preexisting issues in the updated documentation, comment `@claude` on this PR" + " followed by your instructions (`@claude review preexisting issues`" + " or `@claude fix preexisting issues`).\n\n" "Note: Automated fixes are only available for branches in this repository, not forks." ) - INLINE_FOOTER = ( - "\n\n---\n\n" - "Reply with `@claude`, followed by your instructions" - " (e.g. `@claude apply suggestion` or `@claude add suggestion to batch`)." - ) - def parse_diff_to_suggestions(diff_text): suggestions = [] current_file = None @@ -226,7 +208,7 @@ jobs: return None # Pure insertions cannot be placed as inline comments end_line = old_start + len(old_chunk) - 1 new_text = '\n'.join(new_chunk) - comment_body = f"Suggested change:\n```\n{new_text}\n```{INLINE_FOOTER}" + comment_body = f"```suggestion\n{new_text}\n```" comment = { 'path': path, 'line': end_line,