From 51ac85b01dc7f7d2bb20dae274c13791edebc30e Mon Sep 17 00:00:00 2001 From: "Kyle J. Coder" Date: Fri, 29 Aug 2025 01:19:42 -0400 Subject: [PATCH 1/3] Enhance license header script and update README README.md was streamlined for clarity, removing redundant sections and updating setup instructions. Add-LicenseHeaders.ps1 now supports more file types, auto-detects author metadata from Git config, and generates dynamic license headers with customizable fields. Header detection logic was improved for broader compatibility. --- README.md | 32 +--- copilot-instructions/Add-LicenseHeaders.ps1 | 153 ++++++++++++-------- 2 files changed, 92 insertions(+), 93 deletions(-) diff --git a/README.md b/README.md index a8bc177..32dc37e 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,3 @@ - # GitHub Copilot Enterprise Setup Guide (VA) @@ -29,17 +14,13 @@ Interactive Reveal.js slide deck and printable guide to help VA employees (clini - `prompts/` – Role and domain-specific prompt template collections (clinical, analytics, security, etc.) - `dependencies/` – Bundled Reveal.js assets and Apache 2.0 license -## Quick Start (GitHub Pages Hosting) +## Quick Start -1. Fork or clone this repository. -2. Enable GitHub Pages in repository settings: Source = `main` (root). -3. Visit: `https://.github.io/GitHub-Copilot-Setup-Guide/`. -4. Open `index.html` for the interactive version. For printing/distribution, use the PDF at `docs/GitHub Copilot Setup Guide (for VA Employees).pdf`. +### Open [`index.html`](https://kcoderva.github.io/GitHub-Copilot-Setup-Guide/) for the interactive guide. OR, open [`docs/GitHub Copilot Setup Guide (for VA Employees).pdf`](https://github.com/KCoderVA/GitHub-Copilot-Setup-Guide/blob/main/docs/GitHub%20Copilot%20Setup%20Guide%20(for%20VA%20Employees).pdf)for a printable/distributable guide. -## Local Workspace Setup (High Priority) +## Local Workspace Setup (High Recommendation) Run these steps in the workspace where you actually do your work so Copilot follows your local rules. - 1) Download or clone this repository. 2) Open your own active VS Code workspace (the project you want Copilot to obey). 3) Run `copilot-instructions/Install-Copilot-Instructions.bat` from this repo in that workspace. @@ -61,10 +42,6 @@ Why this matters: - Reduces setup time for teammates; gives everyone the same guardrails and shortcuts - Validates a healthy workspace structure quickly and non-destructively -## Printable Version - -Use the "Printable Version" button in the top-right of `index.html` to open the PDF (`docs/GitHub Copilot Setup Guide (for VA Employees).pdf`). - ## Automation & Scripts All automation lives under `copilot-instructions/`. @@ -111,8 +88,5 @@ Apache 2.0 – see `LICENSE`. Attribution required in derivatives. Embedded Reve ## Security & Compliance Reminder No PHI/PII or sensitive VA data should be placed in this repository. All examples are generic. Follow local ISSO guidance before operationalizing any automation. -## Author -Kyle J. Coder – Edward Hines Jr. VA Hospital / Clinical Informatics / Advanced Analytics - --- *If you build a derivative focused on another VA role or specialty, please contribute a link back or open a PR so others can benefit.* diff --git a/copilot-instructions/Add-LicenseHeaders.ps1 b/copilot-instructions/Add-LicenseHeaders.ps1 index 83cbe75..c46bebf 100644 --- a/copilot-instructions/Add-LicenseHeaders.ps1 +++ b/copilot-instructions/Add-LicenseHeaders.ps1 @@ -46,7 +46,7 @@ Team: Clinical Informatics & Advanced Analytics Email: Kyle.Coder@va.gov Created: July 24, 2025 - Version: 1.0.0 + Version: 1.0.1 VA Compliance: - No administrator privileges required @@ -61,13 +61,22 @@ [CmdletBinding()] param( [Parameter(Mandatory = $false, HelpMessage = 'File extensions to process')] - [string]$FileTypes = 'ps1,sql,js,css,html', + [string]$FileTypes = 'ps1,sql,js,css,html,md,txt,bat,psm,json', [Parameter(Mandatory = $false, HelpMessage = 'Skip files that already have headers')] [switch]$SkipExisting, [Parameter(Mandatory = $false, HelpMessage = 'Show changes without applying them')] - [switch]$DryRun + [switch]$DryRun, + + # Metadata to inject into headers (auto-detected if omitted) + [Parameter(Mandatory = $false)] [string]$AuthorName, + [Parameter(Mandatory = $false)] [string]$Email, + [Parameter(Mandatory = $false)] [string]$Organization, + [Parameter(Mandatory = $false)] [string]$Team, + [Parameter(Mandatory = $false)] [string]$ProjectName, + [Parameter(Mandatory = $false)] [string]$LicenseType = 'Apache-2.0', + [Parameter(Mandatory = $false)] [string]$ComplianceNote = 'Internal Use Only' ) # Script initialization @@ -83,96 +92,105 @@ if (-not (Test-Path $LogPath)) { New-Item -ItemType Directory -Path $LogPath -Force | Out-Null } -# License header templates +# Helper: attempt to read Git config (if available) +function Get-GitConfigValue { + param([Parameter(Mandatory=$true)][string]$Key) + try { + $git = Get-Command git -ErrorAction SilentlyContinue + if ($null -eq $git) { return $null } + $val = git config --get $Key 2>$null + if ([string]::IsNullOrWhiteSpace($val)) { return $null } + return $val.Trim() + } catch { return $null } +} + +# Auto-detect metadata if not provided +if (-not $AuthorName -or [string]::IsNullOrWhiteSpace($AuthorName)) { $AuthorName = (Get-GitConfigValue 'user.name'); if (-not $AuthorName) { $AuthorName = $env:USERNAME } } +if (-not $Email -or [string]::IsNullOrWhiteSpace($Email)) { $Email = (Get-GitConfigValue 'user.email'); if (-not $Email) { $Email = '' } } +if (-not $Organization) { $Organization = '' } +if (-not $Team) { $Team = '' } +if (-not $ProjectName -or [string]::IsNullOrWhiteSpace($ProjectName)) { $ProjectName = Split-Path -Leaf (Split-Path -Parent $ScriptPath) } +if (-not $LicenseType) { $LicenseType = 'Apache-2.0' } +if (-not $ComplianceNote) { $ComplianceNote = 'Internal Use Only' } + +# License header templates (generic, populated with the user's info) $LicenseHeaders = @{ 'ps1' = @" <# - * VA Power Platform Development + * Project: $ProjectName + * Author: $AuthorName + * Organization: $Organization + * Team: $Team + * Email: $Email * - * Author: Kyle J. Coder - * Organization: Edward Hines Jr. VA Hospital (Hines VAMC) - * Team: Clinical Informatics & Advanced Analytics - * Email: Kyle.Coder@va.gov - * - * This file is part of the VA Power Platform workspace template. - * Licensed under MIT License - see LICENSE file for details. - * - * VA Compliance: No PHI/ePHI, Internal Use Only + * Licensed under $LicenseType - see LICENSE file for details. + * Compliance: $ComplianceNote * Created: $(Get-Date -Format 'yyyy-MM-dd') + * Generated by Add-LicenseHeaders.ps1 #> "@ 'sql' = @" /* - * VA Power Platform Development - * - * Author: Kyle J. Coder - * Organization: Edward Hines Jr. VA Hospital (Hines VAMC) - * Team: Clinical Informatics & Advanced Analytics - * Email: Kyle.Coder@va.gov + * Project: $ProjectName + * Author: $AuthorName + * Organization: $Organization + * Team: $Team + * Email: $Email * - * This file is part of the VA Power Platform workspace template. - * Licensed under MIT License - see LICENSE file for details. - * - * VA Database: VhaCdwDwhSql33.vha.med.va.gov - * Target Database: D03_VISN12Collab - * Classification: Internal Use Only, No PHI/ePHI + * Licensed under $LicenseType - see LICENSE file for details. + * Compliance: $ComplianceNote * Created: $(Get-Date -Format 'yyyy-MM-dd') + * Generated by Add-LicenseHeaders.ps1 */ "@ 'js' = @" /** - * VA Power Platform Development - * - * @author Kyle J. Coder - * @organization Edward Hines Jr. VA Hospital (Hines VAMC) - * @team Clinical Informatics & Advanced Analytics - * @email Kyle.Coder@va.gov + * Project: $ProjectName + * @author $AuthorName + * @organization $Organization + * @team $Team + * @email $Email * - * This file is part of the VA Power Platform workspace template. - * Licensed under MIT License - see LICENSE file for details. - * - * VA Compliance: Section 508 accessible, Internal Use Only + * Licensed under $LicenseType - see LICENSE file for details. + * Compliance: $ComplianceNote * Created: $(Get-Date -Format 'yyyy-MM-dd') + * Generated by Add-LicenseHeaders.ps1 */ "@ 'css' = @" /* - * VA Power Platform Development - * - * Author: Kyle J. Coder - * Organization: Edward Hines Jr. VA Hospital (Hines VAMC) - * Team: Clinical Informatics & Advanced Analytics - * Email: Kyle.Coder@va.gov + * Project: $ProjectName + * Author: $AuthorName + * Organization: $Organization + * Team: $Team + * Email: $Email * - * This file is part of the VA Power Platform workspace template. - * Licensed under MIT License - see LICENSE file for details. - * - * VA Branding: Official colors and accessibility compliance + * Licensed under $LicenseType - see LICENSE file for details. + * Compliance: $ComplianceNote * Created: $(Get-Date -Format 'yyyy-MM-dd') + * Generated by Add-LicenseHeaders.ps1 */ "@ 'html' = @" "@ @@ -206,10 +224,12 @@ function Test-ExistingHeader { $ContentText = $Content -join "`n" # Check for existing license indicators - return ($ContentText -match 'Kyle J\. Coder' -or - $ContentText -match 'Edward Hines Jr\. VA Hospital' -or - $ContentText -match 'MIT License' -or - $ContentText -match 'VA Power Platform Development') + return ( + $ContentText -match 'Licensed under .+ - see LICENSE file' -or + $ContentText -match 'Generated by Add-LicenseHeaders\.ps1' -or + $ContentText -match '^/\*' -or # typical block comment start + $ContentText -match '^<#!?' # ps1 block comment start + ) } catch { Write-LogMessage -Message "Error reading file $FilePath`: $($_.Exception.Message)" -Level 'WARNING' @@ -255,8 +275,10 @@ function Add-HeaderToFile { try { Write-LogMessage -Message '========================================' -Level 'INFO' Write-LogMessage -Message "$ScriptName v$ScriptVersion" -Level 'INFO' - Write-LogMessage -Message 'Author: Kyle J. Coder' -Level 'INFO' - Write-LogMessage -Message 'Organization: Edward Hines Jr. VA Hospital' -Level 'INFO' + Write-LogMessage -Message "Author: $AuthorName" -Level 'INFO' + Write-LogMessage -Message "Organization: $Organization" -Level 'INFO' + Write-LogMessage -Message "Team: $Team" -Level 'INFO' + Write-LogMessage -Message "Email: $Email" -Level 'INFO' Write-LogMessage -Message '========================================' -Level 'INFO' if ($DryRun) { @@ -276,8 +298,11 @@ try { Write-LogMessage -Message "Processing .$Extension files..." -Level 'INFO' $SearchPattern = "*.$Extension" - $Files = Get-ChildItem -Path $WorkspacePath -Filter $SearchPattern -Recurse -File | - Where-Object { $_.FullName -notmatch '\\\.git\\|\\node_modules\\|\\logs\\' } + # Materialize as an array to avoid $null when there are zero matches (so .Count is safe) + $Files = @( + Get-ChildItem -Path $WorkspacePath -Filter $SearchPattern -Recurse -File -ErrorAction SilentlyContinue | + Where-Object { $_.FullName -notmatch '\\\.git\\|\\node_modules\\|\\logs\\' } + ) Write-LogMessage -Message "Found $($Files.Count) .$Extension files" -Level 'INFO' From c55b3c2f5116a929869f53c7f07f31c940d87618 Mon Sep 17 00:00:00 2001 From: "K. Coder" <103198624+KCoderVA@users.noreply.github.com> Date: Fri, 29 Aug 2025 01:25:13 -0400 Subject: [PATCH 2/3] Update copilot-instructions/Add-LicenseHeaders.ps1 Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- copilot-instructions/Add-LicenseHeaders.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/copilot-instructions/Add-LicenseHeaders.ps1 b/copilot-instructions/Add-LicenseHeaders.ps1 index c46bebf..29541ce 100644 --- a/copilot-instructions/Add-LicenseHeaders.ps1 +++ b/copilot-instructions/Add-LicenseHeaders.ps1 @@ -227,8 +227,8 @@ function Test-ExistingHeader { return ( $ContentText -match 'Licensed under .+ - see LICENSE file' -or $ContentText -match 'Generated by Add-LicenseHeaders\.ps1' -or - $ContentText -match '^/\*' -or # typical block comment start - $ContentText -match '^<#!?' # ps1 block comment start + $ContentText -match '(^/\*.*?(Licensed under|Copyright).*?\*/)' -or # block comment with license + $ContentText -match '(^<#.*?(Licensed under|Copyright).*?#>)' # ps1 block comment with license ) } catch { From 52689056b0c63bef8288ec9e5978d24f42abe21c Mon Sep 17 00:00:00 2001 From: "K. Coder" <103198624+KCoderVA@users.noreply.github.com> Date: Fri, 29 Aug 2025 01:25:27 -0400 Subject: [PATCH 3/3] Update README.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 32dc37e..117e986 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Interactive Reveal.js slide deck and printable guide to help VA employees (clini ## Quick Start -### Open [`index.html`](https://kcoderva.github.io/GitHub-Copilot-Setup-Guide/) for the interactive guide. OR, open [`docs/GitHub Copilot Setup Guide (for VA Employees).pdf`](https://github.com/KCoderVA/GitHub-Copilot-Setup-Guide/blob/main/docs/GitHub%20Copilot%20Setup%20Guide%20(for%20VA%20Employees).pdf)for a printable/distributable guide. +### Open [`index.html`](https://kcoderva.github.io/GitHub-Copilot-Setup-Guide/) for the interactive guide. OR, open [`docs/GitHub Copilot Setup Guide (for VA Employees).pdf`](https://github.com/KCoderVA/GitHub-Copilot-Setup-Guide/blob/main/docs/GitHub%20Copilot%20Setup%20Guide%20(for%20VA%20Employees).pdf) for a printable/distributable guide. ## Local Workspace Setup (High Recommendation)