Add CLAUDE.md modular architecture refactor game plan #285
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Documentation Check | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| branches: | |
| - main | |
| permissions: | |
| pull-requests: write | |
| contents: read | |
| jobs: | |
| check-documentation: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Get full history for diff | |
| - name: Get PR diff | |
| id: diff | |
| run: | | |
| # Get the base branch (main) | |
| git fetch origin ${{ github.base_ref }} | |
| # Generate diff between base and PR branch | |
| git diff origin/${{ github.base_ref }}...${{ github.sha }} > pr_diff.txt | |
| # Get list of changed files | |
| git diff --name-only origin/${{ github.base_ref }}...${{ github.sha }} > changed_files.txt | |
| echo "diff_size=$(wc -l < pr_diff.txt)" >> $GITHUB_OUTPUT | |
| - name: Analyze with GitHub Copilot | |
| id: copilot | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| # Create analysis prompt | |
| cat > analysis_prompt.txt << 'EOF' | |
| You are reviewing a pull request to determine if documentation needs to be updated. | |
| Review the code changes and determine if any of these documentation files need updates: | |
| **Root Documentation:** | |
| - .cursorrules (AI assistant reference) | |
| - ARCHITECTURE.md (system architecture) | |
| - CONVENTIONS.md (code standards) | |
| - CONTEXT.md (domain knowledge) | |
| - IPC_API.md (IPC channels) | |
| - DECISIONS.md (architectural decisions) | |
| - TROUBLESHOOTING.md (common issues) | |
| - TUTORIALS.md (workflow guides) | |
| - DOCUMENTATION.md (documentation index) | |
| **Directory READMEs:** | |
| - electron/README.md | |
| - src/README.md | |
| - src/components/README.md | |
| - src/components/Canvas/README.md | |
| - src/store/README.md | |
| - src/utils/README.md | |
| **Inline Documentation:** | |
| - JSDoc in all modified files | |
| **Changed Files:** | |
| EOF | |
| cat changed_files.txt >> analysis_prompt.txt | |
| cat >> analysis_prompt.txt << 'EOF' | |
| **Code Changes:** | |
| EOF | |
| head -n 500 pr_diff.txt >> analysis_prompt.txt | |
| cat >> analysis_prompt.txt << 'EOF' | |
| Analyze the changes and provide: | |
| 1. **Documentation Impact**: High/Medium/Low/None | |
| 2. **Files Needing Updates**: List specific documentation files that should be updated | |
| 3. **Required Changes**: Brief description of what needs to be updated in each file | |
| 4. **New Documentation**: Any new files that should be created | |
| Format your response as markdown for a GitHub PR comment. | |
| EOF | |
| # Call GitHub Models API (OpenAI-compatible endpoint) | |
| response=$(curl -s https://models.inference.ai.azure.com/chat/completions \ | |
| -H "Content-Type: application/json" \ | |
| -H "Authorization: Bearer $GH_TOKEN" \ | |
| -d @- << JSON | |
| { | |
| "model": "gpt-4o", | |
| "messages": [ | |
| { | |
| "role": "system", | |
| "content": "You are a helpful documentation reviewer. Analyze code changes and provide specific, actionable documentation suggestions." | |
| }, | |
| { | |
| "role": "user", | |
| "content": $(cat analysis_prompt.txt | jq -Rs .) | |
| } | |
| ], | |
| "max_tokens": 4096, | |
| "temperature": 0.3 | |
| } | |
| JSON | |
| ) | |
| # Extract content from response | |
| analysis=$(echo "$response" | jq -r '.choices[0].message.content') | |
| # Save to file for comment | |
| echo "$analysis" > analysis_result.md | |
| # Check if high or medium impact | |
| if echo "$analysis" | grep -qE "(Documentation Impact: High|Documentation Impact: Medium)"; then | |
| echo "needs_update=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "needs_update=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Post PR comment | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const fs = require('fs'); | |
| const analysis = fs.readFileSync('analysis_result.md', 'utf8'); | |
| const comment = `## 📚 Documentation Check | |
| GitHub Copilot has analyzed this PR for documentation impact. | |
| ${analysis} | |
| --- | |
| ### 📝 Documentation Files Reference | |
| **Root docs:** [View all](https://github.com/${{ github.repository }}/tree/${{ github.base_ref }}) | |
| - [\`.cursorrules\`](https://github.com/${{ github.repository }}/blob/${{ github.base_ref }}/.cursorrules) | |
| - [\`ARCHITECTURE.md\`](https://github.com/${{ github.repository }}/blob/${{ github.base_ref }}/ARCHITECTURE.md) | |
| - [\`IPC_API.md\`](https://github.com/${{ github.repository }}/blob/${{ github.base_ref }}/IPC_API.md) | |
| - [\`CONVENTIONS.md\`](https://github.com/${{ github.repository }}/blob/${{ github.base_ref }}/CONVENTIONS.md) | |
| **See [DOCUMENTATION.md](https://github.com/${{ github.repository }}/blob/${{ github.base_ref }}/DOCUMENTATION.md) for complete documentation inventory.** | |
| <sub>Powered by GitHub Copilot • [Documentation Guide](https://github.com/${{ github.repository }}/blob/${{ github.base_ref }}/DOCUMENTATION.md)</sub>`; | |
| // Post comment on PR | |
| github.rest.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: comment | |
| }); | |
| - name: Add PR label | |
| if: steps.copilot.outputs.needs_update == 'true' | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| github.rest.issues.addLabels({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| labels: ['documentation-needed'] | |
| }); |