# DIY Platform: workstation setup for Windows. # # Sets up a Windows 10/11 machine to run DIY Platform with everything around # the window. That means the app, plus the agent tools that live outside it: # - the MCP server (diy_* tools for Claude Code), registered with Claude; # - the `diy` command line; # - the graph daemon (diy-graphd), which holds every project's knowledge graph; # - the agent daemon (diy-agentd), started now and at every sign-in; # - the programs these need: Git, Node.js, GitHub CLI, Python, Claude Code and Codex. # # In PowerShell (no administrator needed): # irm https://install.vibedout.app/diy-setup.ps1 | iex # # With options, run the downloaded file: # powershell -ExecutionPolicy Bypass -File diy-setup.ps1 -Check # only say what is missing # powershell -ExecutionPolicy Bypass -File diy-setup.ps1 -Skip agents,cli # leave sections out # powershell -ExecutionPolicy Bypass -File diy-setup.ps1 -Only tools # just (re)install the agent tools # powershell -ExecutionPolicy Bypass -File diy-setup.ps1 -With automation # also n8n, the automations engine # powershell -ExecutionPolicy Bypass -File diy-setup.ps1 -BuildMachine # also make this a build machine for DIY's lanes (-With worker) # # Sections, in order: # system Git for Windows, Node.js LTS (22.19 or newer), GitHub CLI and Python 3, through winget # agents Claude Code (Anthropic's installer), Codex and pnpm (npm) # app DIY Platform: the newest installer from install.vibedout.app, checksum verified, installed per user # tools the agent tools: the MCP server, the diy CLI, diy-agentd, diy-graphd.exe and the Claude mod, unpacked into # %USERPROFILE%\.local\share\diy-platform\tools (where the app looks), with diy.cmd and diy-agentd.cmd in # %USERPROFILE%\.local\bin (added to your PATH). The MCP server is registered with Claude Code (user scope). # graph starts the graph daemon (diy-graphd) through the app's own diyd.exe --ensure-graphd. The app does the # same when it opens, so it keeps working either way. # agentd the agent daemon: a launcher in your Startup folder (it starts at every sign-in, hidden), and it is started now # graft the code-graph engine, @nanonets/graft at the version the app reads # automation (optional, -With automation) n8n # worker (optional, -BuildMachine or -With worker; 51.40) a build machine for DIY's lanes, through WSL2: setup-windows.ps1 runs in its # own window as Administrator (Windows asks), after the rest; the copy the app's tools carry, else $Site/worker/. When WSL is # new, Windows needs one restart and the set-up carries on by itself at the next sign-in. Joining it to your DIY is a step of # its own: diy worker add on your DIY, then setup-windows.ps1 -Join here. # # Every step checks first and skips what is already there, so it is safe to run again. Running it again is also how you # upgrade: the app and the tools follow the newest release. One failed step does not stop the others; the summary at # the end lists it. # # Environment overrides, for the `irm | iex` form: DIY_SETUP_CHECK=1, DIY_SETUP_ONLY=..., DIY_SETUP_SKIP=..., # DIY_SETUP_WITH=..., DIY_SITE (default https://install.vibedout.app), DIY_TOOLS_ZIP + DIY_APP_VERSION (a local tools # zip and the version it belongs to). [CmdletBinding()] param( [switch]$Check, [string[]]$Only = @(), [string[]]$Skip = @(), [string[]]$With = @(), [switch]$BuildMachine, [switch]$Help ) # This file's own path (empty under irm | iex), read here: inside the function $MyInvocation is the function's. $SelfPath = $MyInvocation.MyCommand.Path # Everything runs from Invoke-DiySetup, called on the last line: a download cut short (irm | iex) does not parse, and runs nothing (51.40 review 1). function Invoke-DiySetup { $ErrorActionPreference = 'Continue' $ProgressPreference = 'SilentlyContinue' # Invoke-WebRequest is many times slower with the progress bar on Windows PowerShell 5.1 try { [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 } catch {} function Split-List($v) { @($v | ForEach-Object { "$_" -split '[,\s]+' } | Where-Object { $_ }) } if ($env:DIY_SETUP_CHECK -eq '1') { $Check = $true } if (-not $Only -and $env:DIY_SETUP_ONLY) { $Only = $env:DIY_SETUP_ONLY } if (-not $Skip -and $env:DIY_SETUP_SKIP) { $Skip = $env:DIY_SETUP_SKIP } if (-not $With -and $env:DIY_SETUP_WITH) { $With = $env:DIY_SETUP_WITH } $Only = @(Split-List $Only); $Skip = @(Split-List $Skip); $With = @(Split-List $With) if ($BuildMachine -or $env:DIY_SETUP_BUILD_MACHINE -eq '1') { $With = @($With) + 'worker' } $Site = if ($env:DIY_SITE) { $env:DIY_SITE.TrimEnd('/') } else { 'https://install.vibedout.app' } $AllSections = @('system', 'agents', 'app', 'tools', 'graph', 'agentd', 'graft') $OptionalSections = @('automation', 'worker') $GraftPin = '0.16.0' $ApiUrl = 'http://127.0.0.1:7421/api' if ($Help) { $self = $SelfPath if ($self -and (Test-Path $self)) { foreach ($l in (Get-Content $self | Select-Object -Skip 1)) { if ($l -notmatch '^#') { break }; $l -replace '^# ?', '' } } else { "Usage: see the top of $Site/diy-setup.ps1" } return } foreach ($s in @($Only + $Skip + $With)) { if (($AllSections + $OptionalSections) -notcontains $s) { Write-Host "unknown section: $s (sections: $($AllSections + $OptionalSections -join ' '))" -ForegroundColor Red; return } } function Want($s) { if ($Only.Count) { return $Only -contains $s } if ($Skip -contains $s) { return $false } if ($OptionalSections -contains $s) { return $With -contains $s } return $true } # -- output -- $Failed = New-Object System.Collections.ArrayList $Missing = New-Object System.Collections.ArrayList $Notes = New-Object System.Collections.ArrayList function Head($t) { Write-Host ""; Write-Host "-- $t --" -ForegroundColor White } function Ok($t) { Write-Host " " -NoNewline; Write-Host 'ok' -ForegroundColor Green -NoNewline; Write-Host " $t" } function Todo($t) { Write-Host " " -NoNewline; Write-Host '->' -ForegroundColor Yellow -NoNewline; Write-Host " $t" } function Fail($t) { Write-Host " " -NoNewline; Write-Host 'x' -ForegroundColor Red -NoNewline; Write-Host " $t"; [void]$Failed.Add($t) } function Need($t) { Todo $t; [void]$Missing.Add($t) } # -- helpers -- $HomeDir = $env:USERPROFILE $LocalBin = Join-Path $HomeDir '.local\bin' $Share = Join-Path $HomeDir '.local\share\diy-platform' $ToolsDir = Join-Path $Share 'tools' $Work = Join-Path ([IO.Path]::GetTempPath()) ("diy-setup-" + [guid]::NewGuid().ToString('N').Substring(0, 8)) New-Item -ItemType Directory -Force -Path $Work | Out-Null function Have($cmd) { [bool](Get-Command $cmd -ErrorAction SilentlyContinue) } function Refresh-Path { $m = [Environment]::GetEnvironmentVariable('Path', 'Machine'); $u = [Environment]::GetEnvironmentVariable('Path', 'User') $env:Path = (@($m, $u, $LocalBin) | Where-Object { $_ }) -join ';' } function Ver($cmd, $arg = '--version') { try { ((& $cmd $arg 2>$null) | Select-Object -First 1) -as [string] } catch { '' } } function Node-Ok { if (-not (Have node)) { return $false } $v = (& node -p 'process.versions.node' 2>$null); if (-not $v) { return $false } $p = $v.Split('.') | ForEach-Object { [int]$_ } return ($p[0] -gt 22) -or ($p[0] -eq 22 -and $p[1] -ge 19) } function Fetch($url, $dest) { for ($i = 1; $i -le 3; $i++) { try { Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $dest -ErrorAction Stop; return $true } catch { Start-Sleep -Seconds (2 * $i) } } return $false } function Download-Verified($asset) { $dest = Join-Path $Work $asset.file if (-not (Fetch $asset.url $dest)) { Fail "download failed: $($asset.url)"; return $null } $sha = (Get-FileHash -Algorithm SHA256 -Path $dest).Hash.ToLower() if ($sha -ne $asset.sha256.ToLower()) { Fail "checksum mismatch: $($asset.file)"; return $null } return $dest } $script:Manifest = $null function Get-Manifest { if ($script:Manifest) { return $script:Manifest } try { $script:Manifest = Invoke-RestMethod -UseBasicParsing -Uri "$Site/releases/diy-platform.json" -ErrorAction Stop } catch { Fail "could not read $Site/releases/diy-platform.json"; return $null } return $script:Manifest } function Win-Asset($suffix) { $m = Get-Manifest; if (-not $m) { return $null } $w = $m.platforms | Where-Object { $_.id -eq 'windows' } | Select-Object -First 1 if (-not $w) { return $null } $w.assets | Where-Object { $_.file.EndsWith($suffix) } | Select-Object -First 1 } function Winget-Install($id, $label) { if (-not (Have winget)) { Fail "$label`: winget is missing (install 'App Installer' from the Microsoft Store), then run this again"; return } & winget install --id $id -e --silent --accept-source-agreements --accept-package-agreements --scope user 2>&1 | Out-Null if ($LASTEXITCODE -ne 0) { # Some packages have no per-user installer; the machine-wide one asks for administrator approval once. & winget install --id $id -e --silent --accept-source-agreements --accept-package-agreements 2>&1 | Out-Null } Refresh-Path } function Add-UserPath($dir) { $u = [Environment]::GetEnvironmentVariable('Path', 'User'); if (-not $u) { $u = '' } if (($u -split ';') -notcontains $dir) { [Environment]::SetEnvironmentVariable('Path', (@($u.TrimEnd(';'), $dir) | Where-Object { $_ }) -join ';', 'User') [void]$Notes.Add("$dir was added to your PATH: open a new terminal to use diy by name.") } Refresh-Path } function Http-Ok($url, $match) { try { $r = Invoke-WebRequest -UseBasicParsing -Uri $url -TimeoutSec 2 -ErrorAction Stop; return ($r.Content -match $match) } catch { return $false } } Write-Host "DIY Platform setup for Windows" -ForegroundColor White if ($Check) { Write-Host "(check only: nothing is installed)" } if ([Environment]::Is64BitOperatingSystem -eq $false) { Write-Host "DIY Platform is only built for 64-bit Windows." -ForegroundColor Red; return } Refresh-Path # -- system -- function Section-System { Head 'System tools' $tools = @( @{ cmd = 'git'; id = 'Git.Git'; label = 'Git for Windows (git and Git Bash)' }, @{ cmd = 'node'; id = 'OpenJS.NodeJS.LTS'; label = 'Node.js LTS' }, @{ cmd = 'gh'; id = 'GitHub.cli'; label = 'GitHub CLI' }, @{ cmd = 'python'; id = 'Python.Python.3.12'; label = 'Python 3' } ) foreach ($t in $tools) { $have = Have $t.cmd if ($t.cmd -eq 'node') { $have = Node-Ok } # The Microsoft Store's python.exe stub opens the Store instead of running Python. if ($t.cmd -eq 'python' -and $have) { $have = [bool](& python -c 'print(1)' 2>$null) } if ($have) { Ok "$($t.label): $(Ver $t.cmd)"; continue } if ($Check) { Need $t.label; continue } Todo "installing $($t.label)" Winget-Install $t.id $t.label $now = Have $t.cmd; if ($t.cmd -eq 'node') { $now = Node-Ok } if ($now) { Ok "$($t.label): $(Ver $t.cmd)" } elseif ($t.cmd -eq 'node' -and (Have node)) { Fail "Node.js $(& node -v) is older than 22.19 (the agent daemon needs 22.19 or newer): winget upgrade OpenJS.NodeJS.LTS" } else { Fail "$($t.label) did not install (winget install --id $($t.id))" } } } # -- agents -- function Section-Agents { Head 'Coding agents' if (Have claude) { Ok "Claude Code: $(Ver claude)" } elseif ($Check) { Need 'Claude Code' } else { Todo 'installing Claude Code (Anthropic''s installer)' try { Invoke-RestMethod -UseBasicParsing https://claude.ai/install.ps1 | Invoke-Expression *>&1 | Out-Null } catch {} Add-UserPath (Join-Path $HomeDir '.local\bin') if (Have claude) { Ok "Claude Code: $(Ver claude)" } else { Fail 'Claude Code did not install (irm https://claude.ai/install.ps1 | iex)' } } if (-not (Have npm)) { if (-not $Check) { Fail 'Codex and pnpm need npm (the system section installs Node.js)' } else { Need 'Codex, pnpm (need Node.js)' }; return } foreach ($p in @(@{ cmd = 'codex'; pkg = '@openai/codex'; label = 'Codex' }, @{ cmd = 'pnpm'; pkg = 'pnpm'; label = 'pnpm' })) { if (Have $p.cmd) { Ok "$($p.label): $(Ver $p.cmd)"; continue } if ($Check) { Need $p.label; continue } & npm install -g $p.pkg --silent 2>&1 | Out-Null; Refresh-Path if (Have $p.cmd) { Ok "$($p.label): $(Ver $p.cmd)" } else { Fail "$($p.label) did not install (npm install -g $($p.pkg))" } } } # -- app -- $UninstallKey = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\DIY Platform' function App-Dir { $loc = (Get-ItemProperty -Path $UninstallKey -ErrorAction SilentlyContinue).InstallLocation foreach ($d in @($loc, (Join-Path $env:LOCALAPPDATA 'DIY Platform'), (Join-Path $env:ProgramFiles 'DIY Platform'))) { if ($d -and (Test-Path (Join-Path $d.Trim('"') 'diy-platform.exe'))) { return $d.Trim('"') } } return $null } function App-Version { $k = Get-ItemProperty -Path $UninstallKey -ErrorAction SilentlyContinue if ($k -and $k.DisplayVersion) { return "$($k.DisplayVersion)" } $k = Get-ItemProperty -Path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\DIY Platform' -ErrorAction SilentlyContinue if ($k -and $k.DisplayVersion) { return "$($k.DisplayVersion)" } return '' } function Latest-Version { if ($env:DIY_TOOLS_ZIP -and $env:DIY_APP_VERSION) { return $env:DIY_APP_VERSION }; $m = Get-Manifest; if ($m) { return "$($m.version)" }; return '' } function Section-App { Head 'DIY Platform' $latest = Latest-Version; if (-not $latest) { return } $current = App-Version if ($current -eq $latest -and (App-Dir)) { Ok "app $current (latest), in $(App-Dir)"; return } if ($Check) { Need ("DIY Platform " + $(if ($current) { "$current -> $latest" } else { $latest })); return } Todo ("app " + $(if ($current) { "$current -> " } else { '' }) + $latest) $asset = Win-Asset '-setup.exe'; if (-not $asset) { Fail "release $latest has no Windows installer"; return } $exe = Download-Verified $asset; if (-not $exe) { return } $running = Get-Process -Name 'diy-platform' -ErrorAction SilentlyContinue if ($running) { Todo 'closing the running DIY Platform so it can be replaced'; $running | Stop-Process -Force; Start-Sleep -Seconds 1 } $p = Start-Process -FilePath $exe -ArgumentList '/S' -Wait -PassThru if ($p.ExitCode -eq 0 -and (App-Dir)) { Ok "app $latest (checksum verified), in $(App-Dir)" } else { Fail "the DIY Platform installer ended with code $($p.ExitCode): run $exe by hand to see why" } } # -- tools -- function Section-Tools { Head 'Agent tools (MCP server, diy CLI, diy-agentd, diy-graphd)' $latest = Latest-Version; if (-not $latest) { return } $verFile = Join-Path $ToolsDir '.version' $have = if (Test-Path $verFile) { (Get-Content $verFile -Raw).Trim() } else { '' } if ($have -eq $latest -and (Test-Path (Join-Path $ToolsDir 'mcp\server.mjs'))) { Ok "agent tools $latest, in $ToolsDir" } elseif ($Check) { Need "DIY agent tools $latest" } else { Todo "agent tools $latest" $zip = $null if ($env:DIY_TOOLS_ZIP -and (Test-Path $env:DIY_TOOLS_ZIP)) { $zip = $env:DIY_TOOLS_ZIP } else { $asset = Win-Asset '_windows-tools.zip' if (-not $asset) { Fail "release $latest has no Windows agent tools (DIYPlatform_${latest}_windows-tools.zip)"; return } $zip = Download-Verified $asset; if (-not $zip) { return } } $unz = Join-Path $Work 'tools' try { Expand-Archive -Path $zip -DestinationPath $unz -Force -ErrorAction Stop } catch { Fail "could not unpack $zip`: $_"; return } $src = Get-ChildItem -Path $unz -Directory | Select-Object -First 1 $src = Join-Path $src.FullName 'tools' if (-not (Test-Path (Join-Path $src 'mcp\server.mjs'))) { Fail 'the tools zip has no mcp\server.mjs'; return } New-Item -ItemType Directory -Force -Path $ToolsDir, (Join-Path $ToolsDir 'bin'), $LocalBin | Out-Null $okAll = $true # The junction of the last install first, on its own: it names an absolute folder, and removing the old tree recursively would # follow it into the new one. Directory.Delete without recursion removes only the junction. $link = Join-Path $ToolsDir 'agentd\node_modules\@vibedout\orchestrator' if (Test-Path $link) { try { [IO.Directory]::Delete($link) } catch { Fail "could not remove the old junction $link`: $_"; return } } foreach ($d in @('mcp', 'cli', 'agentd', 'claude-mods', 'ui-intel', 'automation', 'release-notes', 'worker')) { $from = Join-Path $src $d; if (-not (Test-Path $from)) { continue } $to = Join-Path $ToolsDir $d; $old = "$to.old" try { if (Test-Path $old) { Remove-Item -Recurse -Force $old -ErrorAction Stop } if (Test-Path $to) { Rename-Item -Path $to -NewName (Split-Path $old -Leaf) -ErrorAction Stop } Copy-Item -Recurse -Path $from -Destination $to -ErrorAction Stop if (Test-Path $old) { Remove-Item -Recurse -Force $old -ErrorAction SilentlyContinue } } catch { $okAll = $false; Fail "tools\$d could not be replaced (close Claude Code sessions and DIY Platform, then run this again): $_" } } # Node strips TypeScript only outside node_modules, so the agent engine stays in agentd\orchestrator and node_modules points at it. # A junction needs no administrator rights (a symbolic link does). if (Test-Path (Join-Path $ToolsDir 'agentd\orchestrator')) { New-Item -ItemType Directory -Force -Path (Split-Path $link) | Out-Null $engine = Join-Path $ToolsDir 'agentd\orchestrator' # (A symbolic link where there are no junctions: PowerShell 7 on Linux, which is how this script is tested.) $kind = if ($PSVersionTable.PSEdition -eq 'Core' -and -not $IsWindows) { 'SymbolicLink' } else { 'Junction' } try { New-Item -ItemType $kind -Path $link -Target $engine -ErrorAction Stop | Out-Null } catch { if ($kind -eq 'Junction') { cmd /c mklink /J "$link" "$engine" 2>&1 | Out-Null } } if (-not (Test-Path (Join-Path $link 'package.json'))) { $okAll = $false; Fail "could not link $link to the agent engine" } } # diy-graphd.exe: the app takes the newest copy it carries (beside diy-platform.exe or here) and installs it itself. A running one is # moved aside first: Windows lets a running program be renamed, not overwritten. $g = Join-Path $src 'bin\diy-graphd.exe' if (Test-Path $g) { $gt = Join-Path $ToolsDir 'bin\diy-graphd.exe' try { if (Test-Path $gt) { Remove-Item -Force "$gt.old" -ErrorAction SilentlyContinue; Rename-Item $gt -NewName 'diy-graphd.exe.old' -ErrorAction Stop } Copy-Item $g $gt -ErrorAction Stop } catch { $okAll = $false; Fail "could not put diy-graphd.exe in $ToolsDir\bin: $_" } } # Command shims: diy and diy-agentd by name, from any terminal. $cli = Join-Path $ToolsDir 'cli\diy.mjs' $agentd = Join-Path $ToolsDir 'agentd\bin\diy-agentd.mjs' Set-Content -Encoding ASCII -Path (Join-Path $LocalBin 'diy.cmd') -Value "@echo off`r`nnode `"$cli`" %*" Set-Content -Encoding ASCII -Path (Join-Path $LocalBin 'diy-agentd.cmd') -Value "@echo off`r`nnode --disable-warning=ExperimentalWarning `"$agentd`" %*" Add-UserPath $LocalBin if ($okAll) { Set-Content -Path $verFile -Value $latest; Ok "agent tools $latest, in $ToolsDir" } } # The registration: user scope, so every Claude Code session sees the diy_* tools, wherever it starts. $server = Join-Path $ToolsDir 'mcp\server.mjs' if (-not (Have claude)) { if ($Check) { Need 'MCP registration (needs Claude Code)' } else { [void]$Notes.Add("Claude Code is not installed, so the MCP server was not registered. Afterwards run: claude mcp add diy-platform -s user -e DIY_API=$ApiUrl -- node --max-semi-space-size=1 `"$server`"") } return } $got = (& claude mcp get diy-platform 2>$null) -join "`n" if ($got -and $got -match [regex]::Escape($server)) { Ok 'MCP server registered with Claude Code (user scope)' } elseif ($Check) { Need 'diy-platform MCP registration' } elseif (Test-Path $server) { & claude mcp remove diy-platform -s user 2>&1 | Out-Null & claude mcp add diy-platform -s user -e "DIY_API=$ApiUrl" -- node --max-semi-space-size=1 "$server" 2>&1 | Out-Null if ($LASTEXITCODE -eq 0) { Ok "MCP server registered with Claude Code: $server" } else { Fail 'claude mcp add diy-platform failed' } } } # -- graph daemon -- function Section-Graph { Head 'Graph daemon (diy-graphd)' if (Http-Ok 'http://127.0.0.1:7481/health' '"service" *: *"diy-graphd"') { Ok 'diy-graphd is running on 127.0.0.1:7481'; return } $app = App-Dir if ($Check) { Need 'diy-graphd (not running: DIY Platform starts it when it opens)'; return } $diyd = if ($app) { Join-Path $app 'diyd.exe' } else { $null } if (-not $diyd -or -not (Test-Path $diyd)) { Fail 'no diyd.exe beside DIY Platform to start the graph daemon with (app section); the app starts it when it opens'; return } $out = (& $diyd --ensure-graphd 2>&1) -join ' ' for ($i = 0; $i -lt 15; $i++) { if (Http-Ok 'http://127.0.0.1:7481/health' '"service" *: *"diy-graphd"') { break }; Start-Sleep -Seconds 1 } if (Http-Ok 'http://127.0.0.1:7481/health' '"service" *: *"diy-graphd"') { Ok "diy-graphd is running on 127.0.0.1:7481 ($out)" } else { Fail "diy-graphd did not start: $out" } } # -- agent daemon -- function Section-Agentd { Head 'Agent daemon (diy-agentd)' $entry = Join-Path $ToolsDir 'agentd\bin\diy-agentd.mjs' $startup = [Environment]::GetFolderPath('Startup') $vbs = Join-Path $startup 'DIY Agent (diy-agentd).vbs' $running = Http-Ok 'http://127.0.0.1:7480/health' 'diy-agentd' if ($Check) { if ($running -and (Test-Path $vbs)) { Ok 'diy-agentd is running on 127.0.0.1:7480 and starts at sign-in' } else { Need 'diy-agentd (running, and at sign-in)' } return } if (-not (Test-Path $entry)) { Fail 'no diy-agentd in the agent tools (tools section)'; return } if (-not (Node-Ok)) { Fail 'diy-agentd needs Node.js 22.19 or newer (system section)'; return } $node = (Get-Command node).Source # Started hidden through wscript: no console window at sign-in. Delete the file to stop it starting. $q = '""' # a quote inside a VBScript string $line = 'CreateObject("WScript.Shell").Run "' + $q + $node + $q + ' --disable-warning=ExperimentalWarning ' + $q + $entry + $q + '", 0, False' Set-Content -Encoding ASCII -Path $vbs -Value @("' DIY Agent (diy-agentd): written by diy-setup.ps1 (install.vibedout.app). Delete this file to stop it starting at sign-in.", $line) Ok "starts at sign-in ($vbs)" if ($running) { Ok 'diy-agentd is running on 127.0.0.1:7480'; return } Start-Process -FilePath 'wscript.exe' -ArgumentList "`"$vbs`"" | Out-Null for ($i = 0; $i -lt 20; $i++) { if (Http-Ok 'http://127.0.0.1:7480/health' '"service" *: *"diy-agentd"') { break }; Start-Sleep -Seconds 1 } if (Http-Ok 'http://127.0.0.1:7480/health' '"service" *: *"diy-agentd"') { Ok 'diy-agentd is running on 127.0.0.1:7480' } else { Fail "diy-agentd did not answer on 127.0.0.1:7480: run diy-agentd in a terminal to see why" } } # -- graft -- function Section-Graft { Head 'Code-graph engine (graft)' $v = if (Have graft) { ((& graft --version 2>$null) -join '').Trim() } else { '' } if ($v -eq $GraftPin) { Ok "graft $GraftPin"; return } if ($Check) { Need "graft $GraftPin"; return } if (-not (Have npm)) { Fail 'graft needs npm (system section)'; return } $env:DO_NOT_TRACK = '1' & npm install -g "@nanonets/graft@$GraftPin" --silent 2>&1 | Out-Null; Refresh-Path if (Have graft) { & graft telemetry disable 2>&1 | Out-Null; Ok "graft $GraftPin" } else { Fail "graft did not install (npm install -g @nanonets/graft@$GraftPin); the app falls back to its built-in parser" } } # -- automation -- function Section-Automation { Head 'Automations engine (n8n)' if (Have n8n) { Ok "n8n $(Ver n8n)"; return } if ($Check) { Need 'n8n'; return } & npm install -g n8n 2>&1 | Out-Null; Refresh-Path if (Have n8n) { Ok "n8n $(Ver n8n)" } else { Fail 'n8n did not install (npm install -g n8n)' } } # -- worker (optional, -BuildMachine; 51.40-T27): a build machine for DIY's lanes, through WSL2 -- # The app's own copy when its tools are installed (it then matches the app), else the site's. It needs Administrator, which this script # does not: it runs in a window of its own that Windows asks about. It keeps its files in %ProgramData%\diy-worker for -Join and -Check. function Section-Worker { Head 'Build machine (WSL2)' $dir = Join-Path $env:USERPROFILE '.local\share\diy-platform\tools\worker' if (-not (Test-Path (Join-Path $dir 'setup-windows.ps1'))) { $dir = Join-Path $Work 'worker' New-Item -ItemType Directory -Force -Path $dir | Out-Null foreach ($f in @('setup-windows.ps1', 'setup-linux.sh')) { if (-not (Fetch "$Site/worker/$f" (Join-Path $dir $f))) { Fail "could not download $Site/worker/$f"; return } } } $ps = Join-Path $dir 'setup-windows.ps1' $kept = Join-Path $env:ProgramData 'diy-worker\setup-windows.ps1' if ($Check) { & powershell.exe -NoProfile -ExecutionPolicy Bypass -File $ps -Check if ($LASTEXITCODE -ne 0) { [void]$Missing.Add('build machine (-BuildMachine)') } return } # The elevated run never runs from a folder this user can write (51.40 review 1): as Administrator it copies the two files into # %ProgramData%\diy-worker, made Administrators' and SYSTEM's only, checks there that they are the ones hashed here, and runs that copy. $h1 = (Get-FileHash -Algorithm SHA256 $ps).Hash $h2 = (Get-FileHash -Algorithm SHA256 (Join-Path $dir 'setup-linux.sh')).Hash $dirq = $dir -replace "'", "''" # a folder name with a ' in it (C:\Users\O'Brien) stays one string $elevated = @" `$d = Join-Path `$env:ProgramData 'diy-worker' New-Item -ItemType Directory -Force -Path `$d | Out-Null icacls `$d /setowner '*S-1-5-32-544' /T /C | Out-Null icacls `$d /inheritance:r /grant:r '*S-1-5-32-544:(OI)(CI)F' '*S-1-5-18:(OI)(CI)F' /T /C | Out-Null foreach (`$f in @('setup-windows.ps1', 'setup-linux.sh')) { Copy-Item -Force (Join-Path '$dirq' `$f) (Join-Path `$d `$f) } if ((Get-FileHash -Algorithm SHA256 (Join-Path `$d 'setup-windows.ps1')).Hash -ne '$h1' -or (Get-FileHash -Algorithm SHA256 (Join-Path `$d 'setup-linux.sh')).Hash -ne '$h2') { Write-Host 'The build machine scripts changed after they were checked: stopped, nothing was run.'; exit 1 } & powershell.exe -NoProfile -ExecutionPolicy Bypass -File (Join-Path `$d 'setup-windows.ps1') exit `$LASTEXITCODE "@ $encoded = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($elevated)) $p = Start-Process powershell.exe -Verb RunAs -Wait -PassThru -ArgumentList @('-NoProfile', '-ExecutionPolicy', 'Bypass', '-EncodedCommand', $encoded) switch ($p.ExitCode) { 0 { Ok 'build machine'; [void]$Notes.Add("To send DIY's lane jobs here, join it to your DIY: on your DIY's computer run diy worker add , then in PowerShell as Administrator powershell -ExecutionPolicy Bypass -File `"$kept`" -Join") } 3 { Ok 'build machine: WSL is new'; [void]$Notes.Add('Windows needs one restart for WSL: the build machine set-up carries on by itself at your next sign-in.') } default { Fail "the build machine set-up stopped (exit $($p.ExitCode)): run $kept in PowerShell as Administrator to see why" } } } $sections = [ordered]@{ system = 'Section-System'; agents = 'Section-Agents'; app = 'Section-App'; tools = 'Section-Tools'; graph = 'Section-Graph'; agentd = 'Section-Agentd'; graft = 'Section-Graft'; automation = 'Section-Automation'; worker = 'Section-Worker' } foreach ($k in $sections.Keys) { if (Want $k) { try { & $sections[$k] } catch { Fail "$k`: $_" } } } Remove-Item -Recurse -Force $Work -ErrorAction SilentlyContinue Write-Host "" foreach ($n in $Notes) { Write-Host " note: $n" -ForegroundColor DarkGray } if ($Check) { if ($Missing.Count) { Write-Host "Missing: $($Missing -join '; ')" -ForegroundColor Yellow; Write-Host "Run without -Check to install them." } else { Write-Host "Everything is in place." -ForegroundColor Green } } elseif ($Failed.Count) { Write-Host "Done, with $($Failed.Count) problem(s):" -ForegroundColor Yellow foreach ($f in $Failed) { Write-Host " - $f" } Write-Host "Fix what is named and run this again: it skips what is already done." } else { Write-Host "Done. Open DIY Platform from the Start menu; in a new terminal, 'claude mcp list' shows diy-platform." -ForegroundColor Green } } Invoke-DiySetup