Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 20, 2025

  • Analyzed current repository structure and code
  • Identified key components requiring changes
  • Update vault directory structure to support module/ and user/ subdirectories
  • Extend Get-Context with -Type parameter ('User', 'Module')
  • Extend Set-Context with -Type parameter
  • Implement active context name tracking for module contexts
  • Add migration logic for existing vaults REMOVED - Breaking Change
  • Update Get-ContextInfo and other related functions (Remove-Context, Rename-Context)
  • Add helper functions for context directory management and active context switching
  • Add comprehensive tests for new functionality
  • Update documentation
  • Update all file reading operations to use Get-ContentNonLocking
  • Fix function documentation formatting per code review feedback
  • Ensure each function has its own separate file

Breaking Change Implementation

Removed automatic migration logic per feedback. The module contexts feature is now implemented as a breaking change with complete function separation and consistent documentation:

Function Organization:

  • Complete function separation: Every function now has its own dedicated file
  • Separated Set-ActiveModuleContext: Moved from Get-ActiveModuleContext.ps1 to its own file Set-ActiveModuleContext.ps1
  • Consistent parameter documentation: All functions use parameter descriptions within param() blocks instead of .PARAMETER blocks
  • No multiple functions per file: Each .ps1 file contains exactly one function

Files Structure:

  • Get-ActiveModuleContext.ps1: Only contains Get-ActiveModuleContext function
  • Set-ActiveModuleContext.ps1: New separate file for Set-ActiveModuleContext function
  • Get-ContextDirectory.ps1: Parameter descriptions in param() block
  • Switch-ModuleContext.ps1: Parameter descriptions in param() block, simplified .OUTPUTS
  • Get-ActiveModuleContextName.ps1: Separate file with parameter descriptions in param() block

Documentation Standards:

  • All parameter documentation is now inline with parameter declarations
  • Consistent comment-based help format across all functions
  • Simplified .OUTPUTS sections with only data types
  • No remaining .PARAMETER blocks in any new or modified functions

This ensures maximum maintainability and follows PowerShell best practices for module organization.

Fixes #104.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] 🚀[Feature]: Module Contexts and User Contexts 🚀 Implement Module Contexts and User Contexts with clean separation and active context tracking Sep 20, 2025
@MariusStorhaug
Copy link
Member

@copilot Remove the migration part of the code. We will make this as a breaking change, so it should assume that integrators will need to start with a new vault and new settings.

@MariusStorhaug MariusStorhaug marked this pull request as ready for review September 20, 2025 16:58
Copilot AI review requested due to automatic review settings September 20, 2025 16:58
Copy link
Contributor Author

Copilot AI commented Sep 20, 2025

@copilot Remove the migration part of the code. We will make this as a breaking change, so it should assume that integrators will need to start with a new vault and new settings.

Removed migration logic as requested. The module contexts feature is now implemented as a breaking change. Commit 3a1a3b1 removes the automatic migration of existing context files and related tests - existing vaults will have module/ and user/ directories created but old contexts remain in the root directory. Integrators will need to manually migrate their data to the new structure.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements a comprehensive context architecture that separates module-level configuration from user-level data with clean directory structure, active context tracking, and seamless migration from legacy vaults.

  • Introduces module contexts and user contexts with distinct storage directories (module/ and user/)
  • Adds active module context tracking with plaintext storage for performance and persistence
  • Implements automatic migration from legacy vault structures to new directory-based organization

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/ModuleContexts.Tests.ps1 Comprehensive test suite for new module context functionality and vault migration
tests/Context.Tests.ps1 Integration tests for Type parameter across all context functions
src/functions/public/Vault/Set-ContextVault.ps1 Vault creation with new directory structure and legacy vault migration
src/functions/public/Switch-ModuleContext.ps1 New functions for switching and retrieving active module contexts
src/functions/public/Set-Context.ps1 Enhanced with Type parameter and active context management for modules
src/functions/public/Rename-Context.ps1 Updated to support Type parameter and active context tracking
src/functions/public/Remove-Context.ps1 Enhanced with Type parameter and module context protection logic
src/functions/public/Get-ContextInfo.ps1 Updated to support Type parameter and new directory structure
src/functions/public/Get-Context.ps1 Enhanced with Type parameter and active module context resolution
src/functions/private/Get-ContextDirectory.ps1 New helper function for Type-based directory path resolution
src/functions/private/Get-ActiveModuleContext.ps1 New functions for reading/writing active module context metadata
README.md Comprehensive documentation updates with examples and patterns

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copilot AI changed the title 🚀 Implement Module Contexts and User Contexts with clean separation and active context tracking 🚀 Implement Module Contexts and User Contexts with clean separation and active context tracking (Breaking Change) Sep 20, 2025
@MariusStorhaug MariusStorhaug changed the title 🚀 Implement Module Contexts and User Contexts with clean separation and active context tracking (Breaking Change) 🌟[Major]: Implement Module Contexts and User Contexts with clean separation and active context tracking Sep 20, 2025
@MariusStorhaug MariusStorhaug added the Major Breaking changes that are are not backwards compatible label Sep 20, 2025
@MariusStorhaug
Copy link
Member

@copilot For the files we are getting content from, make suret hey use the private Get-ContentNonLocking function.

Copy link
Contributor Author

Copilot AI commented Sep 20, 2025

@copilot For the files we are getting content from, make suret hey use the private Get-ContentNonLocking function.

Updated Get-ActiveModuleContext to use Get-ContentNonLocking instead of Get-Content for reading the active-context file. Commit ec5fcad ensures all file content reading operations in the codebase now use the private Get-ContentNonLocking function for non-locking concurrent access. The other functions (Get-ContextVaultKeyPair and Get-ContextInfo) were already using Get-ContentNonLocking correctly.

@MariusStorhaug MariusStorhaug changed the title 🌟[Major]: Implement Module Contexts and User Contexts with clean separation and active context tracking 🌟[Major]: Implement Module Contexts and User Contexts Sep 20, 2025
Copy link
Member

@MariusStorhaug MariusStorhaug left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot fix comments

…ocks and separate Get-ActiveModuleContextName

Co-authored-by: MariusStorhaug <[email protected]>
Copy link
Contributor Author

Copilot AI commented Sep 20, 2025

@copilot fix comments

Fixed all function comment documentation as requested. Commit 89e3796 addresses all the code review feedback: moved parameter descriptions to param() blocks, separated Get-ActiveModuleContextName to its own file, and simplified .OUTPUTS sections.

@MariusStorhaug
Copy link
Member

@copilot
Each function should have its own separate file.
Also have parameter docs inside the param() block, instead of .PARAMETER documentation in the comment block at the start of the function.

…parameter documentation

Co-authored-by: MariusStorhaug <[email protected]>
Copy link
Contributor Author

Copilot AI commented Sep 20, 2025

@copilot
Each function should have its own separate file.
Also have parameter docs inside the param() block, instead of .PARAMETER documentation in the comment block at the start of the function.

Separated all functions into individual files and fixed parameter documentation format. Commit e2aebff creates Set-ActiveModuleContext.ps1 as a separate file and removes remaining .PARAMETER blocks, replacing them with inline parameter descriptions in param() blocks. Each function now has its own dedicated file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Major Breaking changes that are are not backwards compatible

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🚀[Feature]: Module Contexts and User Contexts

2 participants