Instructions for AI agents working in this repository. For user-facing usage and examples, see README.md.
This repo is a PowerShell module that discovers and downloads Microsoft Open Specifications (Windows Protocols) from Learn and converts DOCX/PDF documents to strict GFM Markdown. There is no separate build: the module is AwakeCoding.OpenSpecs.psd1 + AwakeCoding.OpenSpecs.psm1 plus dot-sourced Public/*.ps1 and Private/*.ps1 on load.
- PowerShell 7 only. Use the latest stable PowerShell 7 (pwsh) at all times. This is mandatory.
- Windows PowerShell (5.1) compatibility is not a goal and is forbidden. Do not add workarounds, conditional logic, or compatibility shims for Windows PowerShell. Code must assume PowerShell 7+ exclusively.
- Run all scripts, tests, and module commands with
pwsh, notpowershell.exe. CI, local development, and any tooling must target PowerShell 7.
- AwakeCoding.OpenSpecs/ – Module root.
AwakeCoding.OpenSpecs.psd1is the manifest;FunctionsToExportis the source of truth for the public API.AwakeCoding.OpenSpecs.psm1dot-sources Private then Public. - AwakeCoding.OpenSpecs/Public/ – One exported function per file; filename must match the function name (e.g.
Find-OpenSpec.ps1). - AwakeCoding.OpenSpecs/Private/ – Helper functions only; not exported. Use names like
*-OpenSpec*orConvertFrom-OpenSpec*. - tests/AwakeCoding.OpenSpecs.Tests.ps1 – Pester tests (module load, exports, live discovery, conversion report aggregation).
- scripts/ – Standalone helper scripts (e.g.
Test-ParallelConversion.ps1,Build-Publish.ps1); not part of the module. - .github/workflows/convert-and-publish.yml – CI workflow: convert all specs, build publish tree, push to orphan branch.
Adding a new public cmdlet: (1) Add a new file Public/<Verb>-OpenSpec<Noun>.ps1. (2) Add the function name to FunctionsToExport in AwakeCoding.OpenSpecs/AwakeCoding.OpenSpecs.psd1. (3) Add the name to the “exports expected cmdlets” $expected array in tests/AwakeCoding.OpenSpecs.Tests.ps1.
Load the module from repo root:
Import-Module ./AwakeCoding.OpenSpecs/AwakeCoding.OpenSpecs.psd1 -ForceUse these working dirs to avoid polluting the repo: ./artifacts/downloads, ./artifacts/converted-specs, ./artifacts/reports. Their contents are gitignored; directories may use .gitkeep. There is no install or build step; edit .ps1/.psd1 and re-import the module to test.
- Naming: Public cmdlets use
Verb-OpenSpecNoun(e.g.Get-OpenSpecCatalog,Convert-OpenSpecToMarkdown). Private helpers keepOpenSpecin the name where appropriate. - Parameters: Use
[CmdletBinding()]. Add pipeline support viaValueFromPipelineorValueFromPipelineByPropertyNamewhere it fits (e.g.Save-OpenSpecDocumentaccepts pipeline from catalog or download links). - File paths: Prefer
-LiteralPath(andTest-Path -LiteralPathinternally) for user-supplied paths to avoid issues with brackets (e.g.[MS-RDPEWA]). - Output objects: Assign
PSTypeNameto custom objects (e.g.AwakeCoding.OpenSpecs.FidelityResult,AwakeCoding.OpenSpecs.IndexResult) for consistency and formatting. - Errors: Use
throwfor parameter/contract failures; useWrite-Warningfor non-fatal cases (e.g. catalog fetch failed inUpdate-OpenSpecIndex).
Tests use Pester 5. From repo root:
Invoke-Pester ./testsUse PowerShell 7 (required; see above). Some tests are tagged Live and hit the network (Find-OpenSpec, Get-OpenSpecDownloadLink). To skip them:
Invoke-Pester ./tests -Tag '!Live'When you add a new exported function, add its name to the $expected array in the “exports expected cmdlets” test in tests/AwakeCoding.OpenSpecs.Tests.ps1.
- Do not remove or rename exported functions without updating
AwakeCoding.OpenSpecs.psd1and the exports test. - Conversion: DOCX is handled in-module via OpenXML. PDF is not used as a conversion source. Output is textual (tables, ASCII), not image-based.
- For bulk or CI conversions, use
-Parallel -ThrottleLimit NwithConvert-OpenSpecToMarkdownorInvoke-OpenSpecConversionPipeline(PowerShell 7 only).