diff --git a/README.md b/README.md index d510ee3..14a86a8 100644 --- a/README.md +++ b/README.md @@ -36,15 +36,16 @@ Your contributions help make adapter development better for the entire ioBroker ``` Title: ๐Ÿค– Setup ioBroker GitHub Copilot Instructions - GitHub Copilot: Please help me set up GitHub Copilot instructions for my ioBroker adapter repository using the template from: - templates/initial-setup-automation.md + GitHub Copilot: Please help me set up GitHub Copilot instructions for my ioBroker adapter repository using the centralized automation template from: + https://raw.githubusercontent.com/DrozmotiX/ioBroker-Copilot-Instructions/main/templates/initial-setup-automation.md ``` -2. **Let GitHub Copilot handle everything**: - - โœ… Validates existing setup - - ๐Ÿ“ฅ Downloads and customizes latest template - - ๐ŸŽฏ Adds adapter-specific content - - โš™๏ธ Sets up weekly monitoring - - ๐Ÿ›ก๏ธ Preserves any existing customizations +2. **Let GitHub Copilot handle everything** using our **centralized automation system**: + - โœ… Validates existing setup and detects repository status + - ๐Ÿ“ฅ Downloads and customizes latest template using metadata.json + - ๐ŸŽฏ Adds adapter-specific content with intelligent customization + - โš™๏ธ Sets up weekly monitoring with centralized GitHub Action + - ๐Ÿ›ก๏ธ Preserves any existing customizations automatically + - ๐Ÿšซ **Avoids manual scripts** (replaces approaches like validation scripts in package.json) ### For Quick Updates Only 1. **Create a quick update issue** with this simple content: @@ -176,7 +177,7 @@ For advanced users who want more control over the template management process: ### Manual Version Check -If you want to manually check your template status: +For repository diagnostics or manual validation: ```bash # Download and run the version check script @@ -184,10 +185,12 @@ curl -s https://raw.githubusercontent.com/DrozmotiX/ioBroker-Copilot-Instruction ``` This script will: -- Compare your local template version with the latest available +- Compare your local template version with the latest available from metadata.json - Provide update guidance if your template is outdated - Show you what's changed in newer versions +**Note**: The centralized automation system eliminates the need for manual scripts in your repository (avoiding patterns like validation scripts in package.json). + ### Repository Maintenance For repository maintainers who want to contribute or customize the template system: diff --git a/config/automation-setup.yml b/config/automation-setup.yml new file mode 100644 index 0000000..c42c901 --- /dev/null +++ b/config/automation-setup.yml @@ -0,0 +1,161 @@ +# Centralized Initial Setup Configuration for ioBroker Copilot Instructions +# Version: 0.5.0 +# This file contains the configuration and prompts for automated setup + +automation: + repository_detection: + indicators: + - "package.json contains iobroker" + - "io-package.json exists" + - "main.js or lib/ directory exists" + - "admin/ directory exists" + validation: + required_files: + - "package.json" + - "io-package.json" + - "README.md" + optional_files: + - "main.js" + - "lib/" + - "admin/" + + copilot_status_check: + detection_methods: + - "Check .github/copilot-instructions.md existence" + - "Validate version information in copilot instructions" + - "Test Copilot responsiveness in repository" + status_levels: + - "not_initialized" # No copilot-instructions.md + - "needs_update" # Version mismatch + - "up_to_date" # Current version matches + + template_integration: + source_references: + template_url: "https://raw.githubusercontent.com/DrozmotiX/ioBroker-Copilot-Instructions/main/template.md" + metadata_url: "https://raw.githubusercontent.com/DrozmotiX/ioBroker-Copilot-Instructions/main/config/metadata.json" + repository_url: "https://github.com/DrozmotiX/ioBroker-Copilot-Instructions" + + version_storage: + location: ".github/copilot-instructions.md" + format: "**Version:** X.Y.Z" + note: "Store in copilot instructions file, NOT package.json" + + customization_sections: + preserve_tags: ["[CUSTOMIZE]"] + custom_content_types: + - "Adapter-specific API patterns" + - "Unique error codes and handling" + - "Custom device discovery patterns" + - "Authentication flows specific to service" + - "Testing scenarios beyond standard patterns" + + github_action_setup: + workflow_file: ".github/workflows/check-copilot-template.yml" + template_source: "templates/centralized-version-check-action.yml" + features: + - "Weekly automated version checking" + - "Dynamic version detection from metadata.json" + - "Copilot-driven issue creation" + - "Custom section preservation" + - "Duplicate issue prevention" + +prompts: + initial_setup: + analysis_prompt: | + Please analyze this repository and check: + + 1. **Repository Type Confirmation**: + - Confirm this is an ioBroker adapter repository + - Identify the adapter name and type + - Check existing structure and dependencies + + 2. **Copilot Status Assessment**: + - Verify if GitHub Copilot is active in this repository + - Check if .github/copilot-instructions.md exists + - Analyze any existing Copilot configuration + + 3. **Setup Requirements**: + - Determine what needs to be configured + - Identify adapter-specific patterns to customize + - Plan the integration strategy + + template_setup_prompt: | + Create a complete .github/copilot-instructions.md file: + + 1. **Download and process template**: + - Fetch: https://raw.githubusercontent.com/DrozmotiX/ioBroker-Copilot-Instructions/main/template.md + - Remove template comment block ( section) + - Get version from: https://raw.githubusercontent.com/DrozmotiX/ioBroker-Copilot-Instructions/main/config/metadata.json + + 2. **Version and source setup**: + - Set version from metadata.json (store in copilot instructions, NOT package.json) + - Add template source reference + - Include metadata reference for future updates + + 3. **Adapter-specific customization**: + - Customize all [CUSTOMIZE] sections for this specific adapter + - Add unique API patterns, error codes, authentication flows + - Include adapter-specific testing scenarios + - Remove any duplicate content that exists in standard template + + workflow_setup_prompt: | + Create .github/workflows/check-copilot-template.yml: + + 1. **Use centralized template**: + - Copy from: https://raw.githubusercontent.com/DrozmotiX/ioBroker-Copilot-Instructions/main/templates/centralized-version-check-action.yml + - This provides dynamic version checking using metadata.json + - Includes Copilot-driven automation (no manual scripts) + + 2. **Weekly monitoring features**: + - Automatic version checking every Sunday + - Smart issue creation with duplicate prevention + - Custom section preservation during updates + - Manual trigger capability + + update_process: + merge_prompt: | + Update .github/copilot-instructions.md by merging latest template: + + TEMPLATE SOURCES: + - Template: https://raw.githubusercontent.com/DrozmotiX/ioBroker-Copilot-Instructions/main/template.md + - Version from: https://raw.githubusercontent.com/DrozmotiX/ioBroker-Copilot-Instructions/main/config/metadata.json + + PRESERVATION REQUIREMENTS: + 1. Keep ALL [CUSTOMIZE] sections exactly as they are + 2. Preserve adapter-specific context not in standard template + 3. Maintain custom error handling, API patterns, authentication + 4. Keep unique testing scenarios and configuration instructions + 5. REMOVE duplicate content from [CUSTOMIZE] that exists in standard template + 6. Store version in copilot instructions, NOT package.json + + UPDATE REQUIREMENTS: + 1. Integrate latest best practices from new template + 2. Update version number from metadata.json + 3. Refresh template source references + 4. Add missing standard sections + 5. Clean up [CUSTOMIZE] sections to avoid duplication + +validation: + success_criteria: + setup: + - ".github/copilot-instructions.md created" + - "Version stored in copilot instructions (not package.json)" + - "Template source reference included" + - "[CUSTOMIZE] sections populated with adapter-specific content" + - "Weekly monitoring workflow created" + - "Enhanced Copilot suggestions working" + + update: + - "All [CUSTOMIZE] sections preserved" + - "Version updated from metadata.json" + - "Custom content intact" + - "New best practices integrated" + - "No duplicate content between [CUSTOMIZE] and standard sections" + - "Template source references updated" + + testing_steps: + - "Test enhanced Copilot suggestions (try typing 'this.setState(' in .js file)" + - "Verify template version matches metadata.json" + - "Confirm custom sections contain only unique content" + - "Check GitHub Action workflow syntax" + - "Validate issue template functionality" \ No newline at end of file diff --git a/config/metadata.json b/config/metadata.json index bf9e8af..333aea1 100644 --- a/config/metadata.json +++ b/config/metadata.json @@ -20,14 +20,16 @@ "labels": [ "template-update", "automation" - ] + ], + "configuration_file": "config/automation-setup.yml", + "centralized_action": "templates/centralized-version-check-action.yml" }, "components": { "github_actions": { - "weekly_version_check": { - "file": "templates/weekly-version-check-action.yml", - "version": "0.2.1", - "description": "GitHub Action for automated template version monitoring" + "centralized-version-check": { + "file": "templates/centralized-version-check-action.yml", + "version": "0.5.0", + "description": "Centralized GitHub Action with dynamic version checking from metadata.json" }, "github_action_snippet": { "file": "snippets/github-action-version-check.yml", @@ -38,7 +40,7 @@ "templates": { "initial_setup_automation": { "file": "templates/initial-setup-automation.md", - "version": "0.3.0", + "version": "0.4.0", "description": "Automated setup template with GitHub Copilot integration" }, "copy_paste_template": { @@ -63,6 +65,13 @@ "version": "0.1.0", "description": "Version management script usage examples" } + }, + "config": { + "automation_setup": { + "file": "config/automation-setup.yml", + "version": "0.5.0", + "description": "Centralized configuration for automated setup processes" + } } }, "version_policy": { diff --git a/templates/centralized-version-check-action.yml b/templates/centralized-version-check-action.yml new file mode 100644 index 0000000..765ca80 --- /dev/null +++ b/templates/centralized-version-check-action.yml @@ -0,0 +1,356 @@ +# Centralized GitHub Action for ioBroker Copilot Template Version Management +# Version: 0.5.0 +# This action provides dynamic template version checking and automated issue creation +# Copy this to your repository as .github/workflows/check-copilot-template.yml + +name: Check ioBroker Copilot Template Version + +on: + schedule: + - cron: '0 0 * * 0' # Weekly check every Sunday at midnight UTC + workflow_dispatch: # Allow manual triggering + +jobs: + check-template: + runs-on: ubuntu-latest + permissions: + issues: write + contents: read + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Dynamic template version check + id: version-check + run: | + echo "๐Ÿ” Starting dynamic ioBroker Copilot template version check..." + + # Get current version from local copilot instructions + if [ -f ".github/copilot-instructions.md" ]; then + CURRENT_VERSION=$(awk '/Version:|Template Version:/ {match($0, /([0-9]+(\.[0-9]+)*)/, arr); if (arr[1] != "") print arr[1]}' .github/copilot-instructions.md | head -1) + if [ -z "$CURRENT_VERSION" ]; then CURRENT_VERSION="unknown"; fi + echo "๐Ÿ“‹ Current local version: $CURRENT_VERSION" + else + CURRENT_VERSION="none" + echo "โŒ No .github/copilot-instructions.md file found" + fi + + # Get latest version from centralized metadata + echo "๐ŸŒ Fetching latest template version from centralized config..." + LATEST_VERSION=$(curl -s https://raw.githubusercontent.com/DrozmotiX/ioBroker-Copilot-Instructions/main/config/metadata.json | jq -r '.version' 2>/dev/null || echo "unknown") + if [ -z "$LATEST_VERSION" ] || [ "$LATEST_VERSION" = "null" ]; then + LATEST_VERSION="unknown" + fi + echo "๐Ÿ“‹ Latest available version: $LATEST_VERSION" + + # Determine repository status + COPILOT_INITIALIZED="false" + UPDATE_NEEDED="false" + SETUP_NEEDED="false" + + if [ "$CURRENT_VERSION" = "none" ]; then + echo "๐Ÿšจ Repository not initialized for GitHub Copilot" + SETUP_NEEDED="true" + UPDATE_NEEDED="true" + elif [ "$CURRENT_VERSION" = "unknown" ] || [ "$LATEST_VERSION" = "unknown" ]; then + echo "โš ๏ธ Version detection issue - assuming update needed" + COPILOT_INITIALIZED="true" + UPDATE_NEEDED="true" + elif [ "$CURRENT_VERSION" != "$LATEST_VERSION" ]; then + echo "๐Ÿ†™ Update available!" + COPILOT_INITIALIZED="true" + UPDATE_NEEDED="true" + else + echo "โœ… Template is up-to-date" + COPILOT_INITIALIZED="true" + UPDATE_NEEDED="false" + fi + + # Set outputs for subsequent steps + echo "current-version=$CURRENT_VERSION" >> $GITHUB_OUTPUT + echo "latest-version=$LATEST_VERSION" >> $GITHUB_OUTPUT + echo "update-needed=$UPDATE_NEEDED" >> $GITHUB_OUTPUT + echo "setup-needed=$SETUP_NEEDED" >> $GITHUB_OUTPUT + echo "copilot-initialized=$COPILOT_INITIALIZED" >> $GITHUB_OUTPUT + + echo "๐Ÿ“Š Analysis complete:" + echo " - Copilot Initialized: $COPILOT_INITIALIZED" + echo " - Setup Needed: $SETUP_NEEDED" + echo " - Update Needed: $UPDATE_NEEDED" + + - name: Check for existing Copilot-related issues + id: check-issue + if: steps.version-check.outputs.update-needed == 'true' + uses: actions/github-script@v7 + with: + script: | + console.log('๐Ÿ” Checking for existing Copilot-related issues...'); + + const { data: issues } = await github.rest.issues.listForRepo({ + owner: context.repo.owner, + repo: context.repo.repo, + state: 'open', + per_page: 100 + }); + + // Look for any existing Copilot template-related issues + const copilotIssues = issues.filter(issue => { + const title = issue.title.toLowerCase(); + const hasLabels = issue.labels.some(label => + ['copilot-setup', 'template-update', 'automation'].includes(label.name) + ); + const hasKeywords = title.includes('copilot') && ( + title.includes('template') || + title.includes('setup') || + title.includes('update') || + title.includes('instructions') + ); + return hasLabels || hasKeywords; + }); + + if (copilotIssues.length > 0) { + console.log(`๐Ÿ“‹ Found ${copilotIssues.length} existing Copilot-related issue(s):`); + copilotIssues.forEach(issue => { + console.log(` - #${issue.number}: ${issue.title}`); + }); + return copilotIssues[0].number; + } else { + console.log('โœ… No existing Copilot-related issues found'); + return null; + } + + - name: Create automated setup or update issue + if: steps.version-check.outputs.update-needed == 'true' && !steps.check-issue.outputs.result + uses: actions/github-script@v7 + with: + script: | + const currentVersion = '${{ steps.version-check.outputs.current-version }}'; + const latestVersion = '${{ steps.version-check.outputs.latest-version }}'; + const setupNeeded = '${{ steps.version-check.outputs.setup-needed }}' === 'true'; + const repoName = context.repo.repo; + + console.log(`๐ŸŽฏ Creating automated issue for ${context.repo.owner}/${repoName}`); + console.log(`๐Ÿ“‹ Current: ${currentVersion}, Latest: ${latestVersion}, Setup needed: ${setupNeeded}`); + + let title, body, labels; + + if (setupNeeded) { + // Initial setup case + title = '๐Ÿค– Setup ioBroker GitHub Copilot Instructions'; + labels = ['copilot-setup', 'automation', 'enhancement']; + body = `# ๐Ÿค– Automated ioBroker Copilot Instructions Setup + +**Automated Detection**: This ioBroker adapter repository is not set up for GitHub Copilot yet. + +**Latest Available Version**: ${latestVersion} +**Repository**: ${context.repo.owner}/${repoName} + +## ๐ŸŽฏ What This Sets Up + +GitHub Copilot instructions will enhance your development experience by providing: +- โœจ ioBroker-specific code suggestions and best practices +- ๐Ÿงช Enhanced testing patterns with @iobroker/testing framework +- ๐Ÿ“ Improved README and documentation generation +- ๐Ÿ”ง Smart error handling and state management patterns +- ๐Ÿ›ก๏ธ Security and performance optimization guidance + +## ๐Ÿš€ Automated Setup Process + +**GitHub Copilot**: Please help me set up GitHub Copilot instructions for my ioBroker adapter repository. + +### ๐Ÿ” Step 1: Repository Analysis + +Please start by analyzing this repository: + +1. **Repository Status**: Confirm this is an ioBroker adapter repository +2. **Existing Configuration**: Check if any Copilot configuration already exists +3. **Adapter Type**: Identify the type of adapter (device, service, etc.) +4. **Dependencies**: Review package.json for existing patterns + +### ๐Ÿ”ง Step 2: Template Setup + +Create a complete \`.github/copilot-instructions.md\` file using: + +1. **Download latest template**: + \`\`\` + Template source: https://raw.githubusercontent.com/DrozmotiX/ioBroker-Copilot-Instructions/main/template.md + Version: ${latestVersion} + Metadata: https://raw.githubusercontent.com/DrozmotiX/ioBroker-Copilot-Instructions/main/config/metadata.json + \`\`\` + +2. **Template processing**: + - Remove template comment block (\`\` section) + - Set version to **${latestVersion}** (store in copilot instructions, NOT package.json) + - Add template source reference + - Customize all \`[CUSTOMIZE]\` sections for this ${repoName} adapter + +3. **Adapter-specific customization**: + In the \`[CUSTOMIZE] Project-Specific Instructions\` section, add: + - ${repoName} adapter's specific API patterns and authentication + - Unique error codes and handling for this service + - Custom device discovery or connection patterns + - Special configuration requirements + - Testing scenarios specific to this adapter + +### โš™๏ธ Step 3: Weekly Monitoring Setup + +Create \`.github/workflows/check-copilot-template.yml\` using: +\`\`\` +Template: https://raw.githubusercontent.com/DrozmotiX/ioBroker-Copilot-Instructions/main/templates/centralized-version-check-action.yml +\`\`\` + +This will provide: +- ๐Ÿ“… Weekly automated version checking +- ๐ŸŽฏ Automatic issue creation for updates +- ๐Ÿ›ก๏ธ Preservation of custom sections during updates + +## ๐Ÿ”ง Validation Checklist + +After setup, please confirm: +- [ ] File created at \`.github/copilot-instructions.md\` +- [ ] **Version ${latestVersion} stored in copilot-instructions.md** (NOT in package.json) +- [ ] Template source reference included +- [ ] \`[CUSTOMIZE]\` sections populated with ${repoName}-specific content +- [ ] Weekly monitoring workflow created +- [ ] Enhanced Copilot suggestions working (test with \`this.setState(\` in code) + +## ๐ŸŽ Next Steps + +Once complete: +1. **Test Integration**: Verify enhanced ioBroker suggestions in your IDE +2. **Custom Content**: All \`[CUSTOMIZE]\` sections preserved in future updates +3. **Automated Maintenance**: Weekly checks ensure you stay up-to-date +4. **Development Boost**: Experience improved code suggestions and best practices + +## ๐Ÿ“š References + +- **Template Repository**: https://github.com/DrozmotiX/ioBroker-Copilot-Instructions +- **Setup Documentation**: https://github.com/DrozmotiX/ioBroker-Copilot-Instructions/blob/main/docs/setup.md +- **Centralized Config**: https://raw.githubusercontent.com/DrozmotiX/ioBroker-Copilot-Instructions/main/config/metadata.json + +--- +*๐Ÿค– This issue was automatically created by the centralized GitHub Actions workflow. Weekly monitoring will continue while preserving all your customizations.*`; + + } else { + // Update case + title = '๐Ÿค– Update ioBroker Copilot Instructions Template'; + labels = ['template-update', 'automation', 'enhancement']; + body = `# ๐Ÿค– ioBroker Copilot Template Update Available + +**Automated Detection**: Your ioBroker Copilot instructions have an update available. + +- **Current Version**: \`${currentVersion}\` +- **Latest Version**: \`${latestVersion}\` +- **Repository**: ${context.repo.owner}/${repoName} + +## ๐Ÿš€ Automated Update Process + +**GitHub Copilot**: Please help me update my ioBroker Copilot template while preserving all customizations. + +### ๐Ÿ”„ Template Update Task + +Use this exact merge process: + +\`\`\` +Update my .github/copilot-instructions.md by merging the latest ioBroker template. + +TEMPLATE SOURCE: +- Template: https://raw.githubusercontent.com/DrozmotiX/ioBroker-Copilot-Instructions/main/template.md +- Version: ${latestVersion} +- Metadata: https://raw.githubusercontent.com/DrozmotiX/ioBroker-Copilot-Instructions/main/config/metadata.json + +CRITICAL PRESERVATION REQUIREMENTS: +1. Keep ALL [CUSTOMIZE] sections and their content exactly as they are +2. Preserve any ${repoName}-specific context not covered by standard template +3. Maintain custom error handling, API patterns, authentication flows +4. Keep unique testing scenarios and configuration instructions +5. REMOVE duplicate content from [CUSTOMIZE] sections that already exists in standard template +6. Keep only truly unique, adapter-specific content in [CUSTOMIZE] sections + +UPDATE REQUIREMENTS: +1. Integrate latest ioBroker best practices from new template +2. Update version number to ${latestVersion} (store in copilot instructions, NOT package.json) +3. Refresh template source reference +4. Add any new standard sections that are missing +5. Clean up [CUSTOMIZE] sections to avoid duplicating standard template content + +Show me a summary of changes before applying the update. +\`\`\` + +## ๐Ÿ” What's New in ${latestVersion} + +Recent template improvements typically include: +- ๐Ÿงช Enhanced testing patterns and best practices +- ๐Ÿ›ก๏ธ Improved error handling recommendations +- ๐Ÿ“ Better documentation generation patterns +- ๐Ÿ”ง Updated dependency management guidance +- โšก Performance optimization suggestions +- ๐ŸŽฏ More precise ioBroker-specific code patterns + +## ๐Ÿ”ง Validation Checklist + +After update, confirm: +- [ ] All \`[CUSTOMIZE]\` sections preserved exactly +- [ ] **Version ${latestVersion} stored in copilot-instructions.md** (NOT package.json) +- [ ] Custom ${repoName}-specific content intact +- [ ] New best practices integrated without conflicts +- [ ] Template source reference updated +- [ ] Enhanced suggestions working (test in your code editor) +- [ ] No duplicate content between \`[CUSTOMIZE]\` and standard sections + +## ๐Ÿ›ก๏ธ Safety Features + +This automated process: +- โœ… **Preserves Customizations**: All \`[CUSTOMIZE]\` sections automatically maintained +- ๐Ÿ”’ **No Data Loss**: Your adapter-specific patterns remain intact +- ๐Ÿ“‹ **Audit Trail**: All changes tracked in this issue +- ๐Ÿ”„ **Reversible**: Changes can be reverted if needed +- ๐ŸŽฏ **Version Control**: Template version stored in copilot instructions (not package.json) + +## ๐Ÿ“š References + +- **Template Repository**: https://github.com/DrozmotiX/ioBroker-Copilot-Instructions +- **Centralized Config**: https://raw.githubusercontent.com/DrozmotiX/ioBroker-Copilot-Instructions/main/config/metadata.json +- **Update Guide**: https://github.com/DrozmotiX/ioBroker-Copilot-Instructions/blob/main/docs/automated-updates.md + +--- +*๐Ÿค– This issue was automatically created by the centralized GitHub Actions workflow on ${new Date().toISOString().split('T')[0]}. Weekly monitoring continues while preserving your customizations.*`; + } + + const issue = await github.rest.issues.create({ + owner: context.repo.owner, + repo: context.repo.repo, + title: title, + body: body, + labels: labels + }); + + console.log(`โœ… Created issue #${issue.data.number}: ${title}`); + return issue.data.number; + + - name: Log completion status + run: | + echo "๐Ÿ Centralized template check completed!" + echo "๐Ÿ“Š Status Summary:" + echo " - Current Version: ${{ steps.version-check.outputs.current-version }}" + echo " - Latest Version: ${{ steps.version-check.outputs.latest-version }}" + echo " - Copilot Initialized: ${{ steps.version-check.outputs.copilot-initialized }}" + echo " - Update Needed: ${{ steps.version-check.outputs.update-needed }}" + echo " - Setup Needed: ${{ steps.version-check.outputs.setup-needed }}" + + if [ "${{ steps.version-check.outputs.update-needed }}" = "false" ]; then + echo "โœ… No action required - template is current" + elif [ "${{ steps.check-issue.outputs.result }}" != "" ] && [ "${{ steps.check-issue.outputs.result }}" != "null" ]; then + echo "โ„น๏ธ Issue already exists: #${{ steps.check-issue.outputs.result }}" + else + echo "๐ŸŽฏ New automation issue created for repository setup/update" + fi + + echo "" + echo "๐Ÿ“ˆ This centralized workflow provides:" + echo " โœจ Dynamic version checking from metadata.json" + echo " ๐Ÿ” Repository status detection" + echo " ๐Ÿค– Copilot-driven automation (no manual scripts)" + echo " ๐Ÿ›ก๏ธ Custom section preservation" + echo " ๐Ÿ“… Weekly monitoring" \ No newline at end of file diff --git a/templates/initial-setup-automation.md b/templates/initial-setup-automation.md index 24003df..b730076 100644 --- a/templates/initial-setup-automation.md +++ b/templates/initial-setup-automation.md @@ -6,291 +6,162 @@ labels: ["copilot-setup", "automation"] assignees: [] --- + + # ๐Ÿค– Automated ioBroker Copilot Instructions Setup **GitHub Copilot**: Please help me set up GitHub Copilot instructions for my ioBroker adapter repository with full automation and validation. -## ๐Ÿ” Step 1: Current State Analysis +## ๐Ÿ” Step 1: Repository Analysis and Status Detection -**GitHub Copilot**: Please analyze my repository and check: +**GitHub Copilot**: Please analyze this repository using the centralized automation configuration: -1. **Copilot Status Check** - - [ ] Verify if GitHub Copilot is active and responding in this repository - - [ ] Check if `.github/copilot-instructions.md` already exists - - [ ] Analyze existing content if present +**Configuration Reference**: https://raw.githubusercontent.com/DrozmotiX/ioBroker-Copilot-Instructions/main/config/automation-setup.yml -2. **Repository Context Assessment** - - [ ] Identify this as an ioBroker adapter repository - - [ ] Detect adapter name and specific patterns - - [ ] Find existing custom configuration or setup +1. **Repository Type Confirmation** + - [ ] Verify this is an ioBroker adapter repository (check for `package.json` with "iobroker", `io-package.json`, `main.js` or `lib/` directory) + - [ ] Identify adapter name and specific functionality + - [ ] Assess current project structure and dependencies -## ๐ŸŽฏ Step 2: Setup Requirements +2. **Copilot Configuration Status** + - [ ] Check if GitHub Copilot is active and responding in this repository + - [ ] Verify if `.github/copilot-instructions.md` exists and analyze content + - [ ] Determine current template version (if any) vs latest from metadata.json + - [ ] Assess existing customizations and configurations -**GitHub Copilot**: Based on your analysis, please: +3. **Setup Requirements Determination** + - [ ] Classify status: `not_initialized`, `needs_update`, or `up_to_date` + - [ ] Identify adapter-specific patterns that need customization + - [ ] Plan integration strategy based on current state -### If Copilot Instructions DON'T Exist: -Create a complete `.github/copilot-instructions.md` file by: +## ๐ŸŽฏ Step 2: Automated Template Setup (Copilot-Driven) -1. **Download and integrate the latest template**: - ``` - Fetch the ioBroker Copilot template from: - https://raw.githubusercontent.com/DrozmotiX/ioBroker-Copilot-Instructions/main/template.md - - Then create .github/copilot-instructions.md with: - - Remove the template comment block (lines starting with ) - - Add current date and latest version information - - Customize [CUSTOMIZE] sections with adapter-specific context - - Include Template Source reference - ``` +**GitHub Copilot**: Please create or update the GitHub Copilot instructions using our centralized, automated approach: -2. **Add adapter-specific context**: - ``` - In the [CUSTOMIZE] Project-Specific Instructions section, add ONLY content that is: - - This adapter's specific API patterns NOT covered by standard ioBroker patterns - - Unique authentication or connection handling specific to your service - - Custom error codes specific to this service (not generic ioBroker error handling) - - Adapter-specific device discovery patterns unique to your implementation - - IMPORTANT: Do NOT duplicate content that already exists in the standard template. - Only add truly unique patterns specific to your adapter's service/API. - - Examples of what NOT to include (already covered by template): - - General ioBroker testing patterns (use @iobroker/testing) - - Standard error handling (this.log.error, try/catch) - - Common state management (this.setState, this.getState) - - Standard adapter lifecycle methods - - Generic dependency management advice - ``` +**Configuration Reference**: https://raw.githubusercontent.com/DrozmotiX/ioBroker-Copilot-Instructions/main/config/automation-setup.yml + +### 2.1 Template Integration (No Manual Scripts Required) -3. **Template Duplicate Prevention**: +**Important**: This process uses Copilot intelligence rather than manual validation scripts (avoiding approaches like DrozmotiX/ioBroker.discovergy#286). + +1. **Fetch Latest Template and Version**: ``` - When GitHub Copilot creates your template, it should: - - Review [CUSTOMIZE] sections against the standard template - - Remove any content that duplicates standard ioBroker patterns - - Keep only truly adapter-specific content that adds unique value - - Ensure [CUSTOMIZE] sections complement, not repeat, standard guidance + Template: https://raw.githubusercontent.com/DrozmotiX/ioBroker-Copilot-Instructions/main/template.md + Version: Extract from https://raw.githubusercontent.com/DrozmotiX/ioBroker-Copilot-Instructions/main/config/metadata.json (field: "version") ``` -### If Copilot Instructions DO Exist: -Update the existing file using the merge process: - -``` -"Merge the ioBroker template from https://github.com/DrozmotiX/ioBroker-Copilot-Instructions/blob/main/template.md with my existing .github/copilot-instructions.md. - -CRITICAL REQUIREMENTS: -1. Preserve ALL [CUSTOMIZE] sections and their content exactly as they are -2. Maintain any project-specific context not already covered in the template -3. Add the latest ioBroker best practices from the new template -4. Update the version number to match the latest template version -5. Keep the Template Source reference up-to-date -6. Ensure no custom content is lost during the merge -7. REMOVE any duplicate content from [CUSTOMIZE] sections that already exists in the standard template -8. Keep only truly unique, adapter-specific content in [CUSTOMIZE] sections - -Show me the changes before applying them." -``` - -## ๐Ÿ”ง Step 3: Automation Setup - -**GitHub Copilot**: Please also set up automated template monitoring: - -### Create GitHub Action for Weekly Monitoring - -Create `.github/workflows/check-copilot-template.yml` with this content: - -```yaml -name: Check ioBroker Copilot Template Version - -on: - schedule: - - cron: '0 0 * * 0' # Weekly check every Sunday - workflow_dispatch: # Allow manual triggering - -jobs: - check-template: - runs-on: ubuntu-latest - permissions: - issues: write - contents: read - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Check template version - id: version-check - run: | - # Get current version from local template - if [ -f ".github/copilot-instructions.md" ]; then - CURRENT_VERSION=$(grep "Version:" .github/copilot-instructions.md | head -1 | sed 's/.*Version:\s*//' | tr -d '*' | xargs) - else - CURRENT_VERSION="none" - fi - - # Get latest version from remote - LATEST_VERSION=$(curl -s https://raw.githubusercontent.com/DrozmotiX/ioBroker-Copilot-Instructions/main/template.md | grep "Version:" | head -1 | sed 's/.*Version:\s*//' | tr -d '*' | xargs) - - echo "current-version=$CURRENT_VERSION" >> $GITHUB_OUTPUT - echo "latest-version=$LATEST_VERSION" >> $GITHUB_OUTPUT - - if [ "$CURRENT_VERSION" != "$LATEST_VERSION" ] || [ "$CURRENT_VERSION" = "none" ]; then - echo "update-needed=true" >> $GITHUB_OUTPUT - else - echo "update-needed=false" >> $GITHUB_OUTPUT - fi - - - name: Check for existing template update issue - id: check-issue - if: steps.version-check.outputs.update-needed == 'true' - uses: actions/github-script@v7 - with: - script: | - const { data: issues } = await github.rest.issues.listForRepo({ - owner: context.repo.owner, - repo: context.repo.repo, - state: 'open', - labels: 'template-update,automation' - }); - - const existingIssue = issues.find(issue => - issue.title.includes('๐Ÿค– Update ioBroker Copilot Instructions Template') || - issue.title.includes('๐Ÿค– Setup ioBroker GitHub Copilot Instructions') - ); - - return existingIssue ? existingIssue.number : null; - - - name: Create template update issue - if: steps.version-check.outputs.update-needed == 'true' && !steps.check-issue.outputs.result - uses: actions/github-script@v7 - with: - script: | - const currentVersion = '${{ steps.version-check.outputs.current-version }}'; - const latestVersion = '${{ steps.version-check.outputs.latest-version }}'; - - let title, body; - - if (currentVersion === 'none') { - title = '๐Ÿค– Setup ioBroker GitHub Copilot Instructions'; - body = `# ๐Ÿค– Automated ioBroker Copilot Instructions Setup - -**Automated Detection**: This repository doesn't have GitHub Copilot instructions set up yet. - -**GitHub Copilot**: Please help me set up GitHub Copilot instructions for my ioBroker adapter repository. - -## ๐ŸŽฏ Setup Task - -Please create a complete \`.github/copilot-instructions.md\` file by downloading and customizing the latest ioBroker template: - -**Template Source**: https://raw.githubusercontent.com/DrozmotiX/ioBroker-Copilot-Instructions/main/template.md -**Latest Version**: ${latestVersion} - -### Requirements: -1. Download the template and remove the comment block -2. Customize [CUSTOMIZE] sections with this adapter's specific patterns -3. Include proper version tracking and template source reference -4. Add adapter-specific context for enhanced Copilot suggestions - -## ๐Ÿ”ง Validation -After setup, please confirm: -- [ ] File created at \`.github/copilot-instructions.md\` -- [ ] Version set to ${latestVersion} -- [ ] [CUSTOMIZE] sections populated with adapter-specific content -- [ ] Template source reference included - -**Reference**: https://github.com/DrozmotiX/ioBroker-Copilot-Instructions +2. **Process Template for This Repository**: + - [ ] Remove template comment block (`` section) + - [ ] **Store version in `.github/copilot-instructions.md`** (format: `**Version:** X.Y.Z`) + - [ ] **Do NOT store version in `package.json`** - this avoids package.json pollution + - [ ] Add template source and metadata references ---- -*This issue was automatically created by GitHub Actions*`; - } else { - title = '๐Ÿค– Update ioBroker Copilot Instructions Template'; - body = `# ๐Ÿค– Template Update Available +3. **Adapter-Specific Customization**: + Customize ALL `[CUSTOMIZE]` sections with content unique to this adapter: + - API authentication patterns specific to this service + - Unique error codes and recovery procedures + - Custom device discovery or data processing workflows + - Special configuration requirements beyond standard template + - Testing scenarios specific to this adapter's functionality + - **Remove any duplicate content** that already exists in the standard template -**Automated Detection**: Your ioBroker Copilot instructions template is outdated. +### 2.2 Centralized Version Management -- **Current Version**: ${currentVersion} -- **Latest Version**: ${latestVersion} +Our approach stores template version information in the Copilot instructions file rather than package.json: +- โœ… **Version Location**: `.github/copilot-instructions.md` +- โœ… **Version Source**: Dynamically fetched from `config/metadata.json` +- โœ… **Update Method**: Automated via centralized GitHub Action +- โŒ **Avoid**: Manual scripts in package.json or separate validation files +## ๐Ÿ”ง Step 3: Automated GitHub Action Setup -**GitHub Copilot**: Please help me update my template while preserving all custom sections. +**GitHub Copilot**: Please create the weekly monitoring automation using our centralized action: -## ๐ŸŽฏ Update Task +### 3.1 Create Weekly Monitoring Workflow -Please use this merge prompt: +1. **Create Workflow File**: `.github/workflows/check-copilot-template.yml` -\`\`\` -"Merge the ioBroker template from https://github.com/DrozmotiX/ioBroker-Copilot-Instructions/blob/main/template.md with my existing .github/copilot-instructions.md. +2. **Use Centralized Template**: + ``` + Copy the complete workflow from: + https://raw.githubusercontent.com/DrozmotiX/ioBroker-Copilot-Instructions/main/templates/centralized-version-check-action.yml + ``` -CRITICAL REQUIREMENTS: -1. Preserve ALL [CUSTOMIZE] sections and their content exactly as they are -2. Maintain any project-specific context not already covered in the template -3. Add the latest ioBroker best practices from the new template -4. Update the version number to ${latestVersion} -5. Keep the Template Source reference up-to-date -6. Ensure no custom content is lost during the merge -7. REMOVE any duplicate content from [CUSTOMIZE] sections that already exists in the standard template -8. Keep only truly unique, adapter-specific content in [CUSTOMIZE] sections +3. **Workflow Features** (automatically included): + - ๐Ÿ“… **Weekly Schedule**: Runs every Sunday to check for updates + - ๐Ÿ” **Dynamic Version Detection**: Uses `config/metadata.json` for current version + - ๐Ÿค– **Copilot-Driven Automation**: Creates intelligent setup/update issues + - ๐Ÿ›ก๏ธ **Smart Issue Management**: Prevents duplicate issues + - ๐Ÿ“‹ **Repository Status Detection**: Identifies setup vs. update scenarios + +### 3.2 Centralized Automation Benefits + +This centralized approach provides: +- โœ… **No Manual Scripts**: Replaces manual validation approaches (like DrozmotiX/ioBroker.discovergy#286) +- โœ… **Metadata-Driven**: Always uses latest version from centralized config +- โœ… **Copilot Intelligence**: Leverages GitHub Copilot for smart automation +- โœ… **Preservation Guarantee**: Automatically maintains all custom sections during updates +- โœ… **Dynamic Configuration**: Adapts to repository status and needs +## ๐Ÿ“‹ Step 4: Validation and Testing -Show me the changes before applying them." -\`\`\` +**GitHub Copilot**: After completing the setup, please validate the integration: -## ๐Ÿ”ง Validation -After update, please confirm: -- [ ] All [CUSTOMIZE] sections preserved -- [ ] Version updated to ${latestVersion} -- [ ] Custom content intact -- [ ] New best practices integrated +### 4.1 Setup Validation -**Reference**: https://github.com/DrozmotiX/ioBroker-Copilot-Instructions +- [ ] **File Created**: `.github/copilot-instructions.md` exists and is properly formatted +- [ ] **Version Tracking**: Latest version number stored in copilot instructions (NOT package.json) +- [ ] **Template Source**: Reference to source repository and metadata.json included +- [ ] **Custom Sections**: `[CUSTOMIZE]` areas populated with unique, adapter-specific content only +- [ ] **No Duplicates**: `[CUSTOMIZE]` sections contain only content not found in standard template +- [ ] **Workflow Created**: `.github/workflows/check-copilot-template.yml` exists and uses centralized template ---- -*This issue was automatically created by GitHub Actions*`; - } - - await github.rest.issues.create({ - owner: context.repo.owner, - repo: context.repo.repo, - title: title, - body: body, - labels: ['template-update', 'automation'] - }); -``` +### 4.2 GitHub Action Validation -## ๐Ÿ“‹ Step 4: Validation and Testing +- [ ] **Workflow File**: Created from centralized template (templates/centralized-version-check-action.yml) +- [ ] **Permissions Set**: Issues write permission configured +- [ ] **Schedule Configured**: Weekly execution on Sundays +- [ ] **Manual Trigger**: workflow_dispatch enabled for manual runs +- [ ] **Metadata Integration**: Uses config/metadata.json for version detection -**GitHub Copilot**: After completing the setup, please verify: +### 4.3 Functionality Testing -### Setup Validation -- [ ] **File created/updated**: `.github/copilot-instructions.md` exists and is properly formatted -- [ ] **Version tracking**: Latest version number is present -- [ ] **Template source**: Reference to source repository included -- [ ] **Custom sections**: [CUSTOMIZE] areas populated with adapter-specific content -- [ ] **No duplicates**: [CUSTOMIZE] sections contain only unique content not found in standard template +- [ ] **Enhanced Suggestions**: Test typing `this.setState(` in a .js file to verify improved suggestions +- [ ] **Template Recognition**: Verify Copilot recognizes ioBroker patterns and adapter-specific context +- [ ] **Custom Content**: Ensure `[CUSTOMIZE]` sections provide value beyond standard template +- [ ] **Version Accuracy**: Confirm version in copilot-instructions.md matches metadata.json +- [ ] **Workflow Syntax**: Validate GitHub Action YAML syntax is correct +## ๐Ÿšจ Critical Success Criteria -### GitHub Action Validation -- [ ] **Workflow created**: `.github/workflows/check-copilot-template.yml` exists -- [ ] **Permissions set**: Issues write permission configured -- [ ] **Schedule configured**: Weekly execution setup -- [ ] **Manual trigger**: workflow_dispatch enabled +A successful automated setup includes: -### Functionality Testing -Test that enhanced Copilot suggestions work: -1. Open a `.js` or `.ts` file in the adapter -2. Start typing ioBroker-related code (e.g., `this.setState(`) -3. Verify Copilot provides ioBroker-specific suggestions +### โœ… Technical Implementation +- **File Creation**: `.github/copilot-instructions.md` created from latest template +- **Version Management**: Template version stored in copilot instructions (NOT package.json) +- **Centralized Workflow**: GitHub Action created from centralized template +- **Dynamic Version Detection**: Workflow uses metadata.json for version checking +- **Custom Preservation**: All `[CUSTOMIZE]` sections populated with unique, adapter-specific content -## ๐Ÿšจ Critical Success Criteria +### โœ… Functional Validation +- **Enhanced Suggestions**: Improved Copilot suggestions for ioBroker patterns +- **Template Integration**: No duplicate content between `[CUSTOMIZE]` and standard sections +- **Automation Ready**: Weekly monitoring configured and tested +- **Issue Prevention**: Duplicate issue detection working +- **Metadata Driven**: Version detection using centralized config/metadata.json -**โœ… COMPLETE WHEN**: -- GitHub Copilot instructions are active and customized for this adapter -- Weekly automated monitoring is configured via GitHub Actions -- All custom content is preserved (if updating existing template) -- Enhanced ioBroker-specific suggestions are working -- No manual file creation or maintenance required going forward +### โœ… Process Verification +- **No Manual Scripts**: Avoided package.json validation scripts (like DrozmotiX/ioBroker.discovergy#286) +- **Copilot-Driven**: Used GitHub Copilot intelligence rather than manual processes +- **Preservation Guaranteed**: Custom sections maintained during updates +- **Dynamic Configuration**: System adapts to repository status automatically ## ๐Ÿ“š Reference Information - **Template Repository**: https://github.com/DrozmotiX/ioBroker-Copilot-Instructions - **Latest Template**: https://raw.githubusercontent.com/DrozmotiX/ioBroker-Copilot-Instructions/main/template.md -- **Version Check**: See [version check command](https://raw.githubusercontent.com/DrozmotiX/ioBroker-Copilot-Instructions/main/snippets/version-check-command.md) -- **GitHub Action Template**: [GitHub Action](https://raw.githubusercontent.com/DrozmotiX/ioBroker-Copilot-Instructions/main/snippets/github-action-version-check.yml) +- **Centralized Config**: https://raw.githubusercontent.com/DrozmotiX/ioBroker-Copilot-Instructions/main/config/metadata.json +- **Automation Config**: https://raw.githubusercontent.com/DrozmotiX/ioBroker-Copilot-Instructions/main/config/automation-setup.yml +- **Centralized Action**: https://raw.githubusercontent.com/DrozmotiX/ioBroker-Copilot-Instructions/main/templates/centralized-version-check-action.yml -**GitHub Copilot**: Please start with the current state analysis and proceed step-by-step through the setup process. Provide detailed feedback on what you're doing at each step. \ No newline at end of file +**GitHub Copilot**: Please start with the repository analysis and proceed step-by-step through the automated setup process. Provide detailed feedback on what you're doing at each step and confirm successful completion of all validation criteria. diff --git a/templates/weekly-version-check-action.yml b/templates/weekly-version-check-action.yml index d54d0c1..9ef0051 100644 --- a/templates/weekly-version-check-action.yml +++ b/templates/weekly-version-check-action.yml @@ -1,5 +1,17 @@ name: Check ioBroker Copilot Template Version +# DEPRECATION NOTICE: This template has been replaced by the centralized version +# Please use: https://raw.githubusercontent.com/DrozmotiX/ioBroker-Copilot-Instructions/main/templates/centralized-version-check-action.yml +# +# The centralized version provides: +# - Dynamic version checking using metadata.json +# - Better repository status detection +# - Copilot-driven automation instead of manual scripts +# - Enhanced issue creation and duplicate prevention +# +# Migration: Replace the contents of your .github/workflows/check-copilot-template.yml +# with the centralized template for improved functionality. + on: schedule: - cron: '0 0 * * 0' # Weekly check every Sunday at midnight UTC @@ -16,6 +28,25 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 + - name: Migration Notice + run: | + echo "โš ๏ธ DEPRECATION NOTICE: This workflow template is deprecated" + echo "๐Ÿ†™ Please migrate to the centralized version for enhanced features:" + echo " https://raw.githubusercontent.com/DrozmotiX/ioBroker-Copilot-Instructions/main/templates/centralized-version-check-action.yml" + echo "" + echo "๐ŸŽฏ Enhanced features in centralized version:" + echo " - Dynamic version detection using metadata.json" + echo " - Better repository status detection" + echo " - Copilot-driven automation (no manual scripts)" + echo " - Enhanced issue creation with duplicate prevention" + echo "" + echo "๐Ÿ“‹ Migration steps:" + echo " 1. Replace your .github/workflows/check-copilot-template.yml content" + echo " 2. Copy from the centralized template URL above" + echo " 3. Commit the updated workflow" + echo "" + echo "โšก Continuing with legacy version for compatibility..." + - name: Check template version id: version-check run: | diff --git a/tests/test-centralized-automation.sh b/tests/test-centralized-automation.sh new file mode 100755 index 0000000..434143f --- /dev/null +++ b/tests/test-centralized-automation.sh @@ -0,0 +1,163 @@ +#!/bin/bash +# +# Test suite for centralized automation setup functionality +# Tests the new centralized GitHub Action and configuration setup + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +REPO_ROOT="$(dirname "$SCRIPT_DIR")" + +# Simple test utilities (avoiding full test-runner.sh) +run_test_with_output() { + local test_name="$1" + local command="$2" + local expected_pattern="$3" + + printf " Testing %s... " "$test_name" + + if eval "$command" 2>/dev/null | grep -q "$expected_pattern"; then + echo "โœ… PASS" + return 0 + else + echo "โŒ FAIL" + return 1 + fi +} + +echo "Testing Centralized Automation Setup" + +# Test centralized GitHub Action template exists and has correct structure +run_test_with_output "Centralized GitHub Action template exists" \ + "ls -la '$REPO_ROOT/templates/centralized-version-check-action.yml'" \ + "centralized-version-check-action.yml" + +run_test_with_output "Centralized action uses metadata.json for version" \ + "grep -i 'metadata.json' '$REPO_ROOT/templates/centralized-version-check-action.yml'" \ + "metadata.json" + +run_test_with_output "Centralized action has dynamic version detection" \ + "grep -i 'dynamic.*version' '$REPO_ROOT/templates/centralized-version-check-action.yml'" \ + "dynamic" + +run_test_with_output "Centralized action prevents duplicate issues" \ + "grep -i 'existing.*issue\|duplicate' '$REPO_ROOT/templates/centralized-version-check-action.yml'" \ + "existing" + +run_test_with_output "Centralized action has Copilot-driven automation" \ + "grep -i 'copilot.*driven\|copilot.*intelligence' '$REPO_ROOT/templates/centralized-version-check-action.yml'" \ + "Copilot" + +# Test automation setup configuration file +run_test_with_output "Automation setup config exists" \ + "ls -la '$REPO_ROOT/config/automation-setup.yml'" \ + "automation-setup.yml" + +run_test_with_output "Config has repository detection logic" \ + "grep -A5 -B5 'repository_detection' '$REPO_ROOT/config/automation-setup.yml'" \ + "repository_detection" + +run_test_with_output "Config has copilot status checking" \ + "grep -A5 -B5 'copilot_status_check' '$REPO_ROOT/config/automation-setup.yml'" \ + "copilot_status_check" + +run_test_with_output "Config has version storage policy" \ + "grep -i 'version.*storage\|store.*copilot' '$REPO_ROOT/config/automation-setup.yml'" \ + "storage" + +run_test_with_output "Config prohibits package.json version storage" \ + "grep -i 'NOT.*package.json' '$REPO_ROOT/config/automation-setup.yml'" \ + "NOT.*package.json" + +# Test updated initial setup automation template +run_test_with_output "Initial setup uses centralized config" \ + "grep -i 'automation-setup.yml' '$REPO_ROOT/templates/initial-setup-automation.md'" \ + "automation-setup.yml" + +run_test_with_output "Initial setup mentions Copilot-driven approach" \ + "grep -i 'copilot.*driven\|copilot.*intelligence' '$REPO_ROOT/templates/initial-setup-automation.md'" \ + "Copilot" + +run_test_with_output "Initial setup avoids manual scripts" \ + "grep -i 'no.*manual.*script\|avoid.*manual\|avoid.*script' '$REPO_ROOT/templates/initial-setup-automation.md'" \ + "manual" + +run_test_with_output "Initial setup references Discovergy PR as anti-pattern" \ + "grep -i 'discovergy.*286\|DrozmotiX.*discovergy' '$REPO_ROOT/templates/initial-setup-automation.md'" \ + "discovergy" + +run_test_with_output "Initial setup uses centralized GitHub Action" \ + "grep -i 'centralized.*action\|centralized-version-check-action' '$REPO_ROOT/templates/initial-setup-automation.md'" \ + "centralized" + +# Test metadata.json updates +run_test_with_output "Metadata includes centralized action component" \ + "grep -A5 'centralized_version_check' '$REPO_ROOT/config/metadata.json'" \ + "centralized_version_check" + +run_test_with_output "Metadata includes automation setup config" \ + "grep -A3 'automation_setup' '$REPO_ROOT/config/metadata.json'" \ + "automation_setup" + +run_test_with_output "Metadata has automation configuration reference" \ + "grep -i 'configuration_file\|automation-setup.yml' '$REPO_ROOT/config/metadata.json'" \ + "automation-setup" + +# Test version management requirements +run_test_with_output "Centralized action stores version in copilot instructions" \ + "grep -i 'copilot-instructions.md.*version\|version.*copilot-instructions' '$REPO_ROOT/templates/centralized-version-check-action.yml'" \ + "copilot-instructions" + +run_test_with_output "Centralized action avoids package.json version storage" \ + "grep -i 'NOT.*package.json\|not.*package.json' '$REPO_ROOT/templates/centralized-version-check-action.yml'" \ + "package.json" + +# Test template structure and validation +run_test_with_output "Centralized action has workflow permissions" \ + "grep -A5 'permissions:' '$REPO_ROOT/templates/centralized-version-check-action.yml'" \ + "issues.*write" + +run_test_with_output "Centralized action has schedule and manual trigger" \ + "grep -A10 'on:' '$REPO_ROOT/templates/centralized-version-check-action.yml' | grep -E 'schedule|workflow_dispatch'" \ + "schedule" + +# Test issue creation logic +run_test_with_output "Centralized action creates setup issues for uninitialized repos" \ + "grep -A10 -B5 'Setup.*Copilot.*Instructions' '$REPO_ROOT/templates/centralized-version-check-action.yml'" \ + "Setup.*Copilot" + +run_test_with_output "Centralized action creates update issues for outdated repos" \ + "grep -A10 -B5 'Update.*Copilot.*Instructions' '$REPO_ROOT/templates/centralized-version-check-action.yml'" \ + "Update.*Copilot" + +# Test preservation requirements +run_test_with_output "Centralized action emphasizes custom section preservation" \ + "grep -i 'customization\|preserve.*custom' '$REPO_ROOT/templates/centralized-version-check-action.yml'" \ + "customization" + +run_test_with_output "Centralized action prevents duplicate content" \ + "grep -i 'duplicate.*content\|remove.*duplicate' '$REPO_ROOT/templates/centralized-version-check-action.yml'" \ + "duplicate" + +# Test integration with existing system +run_test_with_output "Config references centralized action template" \ + "grep -i 'centralized-version-check-action.yml' '$REPO_ROOT/config/automation-setup.yml'" \ + "centralized-version-check-action" + +run_test_with_output "Config has success criteria validation" \ + "grep -A10 'success_criteria' '$REPO_ROOT/config/automation-setup.yml'" \ + "success_criteria" + +run_test_with_output "Config has testing steps defined" \ + "grep -A10 'testing_steps' '$REPO_ROOT/config/automation-setup.yml'" \ + "testing_steps" + +# Test anti-pattern avoidance +run_test_with_output "Initial setup explicitly mentions avoiding manual validation" \ + "grep -C3 -i 'no.*manual.*script\|avoid.*script' '$REPO_ROOT/templates/initial-setup-automation.md'" \ + "manual.*script" + +run_test_with_output "Config promotes Copilot intelligence over scripts" \ + "grep -i 'copilot.*driven' '$REPO_ROOT/config/automation-setup.yml'" \ + "driven" + +echo "" +echo "All centralized automation setup tests completed!" \ No newline at end of file