name: codesight — Auto-update AI Context on: push: branches: [main, master] pull_request: types: [opened, synchronize] workflow_dispatch: permissions: contents: write pull-requests: write issues: write jobs: codesight: name: Generate AI Context Map runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 token: ${{ secrets.GITHUB_TOKEN }} - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: '20' - name: Run codesight run: npx codesight@latest --wiki - name: Commit updated context if: github.event_name == 'push' run: | git config --local user.email "action@github.com" git config --local user.name "codesight-bot" git add .codesight/ || true git diff --staged --quiet || git commit -m "chore: update AI context map [skip ci]" git push env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Comment on PR if: github.event_name == 'pull_request' uses: actions/github-script@v7 with: script: | const fs = require('fs'); const path = '.codesight/CODESIGHT.md'; if (!fs.existsSync(path)) return; const content = fs.readFileSync(path, 'utf8'); const preview = content.split('\n').slice(0, 50).join('\n'); await github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number, body: `## AI Context Map\n\n\`\`\`\n${preview}\n\`\`\`\n\n_Generated by [codesight](https://github.com/Houseofmvps/codesight)_`, });