diff --git a/.github/workflows/installer-build.yml b/.github/workflows/installer-build.yml index 6225e83..eeb6b5c 100644 --- a/.github/workflows/installer-build.yml +++ b/.github/workflows/installer-build.yml @@ -24,12 +24,13 @@ jobs: if-no-files-found: error - name: Package complete Windows x64 installer run: | - python3 -m zipfile -c ProjectShell-v1.2.0-preview-Windows-x64.zip \ + python3 -m zipfile -c ProjectShell-v1.2.0-Windows-x64.zip \ Install-ProjectShell.exe \ Install-ProjectShell.ps1 \ ProjectShell.ps1 \ ProjectShell.Workspaces.ps1 \ ProjectShell.Catalogue.ps1 \ + ProjectShell.Migration.ps1 \ Diagnose-Launch.ps1 \ README.md \ SECURITY.md \ @@ -44,6 +45,7 @@ jobs: 'ProjectShell.ps1', 'ProjectShell.Workspaces.ps1', 'ProjectShell.Catalogue.ps1', + 'ProjectShell.Migration.ps1', 'Diagnose-Launch.ps1', 'README.md', 'SECURITY.md', @@ -51,7 +53,7 @@ jobs: 'CHANGELOG.md', 'LICENSE', } - with zipfile.ZipFile('ProjectShell-v1.2.0-preview-Windows-x64.zip') as z: + with zipfile.ZipFile('ProjectShell-v1.2.0-Windows-x64.zip') as z: assert set(z.namelist()) == expected, z.namelist() assert z.testzip() is None for filename in expected: @@ -61,29 +63,29 @@ jobs: - name: Build complete standalone installer from source-built ZIP run: | python3 scripts/build-standalone-installer.py \ - ProjectShell-v1.2.0-preview-Windows-x64.zip \ - ProjectShell-v1.2.0-preview-Windows-x64-Setup.exe - python3 scripts/check-installer-pe.py ProjectShell-v1.2.0-preview-Windows-x64-Setup.exe + ProjectShell-v1.2.0-Windows-x64.zip \ + ProjectShell-v1.2.0-Windows-x64-Setup.exe + python3 scripts/check-installer-pe.py ProjectShell-v1.2.0-Windows-x64-Setup.exe - name: Generate release SHA-256 checksums run: | sha256sum \ - ProjectShell-v1.2.0-preview-Windows-x64-Setup.exe \ - ProjectShell-v1.2.0-preview-Windows-x64.zip > SHA256SUMS.txt + ProjectShell-v1.2.0-Windows-x64-Setup.exe \ + ProjectShell-v1.2.0-Windows-x64.zip > SHA256SUMS.txt cat SHA256SUMS.txt - name: Attest release artifacts (main branch only) if: github.ref == 'refs/heads/main' uses: actions/attest@v4 with: subject-path: | - ProjectShell-v1.2.0-preview-Windows-x64-Setup.exe - ProjectShell-v1.2.0-preview-Windows-x64.zip + ProjectShell-v1.2.0-Windows-x64-Setup.exe + ProjectShell-v1.2.0-Windows-x64.zip - name: Upload full release package uses: actions/upload-artifact@v6 with: - name: ProjectShell-v1.2.0-preview-release-unsigned + name: ProjectShell-v1.2.0-release-unsigned path: | - ProjectShell-v1.2.0-preview-Windows-x64-Setup.exe - ProjectShell-v1.2.0-preview-Windows-x64.zip + ProjectShell-v1.2.0-Windows-x64-Setup.exe + ProjectShell-v1.2.0-Windows-x64.zip SHA256SUMS.txt if-no-files-found: error @@ -97,14 +99,14 @@ jobs: python-version: '3.12' - uses: actions/download-artifact@v6 with: - name: ProjectShell-v1.2.0-preview-release-unsigned + name: ProjectShell-v1.2.0-release-unsigned path: release-assets - name: Verify ZIP integrity, PE and committed source equivalence shell: pwsh run: | - python tests/verify_windows_installer_package.py --zip "release-assets/ProjectShell-v1.2.0-preview-Windows-x64.zip" --source . + python tests/verify_windows_installer_package.py --zip "release-assets/ProjectShell-v1.2.0-Windows-x64.zip" --source . if ($LASTEXITCODE -ne 0) { throw 'Windows release package verification failed.' } - name: Test extracted package in an isolated Windows installation shell: pwsh run: | - ./tests/Test-Installer-Sandbox.ps1 -ZipPath "release-assets/ProjectShell-v1.2.0-preview-Windows-x64.zip" + ./tests/Test-Installer-Sandbox.ps1 -ZipPath "release-assets/ProjectShell-v1.2.0-Windows-x64.zip" diff --git a/.github/workflows/powershell-validation.yml b/.github/workflows/powershell-validation.yml index 7ef7af4..19de5b0 100644 --- a/.github/workflows/powershell-validation.yml +++ b/.github/workflows/powershell-validation.yml @@ -18,6 +18,8 @@ jobs: ./tests/Test-Source.ps1 ./tests/Test-Workspaces.ps1 ./tests/Test-CatalogueBridge.ps1 + ./tests/Test-NameMigration.ps1 + ./tests/Test-SessionContext.ps1 validate-powershell-7: name: PowerShell 7 @@ -31,3 +33,5 @@ jobs: ./tests/Test-Source.ps1 ./tests/Test-Workspaces.ps1 ./tests/Test-CatalogueBridge.ps1 + ./tests/Test-NameMigration.ps1 + ./tests/Test-SessionContext.ps1 diff --git a/CHANGELOG.md b/CHANGELOG.md index 06da5e3..c825566 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,16 @@ # Changelog -## Unreleased — ProjectShell v1.2.0 preview: Catalogue dependency handoff +## ProjectShell v1.2.0 — Catalogue, migration and session handoff + +- Added guided application name transition planning in Manager (16), project sessions (10) and workspace menu (9). +- Added exact-confirmation changes to ProjectShell-owned profile/workspace labels and desktop shortcuts, with local snapshots, post-change checks and conservative rollback. +- Added GitHub Package Builder to Distribution Builder Pilot (DBP) naming pilot, optional explicit legacy aliases, and a bounded read-only source-name inventory; no automatic external repository/filesystem rename. Fixtures remain synthetic. +- Documented full software identity checklist for source, installer, ZIP/EXE/MSIX, GitHub distribution, legacy users and migration verification. + +- Export the active profile's saved start directory in the **process-local** PROJECTSHELL_START_DIRECTORY environment variable for approved child tooling, with no persistent environment changes. +- Release ZIP and standalone Windows Setup EXE are unsigned; MSIX is a separate DBP development validation, not included as an official ProjectShell v1.2.0 artifact. + +### Existing Catalogue dependency handoff - Added optional, preview-only Nathan's Catalogue Dependency Broker v1 integration using the alpha.13 structured JSON contract. - Added read-only dependency detection for 7-Zip, Windows Sandbox, WinGet and Chocolatey, with independent operation when Catalogue is missing. @@ -19,7 +29,7 @@ - Added a startup action for shortcuts that automatically runs the selected main tool. - Added a complete source-built Windows x64 ZIP and standalone setup EXE, including code-signing policy, security and removal documentation. - Added isolated Windows package/source integrity and scripted installation tests. Full interactive desktop and UAC testing remains separate. -- Added SHA-256 checksums and free GitHub Actions artifact attestations for official main-branch builds; binaries remain Authenticode unsigned pending SignPath Foundation approval. +- Added SHA-256 checksums and free GitHub Actions artifact attestations for official main-branch builds; binaries remain Authenticode unsigned. SignPath Foundation later declined the application for insufficient public visibility/adoption. ## ProjectShell v1 — Standalone CLI diff --git a/CODE_SIGNING_POLICY.md b/CODE_SIGNING_POLICY.md index 915f350..4d52c65 100644 --- a/CODE_SIGNING_POLICY.md +++ b/CODE_SIGNING_POLICY.md @@ -8,13 +8,15 @@ This policy applies to ProjectShell's official Windows release artifacts and is ## Signing provider and current status -**Selected provider (pending approval):** SignPath Foundation, using SignPath.io. The required acknowledgement for qualifying signed releases is: +**Current status: unsigned; no approved public Authenticode signing provider.** -> Free code signing provided by SignPath.io, certificate by SignPath Foundation +ProjectShell applied to the SignPath Foundation program. The Foundation **declined the application** because the project had not yet established enough independent public adoption and visibility (such as community contributions, external references and sustained public engagement). SignPath invited the project to reapply if those conditions change. This is not a code-security assessment and is not an endorsement of any ProjectShell build. -**Important status:** ProjectShell has selected SignPath Foundation as its code-signing provider, but SignPath Foundation acceptance, signing configuration, and issuance of signed release artifacts have **not yet been verified**. Until those steps are completed, repository-built Windows executables must be described as **unsigned**. This policy alone does **not** sign any files, certify any releases, or imply Foundation approval. +**Do not claim that SignPath Foundation signs, approves, sponsors or provides a certificate for ProjectShell.** The project's public GitHub release binaries remain unsigned unless a future independently verified signing arrangement is explicitly documented. Windows may display an unknown-publisher or SmartScreen warning. -When an official binary is actually signed using a SignPath Foundation certificate, the Windows certificate publisher will be **SignPath Foundation**, while ProjectShell remains developed and maintained by **NathanVarner27**. Only releases whose signatures have been checked may be labeled "signed." +Official build artifacts can include SHA-256 checksums and GitHub Actions build attestations; these help verify artifact integrity and provenance but **do not** make a Windows executable Authenticode-signed, remove SmartScreen warnings, or establish a Windows publisher identity. + +Reapplication to SignPath or selection of another provider must be separately approved, and all signing claims must be based on verified signatures on the actual published file. ## Team roles and responsibilities @@ -22,17 +24,17 @@ When an official binary is actually signed using a SignPath Foundation certifica | --- | --- | --- | | **Author / committer** | [NathanVarner27](https://github.com/NathanVarner27) | Develops and maintains the source repository and build workflows; evaluates requested changes. | | **Reviewer** | [NathanVarner27](https://github.com/NathanVarner27) | Reviews submissions from non-committers before merging, with extra scrutiny for executable behavior, installer changes, and build workflows. | -| **Code-signing approver** | [NathanVarner27](https://github.com/NathanVarner27) | Reviews the exact release and build provenance and explicitly approves **each** signing request. | +| **Release/signing approver** | [NathanVarner27](https://github.com/NathanVarner27) | Reviews release provenance; if a trusted signing service is later established, approves each signing request individually. | -All team members with source or SignPath access must enable multi-factor authentication. If maintainers are added, this table must be updated with their responsibilities; changes from non-committers require review by an authorized project member. Signing approval is a **manual, release-by-release decision** and must not be granted automatically. +All team members with source or future code-signing access should enable multi-factor authentication. If maintainers are added, this table must be updated with their responsibilities; changes from non-committers require review by an authorized project member. Signing approval is a **manual, release-by-release decision** and must not be granted automatically. ## Release and signing procedure 1. Review the exact tagged source revision, changelog, dependencies, license, and all changes to packaging or GitHub Actions workflows. 2. Run Windows PowerShell 5.1 and PowerShell 7 validation and the installer-build checks. Verify interactive installation and update behavior on Windows before a stable release. -3. Build Windows executables **only from the project's public source and build scripts** using an auditable, reproducible GitHub Actions workflow. Verify the resulting artifact identities, source revision, and checksums. A locally supplied or untraceable executable must not be submitted as an official SignPath build. -4. When the project is approved and integrated with SignPath.io, submit only ProjectShell-owned binaries from the verified build pipeline. The trusted **approver** must manually approve every signing request; do not sign unrelated or third-party binaries. -5. After signing, verify Authenticode signatures and the intended release file hashes, then publish artifacts and release notes on [GitHub Releases](https://github.com/NathanVarner27/ProjectShell/releases). Clearly identify any files that remain unsigned. +3. Build Windows executables **only from the project's public source and build scripts** using an auditable, reproducible GitHub Actions workflow. Verify resulting artifact identities, source revision, and checksums. Never represent an untraceable or locally supplied binary as an official verified build. +4. Do **not** submit a signing request under SignPath Foundation's name without a future explicit acceptance. If an approved signing provider is later configured, submit only ProjectShell-owned binaries from the verified build pipeline, and require an authorized maintainer to approve each request. +5. Publish artifacts and release notes on [GitHub Releases](https://github.com/NathanVarner27/ProjectShell/releases), clearly labeling unsigned executables. If future signing is established, verify Authenticode status, publisher identity, and intended release hashes before labeling files signed. 6. If a build, review, signature, or provenance check fails, **do not publish it as signed**. Fix the issue and repeat verification. GitHub Actions builds and checksum files alone do not confer Windows publisher trust. A ZIP can carry checksums and build attestations; its included executable must independently have a valid Authenticode signature to be described as Windows-signed. @@ -47,7 +49,7 @@ ProjectShell is a local-first tool. Its project profiles, saved startup commands ProjectShell does not silently change system-wide PowerShell execution policy or Windows UAC settings. Guided installation describes the file-copy and shortcut actions; administrator execution is explicitly requested through Windows UAC. For instructions to remove installed files, shortcuts, and optional local user data, see [uninstallation](README.md#uninstall-projectshell-manual-user-controlled). -## Verify an official signed executable +## Verify a downloaded executable's signing status On Windows, open PowerShell in the downloaded/extracted release folder and run: @@ -56,12 +58,10 @@ Get-AuthenticodeSignature -FilePath ".\Install-ProjectShell.exe" | Format-List Status, StatusMessage, SignerCertificate ``` -A qualifying signed executable should show `Status : Valid` and a signer certificate issued to **SignPath Foundation**. If the file is unsigned, `Status` will not be `Valid` (for example, `NotSigned`). A valid signature is not a substitute for reviewing which official release and source revision the file belongs to. +An unsigned ProjectShell executable is expected to show a status such as `NotSigned`. If a future release is signed, a result of `Status : Valid` must be accompanied by an appropriate signer certificate; verify the specific provider at that time. A valid signature does not independently establish which release and source revision the file belongs to. **Do not rely on a filename, release description, SmartScreen prompt, or this policy alone as proof of signing.** Verify the individual EXE. ZIP packages are not themselves Authenticode-signed merely because they contain a signed EXE. ## Security concerns and policy violations -Please follow [SECURITY.md](SECURITY.md) and avoid posting secrets or private local paths in public issues. If an artifact claiming a SignPath Foundation signature may violate SignPath's rules, report it using the channels described in the [SignPath Foundation conditions](https://signpath.org/terms.html). - -The project commits to the [SignPath Foundation conditions for open-source projects](https://signpath.org/terms.html) if the application is accepted; publishing this policy does not assert that acceptance has occurred. \ No newline at end of file +Please follow [SECURITY.md](SECURITY.md) and avoid posting secrets or private local paths in public issues. If a file falsely claims a trusted publisher signature, preserve the evidence and report it through the repository's security contact and the relevant certificate provider's abuse channel. \ No newline at end of file diff --git a/Install-ProjectShell.ps1 b/Install-ProjectShell.ps1 index 679c040..a0ac6d8 100644 --- a/Install-ProjectShell.ps1 +++ b/Install-ProjectShell.ps1 @@ -69,7 +69,7 @@ New-Item -Path $dataRoot -ItemType Directory -Force | Out-Null # When source and installation locations match, never copy a file onto itself. # If extracted elsewhere, replace just the app/installer/readme at the stable installation path. -foreach ($fileName in @('ProjectShell.ps1', 'ProjectShell.Workspaces.ps1', 'ProjectShell.Catalogue.ps1', 'Install-ProjectShell.ps1', 'Install-ProjectShell.exe', 'Diagnose-Launch.ps1', 'README.md', 'README.txt')) { +foreach ($fileName in @('ProjectShell.ps1', 'ProjectShell.Workspaces.ps1', 'ProjectShell.Catalogue.ps1', 'ProjectShell.Migration.ps1', 'Install-ProjectShell.ps1', 'Install-ProjectShell.exe', 'Diagnose-Launch.ps1', 'README.md', 'README.txt')) { $from = Join-Path $sourceRoot $fileName $to = Join-Path $installRoot $fileName if (-not (Test-Path -LiteralPath $from -PathType Leaf)) { continue } diff --git a/ProjectShell.Migration.ps1 b/ProjectShell.Migration.ps1 new file mode 100644 index 0000000..8caa18c --- /dev/null +++ b/ProjectShell.Migration.ps1 @@ -0,0 +1,506 @@ +# ProjectShell application-name migration v1. +# User-controlled metadata transition. Never renames source trees, repositories, +# EXEs, installers, workspace folders, or command/script contents. +$script:NameMigrationRoot = Join-Path $script:AppRoot 'name-migrations' + +function Assert-ProjectNameTransitionName([string]$Name) { + if ([string]::IsNullOrWhiteSpace($Name) -or $Name.Trim() -ne $Name -or + $Name.Length -gt 80 -or $Name.Length -lt 3 -or + $Name -match '[\\/:*?"<>|\x00-\x1f]' -or $Name.EndsWith('.')) { + throw 'Enter a name of 3-80 characters without path separators, invalid filename characters or surrounding spaces.' + } +} + +function Convert-ProjectNameTransitionValue([string]$Value,[string]$OldName,[string]$NewName,[string]$OldAlias='', [string]$NewAlias='') { + if ([string]::Equals($Value,$OldName,[StringComparison]::OrdinalIgnoreCase)) { return $NewName } + if ($Value.Length -gt ($OldName.Length+3) -and + $Value.Substring(0,$OldName.Length).Equals($OldName,[StringComparison]::OrdinalIgnoreCase) -and + $Value.Substring($OldName.Length).StartsWith(' - ',[StringComparison]::Ordinal)) { + return ($NewName + $Value.Substring($OldName.Length)) + } + if ($OldAlias) { + if ([string]::Equals($Value,$OldAlias,[StringComparison]::OrdinalIgnoreCase)) { return $NewAlias } + if ($Value.Length -gt ($OldAlias.Length+3) -and + $Value.Substring(0,$OldAlias.Length).Equals($OldAlias,[StringComparison]::OrdinalIgnoreCase) -and + $Value.Substring($OldAlias.Length).StartsWith(' - ',[StringComparison]::Ordinal)) { + return ($NewAlias + $Value.Substring($OldAlias.Length)) + } + } + return $Value +} + +function Get-ProjectNameTransitionHash([string]$Path) { + if (-not (Test-Path -LiteralPath $Path -PathType Leaf)) { return '' } + return (Get-FileHash -LiteralPath $Path -Algorithm SHA256).Hash.ToUpperInvariant() +} + +function New-ProjectNameTransitionPlan([string]$OldName,[string]$NewName,[string]$OldAlias='', [string]$NewAlias='') { + Assert-ProjectNameTransitionName $OldName + Assert-ProjectNameTransitionName $NewName + if ($OldName.Equals($NewName,[StringComparison]::OrdinalIgnoreCase)) { + throw 'The previous and proposed names must be different. Case-only renames are deferred.' + } + if ($OldAlias -or $NewAlias) { + Assert-ProjectNameTransitionName $OldAlias + Assert-ProjectNameTransitionName $NewAlias + if ($OldAlias.Equals($NewAlias,[StringComparison]::OrdinalIgnoreCase) -or + $OldAlias.Equals($OldName,[StringComparison]::OrdinalIgnoreCase)) { + throw 'The optional legacy alias must be distinct from the main name and its replacement.' + } + } + $profiles = if (Test-Path -LiteralPath $script:StorePath -PathType Leaf) { @(Read-Store) } else { @() } + $workspace = Read-WorkspaceStore + $allWorkspaces = @($workspace.Workspaces) + $profileChanges = [System.Collections.Generic.List[object]]::new() + $workspaceChanges = [System.Collections.Generic.List[object]]::new() + $plannedFiles = [System.Collections.Generic.HashSet[string]]::new([StringComparer]::OrdinalIgnoreCase) + + foreach ($profile in $profiles) { + if ([string]$profile.ShortcutFile -notmatch '^[^\/:*?"<>|\x00-\x1f]+\.lnk$') { + throw ('Unsafe saved shortcut filename for profile: ' + $profile.Name) + } + $newTitle = Convert-ProjectNameTransitionValue ([string]$profile.Name) $OldName $NewName $OldAlias $NewAlias + $newGroup = Convert-ProjectNameTransitionValue ([string]$profile.Group) $OldName $NewName $OldAlias $NewAlias + if ($newTitle -cne [string]$profile.Name -or $newGroup -cne [string]$profile.Group) { + if (@($profiles | Where-Object { $_.Id -ne $profile.Id -and $_.Name -ieq $newTitle }).Count -gt 0) { + throw ('A project shortcut already uses the new name: ' + $newTitle) + } + $newLink = [string]$profile.ShortcutFile + if ($newTitle -cne [string]$profile.Name) { + $safeBase = 'ProjectShell - ' + (Get-SafeName $newTitle) + $index = 1 + do { + $suffix = if ($index -eq 1) { '' } else { ' (' + $index + ')' } + $candidate = $safeBase + $suffix + '.lnk' + $target = Join-Path $script:Desktop $candidate + $taken = ((Test-Path -LiteralPath $target) -and + $candidate -ine [string]$profile.ShortcutFile) -or + $plannedFiles.Contains($candidate) -or + (@($profiles | Where-Object { $_.Id -ne $profile.Id -and $_.ShortcutFile -ieq $candidate }).Count -gt 0) + $index++ + } while ($taken -and $index -le 1000) + if ($taken) { throw 'No safe desktop shortcut name available.' } + $newLink = $candidate + } + [void]$plannedFiles.Add($newLink) + $profileChanges.Add([pscustomobject]@{ + Id=[string]$profile.Id + OldName=[string]$profile.Name + NewName=$newTitle + OldGroup=[string]$profile.Group + NewGroup=$newGroup + OldShortcut=[string]$profile.ShortcutFile + NewShortcut=$newLink + StartingFolder=[string]$profile.StartDirectory + Launchable=[string]$profile.MainLaunchable + StartupValue=[string]$profile.StartupValue + }) + } + } + foreach ($item in $allWorkspaces) { + $newLabel = Convert-ProjectNameTransitionValue ([string]$item.Name) $OldName $NewName $OldAlias $NewAlias + if ($newLabel -cne [string]$item.Name) { + if (@($allWorkspaces | Where-Object { $_.Id -ne $item.Id -and $_.Name -ieq $newLabel }).Count -gt 0) { + throw ('A saved workspace already uses the new name: ' + $newLabel) + } + $workspaceChanges.Add([pscustomobject]@{ + Id=[string]$item.Id + OldName=[string]$item.Name + NewName=$newLabel + Folder=[string]$item.Path + Launchable=[string]$item.Launchable + Installer=[string]$item.Installer + }) + } + } + return [pscustomobject]@{ + SchemaVersion=1 + PreviousName=$OldName + ProposedName=$NewName + PreviousAlias=$OldAlias + ProposedAlias=$NewAlias + ProfileHash=(Get-ProjectNameTransitionHash $script:StorePath) + WorkspaceHash=(Get-ProjectNameTransitionHash $script:WorkspaceStorePath) + ProfileChanges=@($profileChanges.ToArray()) + WorkspaceChanges=@($workspaceChanges.ToArray()) + } +} + +function Show-ProjectNameTransitionPlan($Plan) { + Write-Host '' + Write-Host 'PROJECTSHELL | APPLICATION NAME TRANSITION — PREVIEW' -ForegroundColor Cyan + Write-Host ('Previous name: ' + $Plan.PreviousName) + Write-Host ('Proposed name: ' + $Plan.ProposedName) + if ($Plan.PreviousAlias) { Write-Host ('Explicit alias: ' + $Plan.PreviousAlias + ' -> ' + $Plan.ProposedAlias) } + Write-Host ('Saved shortcuts affected: ' + @($Plan.ProfileChanges).Count) + foreach ($item in $Plan.ProfileChanges) { + Write-Host (' ' + $item.OldName + ' -> ' + $item.NewName) + Write-Host (' Desktop: ' + $item.OldShortcut + ' -> ' + $item.NewShortcut) + Write-Host (' Start folder stays: ' + $item.StartingFolder) + } + Write-Host ('Saved workspaces affected: ' + @($Plan.WorkspaceChanges).Count) + foreach ($item in $Plan.WorkspaceChanges) { + Write-Host (' ' + $item.OldName + ' -> ' + $item.NewName) + Write-Host (' Folder stays: ' + $item.Folder) + } + Write-Host 'External identity checks needed for full transition:' -ForegroundColor Yellow + Write-Host ' Source code identifiers, app title, package IDs and internal configuration' + Write-Host ' EXE/ZIP/MSIX names, manifest/publisher data, installer/uninstaller/update paths' + Write-Host ' README, help, tests, GitHub repository, CI, published release and backlinks' + Write-Host ' Existing installs, backwards compatibility, rollback and Windows launch tests' + Write-Host 'No application folders, source files, GitHub projects or installed programs are renamed.' +} + +function Test-ProjectNameTransitionOwnedLink([string]$Path,[string]$Id) { + if (-not (Test-Path -LiteralPath $Path -PathType Leaf)) { return $false } + $shell = $null; $link = $null + try { + $shell = New-Object -ComObject WScript.Shell + $link = $shell.CreateShortcut($Path) + return ([string]$link.Arguments -match '(?i)(?:^|\s)-LaunchId(?:\s|$)' -and + [string]$link.Arguments -match [regex]::Escape($Id) -and + [string]$link.Arguments -match [regex]::Escape('ProjectShell.ps1')) + } + catch { return $false } + finally { + if ($null -ne $link) { [void][Runtime.InteropServices.Marshal]::FinalReleaseComObject($link) } + if ($null -ne $shell) { [void][Runtime.InteropServices.Marshal]::FinalReleaseComObject($shell) } + } +} + +function Invoke-ProjectNameTransition($Plan,[string]$Confirmation) { + if ($Confirmation -cne ('RENAME ' + $Plan.PreviousName)) { + throw ('To proceed, enter exactly: RENAME ' + $Plan.PreviousName) + } + if (@($Plan.ProfileChanges).Count + @($Plan.WorkspaceChanges).Count -eq 0) { + throw 'No exact/prefix ProjectShell names match. Nothing to rename.' + } + if ($Plan.ProfileHash -cne (Get-ProjectNameTransitionHash $script:StorePath) -or + $Plan.WorkspaceHash -cne (Get-ProjectNameTransitionHash $script:WorkspaceStorePath)) { + throw 'Saved projects changed after the preview. Create a new plan before applying.' + } + foreach ($change in $Plan.ProfileChanges) { + $target = Join-Path $script:Desktop $change.NewShortcut + if ($change.NewShortcut -ine $change.OldShortcut -and (Test-Path -LiteralPath $target)) { + throw ('Desktop shortcut already exists; preview again: ' + $target) + } + } + Ensure-Store + $id = (Get-Date).ToUniversalTime().ToString('yyyyMMddTHHmmssZ') + '-' + [guid]::NewGuid().ToString('N') + $folder = Join-Path $script:NameMigrationRoot $id + New-Item -Path $folder -ItemType Directory -Force | Out-Null + $profilesBefore = Join-Path $folder 'profiles.before.json' + $workspacesBefore = Join-Path $folder 'workspaces.before.json' + $oldLinks = [System.Collections.Generic.List[object]]::new() + $newLinks = [System.Collections.Generic.List[string]]::new() + $profileTouched = (@($Plan.ProfileChanges).Count -gt 0) + $workspaceTouched = (@($Plan.WorkspaceChanges).Count -gt 0) + $profilesAfterHash = ''; $workspacesAfterHash = '' + $committed = $false + try { + if ($profileTouched) { Copy-Item -LiteralPath $script:StorePath -Destination $profilesBefore -ErrorAction Stop } + if ($workspaceTouched) { Copy-Item -LiteralPath $script:WorkspaceStorePath -Destination $workspacesBefore -ErrorAction Stop } + foreach ($change in $Plan.ProfileChanges) { + if ($change.OldShortcut -ine $change.NewShortcut) { + $oldPath = Join-Path $script:Desktop $change.OldShortcut + $backupFile = Join-Path $folder ('shortcut-' + [guid]::NewGuid().ToString('N') + '.lnk') + $owned = Test-ProjectNameTransitionOwnedLink $oldPath $change.Id + if ($owned) { Copy-Item -LiteralPath $oldPath -Destination $backupFile -ErrorAction Stop } + $oldLinks.Add([pscustomobject]@{ + Path=$oldPath + Backup=$(if ($owned) { $backupFile } else { '' }) + Owned=$owned + }) + } + } + if ($profileTouched) { + $profiles = @(Read-Store) + foreach ($profile in $profiles) { + foreach ($change in $Plan.ProfileChanges) { + if ([string]$profile.Id -eq $change.Id) { + $profile.Name = $change.NewName + $profile.Group = $change.NewGroup + $profile.ShortcutFile = $change.NewShortcut + } + } + } + Save-Store $profiles + foreach ($change in $Plan.ProfileChanges) { + if ($change.NewShortcut -ine $change.OldShortcut) { + $entry = @($profiles | Where-Object { $_.Id -eq $change.Id })[0] + $newPath = Join-Path $script:Desktop $change.NewShortcut + [void]$newLinks.Add($newPath) + Write-ProfileLink $entry + if (-not (Test-Path -LiteralPath $newPath -PathType Leaf)) { + throw ('New shortcut was not created: ' + $newPath) + } + } + } + $profilesAfterHash = Get-ProjectNameTransitionHash $script:StorePath + } + if ($workspaceTouched) { + $data = Read-WorkspaceStore + foreach ($item in $data.Workspaces) { + foreach ($change in $Plan.WorkspaceChanges) { + if ([string]$item.Id -eq $change.Id) { $item.Name = $change.NewName } + } + } + Save-WorkspaceStore $data + $workspacesAfterHash = Get-ProjectNameTransitionHash $script:WorkspaceStorePath + } + $receipt = [pscustomobject]@{ + SchemaVersion=1; Id=$id; PreviousName=$Plan.PreviousName; ProposedName=$Plan.ProposedName + PreviousAlias=$Plan.PreviousAlias; ProposedAlias=$Plan.ProposedAlias + ProfileTouched=$profileTouched; WorkspaceTouched=$workspaceTouched + ProfilesBeforeHash=$Plan.ProfileHash; WorkspacesBeforeHash=$Plan.WorkspaceHash + ProfilesAfterHash=$profilesAfterHash; WorkspacesAfterHash=$workspacesAfterHash + ProfileChanges=@($Plan.ProfileChanges); WorkspaceChanges=@($Plan.WorkspaceChanges) + OldLinks=@($oldLinks.ToArray()); NewLinks=@($newLinks.ToArray()) + ExternalNamingVerified=$false + } + $manifestPath = Join-Path $folder 'migration.json' + $receipt | ConvertTo-Json -Depth 10 | Set-Content -LiteralPath $manifestPath -Encoding UTF8 -ErrorAction Stop + # Only remove a previous ProjectShell-owned link after the new link and + # receipt exist. Leave ambiguous/unowned links untouched. + foreach ($link in $oldLinks) { + if ($link.Owned -and (Test-Path -LiteralPath $link.Path -PathType Leaf)) { + Remove-Item -LiteralPath $link.Path -Force -ErrorAction Stop + } + } + $committed = $true + Write-Host ('Migration receipt and backups: ' + $folder) -ForegroundColor Green + return $receipt + } + finally { + if (-not $committed) { + 'Transaction did not complete; metadata restore attempted.' | Set-Content -LiteralPath (Join-Path $folder 'aborted.txt') + if ($profileTouched -and (Test-Path -LiteralPath $profilesBefore -PathType Leaf)) { + Copy-Item -LiteralPath $profilesBefore -Destination $script:StorePath -Force + } + if ($workspaceTouched -and (Test-Path -LiteralPath $workspacesBefore -PathType Leaf)) { + Copy-Item -LiteralPath $workspacesBefore -Destination $script:WorkspaceStorePath -Force + } + foreach ($newLink in $newLinks) { + if (Test-Path -LiteralPath $newLink -PathType Leaf) { Remove-Item -LiteralPath $newLink -Force } + } + foreach ($old in $oldLinks) { + if ($old.Backup -and -not (Test-Path -LiteralPath $old.Path) -and + (Test-Path -LiteralPath $old.Backup -PathType Leaf)) { + Copy-Item -LiteralPath $old.Backup -Destination $old.Path + } + } + } + } +} + +function Get-ProjectNameTransitionLatest { + if (-not (Test-Path -LiteralPath $script:NameMigrationRoot -PathType Container)) { return $null } + $folders = @(Get-ChildItem -LiteralPath $script:NameMigrationRoot -Directory | + Sort-Object -Property Name -Descending) + foreach ($dir in $folders) { + $manifest = Join-Path $dir.FullName 'migration.json' + $rollback = Join-Path $dir.FullName 'rolled-back.txt' + $aborted = Join-Path $dir.FullName 'aborted.txt' + if ((Test-Path -LiteralPath $manifest -PathType Leaf) -and + -not (Test-Path -LiteralPath $rollback -PathType Leaf) -and + -not (Test-Path -LiteralPath $aborted -PathType Leaf)) { + return [pscustomobject]@{ Folder=$dir.FullName; Receipt=(Get-Content -LiteralPath $manifest -Raw -Encoding UTF8 | ConvertFrom-Json) } + } + } + return $null +} + +function Test-ProjectNameTransition($Record) { + if (-not $Record) { throw 'No completed migration receipt is available.' } + $r = $Record.Receipt + $profileHashOK = (-not $r.ProfileTouched) -or ($r.ProfilesAfterHash -ceq (Get-ProjectNameTransitionHash $script:StorePath)) + $workspaceHashOK = (-not $r.WorkspaceTouched) -or ($r.WorkspacesAfterHash -ceq (Get-ProjectNameTransitionHash $script:WorkspaceStorePath)) + $newLinksOK = $true + foreach ($link in $r.NewLinks) { + if (-not (Test-Path -LiteralPath ([string]$link) -PathType Leaf)) { $newLinksOK = $false } + } + $remainingOld = @($r.OldLinks | Where-Object { Test-Path -LiteralPath ([string]$_.Path) -PathType Leaf }) + return [pscustomobject]@{ + ProjectShellMetadataVerified=($profileHashOK -and $workspaceHashOK -and $newLinksOK) + OldShortcutLinksRemaining=$remainingOld.Count + ExternalApplicationRenameVerified=$false + ReceiptFolder=$Record.Folder + } +} + +function Undo-ProjectNameTransition($Record,[string]$Confirmation) { + if (-not $Record) { throw 'No completed migration to roll back.' } + $r = $Record.Receipt + if ($Confirmation -cne ('ROLLBACK ' + $r.Id)) { throw ('Type exactly: ROLLBACK ' + $r.Id) } + $check = Test-ProjectNameTransition $Record + if (-not $check.ProjectShellMetadataVerified) { + throw 'Projects or shortcuts changed since migration. Rollback refuses to overwrite them.' + } + if ($r.ProfileTouched) { + $before = Join-Path $Record.Folder 'profiles.before.json' + if ((Get-ProjectNameTransitionHash $before) -cne $r.ProfilesBeforeHash) { throw 'Profile backup checksum mismatch.' } + } + if ($r.WorkspaceTouched) { + $before = Join-Path $Record.Folder 'workspaces.before.json' + if ((Get-ProjectNameTransitionHash $before) -cne $r.WorkspacesBeforeHash) { throw 'Workspace backup checksum mismatch.' } + } + foreach ($old in $r.OldLinks) { + if ($old.Backup -and (Test-Path -LiteralPath ([string]$old.Path))) { + throw ('Old desktop shortcut path has been reused; rollback stopped: ' + $old.Path) + } + } + foreach ($link in $r.NewLinks) { + if (-not (Test-ProjectNameTransitionOwnedLink ([string]$link) ([string](@($r.ProfileChanges | Where-Object { + (Join-Path $script:Desktop $_.NewShortcut) -eq [string]$link })[0].Id)))) { + throw ('New shortcut ownership cannot be verified; rollback stopped: ' + $link) + } + } + if ($r.ProfileTouched) { + Copy-Item -LiteralPath (Join-Path $Record.Folder 'profiles.before.json') -Destination $script:StorePath -Force + } + if ($r.WorkspaceTouched) { + Copy-Item -LiteralPath (Join-Path $Record.Folder 'workspaces.before.json') -Destination $script:WorkspaceStorePath -Force + } + foreach ($link in $r.NewLinks) { Remove-Item -LiteralPath ([string]$link) -Force } + foreach ($old in $r.OldLinks) { + if ($old.Backup) { Copy-Item -LiteralPath ([string]$old.Backup) -Destination ([string]$old.Path) -Force } + } + 'Rolled back by explicit user request.' | Set-Content -LiteralPath (Join-Path $Record.Folder 'rolled-back.txt') + Write-Host ('ProjectShell metadata restored from: ' + $Record.Folder) -ForegroundColor Green +} + +function Find-ProjectNameTransitionReferences([string]$ProjectRoot,[string]$OldName,[string]$NewName) { + Assert-ProjectNameTransitionName $OldName + Assert-ProjectNameTransitionName $NewName + if (-not (Test-Path -LiteralPath $ProjectRoot -PathType Container)) { + throw 'Select an existing project folder for the read-only inventory.' + } + $root = [IO.Path]::GetFullPath($ProjectRoot) + if ($root.TrimEnd('\') -eq [IO.Path]::GetPathRoot($root).TrimEnd('\')) { + throw 'Choose a specific project folder, not an entire drive.' + } + if ((Get-Item -LiteralPath $root -Force).Attributes -band [IO.FileAttributes]::ReparsePoint) { + throw 'Do not select a symlink or junction root.' + } + $ignoredFolders = @('.git','.venv','venv','node_modules','.tox','__pycache__','.vs','.idea','.pytest_cache','dist','build') + $allowedExtensions = @('.ps1','.psm1','.psd1','.py','.json','.md','.txt','.yml','.yaml','.toml','.ini','.cfg','.xml','.cs','.c','.h','.js','.ts','.tsx','.jsx','.cmd','.bat','.spec','.wxs','.iss') + $toVisit = [System.Collections.Generic.Queue[string]]::new() + $toVisit.Enqueue($root) + $findings = [System.Collections.Generic.List[object]]::new() + $scanned = 0; $skipped = 0; $entries = 0 + while ($toVisit.Count -gt 0) { + $dir = $toVisit.Dequeue() + foreach ($item in (Get-ChildItem -LiteralPath $dir -Force -ErrorAction Stop)) { + $entries++ + if ($entries -gt 3000) { throw 'Inventory limit reached (3000 entries). Narrow the source folder before scanning.' } + if ($item.Attributes -band [IO.FileAttributes]::ReparsePoint) { $skipped++; continue } + if ($item.PSIsContainer) { + if ($item.Name -in $ignoredFolders) { $skipped++; continue } + $toVisit.Enqueue($item.FullName) + continue + } + $fileOld = $item.Name.IndexOf($OldName,[StringComparison]::OrdinalIgnoreCase) -ge 0 + $fileNew = $item.Name.IndexOf($NewName,[StringComparison]::OrdinalIgnoreCase) -ge 0 + $contentOld = 0; $contentNew = 0 + $scanContent = ([IO.Path]::GetExtension($item.Name).ToLowerInvariant() -in $allowedExtensions) -and + ($item.Length -le 262144) -and ($item.Name -notmatch '(?i)(password|secret|token|credential|\.env)') + if ($scanContent) { + try { + $content = Get-Content -LiteralPath $item.FullName -Raw -Encoding UTF8 -ErrorAction Stop + $contentOld = [regex]::Matches($content,[regex]::Escape($OldName),[Text.RegularExpressions.RegexOptions]::IgnoreCase).Count + $contentNew = [regex]::Matches($content,[regex]::Escape($NewName),[Text.RegularExpressions.RegexOptions]::IgnoreCase).Count + $scanned++ + } + catch { $skipped++ } + } else { $skipped++ } + if ($fileOld -or $fileNew -or $contentOld -or $contentNew) { + $findings.Add([pscustomobject]@{ + RelativePath=$item.FullName.Substring($root.TrimEnd('\').Length).TrimStart('\') + OldNameInFileName=$fileOld + NewNameInFileName=$fileNew + OldNameTextMatches=$contentOld + NewNameTextMatches=$contentNew + }) + } + } + } + return [pscustomobject]@{ + ProjectRoot=$root + OldName=$OldName + NewName=$NewName + TextFilesInspected=$scanned + ItemsSkipped=$skipped + NameReferences=@($findings.ToArray()) + ExternalIdentityVerified=$false + } +} + +function Show-ProjectNameTransitionMenu { + $plan = $null + while ($true) { + Write-Host '' + Write-Host 'PROJECTSHELL | APPLICATION NAME TRANSITION' -ForegroundColor Cyan + Write-Host ' 1. Plan/preview a name transition (read-only)' + Write-Host ' 2. Apply only ProjectShell-managed names (backup + exact approval)' + Write-Host ' 3. Verify latest ProjectShell-managed transition' + Write-Host ' 4. Roll back latest transition (only if no later changes)' + Write-Host ' 5. Inventory a selected app folder for old/new name references (read-only)' + Write-Host ' 0. Back' + $choice = (Read-Host 'Number').Trim() + try { + switch ($choice) { + '1' { + $old = (Read-Host 'Current application name').Trim() + $next = (Read-Host 'Proposed application name').Trim() + $oldAlias = (Read-Host 'Existing short name/alias to update too (optional)').Trim() + $newAlias = '' + if ($oldAlias) { $newAlias = (Read-Host 'New short name/alias').Trim() } + $plan = New-ProjectNameTransitionPlan $old $next $oldAlias $newAlias + Show-ProjectNameTransitionPlan $plan + } + '2' { + if (-not $plan) { Write-Host 'Use option 1 to preview first.' -ForegroundColor Yellow; continue } + if (-not (Read-YesNo 'Backups will be created. Apply only ProjectShell names?' $false)) { continue } + $typed = Read-Host ('Type RENAME ' + $plan.PreviousName) + $null = Invoke-ProjectNameTransition $plan $typed + $plan = $null + Write-Host 'Only ProjectShell-managed names changed. External identity checks are still pending.' -ForegroundColor Yellow + } + '3' { + $latest = Get-ProjectNameTransitionLatest + if (-not $latest) { Write-Host 'No completed transition.'; continue } + $result = Test-ProjectNameTransition $latest + Write-Host ('ProjectShell metadata verified: ' + $result.ProjectShellMetadataVerified) + Write-Host ('Previous desktop shortcuts remaining: ' + $result.OldShortcutLinksRemaining) + Write-Host 'Full application naming transition: NOT VERIFIED (external gates need separate review).' -ForegroundColor Yellow + Write-Host ('Receipt: ' + $result.ReceiptFolder) + } + '4' { + $latest = Get-ProjectNameTransitionLatest + if (-not $latest) { Write-Host 'No completed transition to roll back.'; continue } + Write-Host ('Selected receipt: ' + $latest.Receipt.Id) + if (-not (Read-YesNo 'Restore the saved ProjectShell metadata and links?' $false)) { continue } + $typed = Read-Host ('Type ROLLBACK ' + $latest.Receipt.Id) + Undo-ProjectNameTransition $latest $typed + } + '5' { + $old = if ($plan) { $plan.PreviousName } else { (Read-Host 'Existing application name').Trim() } + $next = if ($plan) { $plan.ProposedName } else { (Read-Host 'Proposed application name').Trim() } + $folder = (Read-Host 'Application source folder (full path; no changes)').Trim().Trim('"') + $result = Find-ProjectNameTransitionReferences $folder $old $next + Write-Host ('Text files inspected: ' + $result.TextFilesInspected) + Write-Host ('Skipped entries: ' + $result.ItemsSkipped) + Write-Host ('Files with old/new name references: ' + @($result.NameReferences).Count) + foreach ($item in $result.NameReferences) { + Write-Host (' ' + $item.RelativePath + ' | old: ' + $item.OldNameTextMatches + ' | new: ' + $item.NewNameTextMatches) + } + Write-Host 'Inventory is bounded, read-only and incomplete for binaries, installers, GitHub or ignored folders.' -ForegroundColor Yellow + Write-Host 'A full renaming transition still requires manual acceptance.' + } + '0' { return } + default { Write-Host 'Choose a listed number.' -ForegroundColor Yellow } + } + } + catch { Write-Host ('MIGRATION ERROR: ' + $_.Exception.Message) -ForegroundColor Red } + } +} diff --git a/ProjectShell.Workspaces.ps1 b/ProjectShell.Workspaces.ps1 index 248d554..7d3b9b1 100644 --- a/ProjectShell.Workspaces.ps1 +++ b/ProjectShell.Workspaces.ps1 @@ -421,6 +421,7 @@ function Start-ProfileLaunchable($Profile) { Write-Host 'A standard profile launch cannot run from an elevated session.' -ForegroundColor Yellow return } + Set-ProjectShellLaunchContext $Profile Invoke-SavedTool (Get-ProfileLaunchable $Profile) ([string]$Profile.StartDirectory) } @@ -439,6 +440,7 @@ function Show-WorkspaceToolsMenu { Write-Host ' 6. Save workspace installer location' Write-Host ' 7. Make ProjectShell desktop shortcut' Write-Host ' 8. Check archive dependencies / Catalogue preview' + Write-Host ' 9. Application name transition / migration' Write-Host ' 0. Back' $choice = (Read-Host 'Number').Trim() try { @@ -470,6 +472,7 @@ function Show-WorkspaceToolsMenu { if ($selected) { $null = New-Profile @(Read-Store) $null ([string]$selected.Path) ([string]$selected.Name) ([string]$selected.Id) } } '8' { Show-ProjectShellCatalogueMenu } + '9' { Show-ProjectNameTransitionMenu } '0' { return } default { Write-Host 'Choose a listed number.' -ForegroundColor Yellow } } diff --git a/ProjectShell.ps1 b/ProjectShell.ps1 index 17a8b59..2849ee8 100644 --- a/ProjectShell.ps1 +++ b/ProjectShell.ps1 @@ -787,6 +787,11 @@ $script:CatalogueModule = Join-Path (Split-Path -Path $script:ProgramPath -Paren if (-not (Test-Path -LiteralPath $script:CatalogueModule -PathType Leaf)) { throw 'Missing ProjectShell.Catalogue.ps1; rerun the current installer.' } . $script:CatalogueModule +# Migration is independent of package installation, shortcut privileges or Catalogue. +$script:MigrationModule = Join-Path (Split-Path -Path $script:ProgramPath -Parent) 'ProjectShell.Migration.ps1' +if (-not (Test-Path -LiteralPath $script:MigrationModule -PathType Leaf)) { throw 'Missing ProjectShell.Migration.ps1; rerun the current installer.' } +. $script:MigrationModule + function Show-Manager { while ($true) { $profiles = @(Read-Store) @@ -813,6 +818,7 @@ function Show-Manager { Write-Host ' 13. DevTools folder and saved workspace/tool lookups' Write-Host ' 14. Set primary launchable for a shortcut' Write-Host ' 15. Optional system dependencies (Catalogue preview only)' + Write-Host ' 16. Application name transition / migration' Write-Host ' 0. Exit manager' $choice = (Read-Host 'Number').Trim() try { @@ -861,6 +867,7 @@ function Show-Manager { '12' { Show-LauncherAudit } '13' { Show-WorkspaceToolsMenu } '15' { Show-ProjectShellCatalogueMenu } + '16' { Show-ProjectNameTransitionMenu } '14' { $selected = Select-Profile $profiles 'Set launchable for shortcut number' if ($null -ne $selected) { Set-ProfileLaunchable $selected } @@ -900,6 +907,16 @@ function Set-ProjectTitle([string]$Name) { try { $Host.UI.RawUI.WindowTitle = $Name } catch { } } +function Set-ProjectShellLaunchContext($entry) { + # Share only the user's saved starting folder with child processes. + # Never persist a machine/user setting or pass profiles.json to an app. + $folder = [string]$entry.StartDirectory + if (-not (Test-Path -LiteralPath $folder -PathType Container)) { + throw ('ProjectShell configured starting folder is missing: ' + $folder) + } + $env:PROJECTSHELL_START_DIRECTORY = [IO.Path]::GetFullPath($folder) +} + function Invoke-ProjectTask($entry) { Set-ProjectTitle $entry.Name if (-not (Test-Path -LiteralPath $entry.StartDirectory -PathType Container)) { @@ -907,6 +924,7 @@ function Invoke-ProjectTask($entry) { return } Set-Location -LiteralPath $entry.StartDirectory + Set-ProjectShellLaunchContext $entry Write-Host '' Write-Host '============================================================' -ForegroundColor Cyan Write-Host (' ' + $entry.Name) -ForegroundColor Cyan @@ -947,6 +965,7 @@ function Invoke-ProjectTask($entry) { function Show-OpenProjectMenu([string]$Id) { while ($true) { $entry = Get-ProfileById $Id + Set-ProjectShellLaunchContext $entry Set-ProjectTitle $entry.Name Write-Host '' Write-Host (' ' + $entry.Name + ' | SESSION MENU') -ForegroundColor Cyan @@ -959,6 +978,7 @@ function Show-OpenProjectMenu([string]$Id) { Write-Host ' 7. Set/change this shortcut main launchable' Write-Host ' 8. DevTools folder and saved tool lookups' Write-Host ' 9. Optional system dependencies (Catalogue preview only)' + Write-Host ' 10. Application name transition / migration' Write-Host ' 0. Return to PowerShell prompt' $answer = (Read-Host 'Number').Trim() try { @@ -975,6 +995,7 @@ function Show-OpenProjectMenu([string]$Id) { '7' { Set-ProfileLaunchable $entry } '8' { Show-WorkspaceToolsMenu } '9' { Show-ProjectShellCatalogueMenu } + '10' { Show-ProjectNameTransitionMenu } '5' { Enter-UserProfileFolder # Leave the project menu so the user can enter regular commands. diff --git a/README.md b/README.md index 5d5f60b..bdf1ffa 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,14 @@ Choose **15** in the ProjectShell Manager, **9** in a project session menu, or * Recognized requests: optional **7-Zip** (WinGet exact ID), **Windows Sandbox** (Windows Optional Feature), and manual locators for **WinGet** and **Chocolatey**. General PowerShell modules, Python/Node/Java runtimes, and other Windows features are **not supported by this broker mapping**; follow the manual fallback. See [Catalogue integration and supported dependencies](docs/PROJECTSHELL_CATALOGUE_DEPENDENCIES.md) for full details. +### Transition an application to a new name (post-v1.1 preview) + +ProjectShell includes a guided **application name transition** workflow for independent software that is changing names. It previews the exact ProjectShell-managed profile, group, workspace and desktop shortcut labels, including one optional explicitly mapped legacy abbreviation, then requires explicit confirmation before changing local metadata. It creates a recoverable backup and offers verification and rollback. A separate bounded, read-only inventory can find old/new names within selected source files, but cannot verify binary or public distribution changes. **It does not rename application binaries, source trees, folders, GitHub repositories, published releases or user startup commands.** + +Open **16 — Application name transition / migration** in the ProjectShell Manager, **10** in a project session, or **9** in the workspace tools menu. The developer must independently verify a complete product-wide rename, including EXE/ZIP/MSIX identity, install/upgrade compatibility, documented aliases and existing user settings. + +**First pilot:** GitHub Package Builder. Its future public name has not yet been selected, so automated tests use a synthetic name, not a new published product identity. Follow the [migration guide and acceptance checklist](docs/PROJECTSHELL_APPLICATION_NAME_MIGRATION.md) before performing a real rename. + ## What you'll need - Windows 10 or 11 with an interactive desktop and Windows Explorer. @@ -133,7 +141,7 @@ ProjectShell currently **does not register a Windows Apps & Features uninstaller ## Code signing policy -ProjectShell has selected **SignPath Foundation** as its intended free code-signing provider. **SignPath approval and workflow integration are pending.** The current GitHub-built Windows launcher is **unsigned**; do not assume a GitHub download is Authenticode-signed unless its signature verifies. +ProjectShell applied to the **SignPath Foundation** program, but its application was **declined for insufficient public visibility and adoption**. The current GitHub-built Windows executables are **unsigned**; there is no approved SignPath certificate or signed-publisher claim. GitHub attestations and SHA-256 checksums support integrity/provenance verification, not Windows publisher trust. See the [ProjectShell code signing policy](CODE_SIGNING_POLICY.md), including maintainer roles, privacy commitments, signing approvals, and how to verify a signed release. Only the official [Releases](https://github.com/NathanVarner27/ProjectShell/releases) page should be used for public installer downloads. @@ -165,9 +173,16 @@ ProjectShell keeps your settings on your own computer: | DevTools root and saved workspace/tool lookups | `%LOCALAPPDATA%\ProjectShell\workspaces.json` | | Optional Catalogue location and generated broker requests | `%LOCALAPPDATA%\ProjectShell\catalogue-integration.json` and `dependency-requests\` | | Created project shortcuts | The Windows desktop folder chosen during installation | +| Application naming migration receipts/backups | `%LOCALAPPDATA%\ProjectShell\name-migrations\` | Updating ProjectShell keeps your saved profiles, workspace registry, and startup commands in place. These personal files aren't meant to go in the public GitHub repository. **Don't upload your profiles, settings, logs, backups, or personal `.lnk` files**, since they may reveal local folders or commands. +### Active ProjectShell folder handoff (v1.2.0) + +When a ProjectShell project session starts or launches its saved tool, it passes the saved `StartDirectory` as `PROJECTSHELL_START_DIRECTORY` **in that process only**. Children such as Distribution Builder Pilot can propose the exact workspace folder even after you change directories. This is not written to persistent user/system environment settings, and ProjectShell does not expose your profile store to other applications. + +The application-name migration wizard changes ProjectShell-managed names and verified desktop links only. It does not move external application files or rewrite saved folder paths, launchables or startup commands; edit those separately in the Manager. + ## If a shortcut isn't working From the installed ProjectShell folder, run: diff --git a/docs/PROJECTSHELL_APPLICATION_NAME_MIGRATION.md b/docs/PROJECTSHELL_APPLICATION_NAME_MIGRATION.md new file mode 100644 index 0000000..c219dba --- /dev/null +++ b/docs/PROJECTSHELL_APPLICATION_NAME_MIGRATION.md @@ -0,0 +1,88 @@ +# Application Name Transition and Migration — preview v1 + +**Status:** Post-v1.1.0 development feature. Local ProjectShell metadata migration is implemented; a full external application rename is NOT automatically performed or verified. + +## Purpose + +ProjectShell provides a guided pathway when a separate application changes its public name. GitHub Package Builder's owner has approved the new public name **Distribution Builder Pilot (DBP)**. Test fixtures remain synthetic and do not themselves rename any external application or GitHub repository. + +A complete rename includes much more than changing a desktop shortcut. ProjectShell can inventory the work and update **ProjectShell-owned display names only**. The developer remains responsible for editing and validating the application itself. This is **not** a folder, source-code, GitHub-repository or installed-program renamer. + +## Start the wizard + +- ProjectShell Manager: **16 — Application name transition / migration** +- Open project session (`psmenu`): **10** +- DevTools/workspace menu: **9** + +1. Select **1 — Plan/preview**, enter the existing application name and proposed new name. You can optionally map one explicitly specified old short name/alias to a new alias. The old name or an explicitly selected old alias must match a ProjectShell profile/workspace name exactly or be followed by ` - ` and a suffix (e.g. "GitHub Package Builder - Testing"). Abbreviated names such as `GPB` and `GHPB`, and folders like `GitHubPackageBuilder`, are **not silently rewritten**. +2. Review the matched project titles, profile groups, workspace labels and desktop shortcut filenames. **Preview does not change any files.** +3. Choose **2 — Apply**, confirm a default-no prompt, and type exactly `RENAME `. +4. ProjectShell writes a receipt and copies the original metadata/owned shortcuts to `%LOCALAPPDATA%\ProjectShell\name-migrations\-\`, updates matching display names, and regenerates verified desktop shortcuts. Previous links are removed only when ProjectShell verifies that they target the corresponding ProjectShell profile. Unknown/unowned desktop links are left untouched. +5. Choose **3 — Verify** to check metadata hashes and desktop shortcut presence. **This is not an application-wide verification.** +6. Select **5 — Inventory a selected app folder** to review matching old/new display names and text references without editing anything. The scan has directory and size caps, skips symlinks and common build/venv folders, and does **not** cover binaries, ignored directories, online distributions or hidden dependencies. +7. Choose **4 — Roll back**. The app requires `ROLLBACK ` and refuses if source data changed, backups fail SHA-256 verification, or former shortcut paths are occupied. + +Application folders, executable paths, source files, GitHub projects, manifests, startup command text and other developer-owned assets are never automatically renamed. Nathan's Catalogue integration remains independent. + +## What counts as a full naming transition? + +A project cannot be marked fully renamed until the **application owner** verifies all applicable areas: + +| Area | Required checks | Current ProjectShell scope | +| --- | --- | --- | +| Public identity | Windows titles, menus, help, about text, accessible labels | Local ProjectShell labels only | +| Launch behavior | Profiles, desktop shortcuts, working folder, standard/admin privileges | Local profile name/link replacement with backup and restore | +| Application source | Internal names, CLI commands, app IDs, modules, APIs, README/tests | Manual developer change and regression testing | +| Distribution | EXE, ZIP, MSIX, installer/uninstall identity, update detection | Manual; no binary editing or signing | +| GitHub | Repository URL and redirects, workflows, release tags, downloads | Manual; no GitHub mutation | +| Stored user data | Old config paths, upgrades, legacy aliases and compatibility | External app-specific migration tests | +| Dependencies | Catalogue identifiers, structured broker requests and version agreements | Not rewritten; check after changing product app ID | +| Safety and recovery | Backups, rollback, source integrity, Windows tests, UAC | Local ProjectShell metadata safety only; remaining checks external | + +A migration can be **partially complete** even if ProjectShell's titles are updated. The verification command always reports **external application rename not verified**. + +## GitHub Package Builder — first pilot + +**Existing name:** GitHub Package Builder. + +**Approved new name:** Distribution Builder Pilot (DBP). + +**Test fixtures:** Isolated fixtures use these labels to verify ProjectShell-only metadata operations; they do not modify external binaries or source. + +### Stage A — Isolated ProjectShell tests + +- [ ] Preview recognizes the main shortcut, suffixed testing shortcut and matching workspace. +- [ ] Preview leaves user metadata and external application files untouched. +- [ ] Apply requires exact consent, records snapshot backups and changes only ProjectShell-owned labels. +- [ ] Start folders, startup content, launchables, unrelated projects and abbreviations remain unchanged. +- [ ] New shortcuts verify; old ProjectShell-owned shortcuts can be safely replaced. +- [ ] Rollback restores previous saved data and owned shortcuts. +- [ ] Unsafe names and stale plans are rejected. +- [ ] Explicit legacy alias mapping updates only the selected abbreviation. +- [ ] A bounded read-only source inventory identifies old names in text files but never edits the application. + +Tests are defined in `tests/Test-NameMigration.ps1`; verify successful Windows PowerShell 5.1/7 CI before checking these items. + +### Stage B — Real DBP naming transition (partially completed) + +- [x] Select the public name Distribution Builder Pilot (DBP). The app has a canonical dbp Python module and retains gpb aliases for backwards compatibility. Full external identity reconciliation remains a separate DBP release gate. +- [ ] Back up the actual source, installation, manifests, settings, release automation and ProjectShell profiles. +- [ ] Update application-owned names in a reviewable development branch; retain existing data and backward-compatible aliases/migrations. +- [ ] Use ProjectShell's preview and approved local metadata transition; verify normal and admin shortcuts and launcher paths. +- [ ] Build and test the newly named ZIP, EXE and planned MSIX; test installation and upgrade on Windows without overwriting v1.1.0 ProjectShell. +- [ ] Verify existing users' settings, paths, and shortcuts survive the app rename. +- [ ] Verify GitHub repository, redirect/backlinks, release assets and documentation match the official selected name. +- [ ] Run security, uninstall and rollback checks; document unsupported rename surfaces. + +**Full transition gate:** Stage B must pass before describing GitHub Package Builder as fully renamed or publishing its new identity. + +## Safety limits / unsupported operations + +- No arbitrary search-and-replace inside source trees, ZIP, EXE, MSIX, binaries or unknown settings. +- No automatic folder moves or deletion, background installer, elevation, package installation, GitHub commit/push/rename or release publication. +- No silent rewriting of user-configured startup commands or executable paths. +- No automatic updates for old abbreviations, aliases or unrelated profiles. +- Case-only renames, duplicate names, modified metadata, or reused old shortcut destinations may need explicit manual resolution. +- Rollback requires stored post-migration metadata and backup SHA-256 checks to match. Keep independent backups for any external application-wide migration. + +This is post-**ProjectShell v1.1.0** development. The published v1.1.0 release is unchanged. \ No newline at end of file diff --git a/docs/PROJECTSHELL_RELEASE_V1_2_0.md b/docs/PROJECTSHELL_RELEASE_V1_2_0.md new file mode 100644 index 0000000..af41f38 --- /dev/null +++ b/docs/PROJECTSHELL_RELEASE_V1_2_0.md @@ -0,0 +1,28 @@ +# ProjectShell v1.2.0 — release and local acceptance checklist + +## Included functionality + +- Windows CLI ProjectShell Manager, numbered menus, saved profiles and launchable tools. +- Guided **ProjectShell-owned** application name migration: read-only preview, exact approval, backup, receipt, verification, conservative rollback. Does not move or rewrite third-party application source, binary, settings, GitHub repo or launchable paths. +- Process-local `PROJECTSHELL_START_DIRECTORY` handoff to child applications; existing working-directory fallback retained. +- Optional Nathan's Catalogue preview-only dependency review. No automatic dependency installs. +- Windows ZIP with the complete launcher/script set and a standalone source-built Windows x64 Setup EXE; both Authenticode unsigned. + +## Verified or required acceptance + +- [x] The application migration feature has Windows PowerShell 5.1/7 source/build CI passing in its development branch. +- [x] Real user's migration planning, apply/rollback, stored JSON syntax/readability, script parsing, restored desktop links and permissions were tested separately. +- [x] Real DBP installed files: 66 content-equivalent to the tested DBP commit; local 163-test Python regression (5 expected skips), canonical/legacy CLI and Windows launchers passed. +- [x] Both local ProjectShell DBP saved profiles have correct name, group, folder and launchable, with desktop links present and different administrator settings. +- [ ] Confirm BOTH DBP desktop links open at the expected location and actual privilege (normal and UAC); a saved flag is not proof of actual privilege. +- [ ] Run combined PR CI (PowerShell 5.1/7; Windows ZIP/EXE build and isolated installation); ensure the process-local handoff test runs. +- [ ] Validate new v1.2.0 installer on a real Windows desktop and confirm user data survives upgrade. Existing installed files/hashes from older build do not prove new build equivalence. +- [ ] Inspect artifact hashes, license, provenance and published asset names before public release. +- [ ] Publish only after approving the verified version/tag and labeling both ZIP/EXE Authenticode **unsigned**. +- [ ] Test ProjectShell with DBP-generated ZIP, reviewed standalone EXE and separately prototyped MSIX. DBP does not compile EXEs and an installer EXE is **not** automatically a suitable MSIX entry point. + +## Boundaries + +Preserve local `%LOCALAPPDATA%\ProjectShell` profiles/workspaces/settings and saved shortcuts during upgrade. Keep administrative and standard-user test profiles separate; do not change elevation settings without review. Do not remove old ProjectShell v1.1.0 release. + +MSIX: not an official v1.2.0 deliverable. Full-trust Windows packaged app behavior, runtime entrypoint, three PNG assets, SDK MakeAppx, Partner Center identity/publisher for Store submission, signature/trust for local installation, WACK and clean-machine update/uninstall acceptance remain separate. diff --git a/native/BUILD.md b/native/BUILD.md index b199cff..1078a61 100644 --- a/native/BUILD.md +++ b/native/BUILD.md @@ -4,7 +4,7 @@ The executable **is not a self-contained installer**. It must be distributed with the PowerShell scripts it launches. -A **different binary**, `ProjectShell-v1.1.0-Windows-x64-Setup.exe`, is also built from the verified complete release ZIP by `scripts/build-standalone-installer.py`. That release asset **is self-contained**. Both EXEs are currently unsigned while SignPath Foundation approval remains pending. +A **different binary**, `ProjectShell-v1.2.0-Windows-x64-Setup.exe`, is also built from the verified complete release ZIP by `scripts/build-standalone-installer.py`. That release asset **is self-contained**. Both EXEs are currently unsigned. SignPath Foundation declined ProjectShell's application on public visibility/adoption grounds; no Foundation signing is available. ## Build it @@ -29,15 +29,16 @@ Include these files together in the extracted installation folder: - `ProjectShell.ps1` - `ProjectShell.Workspaces.ps1` - `ProjectShell.Catalogue.ps1` (optional, preview-only system dependency handoff) +- `ProjectShell.Migration.ps1` (local application-name migration, backup and rollback) - `Diagnose-Launch.ps1` -Also include `README.md`, `SECURITY.md`, `CODE_SIGNING_POLICY.md`, `CHANGELOG.md`, and `LICENSE` in a public distribution package. **Do not distribute the EXE by itself.** Users should extract the complete ZIP before running the bundled launcher; the separate `ProjectShell-v1.1.0-Windows-x64-Setup.exe` release asset does not require extraction. +Also include `README.md`, `SECURITY.md`, `CODE_SIGNING_POLICY.md`, `CHANGELOG.md`, and `LICENSE` in a public distribution package. **Do not distribute the EXE by itself.** Users should extract the complete ZIP before running the bundled launcher; the separate `ProjectShell-v1.2.0-Windows-x64-Setup.exe` release asset does not require extraction. ## Permissions and Windows testing The executable requests `asInvoker`, so it does not request elevation on its own. The launcher still cannot turn an already elevated process into a standard-user process. -The PowerShell installer uses a process-local `-ExecutionPolicy Bypass`; this does not change system-wide policy or disable UAC. The repository-built EXE is currently unsigned, so Windows SmartScreen may warn users. See the [code signing policy](../CODE_SIGNING_POLICY.md) for the planned SignPath Foundation integration; no signing is claimed until a built artifact has a valid signature. +The PowerShell installer uses a process-local `-ExecutionPolicy Bypass`; this does not change system-wide policy or disable UAC. The repository-built EXE is currently unsigned, so Windows SmartScreen may warn users. See the [code signing policy](../CODE_SIGNING_POLICY.md) for the declined SignPath application and unsigned release verification; no signing is claimed until a built artifact has a verified trusted Authenticode signature. Before publishing a new downloadable installer package, test installation, updates, desktop shortcut selection, standard launches, and administrator launches on a real Windows desktop. Include testing on systems without a `D:` drive if possible. diff --git a/scripts/build-standalone-installer.py b/scripts/build-standalone-installer.py index 6944914..61cbe95 100644 --- a/scripts/build-standalone-installer.py +++ b/scripts/build-standalone-installer.py @@ -131,7 +131,7 @@ } New-Item -ItemType Directory -Path $extract -Force | Out-Null Expand-Archive -LiteralPath $bundle -DestinationPath $extract -Force - foreach ($name in @('Install-ProjectShell.ps1','ProjectShell.ps1','ProjectShell.Workspaces.ps1','ProjectShell.Catalogue.ps1','Diagnose-Launch.ps1')) { + foreach ($name in @('Install-ProjectShell.ps1','ProjectShell.ps1','ProjectShell.Workspaces.ps1','ProjectShell.Catalogue.ps1','ProjectShell.Migration.ps1','Diagnose-Launch.ps1')) { if (-not (Test-Path -LiteralPath (Join-Path $extract $name) -PathType Leaf)) { throw ('Missing required component: ' + $name) } @@ -171,6 +171,7 @@ def main() -> None: "ProjectShell.ps1", "ProjectShell.Workspaces.ps1", "ProjectShell.Catalogue.ps1", + "ProjectShell.Migration.ps1", "Diagnose-Launch.ps1", }.issubset(set(z.namelist())), "Missing essential installer scripts" digest = hashlib.sha256(archive).hexdigest().upper() diff --git a/tests/Test-Installer-Sandbox.ps1 b/tests/Test-Installer-Sandbox.ps1 index 84ceeda..0dc2103 100644 --- a/tests/Test-Installer-Sandbox.ps1 +++ b/tests/Test-Installer-Sandbox.ps1 @@ -53,7 +53,7 @@ try { finally { $process.Dispose() } foreach ($file in @('ProjectShell.ps1', 'ProjectShell.Workspaces.ps1', 'ProjectShell.Catalogue.ps1', - 'Install-ProjectShell.ps1', 'Diagnose-Launch.ps1', 'Install-ProjectShell.exe')) { + 'Install-ProjectShell.ps1', 'ProjectShell.Migration.ps1', 'Diagnose-Launch.ps1', 'Install-ProjectShell.exe')) { $path = Join-Path $installed $file if (-not (Test-Path -LiteralPath $path -PathType Leaf)) { throw ('Installed file missing: ' + $file) } if ((Get-FileHash -LiteralPath $path -Algorithm SHA256).Hash -ne diff --git a/tests/Test-NameMigration.ps1 b/tests/Test-NameMigration.ps1 new file mode 100644 index 0000000..1968b2c --- /dev/null +++ b/tests/Test-NameMigration.ps1 @@ -0,0 +1,154 @@ +# Isolated Windows PowerShell 5.1 / PowerShell 7 tests for ProjectShell migration. +# No real Desktop, existing profiles, GitHub repositories, or external project files touched. +$ErrorActionPreference = 'Stop' +$root = Split-Path -Path $PSScriptRoot -Parent +$temp = Join-Path $env:TEMP ('ProjectShell-NameMigration-' + [guid]::NewGuid().ToString('N')) +New-Item -Path $temp -ItemType Directory -Force | Out-Null +function Assert([bool]$OK,[string]$Description) { + if (-not $OK) { throw ('FAIL: ' + $Description) } + Write-Host ('PASS: ' + $Description) -ForegroundColor Green +} + +try { + $script:AppRoot = Join-Path $temp 'AppData' + $script:StorePath = Join-Path $script:AppRoot 'profiles.json' + $script:WorkspaceStorePath = Join-Path $script:AppRoot 'workspaces.json' + $script:Desktop = Join-Path $temp 'FakeDesktop' + $script:ProgramPath = Join-Path $temp 'ProjectShell.ps1' + $project = Join-Path $temp 'GitHubPackageBuilder' + $script:NameMigrationRoot = Join-Path $script:AppRoot 'name-migrations' + New-Item -Path $script:Desktop,$script:AppRoot,$project -ItemType Directory -Force | Out-Null + Set-Content -LiteralPath (Join-Path $project 'package_config.json') -Value '{"app_name":"GitHub Package Builder"}' -Encoding UTF8 + $sourceHash = (Get-FileHash (Join-Path $project 'package_config.json') -Algorithm SHA256).Hash + + function Ensure-Store { + New-Item -Path $script:AppRoot -ItemType Directory -Force | Out-Null + } + function Read-Store { + if (-not (Test-Path -LiteralPath $script:StorePath -PathType Leaf)) { return @() } + $data = Get-Content -LiteralPath $script:StorePath -Raw -Encoding UTF8 | ConvertFrom-Json + return @($data.Profiles) + } + function Save-Store([object[]]$Profiles) { + ([pscustomobject]@{ Version=1; Profiles=@($Profiles) } | ConvertTo-Json -Depth 10) | + Set-Content -LiteralPath $script:StorePath -Encoding UTF8 + } + function Read-WorkspaceStore { + return (Get-Content -LiteralPath $script:WorkspaceStorePath -Raw -Encoding UTF8 | ConvertFrom-Json) + } + function Save-WorkspaceStore($Data) { + $Data | ConvertTo-Json -Depth 10 | Set-Content -LiteralPath $script:WorkspaceStorePath -Encoding UTF8 + } + function Get-SafeName([string]$Name) { + return ($Name -replace '[\\/:*?"<>|]', '-') + } + function Write-ProfileLink($Entry) { + $path = Join-Path $script:Desktop $Entry.ShortcutFile + $shell = New-Object -ComObject WScript.Shell + $link = $null + try { + $link = $shell.CreateShortcut($path) + $link.TargetPath = Join-Path $env:SystemRoot 'System32\WindowsPowerShell\v1.0\powershell.exe' + $link.Arguments = '-NoLogo -File "' + $script:ProgramPath + '" -LaunchId "' + $Entry.Id + '"' + $link.WorkingDirectory = $Entry.StartDirectory + $link.Save() + } + finally { + if ($link) { [void][Runtime.InteropServices.Marshal]::FinalReleaseComObject($link) } + [void][Runtime.InteropServices.Marshal]::FinalReleaseComObject($shell) + } + } + + . (Join-Path $root 'ProjectShell.Migration.ps1') + $old = 'GitHub Package Builder' + $new = 'Distribution Builder Pilot' + $profiles = @( + [pscustomobject]@{ Id='gpb-main'; Name=$old; Group=$old; ShortcutFile='ProjectShell - GitHub Package Builder.lnk'; StartDirectory=$project; MainLaunchable=(Join-Path $project 'GPB.exe'); StartupValue=''; Admin=$false; Terminal='Console' }, + [pscustomobject]@{ Id='gpb-test'; Name=($old+' - Testing'); Group='GPB'; ShortcutFile='ProjectShell - GitHub Package Builder - Testing.lnk'; StartDirectory=$project; MainLaunchable=''; StartupValue=''; Admin=$false; Terminal='Console' }, + [pscustomobject]@{ Id='other'; Name='Universal Game Audio'; Group='UGA'; ShortcutFile='ProjectShell - Universal Game Audio.lnk'; StartDirectory=$temp; MainLaunchable=''; StartupValue=''; Admin=$false; Terminal='Console' } + ) + Save-Store $profiles + Save-WorkspaceStore ([pscustomobject]@{ + Version=1; DevToolsRoot=$temp; Workspaces=@( + [pscustomobject]@{ Id='gpb-ws'; Name=$old; Path=$project; Launchable=(Join-Path $project 'GPB.exe'); Installer=''; OtherState='preserve' }, + [pscustomobject]@{ Id='other-ws'; Name='Another App'; Path=$temp; Launchable=''; Installer='' } + ) + }) + foreach ($p in $profiles) { Write-ProfileLink $p } + $beforeProfile = Get-ProjectNameTransitionHash $script:StorePath + $beforeWorkspace = Get-ProjectNameTransitionHash $script:WorkspaceStorePath + + $plan = New-ProjectNameTransitionPlan $old $new + Assert (@($plan.ProfileChanges).Count -eq 2) 'Pilot previews the main + testing ProjectShell shortcuts' + Assert (@($plan.WorkspaceChanges).Count -eq 1) 'Pilot previews the workspace identity change' + Assert ((Get-ProjectNameTransitionHash $script:StorePath) -eq $beforeProfile) 'Preview does not change existing profiles' + Assert ((Get-ProjectNameTransitionHash $script:WorkspaceStorePath) -eq $beforeWorkspace) 'Preview does not change workspace registry' + Assert (-not (Test-Path -LiteralPath $script:NameMigrationRoot)) 'Preview creates no migration backup or receipt' + $inventory = Find-ProjectNameTransitionReferences $project $old $new + Assert ($inventory.TextFilesInspected -ge 1) 'Bounded read-only file inventory checks text sources' + Assert (@($inventory.NameReferences | Where-Object { $_.RelativePath -eq 'package_config.json' -and $_.OldNameTextMatches -ge 1 }).Count -eq 1) 'Old GPB identity is located for external migration' + Assert (-not $inventory.ExternalIdentityVerified) 'Inventory does not certify the entire software identity' + $wholeDrive = $false + try { $null = Find-ProjectNameTransitionReferences ([IO.Path]::GetPathRoot($project)) $old $new } catch { $wholeDrive = $true } + Assert $wholeDrive 'Drive-wide inventory is blocked' + Assert ((Get-FileHash (Join-Path $project 'package_config.json') -Algorithm SHA256).Hash -eq $sourceHash) 'Preview preserves external application contents' + + $rejected = $false + try { $null = Invoke-ProjectNameTransition $plan 'yes' } catch { $rejected = $true } + Assert $rejected 'Apply requires exact RENAME confirmation' + $receipt = Invoke-ProjectNameTransition $plan ('RENAME ' + $old) + Assert ($receipt.Id -and (Test-Path -LiteralPath (Join-Path $script:NameMigrationRoot $receipt.Id) -PathType Container)) 'Apply creates rollback receipt and backups' + + $actual = @(Read-Store) + Assert (@($actual | Where-Object { $_.Name -eq $new }).Count -eq 1) 'Main profile renamed' + Assert (@($actual | Where-Object { $_.Name -eq ($new+' - Testing') }).Count -eq 1) 'Suffix profile renamed' + Assert (@($actual | Where-Object { $_.Name -eq 'Universal Game Audio' }).Count -eq 1) 'Unrelated profile preserved' + Assert ((@($actual | Where-Object { $_.Id -eq 'gpb-main' })[0].StartDirectory -eq $project)) 'Start directory not moved' + Assert ((@($actual | Where-Object { $_.Id -eq 'gpb-test' })[0].Group -eq 'GPB')) 'Abbreviated group not silently changed' + Assert ((@((Read-WorkspaceStore).Workspaces | Where-Object { $_.Name -eq $new }).Count -eq 1)) 'Workspace display name changed' + Assert ((@((Read-WorkspaceStore).Workspaces | Where-Object { $_.Id -eq 'gpb-ws' })[0].OtherState -eq 'preserve')) 'Unrelated workspace metadata preserved' + Assert (-not (Test-Path -LiteralPath (Join-Path $script:Desktop 'ProjectShell - GitHub Package Builder.lnk'))) 'Verified owned former shortcut removed' + Assert (Test-Path -LiteralPath (Join-Path $script:Desktop 'ProjectShell - Distribution Builder Pilot.lnk') -PathType Leaf) 'New launch shortcut created' + Assert ((Get-FileHash (Join-Path $project 'package_config.json') -Algorithm SHA256).Hash -eq $sourceHash) 'Apply did not edit external source code' + + $latest = Get-ProjectNameTransitionLatest + $check = Test-ProjectNameTransition $latest + Assert ($check.ProjectShellMetadataVerified) 'Post-migration state verifies' + Assert (-not $check.ExternalApplicationRenameVerified) 'Full GPB rename remains pending outside ProjectShell' + $badRollback = $false + try { Undo-ProjectNameTransition $latest 'ROLLBACK wrong' } catch { $badRollback = $true } + Assert $badRollback 'Rollback requires exact receipt confirmation' + Undo-ProjectNameTransition $latest ('ROLLBACK ' + $receipt.Id) + Assert ((Get-ProjectNameTransitionHash $script:StorePath) -eq $beforeProfile) 'Rollback restores original profiles byte-for-byte' + Assert ((Get-ProjectNameTransitionHash $script:WorkspaceStorePath) -eq $beforeWorkspace) 'Rollback restores original workspaces byte-for-byte' + Assert (Test-Path -LiteralPath (Join-Path $script:Desktop 'ProjectShell - GitHub Package Builder.lnk') -PathType Leaf) 'Rollback restores original owned shortcut' + Assert (-not (Test-Path -LiteralPath (Join-Path $script:Desktop 'ProjectShell - Distribution Builder Pilot.lnk'))) 'Rollback removes new owned shortcut' + Assert (-not (Get-ProjectNameTransitionLatest)) 'Rolled-back receipt no longer eligible for duplicate rollback' + + $invalid = $false + try { $null = New-ProjectNameTransitionPlan 'GitHub Package Builder' '..\unsafe' } catch { $invalid = $true } + Assert $invalid 'Invalid names and paths rejected' + $stale = New-ProjectNameTransitionPlan $old $new + $saved = @(Read-Store) + $saved[2].Group = 'Unrelated profile edited after preview' + Save-Store $saved + $refused = $false + try { $null = Invoke-ProjectNameTransition $stale ('RENAME ' + $old) } catch { $refused = $true } + Assert $refused 'Stale plan refuses overwriting user edits' + # One explicitly supplied legacy alias can be mapped in the same reviewed plan. + $saved[2].Group = 'UGA' + Save-Store $saved + $aliasPlan = New-ProjectNameTransitionPlan $old $new 'GPB' 'DBP' + Assert (@($aliasPlan.ProfileChanges).Count -eq 2) 'Explicit GPB alias is included in the pilot preview' + $aliasReceipt = Invoke-ProjectNameTransition $aliasPlan ('RENAME ' + $old) + $testingProfile = @((Read-Store) | Where-Object { $_.Id -eq 'gpb-test' })[0] + Assert ($testingProfile.Group -eq 'DBP') 'Only explicitly mapped legacy short name changes' + Assert ((@((Read-Store) | Where-Object { $_.Id -eq 'other' })[0].Group -eq 'UGA')) 'Unrelated short name is preserved' + $aliasLatest = Get-ProjectNameTransitionLatest + Undo-ProjectNameTransition $aliasLatest ('ROLLBACK ' + $aliasReceipt.Id) + Assert ((Get-ProjectNameTransitionHash $script:StorePath) -eq $beforeProfile) 'Alias test rollback also restores all original settings' + Write-Host 'PROJECTSHELL_NAME_MIGRATION_PILOT_TESTS_PASSED' -ForegroundColor Green +} +finally { + if (Test-Path -LiteralPath $temp) { Remove-Item -LiteralPath $temp -Recurse -Force -ErrorAction SilentlyContinue } +} diff --git a/tests/Test-SessionContext.ps1 b/tests/Test-SessionContext.ps1 new file mode 100644 index 0000000..14540a5 --- /dev/null +++ b/tests/Test-SessionContext.ps1 @@ -0,0 +1,50 @@ +# Test only the process-local ProjectShell starting-folder handoff, not UI/install. +$ErrorActionPreference = 'Stop' +$sourcePath = Join-Path (Split-Path -Parent $PSScriptRoot) 'ProjectShell.ps1' +$tokens = $null +$errors = $null +$ast = [System.Management.Automation.Language.Parser]::ParseFile( + $sourcePath, [ref]$tokens, [ref]$errors +) +if ($errors.Count -ne 0) { throw 'Cannot parse ProjectShell source.' } +$fn = $ast.Find({ + param($node) + $node -is [System.Management.Automation.Language.FunctionDefinitionAst] -and + $node.Name -eq 'Set-ProjectShellLaunchContext' +}, $true) +if (-not $fn) { throw 'ProjectShell session-context function is absent.' } + +# Import only this one function, avoiding loading profiles or invoking the manager. +. ([scriptblock]::Create($fn.Extent.Text)) +$key = 'PROJECTSHELL_START_DIRECTORY' +$before = [Environment]::GetEnvironmentVariable($key, 'Process') +$userBefore = [Environment]::GetEnvironmentVariable($key, 'User') +$machineBefore = [Environment]::GetEnvironmentVariable($key, 'Machine') + +try { + $target = Split-Path -Parent $PSScriptRoot + Set-ProjectShellLaunchContext ([pscustomobject]@{ StartDirectory = $target }) + $actual = [Environment]::GetEnvironmentVariable($key, 'Process') + if ([IO.Path]::GetFullPath($actual).TrimEnd('\') -ne [IO.Path]::GetFullPath($target).TrimEnd('\')) { + throw 'Process-local starting-folder handoff does not match the saved profile.' + } + $nonexistent = Join-Path $target ('No-Such-ProjectShell-Folder-' + [guid]::NewGuid().ToString('N')) + try { + Set-ProjectShellLaunchContext ([pscustomobject]@{ StartDirectory = $nonexistent }) + throw 'Invalid starting folder did not fail closed.' + } + catch { + if ($_.Exception.Message -match 'Invalid starting folder did not fail closed') { throw } + } + if ([Environment]::GetEnvironmentVariable($key, 'Process') -ne $actual) { + throw 'Invalid folder unexpectedly changed the existing process context.' + } + if ([Environment]::GetEnvironmentVariable($key, 'User') -ne $userBefore -or + [Environment]::GetEnvironmentVariable($key, 'Machine') -ne $machineBefore) { + throw 'Profile handoff wrote persistent User/Machine environment variables.' + } + Write-Host 'PROJECTSHELL_PROCESS_STARTDIRECTORY_HANDOFF_PASSED' -ForegroundColor Green +} +finally { + [Environment]::SetEnvironmentVariable($key, $before, 'Process') +} diff --git a/tests/Test-Source.ps1 b/tests/Test-Source.ps1 index 588dc1a..7793018 100644 --- a/tests/Test-Source.ps1 +++ b/tests/Test-Source.ps1 @@ -1,7 +1,7 @@ # Read-only validation: parse application scripts and check release invariants. $ErrorActionPreference = 'Stop' $root = Split-Path -Path $PSScriptRoot -Parent -$files = @('ProjectShell.ps1', 'ProjectShell.Workspaces.ps1', 'ProjectShell.Catalogue.ps1', 'Install-ProjectShell.ps1', 'Diagnose-Launch.ps1') +$files = @('ProjectShell.ps1', 'ProjectShell.Workspaces.ps1', 'ProjectShell.Catalogue.ps1', 'ProjectShell.Migration.ps1', 'Install-ProjectShell.ps1', 'Diagnose-Launch.ps1') foreach ($relative in $files) { $file = Join-Path $root $relative if (-not (Test-Path -LiteralPath $file -PathType Leaf)) { throw "Missing: $relative" } @@ -20,6 +20,7 @@ $installer = Get-Content -LiteralPath (Join-Path $root 'Install-ProjectShell.ps1 $diagnostic = Get-Content -LiteralPath (Join-Path $root 'Diagnose-Launch.ps1') -Raw $workspace = Get-Content -LiteralPath (Join-Path $root 'ProjectShell.Workspaces.ps1') -Raw $catalogue = Get-Content -LiteralPath (Join-Path $root 'ProjectShell.Catalogue.ps1') -Raw +$migration = Get-Content -LiteralPath (Join-Path $root 'ProjectShell.Migration.ps1') -Raw $checks = @( @{ Name='Standard shell selection'; Pass=($app -match 'function Get-StandardPowerShellExe' -and $app.Contains('WindowsPowerShell\v1.0\powershell.exe')) }, @{ Name='Explicit manager UAC'; Pass=($app -match '-ElevateManager' -and $app -match '-Verb RunAs') }, @@ -32,6 +33,10 @@ $checks = @( @{ Name='Application profiles stored outside installation'; Pass=($app -match 'Join-Path \$env:LOCALAPPDATA') }, @{ Name='Catalogue broker module installed'; Pass=($installer.Contains('ProjectShell.Catalogue.ps1') -and $app.Contains('. $script:CatalogueModule')) }, @{ Name='Catalogue preview only'; Pass=($catalogue.Contains('schema_version=1') -and $catalogue.Contains('dependency-request') -and -not $catalogue.Contains('--interactive-apply') -and -not $catalogue.Contains('Start-Process')) }, + @{ Name='Process-local ProjectShell folder handoff'; Pass=($app.Contains('function Set-ProjectShellLaunchContext') -and $app.Contains('$env:PROJECTSHELL_START_DIRECTORY') -and $app.Contains('Set-ProjectShellLaunchContext $entry') -and $workspace.Contains('Set-ProjectShellLaunchContext $Profile')) }, + @{ Name='Migration module installed'; Pass=($installer.Contains('ProjectShell.Migration.ps1') -and $app.Contains('. $script:MigrationModule')) }, + @{ Name='Migration preview, receipt and rollback'; Pass=($migration.Contains('New-ProjectNameTransitionPlan') -and $migration.Contains('Invoke-ProjectNameTransition') -and $migration.Contains('Undo-ProjectNameTransition') -and $migration.Contains('RENAME ')) }, + @{ Name='Migration bounded source inventory'; Pass=($migration.Contains('Find-ProjectNameTransitionReferences') -and $migration.Contains('Inventory limit reached')) }, @{ Name='Workspace module installed'; Pass=($installer.Contains('ProjectShell.Workspaces.ps1') -and $app.Contains('. $script:WorkspaceModule')) }, @{ Name='Session tool launch and update menu'; Pass=($app.Contains('Start-ProfileLaunchable $entry') -and $app.Contains('Set-ProfileLaunchable $entry')) }, @{ Name='Workspace source transfer approval'; Pass=($workspace.Contains('Assert-CopiedFolder') -and $workspace.Contains('Confirm original deletion after verifying copied content?')) }, diff --git a/tests/verify_windows_installer_package.py b/tests/verify_windows_installer_package.py index afab47f..32b3060 100644 --- a/tests/verify_windows_installer_package.py +++ b/tests/verify_windows_installer_package.py @@ -21,6 +21,7 @@ "ProjectShell.ps1", "ProjectShell.Workspaces.ps1", "ProjectShell.Catalogue.ps1", + "ProjectShell.Migration.ps1", "Diagnose-Launch.ps1", "README.md", "SECURITY.md",