#Requires -Version 5.1 # Cymatix Context installer for Windows (PowerShell 5.1 or 7). # # irm https://cymatixcontext.com/install.ps1 | iex # # By default installs cymatix-context[cpu,mcp] with the first of these it finds: # 1. uv (uv tool install) # 2. pipx (pipx install) # 3. Python 3.11+ via the py launcher or python.exe (a private virtualenv in # %LOCALAPPDATA%\cymatix-context\venv) # It installs no other tools and does not change PATH or any other setting. # # Options, as environment variables set before running it: # $env:CYMATIX_VERSION = "0.11.4" a release to pin (default: latest) # $env:CYMATIX_EXTRAS = "cpu,mcp" pip extras (default: cpu,mcp). With "cpu", # the spaCy en_core_web_sm model is installed too. # Empty string = core only. # $env:CYMATIX_VENV_DIR = "D:\envs\cymatix" where the virtualenv goes when # neither uv nor pipx is installed # $env:CYMATIX_DRY_RUN = "1" print each command instead of running it & { $ErrorActionPreference = 'Stop' $SpacyModelUrl = 'https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.8.0/en_core_web_sm-3.8.0-py3-none-any.whl' $DryRun = $env:CYMATIX_DRY_RUN -eq '1' function Invoke-InstallStep { param([Parameter(Mandatory)][string]$Exe, [string[]]$Arguments = @()) if ($DryRun) { Write-Output ("+ " + (@($Exe) + $Arguments -join ' ')) return } & $Exe @Arguments if ($LASTEXITCODE -ne 0) { throw "cymatix install: '$Exe $($Arguments -join ' ')' failed with exit code $LASTEXITCODE" } } function Test-Tool([string]$Name) { return [bool](Get-Command $Name -ErrorAction SilentlyContinue) } # True when the command runs Python 3.11+. A probe that fails or writes to # stderr must not throw (PowerShell 5.1 turns native stderr into errors). function Test-PythonCommand([string[]]$Command) { if (-not (Test-Tool $Command[0])) { return $false } $check = 'import sys; sys.exit(sys.version_info < (3, 11))' $rest = @() if ($Command.Count -gt 1) { $rest = $Command[1..($Command.Count - 1)] } $saved = $ErrorActionPreference $ErrorActionPreference = 'Continue' try { & $Command[0] @rest -c $check 2>&1 | Out-Null return $LASTEXITCODE -eq 0 } catch { return $false } finally { $ErrorActionPreference = $saved } } function Find-Python { foreach ($candidate in @(@('py', '-3'), @('python'), @('python3'))) { if (Test-PythonCommand $candidate) { return $candidate } } return $null } $version = if ($env:CYMATIX_VERSION) { $env:CYMATIX_VERSION } else { '' } $extras = if ($null -ne $env:CYMATIX_EXTRAS) { $env:CYMATIX_EXTRAS } else { 'cpu,mcp' } if ($version -and $version -notmatch '^[0-9A-Za-z.+-]+$') { throw "cymatix install: CYMATIX_VERSION must look like 0.11.4, got: $version" } if ($extras -and $extras -notmatch '^[a-z0-9,-]+$') { throw "cymatix install: CYMATIX_EXTRAS must be a comma-separated list like cpu,mcp, got: $extras" } $spec = 'cymatix-context' if ($extras) { $spec += "[$extras]" } if ($version) { $spec += "==$version" } $wantModel = (",$extras,") -like '*,cpu,*' # CYMATIX_FORCE_ROUTE (uv, pipx, venv) is for tests; normally the route is detected. $route = $env:CYMATIX_FORCE_ROUTE if (-not $route) { if (Test-Tool 'uv') { $route = 'uv' } elseif (Test-Tool 'pipx') { $route = 'pipx' } else { $route = 'venv' } } Write-Output "Installing $spec" switch ($route) { 'uv' { Write-Output 'Using uv' $uvArgs = @('tool', 'install', '--force', $spec) if ($wantModel) { $uvArgs += @('--with', "en_core_web_sm @ $SpacyModelUrl") } Invoke-InstallStep 'uv' $uvArgs $hint = "If 'cymatix' is not found, run: uv tool update-shell" } 'pipx' { Write-Output 'Using pipx' Invoke-InstallStep 'pipx' @('install', '--force', $spec) if ($wantModel) { Invoke-InstallStep 'pipx' @('inject', 'cymatix-context', $SpacyModelUrl) } $hint = "If 'cymatix' is not found, run: pipx ensurepath" } 'venv' { $python = Find-Python if (-not $python) { throw 'cymatix install: needs uv, pipx, or Python 3.11 or newer. Install one and run this again.' } $venv = if ($env:CYMATIX_VENV_DIR) { $env:CYMATIX_VENV_DIR } else { Join-Path $env:LOCALAPPDATA 'cymatix-context\venv' } $venvPython = Join-Path $venv 'Scripts\python.exe' Write-Output "Using $($python -join ' ') with a virtualenv in $venv" $pyArgs = @() if ($python.Count -gt 1) { $pyArgs = $python[1..($python.Count - 1)] } Invoke-InstallStep $python[0] ($pyArgs + @('-m', 'venv', $venv)) Invoke-InstallStep $venvPython @('-m', 'pip', 'install', '--upgrade', 'pip') Invoke-InstallStep $venvPython @('-m', 'pip', 'install', '--upgrade', $spec) if ($wantModel) { Invoke-InstallStep $venvPython @('-m', 'pip', 'install', $SpacyModelUrl) } $hint = "The commands are in $(Join-Path $venv 'Scripts'). Add that folder to your PATH to run 'cymatix' from anywhere." } default { throw "cymatix install: unknown CYMATIX_FORCE_ROUTE '$route' (use uv, pipx, or venv)" } } Write-Output '' Write-Output 'Done. Next:' Write-Output ' cymatix status' Write-Output ' cymatix ingest .\docs --recursive' Write-Output ' cymatix query "what does the splice step do?"' Write-Output $hint Write-Output 'Guide: https://cymatixcontext.com/wiki/getting-started/' }