Skip to content

Commit bfee666

Browse files
chore: Update plan template to reference Constitution v1.3.0
1 parent 849ff31 commit bfee666

File tree

2 files changed

+211
-19
lines changed

2 files changed

+211
-19
lines changed

.specify/memory/constitution.md

Lines changed: 210 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,38 @@
11
<!--
2-
Sync Impact Report - Constitution v1.1.2
2+
Sync Impact Report - Constitution v1.3.0
33
========================================
4-
Version Change: 1.1.1 → 1.1.2 (PATCH - product clarification)
4+
Version Change: 1.2.0 → 1.3.0 (MINOR - expanded build process documentation)
55
Date: 2025-10-01
66
7-
Modified Principles:
8-
- Added preamble clarifying Process-PSModule as an opinionated reusable workflow product
9-
- Enhanced configuration guidance for consuming repositories
10-
- Clarified relationship between framework and consuming repos
7+
Modified Principles: None
118
129
Added Sections:
13-
- Product Overview (new section before Core Principles)
10+
- Build Process Requirements (comprehensive build execution flow documentation)
11+
- Custom build scripts support
12+
- Module manifest generation details
13+
- Root module compilation process
14+
- Data loading mechanism
15+
- Class/enum export mechanism
16+
- Source file processing order
1417
1518
Removed Sections: None
1619
1720
Templates Status:
18-
✅ plan-template.md - Updated to reference v1.1.2
21+
✅ plan-template.md - No changes needed (constitution check references general principles)
1922
✅ spec-template.md - No changes needed (no constitution-specific requirements)
2023
✅ tasks-template.md - No changes needed (general task structure applies)
2124
2225
Follow-up TODOs:
2326
- TODO(RATIFICATION_DATE): Determine original constitution adoption date
2427
25-
Rationale for PATCH bump:
26-
- Clarification of product nature and scope without new requirements
27-
- Added context about opinionated flow and structure
28-
- Explained configuration mechanism and consuming repo requirements
29-
- Non-semantic refinement that improves understanding of product purpose
28+
Rationale for MINOR bump:
29+
- Added materially expanded guidance on Build-PSModule action execution flow
30+
- Documented custom build script (*build.ps1) support and execution order
31+
- Detailed manifest generation process including derived vs. preserved properties
32+
- Documented root module compilation with specific folder processing order
33+
- Added data loader and class/enum export mechanism documentation
34+
- Material expansion that provides actionable build process requirements
35+
- Consuming repositories now understand complete build automation
3036
-->
3137

3238
# Process-PSModule Constitution
@@ -44,11 +50,197 @@ Rationale for PATCH bump:
4450

4551
### Consuming Repository Requirements
4652
Repositories that consume Process-PSModule workflows MUST:
47-
- Follow the module source structure documented in framework actions
53+
- Follow the module source structure documented in framework actions (see Required Module Structure below)
4854
- Provide configuration file (`.github/PSModule.yml`) with appropriate settings
4955
- Adhere to the opinionated workflow execution order
50-
- Reference Process-PSModule workflows using stable version tags
56+
- Reference Process-PSModule workflows using stable version tags (e.g., `@v4`)
5157
- Review action README documentation for structure and configuration requirements
58+
- Use the [Template-PSModule](https://github.com/PSModule/Template-PSModule) repository as a starting point
59+
60+
### Required Module Structure
61+
62+
**Process-PSModule enforces an opinionated module structure.** Consuming repositories MUST organize their PowerShell module source code in the following structure within the `src/` folder:
63+
64+
```
65+
src/
66+
├── manifest.psd1 # PowerShell module manifest (optional, auto-generated if missing)
67+
├── header.ps1 # Code executed at module load start
68+
├── finally.ps1 # Code executed at module load end
69+
├── README.md # Documentation reference (points to Build-PSModule)
70+
├── assemblies/ # .NET assemblies (.dll) to load
71+
├── classes/
72+
│ ├── private/ # Private PowerShell classes
73+
│ └── public/ # Public PowerShell classes (exported)
74+
├── data/ # Configuration data files (.psd1)
75+
├── formats/ # Format definition files (.ps1xml)
76+
├── functions/
77+
│ ├── private/ # Private functions (not exported)
78+
│ └── public/ # Public functions (exported to module)
79+
├── init/ # Initialization scripts
80+
├── modules/ # Nested PowerShell modules (.psm1)
81+
├── scripts/ # Script files (.ps1)
82+
├── types/ # Type definition files (.ps1xml)
83+
└── variables/
84+
├── private/ # Private variables
85+
└── public/ # Public variables (exported)
86+
```
87+
88+
**Structure Details**:
89+
- **Build-PSModule** action processes this structure and compiles it into a module
90+
- **Private vs Public**: `private/` folders contain internal implementations; `public/` folders contain exported elements
91+
- **Optional Components**: Not all folders are required; include only what your module needs
92+
- **Function Organization**: Functions can be organized in subdirectories (e.g., `functions/public/Get-/Get-Item.ps1`)
93+
- **Manifest**: If `manifest.psd1` is not provided, Build-PSModule generates one automatically
94+
- **Documentation**: See [Build-PSModule README](https://github.com/PSModule/Build-PSModule) for complete structure details
95+
96+
### Workflow Integration Requirements
97+
98+
Consuming repositories MUST create a workflow file (e.g., `.github/workflows/Process-PSModule.yml`) that calls the reusable Process-PSModule workflow:
99+
100+
```yaml
101+
name: Process-PSModule
102+
103+
on:
104+
pull_request:
105+
branches: [main]
106+
types: [closed, opened, reopened, synchronize, labeled]
107+
108+
jobs:
109+
Process-PSModule:
110+
uses: PSModule/Process-PSModule/.github/workflows/workflow.yml@v4
111+
secrets:
112+
APIKEY: ${{ secrets.APIKEY }} # PowerShell Gallery API key
113+
```
114+
115+
**Configuration Requirements**:
116+
- Configuration file at `.github/PSModule.yml` (YAML, JSON, or PSD1 format supported)
117+
- Reference: [Process-PSModule Configuration Documentation](https://github.com/PSModule/Process-PSModule#configuration)
118+
- Use Template-PSModule as starting point: https://github.com/PSModule/Template-PSModule
119+
120+
### Build Process Requirements
121+
122+
**Process-PSModule uses the Build-PSModule action to compile module source code into a production-ready PowerShell module.** The build process is automated and opinionated, following a specific execution flow:
123+
124+
#### Build Execution Flow
125+
126+
1. **Execute Custom Build Scripts** (Optional)
127+
- Build-PSModule searches for `*build.ps1` files **anywhere in the repository**
128+
- Scripts are executed in **alphabetical order by filename** (path-independent)
129+
- Allows custom pre-build logic (e.g., code generation, asset processing, configuration setup)
130+
- Example: `1-build.ps1` runs before `2-build.ps1` regardless of directory location
131+
- Custom scripts can modify source files before the build process continues
132+
133+
2. **Copy Source Code**
134+
- All files from `src/` folder are copied to the output folder
135+
- Existing root module file (`<ModuleName>.psm1`) is **excluded** (recreated in step 4)
136+
- Creates a clean build environment for compilation
137+
138+
3. **Build Module Manifest** (`<ModuleName>.psd1`)
139+
- Searches for existing `manifest.psd1` or `<ModuleName>.psd1` in source
140+
- If found, uses it as base (preserving specified properties)
141+
- If not found, creates new manifest from scratch
142+
- **Automatically Derived Properties**:
143+
- `RootModule`: Set to `<ModuleName>.psm1`
144+
- `ModuleVersion`: Temporary value (`999.0.0`) - updated by Publish-PSModule during release
145+
- `Author`: GitHub repository owner (or preserved from source manifest)
146+
- `CompanyName`: GitHub repository owner (or preserved from source manifest)
147+
- `Copyright`: Generated as `(c) YYYY <Owner>. All rights reserved.` (or preserved from source manifest)
148+
- `Description`: GitHub repository description (or preserved from source manifest)
149+
- `GUID`: New GUID generated by New-ModuleManifest
150+
- `FileList`: All files in the module output folder
151+
- `RequiredAssemblies`: All `*.dll` files from `assemblies/` and `modules/` (depth = 1)
152+
- `NestedModules`: All `*.psm1`, `*.ps1`, `*.dll` files from `modules/` (one level down)
153+
- `ScriptsToProcess`: All `*.ps1` files from `scripts/` folder (loaded into caller session)
154+
- `TypesToProcess`: All `*.Types.ps1xml` files (searched recursively)
155+
- `FormatsToProcess`: All `*.Format.ps1xml` files (searched recursively)
156+
- `DscResourcesToExport`: All `*.psm1` files from `resources/` folder
157+
- `FunctionsToExport`: All functions from `functions/public/` (determined by AST parsing)
158+
- `CmdletsToExport`: Empty array (or preserved from source manifest)
159+
- `VariablesToExport`: All variables from `variables/public/` (determined by AST parsing)
160+
- `AliasesToExport`: All aliases from `functions/public/` (determined by AST parsing)
161+
- `ModuleList`: All `*.psm1` files in source folder (excluding root module)
162+
- `RequiredModules`: Gathered from `#Requires -Modules` statements in source files
163+
- `PowerShellVersion`: Gathered from `#Requires -Version` statements in source files
164+
- `CompatiblePSEditions`: Gathered from `#Requires -PSEdition` statements (defaults to `@('Core','Desktop')`)
165+
- `Tags`: GitHub repository topics plus compatibility tags from source files
166+
- `LicenseUri`: Public URL to `LICENSE` file (or preserved from source manifest)
167+
- `ProjectUri`: GitHub repository URL (or preserved from source manifest)
168+
- `IconUri`: Public URL to `icon/icon.png` (or preserved from source manifest)
169+
- **Preserved from Source Manifest** (if provided):
170+
- `PowerShellHostName`, `PowerShellHostVersion`, `DotNetFrameworkVersion`, `ClrVersion`, `ProcessorArchitecture`
171+
- `RequireLicenseAcceptance` (defaults to `false` if not specified)
172+
- `ExternalModuleDependencies`, `HelpInfoURI`, `DefaultCommandPrefix`
173+
- `ReleaseNotes` (not automated - can be set via PR/release description)
174+
- `Prerelease` (managed by Publish-PSModule during release)
175+
176+
4. **Build Root Module** (`<ModuleName>.psm1`)
177+
- Creates new root module file (ignoring any existing `.psm1` in source)
178+
- **Compilation Order**:
179+
1. **Module Header**:
180+
- Adds content from `header.ps1` if exists (then removes file)
181+
- If no `header.ps1`, adds default `[CmdletBinding()]` parameter block
182+
- Adds PSScriptAnalyzer suppression for cross-platform compatibility
183+
2. **Post-Header Initialization**:
184+
- Loads module manifest information (`$script:PSModuleInfo`)
185+
- Adds platform detection (`$IsWindows` for PS 5.1 compatibility)
186+
3. **Data Loader** (if `data/` folder exists):
187+
- Recursively imports all `*.psd1` files from `data/` folder
188+
- Creates module-scoped variables: `$script:<filename>` for each data file
189+
- Example: `data/Config.psd1` becomes `$script:Config`
190+
4. **Source File Integration** (in this specific order):
191+
- Processes each folder alphabetically within the folder, files on root first, then subfolders
192+
- Files are wrapped with debug logging regions
193+
- After processing, source folders are **removed** from output:
194+
1. `init/` - Initialization scripts (executed first during module load)
195+
2. `classes/private/` - Private PowerShell classes (not exported)
196+
3. `classes/public/` - Public PowerShell classes (exported via TypeAccelerators)
197+
4. `functions/private/` - Private functions (not exported)
198+
5. `functions/public/` - Public functions (exported to module consumers)
199+
6. `variables/private/` - Private variables (not exported)
200+
7. `variables/public/` - Public variables (exported to module consumers)
201+
8. Any remaining `*.ps1` files on module root
202+
5. **Class and Enum Exporter** (if `classes/public/` exists):
203+
- Uses `System.Management.Automation.TypeAccelerators` for type registration
204+
- Exports enums from `classes/public/` as type accelerators
205+
- Exports classes from `classes/public/` as type accelerators
206+
- Adds `OnRemove` handler to clean up type accelerators when module is removed
207+
- Provides Write-Verbose output for each exported type
208+
6. **Export-ModuleMember**:
209+
- Adds `Export-ModuleMember` call with explicit lists
210+
- Only exports items from `public/` folders:
211+
- **Functions**: From `functions/public/`
212+
- **Cmdlets**: From manifest (usually empty for script modules)
213+
- **Variables**: From `variables/public/`
214+
- **Aliases**: From functions in `functions/public/`
215+
7. **Format with PSScriptAnalyzer**:
216+
- Entire root module content is formatted using `Invoke-Formatter`
217+
- Uses PSScriptAnalyzer settings from `Build/PSScriptAnalyzer.Tests.psd1`
218+
- Ensures consistent code style and UTF-8 BOM encoding
219+
220+
5. **Update Manifest Aliases**
221+
- Re-analyzes root module to extract actual aliases defined
222+
- Updates `AliasesToExport` in manifest with discovered aliases
223+
224+
6. **Upload Module Artifact**
225+
- Built module is packaged and uploaded as workflow artifact
226+
- Artifact name defaults to `module` (configurable via action input)
227+
- Available for subsequent workflow steps (testing, publishing)
228+
229+
#### Build Process Constraints
230+
231+
- **No Manual Root Module**: Any existing `.psm1` file in `src/` is **ignored and replaced**
232+
- **Source Folder Removal**: Processed source folders are removed from output (only compiled root module remains)
233+
- **Alphabetical Processing**: Files within each folder are processed alphabetically
234+
- **Manifest Precedence**: Source manifest values take precedence over generated values
235+
- **UTF-8 BOM Encoding**: Final root module uses UTF-8 with BOM encoding
236+
- **PowerShell 7.4+ Target**: Build process and generated code target PowerShell 7.4+
237+
238+
#### Build Process References
239+
240+
- [Build-PSModule Action](https://github.com/PSModule/Build-PSModule)
241+
- [PowerShell Gallery Publishing Guidelines](https://learn.microsoft.com/powershell/gallery/concepts/publishing-guidelines)
242+
- [PowerShell Module Manifests](https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_module_manifests)
243+
- [PowerShell Module Authoring](https://learn.microsoft.com/powershell/scripting/dev-cross-plat/performance/module-authoring-considerations)
52244

53245
## Core Principles
54246

@@ -215,13 +407,13 @@ Changes to this constitution require:
215407
- PowerShell 7.4+ compatibility MUST be verified
216408
- Action-based implementation preferred over inline workflow code
217409
- CI validation workflow MUST pass before merging changes to core workflows
218-
- **Consuming repositories** MUST follow structure requirements in action README documentation
410+
- **Consuming repositories** MUST follow the Required Module Structure documented in Product Overview
219411

220412
### Runtime Development Guidance
221413
For agent-specific runtime development guidance **when developing the framework**, agents should reference:
222414
- GitHub Copilot: `.github/copilot-instructions.md` (if exists)
223415
- Other agents: Check for `AGENTS.md`, `CLAUDE.md`, `GEMINI.md`, or `QWEN.md`
224416

225-
**For Consuming Repositories**: Follow the opinionated structure and configuration documented in the README files of the GitHub Actions this framework provides.
417+
**For Consuming Repositories**: Follow the Required Module Structure and Workflow Integration Requirements documented in the Product Overview section. Start with [Template-PSModule](https://github.com/PSModule/Template-PSModule).
226418

227-
**Version**: 1.1.2 | **Ratified**: TODO(RATIFICATION_DATE) | **Last Amended**: 2025-10-01
419+
**Version**: 1.3.0 | **Ratified**: TODO(RATIFICATION_DATE) | **Last Amended**: 2025-10-01

.specify/templates/plan-template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,4 +254,4 @@ directories captured above]
254254
- [ ] Complexity deviations documented
255255

256256
---
257-
*Based on Constitution v1.1.2 - See `.specify/memory/constitution.md`*
257+
*Based on Constitution v1.3.0 - See `.specify/memory/constitution.md`*

0 commit comments

Comments
 (0)