Diffinery

codician/diffinerypublic

Open-source, agent-first GitHub and GitHub Actions alternative that runs on your own Cloudflare account: git hosting, pull requests, code review and drop-in GitHub Actions YAML on Workers, Durable Objects, R2 and Containers.

52 lines · 3.2 KBRaw History
1# Installs the Diffinery extension into the editors built on VS Code on this computer (Windows):
2#
3# powershell -c "irm https://diffinery.com/install-editor.ps1 | iex"
4#
5# Set $env:DIFFINERY_EDITORS = "cursor" (names: code, code-insiders, cursor, windsurf, codium) to choose.
6# Each editor's command-line tool is used from PATH, or from its usual install folder. The .vsix comes
7# from the server that served this script and is checked against the SHA-256 it publishes. The
8# extension updates itself afterwards. Served by Diffinery from apps/vscode/install/.
9$ErrorActionPreference = "Stop"
10$server = if ($env:DIFFINERY_URL) { $env:DIFFINERY_URL } else { "__DIFFINERY_URL__" }
11if ($server.StartsWith("__")) { $server = "https://diffinery.com" }
12$server = $server.TrimEnd("/")
13
14$known = @(
15 @{ Name = "code"; Label = "VS Code"; Paths = @("$env:LOCALAPPDATA\Programs\Microsoft VS Code\bin\code.cmd", "$env:ProgramFiles\Microsoft VS Code\bin\code.cmd") },
16 @{ Name = "code-insiders"; Label = "VS Code Insiders"; Paths = @("$env:LOCALAPPDATA\Programs\Microsoft VS Code Insiders\bin\code-insiders.cmd") },
17 @{ Name = "cursor"; Label = "Cursor"; Paths = @("$env:LOCALAPPDATA\Programs\cursor\resources\app\bin\cursor.cmd") },
18 @{ Name = "windsurf"; Label = "Windsurf"; Paths = @("$env:LOCALAPPDATA\Programs\Windsurf\bin\windsurf.cmd") },
19 @{ Name = "codium"; Label = "VSCodium"; Paths = @("$env:LOCALAPPDATA\Programs\VSCodium\bin\codium.cmd", "$env:ProgramFiles\VSCodium\bin\codium.cmd") }
20)
21$wanted = if ($env:DIFFINERY_EDITORS) { $env:DIFFINERY_EDITORS -split "[ ,]+" } else { @() }
22
23$meta = Invoke-RestMethod "$server/-/vscode/version.json"
24$tmp = Join-Path ([IO.Path]::GetTempPath()) ("diffinery-" + [Guid]::NewGuid())
25New-Item -ItemType Directory $tmp | Out-Null
26try {
27 $vsix = Join-Path $tmp "diffinery-$($meta.version).vsix"
28 Invoke-WebRequest "$server/-/vscode/diffinery-$($meta.version).vsix" -OutFile $vsix -UseBasicParsing
29 if ((Get-FileHash $vsix -Algorithm SHA256).Hash.ToLower() -ne $meta.sha256) { throw "The download didn't match the published SHA-256; nothing was installed." }
30 $installed = 0
31 foreach ($e in $known) {
32 if ($wanted.Count -gt 0 -and $wanted -notcontains $e.Name) { continue }
33 $cli = (Get-Command "$($e.Name).cmd" -ErrorAction SilentlyContinue).Source
34 if (-not $cli) { $cli = $e.Paths | Where-Object { Test-Path $_ } | Select-Object -First 1 }
35 if (-not $cli) {
36 if ($wanted.Count -gt 0) { Write-Host "x $($e.Label): its command-line tool ($($e.Name)) wasn't found" }
37 continue
38 }
39 & $cli --install-extension $vsix --force | Out-Null
40 if ($LASTEXITCODE -eq 0) { Write-Host "v $($e.Label): Diffinery extension $($meta.version) installed"; $installed++ }
41 else { Write-Host "x $($e.Label): installing failed" }
42 }
43 if ($installed -eq 0) {
44 Write-Host "No editor took the extension. Install it from the editor instead: Extensions > ... > Install from VSIX..."
45 Write-Host "with $server/-/vscode/diffinery.vsix, or see $server/docs/repositories/clone-in-your-editor"
46 exit 1
47 }
48 Write-Host ""
49 Write-Host "Next: in the editor, run Git: Clone and pick Clone from Diffinery. ($server/docs/repositories/clone-in-your-editor)"
50} finally {
51 Remove-Item -Recurse -Force $tmp -ErrorAction SilentlyContinue
52}