Skip to content

Restructure as PowerShell module with cmdlets#6

Open
jamesc wants to merge 2 commits into
mainfrom
feat/powershell-module
Open

Restructure as PowerShell module with cmdlets#6
jamesc wants to merge 2 commits into
mainfrom
feat/powershell-module

Conversation

@jamesc
Copy link
Copy Markdown
Owner

@jamesc jamesc commented Mar 4, 2026

Summary

Restructures the repo from loose scripts into a proper PowerShell module (MultiCopilot), installable via Import-Module.

Changes

New module structure

  • MultiCopilot.psd1 — Module manifest (PSGallery-ready metadata)
  • MultiCopilot.psm1 — Auto-loads all Private/ and Public/ scripts
  • Private/GitHelpers.ps1 — Shared helpers extracted from scripts

5 cmdlets (replacing 4 scripts)

Old Script New Cmdlet
worktree-up.ps1 New-CopilotWorktree
worktree-down.ps1 Remove-CopilotWorktree
worktree-status.ps1 Get-CopilotWorktree
worktree-cleanup.ps1 Clear-CopilotWorktree
(new) Initialize-CopilotProject

Key improvements

  • [CmdletBinding()] with proper parameter attributes and Get-Help support
  • SupportsShouldProcess (-WhatIf/-Confirm) on destructive cmdlets
  • Initialize-CopilotProject replaces manual "copy these files" step
  • AMP_API_KEY validation moved to fail-fast (before container setup)
  • Template files bundled in MultiCopilot/Templates/

Installation

Import-Module ./MultiCopilot
Initialize-CopilotProject    # scaffold .devcontainer/ into any project
New-CopilotWorktree feature-branch

jamesc and others added 2 commits March 4, 2026 09:01
- Add MultiCopilot module (psd1, psm1, loader)
- Convert scripts to cmdlets: New-CopilotWorktree, Remove-CopilotWorktree,
  Get-CopilotWorktree, Clear-CopilotWorktree
- Add Initialize-CopilotProject cmdlet to scaffold .devcontainer/ templates
- Extract shared helpers to Private/GitHelpers.ps1
- Bundle template files in MultiCopilot/Templates/
- Add SupportsShouldProcess (-WhatIf/-Confirm) to destructive cmdlets
- Move AMP_API_KEY validation to fail-fast (before container setup)
- Remove old scripts/ directory

Amp-Thread-ID: https://ampcode.com/threads/T-019cb806-b11a-70be-8c9b-1fb00a8b8ee2
Co-authored-by: Amp <amp@ampcode.com>
…butes merge

- Replace $LASTEXITCODE with $? for PowerShell hook success check in Remove-CopilotWorktree
- Use bash -c for devcontainer exec to preserve quoted arguments in New-CopilotWorktree
- Wrap Get-DefaultBranch in try/finally to ensure Pop-Location runs on error
- Use line-by-line comparison instead of regex for .gitattributes merge in Initialize-CopilotProject

Amp-Thread-ID: https://ampcode.com/threads/T-019cb823-a1da-74f9-90bd-e2626b6a78bd
Co-authored-by: Amp <amp@ampcode.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant