Skip to content

Commit 1e89f8e

Browse files
committed
chore(release): v0.2.4
1 parent bc8dd22 commit 1e89f8e

4 files changed

Lines changed: 67 additions & 5 deletions

File tree

cmd/server/main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"syscall"
1515
"time"
1616

17+
"github.com/brainplusplus/9ed/internal/chat/acpinstall"
1718
"github.com/brainplusplus/9ed/internal/config"
1819
"github.com/brainplusplus/9ed/internal/debug"
1920
"github.com/brainplusplus/9ed/internal/server"
@@ -39,6 +40,9 @@ func main() {
3940
serverErrCh <- srv.ListenAndServe()
4041
}()
4142

43+
// Update installed ACP adapters in background on startup
44+
go acpinstall.UpdateAllInstalled()
45+
4246
waitForPortListening(cfg.Port, 5*time.Second)
4347

4448
var tn *tunnel.Tunnel

internal/chat/acpinstall/install.go

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ package acpinstall
22

33
import (
44
"fmt"
5+
"log"
56
"os/exec"
67
"runtime"
8+
"strings"
79
"sync"
810
)
911

@@ -90,6 +92,54 @@ func Update(agentID string) error {
9092
return install(info)
9193
}
9294

95+
// UpdateAllInstalled checks all known adapters and updates the ones already installed.
96+
// Runs updates concurrently. Logs progress to stdout.
97+
func UpdateAllInstalled() {
98+
var wg sync.WaitGroup
99+
100+
// Special case: opencode uses its own upgrade command
101+
if _, err := exec.LookPath("opencode"); err == nil {
102+
wg.Add(1)
103+
go func() {
104+
defer wg.Done()
105+
log.Printf("[acpinstall] updating opencode (opencode upgrade)...")
106+
cmd := exec.Command("opencode", "upgrade")
107+
output, err := cmd.CombinedOutput()
108+
if err != nil {
109+
log.Printf("[acpinstall] update opencode failed: %v: %s", err, strings.TrimSpace(string(output)))
110+
} else {
111+
log.Printf("[acpinstall] opencode updated")
112+
}
113+
}()
114+
}
115+
116+
for _, info := range adapters {
117+
if _, err := exec.LookPath(info.BinaryName); err != nil {
118+
continue // not installed, skip
119+
}
120+
121+
wg.Add(1)
122+
go func(info AdapterInfo) {
123+
defer wg.Done()
124+
log.Printf("[acpinstall] updating %s (%s)...", info.ID, info.Package)
125+
if err := updateOne(&info); err != nil {
126+
log.Printf("[acpinstall] update %s failed: %v", info.ID, err)
127+
} else {
128+
log.Printf("[acpinstall] %s updated", info.ID)
129+
}
130+
}(info)
131+
}
132+
133+
wg.Wait()
134+
}
135+
136+
func updateOne(info *AdapterInfo) error {
137+
installMu.Lock()
138+
defer installMu.Unlock()
139+
140+
return install(info)
141+
}
142+
93143
func install(info *AdapterInfo) error {
94144
switch info.Manager {
95145
case "npm":
@@ -113,7 +163,11 @@ func npmInstallGlobal(pkg string) error {
113163
} else {
114164
cmd = exec.Command(npm, "install", "-g", pkg)
115165
}
116-
return cmd.Run()
166+
output, err := cmd.CombinedOutput()
167+
if err != nil {
168+
return fmt.Errorf("%w: %s", err, strings.TrimSpace(string(output)))
169+
}
170+
return nil
117171
}
118172

119173
func pipInstall(pkg string) error {
@@ -124,5 +178,9 @@ func pipInstall(pkg string) error {
124178
}
125179
}
126180
cmd := exec.Command(pip, "install", "--upgrade", pkg)
127-
return cmd.Run()
181+
output, err := cmd.CombinedOutput()
182+
if err != nil {
183+
return fmt.Errorf("%w: %s", err, strings.TrimSpace(string(output)))
184+
}
185+
return nil
128186
}

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "9ed",
3-
"version": "0.2.3",
3+
"version": "0.2.4",
44
"private": true,
55
"type": "module",
66
"scripts": {

0 commit comments

Comments
 (0)