Export-ModuleInfoForLLM.psm1
#Requires -Version 5.1 using namespace System.Collections.Generic using namespace System.Text Set-StrictMode -Version Latest $ErrorActionPreference = 'Stop' # Check if we have the modular structure, otherwise load from parent $publicFunctions = @(Get-ChildItem -Path "$PSScriptRoot\Public\*.ps1" -ErrorAction SilentlyContinue) $privateFunctions = @(Get-ChildItem -Path "$PSScriptRoot\Private\*.ps1" -ErrorAction SilentlyContinue) if ($publicFunctions.Count -gt 0 -or $privateFunctions.Count -gt 0) { # Load from modular structure foreach ($function in @($publicFunctions + $privateFunctions)) { try { Write-Verbose "Importing function: $($function.BaseName)" . $function.FullName } catch { Write-Error "Failed to import function $($function.FullName): $_" } } # Export public functions Export-ModuleMember -Function $publicFunctions.BaseName } else { # Load from single file in parent directory (temporary backward compatibility) $parentModulePath = Join-Path (Split-Path $PSScriptRoot -Parent) 'Export-ModuleInfoForLLM.psm1' if (Test-Path $parentModulePath) { Write-Verbose "Loading module from parent directory for backward compatibility" . $parentModulePath # Note: The Export-ModuleMember at the end of the parent module file will handle exports # We don't need to re-export here as it's already done in the sourced file } else { Write-Error "No module functions found. Expected either:" Write-Error " - Functions in $PSScriptRoot\Public and $PSScriptRoot\Private" Write-Error " - Module file at $parentModulePath" throw "Module structure not found" } } |