Skip to content

Stale Hermes SOUL.md is never replaced on Windows (Test-Path -PathType Container on a file) #3334

Description

@patil2001

File: ods/installers/windows/phases/06-directories.ps1, Repair-HermesSoulMd (line 547).

Defective code:

if (-not $_rendered) {
    if (Test-Path -LiteralPath $_output -PathType Container) {
        Remove-Item -LiteralPath $_output -Recurse -Force
    }
    if (-not (Test-Path -LiteralPath $_output -PathType Leaf)) {
        $_content = Get-Content -LiteralPath $template -Raw
        $_content = $_content -replace "(?m)^\s*<!-- INSTALLATION_CONTEXT -->\s*\r?\n?", ""
        Write-Utf8NoBom -Path $_output -Content $_content
        Write-AIWarn "Generated fallback Hermes SOUL.md without dynamic installation context"
    }
}

($_output is data\persona\SOUL.md — a file path.)

Behavior:
The fallback branch guards its cleanup with Test-Path ... -PathType Container, which only returns $true if the path is a directory. Since $_output is a file (SOUL.md), this test is always $false, so the Remove-Item that should discard a stale/leftover SOUL.md never runs. Control then falls through to the next if, which only writes the fallback when a SOUL.md file does not already exist (-not (Test-Path ... -PathType Leaf)). If a stale SOUL.md is already present (the common case after a previous install/upgrade), it is left untouched.

Impact:
The intended "refresh without dynamic installation context" fallback is effectively dead: a stale SOUL.md is never regenerated, so Hermes keeps serving the old persona/instruction content across upgrades and reinstalls on Windows.

Fix:
The cleanup guard should test for the file (or any item) at $_output, e.g.:

if (Test-Path -LiteralPath $_output) {
    Remove-Item -LiteralPath $_output -Recurse -Force
}

(Optionally keep -PathType Leaf if a directory at that path is also expected.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions