Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix(issue-1788): add UTF-8 BOM to .ps1 scripts so Windows PowerShell 5.1 parses them
[._.]/ Adam Eivy99a409049009
diff --git a/scripts/ps1-bom.test.js b/scripts/ps1-bom.test.jsnew file mode 100644index 0000000000..6ff5394b7a--- /dev/null+++ b/scripts/ps1-bom.test.js@@ -0,0 +1,51 @@+import { describe, it, expect } from 'vitest';+import { readdirSync, readFileSync, statSync } from 'fs';+import { dirname, join, relative } from 'path';+import { fileURLToPath } from 'url';++// Regression guard for issue #1788: setup.ps1 failed to parse on Windows+// PowerShell 5.1 ("string is missing the terminator" / "missing closing '}'").+// Root cause: the file was UTF-8 *without* a BOM and contained non-ASCII+// characters (em-dashes, an emoji). Windows PowerShell 5.1 reads BOM-less files+// as the system ANSI codepage, not UTF-8, so the multi-byte sequences misalign+// the parser. The fix is a UTF-8 BOM, which is Microsoft's documented+// requirement for 5.1 to interpret non-ASCII scripts (and harmless on 7+).+//+// This test fails the moment any tracked .ps1 loses (or is added without) its+// BOM, so the bug can't silently return via an editor that strips it.++const REPO_ROOT = join(dirname(fileURLToPath(import.meta.url)), '..');+const SKIP_DIRS = new Set(['node_modules', '.git']);+const UTF8_BOM = Buffer.from([0xef, 0xbb, 0xbf]);++function findPs1Files(dir, acc = []) {+ for (const entry of readdirSync(dir, { withFileTypes: true })) {+ // Skip the vendored slashdo submodule — it owns its own files.+ if (entry.isDirectory()) {+ if (SKIP_DIRS.has(entry.name)) continue;+ const full = join(dir, entry.name);+ if (relative(REPO_ROOT, full) === join('lib', 'slashdo')) continue;+ findPs1Files(full, acc);+ } else if (entry.isFile() && entry.name.toLowerCase().endsWith('.ps1')) {+ acc.push(join(dir, entry.name));+ }+ }+ return acc;+}++describe('PowerShell scripts (.ps1) ship a UTF-8 BOM (issue #1788)', () => {+ const files = findPs1Files(REPO_ROOT);++ it('finds the project .ps1 scripts to verify', () => {+ // Sanity: if the walk finds nothing the assertions below are vacuous.+ expect(files.length).toBeGreaterThan(0);+ });++ it.each(files.map((f) => relative(REPO_ROOT, f)))(+ '%s starts with a UTF-8 BOM so Windows PowerShell 5.1 reads it as UTF-8',+ (rel) => {+ const head = readFileSync(join(REPO_ROOT, rel)).subarray(0, 3);+ expect(head.equals(UTF8_BOM)).toBe(true);+ }+ );+});diff --git a/scripts/setup-voice.ps1 b/scripts/setup-voice.ps1index 080936dbbc..b90c4c8e7f 100644--- a/scripts/setup-voice.ps1+++ b/scripts/setup-voice.ps1@@ -1,4 +1,4 @@-# Bootstrap local voice stack on Windows: whisper.cpp (STT) + active TTS backend.+# Bootstrap local voice stack on Windows: whisper.cpp (STT) + active TTS backend.# Safe to re-run: installs only what's missing, downloads only what's missing.## Env overrides (same as setup-voice.sh):diff --git a/setup.ps1 b/setup.ps1index 10fa21db40..e6a6564c1b 100644--- a/setup.ps1+++ b/setup.ps1@@ -1,4 +1,4 @@-# PortOS Setup Script for Windows PowerShell+# PortOS Setup Script for Windows PowerShell$ErrorActionPreference = "Stop"$RootDir = Split-Path -Parent $MyInvocation.MyCommand.Pathdiff --git a/update.ps1 b/update.ps1index e050f46cb3..1454562fb2 100644--- a/update.ps1+++ b/update.ps1@@ -1,4 +1,4 @@-# PortOS Update Script for Windows PowerShell+# PortOS Update Script for Windows PowerShell$ErrorActionPreference = "Stop"$RootDir = Split-Path -Parent $MyInvocation.MyCommand.Path