[Windows] Feilian blocks .engine-staging-* and prevents source installation
Author: TQtongCreated Sep 20, 2026Updated Sep 20, 2026
Problem
On Windows with Feilian enabled, running the source installer fails while copying the runtime into the managed staging directory. The observed failure is an access-denied error for:
%LOCALAPPDATA%\CodexDreamSkin\.engine-staging-<token>\scripts\apply-community-theme.ps1The failure happens before the managed engine can be committed. The source checkout itself is readable; the blocked operation is the PowerShell Copy-Item -Recurse into the temporary staging tree.
The intended fix is to let a trusted source checkout run in place, so Feilian does not need to approve or scan a second copy of every PowerShell file. This does not disable Feilian, alter ACLs, modify WindowsApps, or use ExecutionPolicy Bypass.
Code diff
diff --git a/windows/installer/setup-bootstrap.ps1 b/windows/installer/setup-bootstrap.ps1
index 154fd74..8c1e52e 100644
--- a/windows/installer/setup-bootstrap.ps1
+++ b/windows/installer/setup-bootstrap.ps1
@@ -148,7 +148,7 @@ try {
if ($needsInstall) {
Wait-DreamSkinCodexClosedForSetup
Stop-DreamSkinTrayProcess -ScriptPaths @($engine.Tray) -RequireStopped
- & (Join-Path $payloadScripts 'install-dream-skin.ps1') -NoShortcuts
+ & (Join-Path $payloadScripts 'install-dream-skin.ps1') -NoShortcuts -CopyRuntime
$engine = Get-DreamSkinRuntimeEnginePaths -StateRoot $stateRoot
$committedVersion = if (Test-Path -LiteralPath $engine.Version -PathType Leaf) {
([System.IO.File]::ReadAllText($engine.Version)).Trim()
diff --git a/windows/scripts/common-windows.ps1 b/windows/scripts/common-windows.ps1
index 97b7a1d..8c61359 100644
--- a/windows/scripts/common-windows.ps1
+++ b/windows/scripts/common-windows.ps1
@@ -230,9 +230,9 @@ function Test-DreamSkinPathWithin {
}
}
-function Get-DreamSkinRuntimeEnginePaths {
- param([string]$StateRoot = (Join-Path $env:LOCALAPPDATA 'CodexDreamSkin'))
- $root = Join-Path ([System.IO.Path]::GetFullPath($StateRoot)) 'engine'
+function Get-DreamSkinRuntimePaths {
+ param([Parameter(Mandatory = $true)][string]$Root)
+ $root = [System.IO.Path]::GetFullPath($Root)
$scripts = Join-Path $root 'scripts'
return [pscustomobject]@{
Root = $root
@@ -247,6 +247,13 @@ function Get-DreamSkinRuntimeEnginePaths {
}
}
+function Get-DreamSkinRuntimeEnginePaths {
+ param([string]$StateRoot = (Join-Path $env:LOCALAPPDATA 'CodexDreamSkin'))
+ return Get-DreamSkinRuntimePaths -Root (
+ Join-Path ([System.IO.Path]::GetFullPath($StateRoot)) 'engine'
+ )
+}
+
function Test-DreamSkinTrayActive {
$sid = [System.Security.Principal.WindowsIdentity]::GetCurrent().User.Value
$mutex = [System.Threading.Mutex]::new($false, "Local\CodexDreamSkin.$sid.Tray")
@@ -344,18 +351,13 @@ function Remove-DreamSkinRuntimeTree {
Remove-Item -LiteralPath $fullPath -Recurse -Force -ErrorAction Stop
}
-function Install-DreamSkinRuntimeEngine {
+function Get-DreamSkinRuntimeSource {
param(
[Parameter(Mandatory = $true)][string]$SkillRoot,
[Parameter(Mandatory = $true)][string]$StateRoot
)
- if (-not (Get-Command Ensure-DreamSkinManagedDirectory -ErrorAction SilentlyContinue)) {
- throw 'Dream Skin managed-directory validation is unavailable.'
- }
-
$sourceRoot = [System.IO.Path]::GetFullPath($SkillRoot)
$fullStateRoot = [System.IO.Path]::GetFullPath($StateRoot)
- $engine = Get-DreamSkinRuntimeEnginePaths -StateRoot $fullStateRoot
$required = @(
'VERSION',
'assets\dream-reference.jpg',
@@ -406,6 +408,28 @@ function Install-DreamSkinRuntimeEngine {
Assert-DreamSkinRuntimeTree -Path $sourceDirectory
}
+ return [pscustomobject]@{
+ Root = $sourceRoot
+ Required = $required
+ Directories = $sourceDirectories
+ }
+}
+
+function Install-DreamSkinRuntimeEngine {
+ param(
+ [Parameter(Mandatory = $true)][string]$SkillRoot,
+ [Parameter(Mandatory = $true)][string]$StateRoot
+ )
+ if (-not (Get-Command Ensure-DreamSkinManagedDirectory -ErrorAction SilentlyContinue)) {
+ throw 'Dream Skin managed-directory validation is unavailable.'
+ }
+ $source = Get-DreamSkinRuntimeSource -SkillRoot $SkillRoot -StateRoot $StateRoot
+ $sourceRoot = $source.Root
+ $required = @($source.Required)
+ $sourceDirectories = @($source.Directories)
+ $fullStateRoot = [System.IO.Path]::GetFullPath($StateRoot)
+ $engine = Get-DreamSkinRuntimeEnginePaths -StateRoot $fullStateRoot
+
Ensure-DreamSkinManagedDirectory -Path $fullStateRoot -Root $fullStateRoot
$token = [guid]::NewGuid().ToString('N')
$stagingRoot = Join-Path $fullStateRoot ".engine-staging-$token"
diff --git a/windows/scripts/install-dream-skin.ps1 b/windows/scripts/install-dream-skin.ps1
index 5548d56..537b0c9 100644
--- a/windows/scripts/install-dream-skin.ps1
+++ b/windows/scripts/install-dream-skin.ps1
@@ -1,7 +1,8 @@
[CmdletBinding()]
param(
[int]$Port = 9335,
- [switch]$NoShortcuts
+ [switch]$NoShortcuts,
+ [switch]$CopyRuntime
)
$ErrorActionPreference = 'Stop'
@@ -38,7 +39,15 @@ try {
if (Test-DreamSkinTrayActive) {
throw 'Exit the Codex Dream Skin tray before reinstalling so every shortcut can move to the new runtime safely.'
}
- $engine = Install-DreamSkinRuntimeEngine -SkillRoot $SkillRoot -StateRoot $StateRoot
+ if ($CopyRuntime) {
+ $engine = Install-DreamSkinRuntimeEngine -SkillRoot $SkillRoot -StateRoot $StateRoot
+ } else {
+ # Source installs use this checkout directly. The packaged installer passes
+ # -CopyRuntime explicitly so its payload remains independent of its staging
+ # directory after setup exits.
+ $source = Get-DreamSkinRuntimeSource -SkillRoot $SkillRoot -StateRoot $StateRoot
+ $engine = Get-DreamSkinRuntimePaths -Root $source.Root
+ }
$null = Initialize-DreamSkinThemeStore -SkillRoot $engine.Root -StateRoot $StateRoot
$ConfigPath = Join-Path $HOME '.codex\config.toml'
$BackupPath = Join-Path $StateRoot 'config.before-dream-skin.toml'
@@ -85,7 +94,9 @@ try {
}
if ($NoShortcuts) {
- Write-Host "Codex Dream Skin base theme installed at $($engine.Root). Run $($engine.Start) to launch it."
+ Write-Host "Codex Dream Skin is ready at $($engine.Root). Run $($engine.Start) to launch it."
+ } elseif (-not $CopyRuntime) {
+ Write-Host "Codex Dream Skin shortcuts now run directly from $($engine.Root). Keep this folder in place."
} else {
Write-Host 'Codex Dream Skin installed. The launch shortcut asks before restarting an open Codex window.'
}
diff --git a/windows/tests/installer-static.tests.ps1 b/windows/tests/installer-static.tests.ps1
index 4b871cd..85edad4 100644
--- a/windows/tests/installer-static.tests.ps1
+++ b/windows/tests/installer-static.tests.ps1
@@ -196,6 +196,7 @@ foreach ($requiredRepairContract in @(
'runtime\node\node.exe',
'runtime\node\LICENSE',
'$missingEngineFiles.Count -eq 0',
+ '& (Join-Path $payloadScripts ''install-dream-skin.ps1'') -NoShortcuts -CopyRuntime',
'A newer Codex Dream Skin',
'The installer payload is missing its bundled Node.js runtime'
)) {
diff --git a/windows/tests/run-tests.ps1 b/windows/tests/run-tests.ps1
index b77dff8..420b548 100644
--- a/windows/tests/run-tests.ps1
+++ b/windows/tests/run-tests.ps1
@@ -328,8 +328,10 @@ try {
}
Remove-Item -LiteralPath $invalidRuntimeRoot, $runtimeStateRoot -Recurse -Force
+ & (Join-Path $PSScriptRoot 'source-runtime.tests.ps1') -Root $Root
+
if ($EngineOnly) {
- Write-Host 'PASS: managed runtime staging, replacement, invalid-source guard, and source-independent shortcuts.'
+ Write-Host 'PASS: source runtime selection plus managed staging, replacement, and invalid-source guards.'
return
}
Source: Fei-Away/Codex-Dream-Skin