patchwork-os 0.2.0-beta.4 → 0.2.0-beta.5.canary.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,158 +1,158 @@
1
- #Requires -Version 5.1
2
- <#
3
- .SYNOPSIS
4
- Windows orchestrator launcher — bridges multiple IDE windows simultaneously.
5
-
6
- .DESCRIPTION
7
- Starts the meta-bridge that coordinates multiple IDE windows. Each IDE window
8
- must already have the claude-ide-bridge extension running — this script
9
- connects to them all via the orchestrator mode.
10
-
11
- Run via npm:
12
- npm run start-orchestrator:win
13
-
14
- Or directly:
15
- pwsh -File scripts\start-orchestrator.ps1
16
- pwsh -File scripts\start-orchestrator.ps1 -Port 4746 -Verbose
17
-
18
- .PARAMETER Port
19
- Orchestrator port (default: 4746).
20
-
21
- .PARAMETER Notify
22
- ntfy.sh topic for push notifications (optional).
23
-
24
- .PARAMETER Verbose
25
- Enable verbose orchestrator logging.
26
- #>
27
- [CmdletBinding()]
28
- param(
29
- [int] $Port = 4746,
30
- [string]$Notify = "",
31
- [switch]$VerboseLogging
32
- )
33
-
34
- Set-StrictMode -Version Latest
35
- $ErrorActionPreference = "Stop"
36
-
37
- $ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
38
- $BridgeDir = Split-Path -Parent $ScriptDir
39
-
40
- function Write-Status($msg) { Write-Host "[orchestrator] $msg" -ForegroundColor Cyan }
41
- function Write-Ok($msg) { Write-Host "[ok] $msg" -ForegroundColor Green }
42
- function Write-Warn($msg) { Write-Host "[warn] $msg" -ForegroundColor Yellow }
43
-
44
- function Send-Notify($msg) {
45
- if (-not $Notify) { return }
46
- try {
47
- Invoke-RestMethod -Uri "https://ntfy.sh/$Notify" -Method Post -Body $msg -TimeoutSec 5 | Out-Null
48
- } catch { Write-Warn "ntfy notification failed: $_" }
49
- }
50
-
51
- $Jobs = [System.Collections.Generic.List[System.Diagnostics.Process]]::new()
52
-
53
- function Stop-AllJobs {
54
- foreach ($p in $Jobs) {
55
- if (-not $p.HasExited) { try { $p.Kill($true) } catch { } }
56
- }
57
- }
58
-
59
- $null = Register-EngineEvent -SourceIdentifier PowerShell.Exiting -Action { Stop-AllJobs }
60
-
61
- # ── Dependency check ──────────────────────────────────────────────────────────
62
- $claudeFound = $false
63
- try {
64
- $null = & where.exe claude 2>$null
65
- $claudeFound = $true
66
- } catch { }
67
-
68
- if (-not $claudeFound) {
69
- Write-Error "claude CLI not found on PATH. Install from https://docs.anthropic.com/en/docs/claude-code"
70
- exit 1
71
- }
72
-
73
- # ── Build orchestrator args ───────────────────────────────────────────────────
74
- $orchArgs = @("orchestrator", "--port", $Port)
75
- if ($VerboseLogging) { $orchArgs += "--verbose" }
76
-
77
- # Use dist/ (npm install) or fallback message
78
- $distIndex = Join-Path $BridgeDir "dist\index.js"
79
- if (-not (Test-Path $distIndex)) {
80
- Write-Error "dist/index.js not found. Run 'npm run build' first."
81
- exit 1
82
- }
83
-
84
- # ── Start orchestrator bridge ─────────────────────────────────────────────────
85
- Write-Status "Starting orchestrator bridge on port $Port..."
86
-
87
- $orchInfo = New-Object System.Diagnostics.ProcessStartInfo
88
- $orchInfo.FileName = "cmd.exe"
89
- $orchInfo.Arguments = "/c node `"$distIndex`" " + ($orchArgs -join " ")
90
- $orchInfo.UseShellExecute = $false
91
- $orchInfo.WorkingDirectory = $BridgeDir
92
- $orchProc = [System.Diagnostics.Process]::Start($orchInfo)
93
- $Jobs.Add($orchProc)
94
-
95
- # ── Wait for lock file ────────────────────────────────────────────────────────
96
- $ClaudeBase = if ($env:CLAUDE_CONFIG_DIR) { $env:CLAUDE_CONFIG_DIR } else { Join-Path $env:USERPROFILE ".claude" }
97
- $IdeDir = Join-Path $ClaudeBase "ide"
98
- $LockFile = Join-Path $IdeDir "$Port.lock"
99
- $Deadline = (Get-Date).AddSeconds(20)
100
-
101
- Write-Status "Waiting for orchestrator lock file..."
102
- while ((Get-Date) -lt $Deadline -and -not (Test-Path $LockFile)) {
103
- Start-Sleep -Milliseconds 200
104
- }
105
-
106
- if (-not (Test-Path $LockFile)) {
107
- Write-Error "Orchestrator lock file not written after 20s. Bridge may have failed to start."
108
- Stop-AllJobs
109
- exit 1
110
- }
111
-
112
- try {
113
- $lockContent = Get-Content $LockFile -Raw | ConvertFrom-Json
114
- $token = $lockContent.authToken
115
- } catch {
116
- $token = "(unknown)"
117
- }
118
-
119
- Write-Ok "Orchestrator ready on port $Port"
120
- Send-Notify "Orchestrator started on port $Port"
121
-
122
- # ── Start Claude --ide ────────────────────────────────────────────────────────
123
- Write-Status "Starting claude --ide (connects to orchestrator)..."
124
-
125
- $claudeEnv = [System.Collections.Generic.Dictionary[string,string]]::new()
126
- foreach ($entry in [System.Environment]::GetEnvironmentVariables().GetEnumerator()) {
127
- $claudeEnv[$entry.Key] = $entry.Value
128
- }
129
- $claudeEnv["CLAUDE_CODE_IDE_SKIP_VALID_CHECK"] = "true"
130
-
131
- $claudeInfo = New-Object System.Diagnostics.ProcessStartInfo
132
- $claudeInfo.FileName = "cmd.exe"
133
- $claudeInfo.Arguments = "/c claude --ide"
134
- $claudeInfo.UseShellExecute = $false
135
- foreach ($kv in $claudeEnv.GetEnumerator()) {
136
- $claudeInfo.EnvironmentVariables[$kv.Key] = $kv.Value
137
- }
138
- $claudeProc = [System.Diagnostics.Process]::Start($claudeInfo)
139
- $Jobs.Add($claudeProc)
140
-
141
- # ── Summary ───────────────────────────────────────────────────────────────────
142
- Write-Host ""
143
- Write-Ok "Orchestrator running. Press Ctrl+C to stop all processes."
144
- Write-Host " Orchestrator PID : $($orchProc.Id)"
145
- Write-Host " Claude PID : $($claudeProc.Id)"
146
- Write-Host " Port : $Port"
147
- Write-Host " Token : $($token.Substring(0, [Math]::Min(8, $token.Length)))..."
148
- Write-Host ""
149
- Write-Host "Each IDE window with the bridge extension running will be discovered"
150
- Write-Host "automatically. Type /ide in Claude Code to verify the connection."
151
- Write-Host ""
152
-
153
- try {
154
- $orchProc.WaitForExit()
155
- } finally {
156
- Write-Status "Orchestrator exited — stopping all processes..."
157
- Stop-AllJobs
158
- }
1
+ #Requires -Version 5.1
2
+ <#
3
+ .SYNOPSIS
4
+ Windows orchestrator launcher — bridges multiple IDE windows simultaneously.
5
+
6
+ .DESCRIPTION
7
+ Starts the meta-bridge that coordinates multiple IDE windows. Each IDE window
8
+ must already have the claude-ide-bridge extension running — this script
9
+ connects to them all via the orchestrator mode.
10
+
11
+ Run via npm:
12
+ npm run start-orchestrator:win
13
+
14
+ Or directly:
15
+ pwsh -File scripts\start-orchestrator.ps1
16
+ pwsh -File scripts\start-orchestrator.ps1 -Port 4746 -Verbose
17
+
18
+ .PARAMETER Port
19
+ Orchestrator port (default: 4746).
20
+
21
+ .PARAMETER Notify
22
+ ntfy.sh topic for push notifications (optional).
23
+
24
+ .PARAMETER Verbose
25
+ Enable verbose orchestrator logging.
26
+ #>
27
+ [CmdletBinding()]
28
+ param(
29
+ [int] $Port = 4746,
30
+ [string]$Notify = "",
31
+ [switch]$VerboseLogging
32
+ )
33
+
34
+ Set-StrictMode -Version Latest
35
+ $ErrorActionPreference = "Stop"
36
+
37
+ $ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
38
+ $BridgeDir = Split-Path -Parent $ScriptDir
39
+
40
+ function Write-Status($msg) { Write-Host "[orchestrator] $msg" -ForegroundColor Cyan }
41
+ function Write-Ok($msg) { Write-Host "[ok] $msg" -ForegroundColor Green }
42
+ function Write-Warn($msg) { Write-Host "[warn] $msg" -ForegroundColor Yellow }
43
+
44
+ function Send-Notify($msg) {
45
+ if (-not $Notify) { return }
46
+ try {
47
+ Invoke-RestMethod -Uri "https://ntfy.sh/$Notify" -Method Post -Body $msg -TimeoutSec 5 | Out-Null
48
+ } catch { Write-Warn "ntfy notification failed: $_" }
49
+ }
50
+
51
+ $Jobs = [System.Collections.Generic.List[System.Diagnostics.Process]]::new()
52
+
53
+ function Stop-AllJobs {
54
+ foreach ($p in $Jobs) {
55
+ if (-not $p.HasExited) { try { $p.Kill($true) } catch { } }
56
+ }
57
+ }
58
+
59
+ $null = Register-EngineEvent -SourceIdentifier PowerShell.Exiting -Action { Stop-AllJobs }
60
+
61
+ # ── Dependency check ──────────────────────────────────────────────────────────
62
+ $claudeFound = $false
63
+ try {
64
+ $null = & where.exe claude 2>$null
65
+ $claudeFound = $true
66
+ } catch { }
67
+
68
+ if (-not $claudeFound) {
69
+ Write-Error "claude CLI not found on PATH. Install from https://docs.anthropic.com/en/docs/claude-code"
70
+ exit 1
71
+ }
72
+
73
+ # ── Build orchestrator args ───────────────────────────────────────────────────
74
+ $orchArgs = @("orchestrator", "--port", $Port)
75
+ if ($VerboseLogging) { $orchArgs += "--verbose" }
76
+
77
+ # Use dist/ (npm install) or fallback message
78
+ $distIndex = Join-Path $BridgeDir "dist\index.js"
79
+ if (-not (Test-Path $distIndex)) {
80
+ Write-Error "dist/index.js not found. Run 'npm run build' first."
81
+ exit 1
82
+ }
83
+
84
+ # ── Start orchestrator bridge ─────────────────────────────────────────────────
85
+ Write-Status "Starting orchestrator bridge on port $Port..."
86
+
87
+ $orchInfo = New-Object System.Diagnostics.ProcessStartInfo
88
+ $orchInfo.FileName = "cmd.exe"
89
+ $orchInfo.Arguments = "/c node `"$distIndex`" " + ($orchArgs -join " ")
90
+ $orchInfo.UseShellExecute = $false
91
+ $orchInfo.WorkingDirectory = $BridgeDir
92
+ $orchProc = [System.Diagnostics.Process]::Start($orchInfo)
93
+ $Jobs.Add($orchProc)
94
+
95
+ # ── Wait for lock file ────────────────────────────────────────────────────────
96
+ $ClaudeBase = if ($env:CLAUDE_CONFIG_DIR) { $env:CLAUDE_CONFIG_DIR } else { Join-Path $env:USERPROFILE ".claude" }
97
+ $IdeDir = Join-Path $ClaudeBase "ide"
98
+ $LockFile = Join-Path $IdeDir "$Port.lock"
99
+ $Deadline = (Get-Date).AddSeconds(20)
100
+
101
+ Write-Status "Waiting for orchestrator lock file..."
102
+ while ((Get-Date) -lt $Deadline -and -not (Test-Path $LockFile)) {
103
+ Start-Sleep -Milliseconds 200
104
+ }
105
+
106
+ if (-not (Test-Path $LockFile)) {
107
+ Write-Error "Orchestrator lock file not written after 20s. Bridge may have failed to start."
108
+ Stop-AllJobs
109
+ exit 1
110
+ }
111
+
112
+ try {
113
+ $lockContent = Get-Content $LockFile -Raw | ConvertFrom-Json
114
+ $token = $lockContent.authToken
115
+ } catch {
116
+ $token = "(unknown)"
117
+ }
118
+
119
+ Write-Ok "Orchestrator ready on port $Port"
120
+ Send-Notify "Orchestrator started on port $Port"
121
+
122
+ # ── Start Claude --ide ────────────────────────────────────────────────────────
123
+ Write-Status "Starting claude --ide (connects to orchestrator)..."
124
+
125
+ $claudeEnv = [System.Collections.Generic.Dictionary[string,string]]::new()
126
+ foreach ($entry in [System.Environment]::GetEnvironmentVariables().GetEnumerator()) {
127
+ $claudeEnv[$entry.Key] = $entry.Value
128
+ }
129
+ $claudeEnv["CLAUDE_CODE_IDE_SKIP_VALID_CHECK"] = "true"
130
+
131
+ $claudeInfo = New-Object System.Diagnostics.ProcessStartInfo
132
+ $claudeInfo.FileName = "cmd.exe"
133
+ $claudeInfo.Arguments = "/c claude --ide"
134
+ $claudeInfo.UseShellExecute = $false
135
+ foreach ($kv in $claudeEnv.GetEnumerator()) {
136
+ $claudeInfo.EnvironmentVariables[$kv.Key] = $kv.Value
137
+ }
138
+ $claudeProc = [System.Diagnostics.Process]::Start($claudeInfo)
139
+ $Jobs.Add($claudeProc)
140
+
141
+ # ── Summary ───────────────────────────────────────────────────────────────────
142
+ Write-Host ""
143
+ Write-Ok "Orchestrator running. Press Ctrl+C to stop all processes."
144
+ Write-Host " Orchestrator PID : $($orchProc.Id)"
145
+ Write-Host " Claude PID : $($claudeProc.Id)"
146
+ Write-Host " Port : $Port"
147
+ Write-Host " Token : $($token.Substring(0, [Math]::Min(8, $token.Length)))..."
148
+ Write-Host ""
149
+ Write-Host "Each IDE window with the bridge extension running will be discovered"
150
+ Write-Host "automatically. Type /ide in Claude Code to verify the connection."
151
+ Write-Host ""
152
+
153
+ try {
154
+ $orchProc.WaitForExit()
155
+ } finally {
156
+ Write-Status "Orchestrator exited — stopping all processes..."
157
+ Stop-AllJobs
158
+ }