diff --git a/TimeWarp.Architecture/.github/workflows/claude-code-review.yml b/TimeWarp.Architecture/.github/workflows/claude-code-review.yml new file mode 100644 index 00000000..ecd27d0a --- /dev/null +++ b/TimeWarp.Architecture/.github/workflows/claude-code-review.yml @@ -0,0 +1,75 @@ +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@beta + with: + anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} + + # Optional: Specify model (defaults to Claude Sonnet 4, uncomment for Claude Opus 4) + # model: "claude-opus-4-20250514" + + # Direct prompt for automated review (no @claude mention needed) + direct_prompt: | + Please review this pull request and provide feedback on: + - Code quality and best practices + - Potential bugs or issues + - Performance considerations + - Security concerns + - Test coverage + + Be constructive and helpful in your feedback. + + # Optional: Customize review based on file types + # direct_prompt: | + # Review this PR focusing on: + # - For TypeScript files: Type safety and proper interface usage + # - For API endpoints: Security, input validation, and error handling + # - For React components: Performance, accessibility, and best practices + # - For tests: Coverage, edge cases, and test quality + + # Optional: Different prompts for different authors + # direct_prompt: | + # ${{ github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR' && + # 'Welcome! Please review this PR from a first-time contributor. Be encouraging and provide detailed explanations for any suggestions.' || + # 'Please provide a thorough code review focusing on our coding standards and best practices.' }} + + # Optional: Add specific tools for running tests or linting + # allowed_tools: "Bash(npm run test),Bash(npm run lint),Bash(npm run typecheck)" + + # Optional: Skip review for certain conditions + # if: | + # !contains(github.event.pull_request.title, '[skip-review]') && + # !contains(github.event.pull_request.title, '[WIP]') + diff --git a/TimeWarp.Architecture/.github/workflows/claude.yml b/TimeWarp.Architecture/.github/workflows/claude.yml new file mode 100644 index 00000000..58d0fa2e --- /dev/null +++ b/TimeWarp.Architecture/.github/workflows/claude.yml @@ -0,0 +1,59 @@ +name: Claude Code + +on: + issue_comment: + types: [created] + pull_request_review_comment: + types: [created] + issues: + types: [opened, assigned] + pull_request_review: + types: [submitted] + +jobs: + claude: + if: | + (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) || + (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) || + (github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) || + (github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude'))) + 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 + id: claude + uses: anthropics/claude-code-action@beta + with: + anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} + + # Optional: Specify model (defaults to Claude Sonnet 4, uncomment for Claude Opus 4) + # model: "claude-opus-4-20250514" + + # Optional: Customize the trigger phrase (default: @claude) + # trigger_phrase: "/claude" + + # Optional: Trigger when specific user is assigned to an issue + # assignee_trigger: "claude-bot" + + # Optional: Allow Claude to run specific commands + # allowed_tools: "Bash(npm install),Bash(npm run build),Bash(npm run test:*),Bash(npm run lint:*)" + + # Optional: Add custom instructions for Claude to customize its behavior for your project + # custom_instructions: | + # Follow our coding standards + # Ensure all new code has tests + # Use TypeScript for new files + + # Optional: Custom environment variables for Claude + # claude_env: | + # NODE_ENV: test + diff --git a/TimeWarp.Architecture/.github/workflows/test-sync.yml b/TimeWarp.Architecture/.github/workflows/test-sync.yml new file mode 100644 index 00000000..86bf4c8f --- /dev/null +++ b/TimeWarp.Architecture/.github/workflows/test-sync.yml @@ -0,0 +1,23 @@ +# Test workflow file for sync functionality +# This is a safe test file that does nothing important +# Used to test GitHub API workflow sync without affecting real workflows + +name: Test Sync Workflow + +on: + workflow_dispatch: + inputs: + test_input: + description: 'Test input parameter' + required: false + default: 'test-value' + +jobs: + test-job: + runs-on: ubuntu-latest + steps: + - name: Test Step + run: | + echo "This is a test workflow for sync functionality" + echo "Input: ${{ github.event.inputs.test_input }}" + echo "This workflow does nothing important and is safe to sync" \ No newline at end of file diff --git a/TimeWarp.Architecture/Kanban/ToDo/sync-workflow-issue-template.md b/TimeWarp.Architecture/Kanban/ToDo/sync-workflow-issue-template.md deleted file mode 100644 index ea320c68..00000000 --- a/TimeWarp.Architecture/Kanban/ToDo/sync-workflow-issue-template.md +++ /dev/null @@ -1,119 +0,0 @@ -# Add Sync Workflow for Configurable Files - -## Description - -Add the sync-configurable-files workflow to this repository to maintain consistency with organizational standards and shared configurations. This workflow will automatically sync common files from the parent TimeWarp Architecture repository. - -## Requirements - -- [ ] Add `workflows-temp/sync-configurable-files.yml` workflow file (GitHub Apps cannot write to .github/workflows/) -- [ ] Create `workflows-temp/sync-config.yml` configuration file tailored to this repository's technology stack -- [ ] Add PowerShell script `workflows-temp/sync-configurable-files.ps1` -- [ ] Create manual copy script `copy-workflows.ps1` to move files from temp to .github/workflows/ -- [ ] Test workflow functionality via manual trigger after copying -- [ ] Implement `.gitignore` sync strategy (see strategy below) - -## Repository Analysis Needed - -Please analyze this repository to determine: - -1. **Technology Stack**: (.NET, npm/Node.js, documentation, etc.) -2. **File Structure**: Existing `.github/` directory structure -3. **Configuration Files**: Current presence of files like: - - `Directory.Build.props` / `Directory.Build.targets` - - `global.json` - - `.editorconfig` - - `package.json` (for npm repos) - - `.nvmrc` (for Node.js repos) - - Documentation templates -4. **Existing Workflows**: Current GitHub Actions workflows that might conflict - -## Sync Configuration Requirements - -Based on repository type, the sync config should include: - -### For .NET Repositories -- `Directory.Build.props` -- `Directory.Build.targets` -- `global.json` -- `.editorconfig` -- Common GitHub workflow templates - -### For npm/Node.js Repositories -- `package.json` scripts section -- `.nvmrc` -- ESLint/Prettier configurations -- TypeScript configurations - -### For Documentation Repositories -- Markdown templates -- DocFX configurations -- Documentation workflow templates - -### For All Repositories -- `.gitignore` (using merge strategy - see below) -- Common GitHub workflow templates -- Security and code quality configurations - -## GitIgnore Sync Strategy - -**.gitignore files require special handling** to maintain both global consistency and repository-specific needs: - -### Merge Strategy -- **Global Section**: Sync common ignore patterns from parent repository -- **Local Section**: Preserve repository-specific ignore patterns -- **Process**: Sync script merges global section while preserving local section - -**Implementation using section markers:** -``` -# ----- Global .gitignore (synced from TimeWarp Architecture) ----- -# This section is automatically synced - do not edit manually -[global ignore patterns] - -# ----- Repository-specific .gitignore ----- -# Add repository-specific ignore patterns below this line -[local additions] -``` - -## Expected Deliverables - -1. **Temporary Workflow File**: `workflows-temp/sync-configurable-files.yml` -2. **Temporary Configuration**: `workflows-temp/sync-config.yml` with repository-specific file list -3. **Temporary Script**: `workflows-temp/sync-configurable-files.ps1` -4. **Manual Copy Script**: `copy-workflows.ps1` to move files from temp to proper locations -5. **Testing**: Successful manual workflow run after copying files -6. **Documentation**: Brief summary of what files will be synced and the two-step deployment process - -## Parent Repository - -- **Source**: `TimeWarpEngineering/timewarp-architecture` -- **Branch**: `master` -- **Template Location**: `TimeWarp.Architecture/.github/workflows/sync-configurable-files.yml` - -## Implementation Notes - -- Use the existing sync workflow from `timewarp-architecture` as the base template -- Customize the `sync-config.yml` based on this repository's specific needs -- Generate all workflow files in `workflows-temp/` directory instead of `.github/workflows/` -- Create `copy-workflows.ps1` script for manual deployment due to GitHub Apps limitations -- Ensure the workflow has proper permissions and PAT configuration -- Test with a dry run before enabling automatic scheduling - -## Two-Step Deployment Process - -Due to GitHub Apps being unable to update workflow files directly: - -1. **Automated Step**: Generate workflow files in `workflows-temp/` directory -2. **Manual Step**: Run `copy-workflows.ps1` to copy files to `.github/workflows/` and `.github/scripts/` - ---- - -@Claude Please implement this sync workflow for this repository using the two-step process. Analyze the codebase, create the appropriate configuration in the temp directory, and provide the manual copy script. - -## Acceptance Criteria - -- [ ] Sync workflow files are generated in `workflows-temp/` directory -- [ ] Manual copy script `copy-workflows.ps1` is created and functional -- [ ] Configuration is appropriate for this repository's technology stack -- [ ] No conflicts with existing workflows or configurations after manual copying -- [ ] Documentation includes instructions for the two-step deployment process \ No newline at end of file diff --git a/TimeWarp.Architecture/copy-workflows.ps1 b/TimeWarp.Architecture/copy-workflows.ps1 deleted file mode 100644 index 24680b7b..00000000 --- a/TimeWarp.Architecture/copy-workflows.ps1 +++ /dev/null @@ -1,120 +0,0 @@ -#!/usr/bin/env pwsh - -<# -.SYNOPSIS - Copy workflow files from workflows-temp/ to their proper GitHub locations - -.DESCRIPTION - Due to GitHub Apps limitations in updating workflow files, this script manually copies - workflow files from the temporary location to their proper GitHub directories. - -.PARAMETER DryRun - Show what would be copied without actually copying files - -.EXAMPLE - ./copy-workflows.ps1 - Copy all workflow files to their proper locations - -.EXAMPLE - ./copy-workflows.ps1 -DryRun - Show what would be copied without making changes -#> - -param( - [switch]$DryRun -) - -# Ensure we're in the correct directory -$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path -Push-Location $scriptDir - -try { - Write-Host "🔄 Copying workflow files from workflows-temp/ to proper GitHub locations..." -ForegroundColor Cyan - - # Define source and destination mappings - $fileMappings = @( - @{ - Source = "workflows-temp/sync-configurable-files.yml" - Destination = ".github/workflows/sync-configurable-files.yml" - Description = "Sync workflow YAML file" - }, - @{ - Source = "workflows-temp/sync-config.yml" - Destination = ".github/sync-config.yml" - Description = "Sync configuration file" - }, - @{ - Source = "workflows-temp/sync-configurable-files.ps1" - Destination = ".github/scripts/sync-configurable-files.ps1" - Description = "Sync PowerShell script" - } - ) - - # Check if workflows-temp directory exists - if (-not (Test-Path "workflows-temp")) { - Write-Error "❌ workflows-temp/ directory not found. Please generate workflow files first." - exit 1 - } - - # Create destination directories if they don't exist - $directories = @(".github/workflows", ".github/scripts") - foreach ($dir in $directories) { - if (-not (Test-Path $dir)) { - if ($DryRun) { - Write-Host "📁 Would create directory: $dir" -ForegroundColor Yellow - } else { - New-Item -ItemType Directory -Path $dir -Force | Out-Null - Write-Host "📁 Created directory: $dir" -ForegroundColor Green - } - } - } - - # Copy each file - $copiedCount = 0 - $skippedCount = 0 - - foreach ($mapping in $fileMappings) { - $sourcePath = $mapping.Source - $destPath = $mapping.Destination - $description = $mapping.Description - - if (Test-Path $sourcePath) { - if ($DryRun) { - Write-Host "📄 Would copy: $sourcePath → $destPath ($description)" -ForegroundColor Yellow - } else { - Copy-Item -Path $sourcePath -Destination $destPath -Force - Write-Host "✅ Copied: $sourcePath → $destPath ($description)" -ForegroundColor Green - $copiedCount++ - } - } else { - Write-Host "⚠️ Skipped: $sourcePath (file not found)" -ForegroundColor Yellow - $skippedCount++ - } - } - - # Summary - Write-Host "" - if ($DryRun) { - Write-Host "🔍 Dry run completed. No files were actually copied." -ForegroundColor Cyan - } else { - Write-Host "✨ Copy operation completed!" -ForegroundColor Green - Write-Host " Copied: $copiedCount files" -ForegroundColor Green - if ($skippedCount -gt 0) { - Write-Host " Skipped: $skippedCount files (not found)" -ForegroundColor Yellow - } - } - - # Next steps guidance - Write-Host "" - Write-Host "📋 Next Steps:" -ForegroundColor Cyan - Write-Host " 1. Review the copied workflow files in .github/" -ForegroundColor White - Write-Host " 2. Commit and push the changes" -ForegroundColor White - Write-Host " 3. Test the sync workflow via manual trigger in GitHub Actions" -ForegroundColor White - Write-Host " 4. Configure repository secrets if needed (PAT_TOKEN, etc.)" -ForegroundColor White - -} catch { - Write-Error "❌ Error during copy operation: $_" - exit 1 -} finally { - Pop-Location -} \ No newline at end of file