Pārlūkot izejas kodu

Merge branch 'zmk' of ZhangJinChen/opencode into main

ZhangMingKai 1 dienu atpakaļ
vecāks
revīzija
5ed7bbcd9f

+ 0 - 2
bun.lock

@@ -1062,11 +1062,9 @@
   },
   "trustedDependencies": [
     "esbuild",
-    "tree-sitter-powershell",
     "protobufjs",
     "electron",
     "web-tree-sitter",
-    "tree-sitter-bash",
   ],
   "patchedDependencies": {
     "@pierre/trees@1.0.0-beta.4": "patches/@pierre%2Ftrees@1.0.0-beta.4.patch",

+ 0 - 2
package.json

@@ -131,8 +131,6 @@
     "node-pty",
     "protobufjs",
     "tree-sitter",
-    "tree-sitter-bash",
-    "tree-sitter-powershell",
     "web-tree-sitter",
     "electron"
   ],

+ 8 - 0
packages/desktop/electron-builder.config.ts

@@ -85,6 +85,14 @@ const getBase = (appId: string): Configuration => ({
     schemes: ["lambda-scientist"],
   },
   win: {
+    ...(channel === "beta" && process.env.LAMBDA_AGENT_WINDOWS_RUNTIME
+      ? {
+          extraResources: ["git", "ripgrep"].map((tool) => ({
+            from: path.join(process.env.LAMBDA_AGENT_WINDOWS_RUNTIME!, tool),
+            to: `windows-runtime/${tool}`,
+          })),
+        }
+      : {}),
     icon: `resources/icons/icon.ico`,
     signtoolOptions: {
       sign: signWindows,

+ 14 - 0
packages/desktop/scripts/package-beta.ts

@@ -1,5 +1,7 @@
 #!/usr/bin/env bun
 import { $ } from "bun"
+import { existsSync } from "node:fs"
+import { join, resolve } from "node:path"
 import { validateRuntimeBundle } from "./runtime-bundle"
 
 // Build and package locally. Publishing is always a separate, explicit action.
@@ -25,8 +27,20 @@ if (!external) {
     )
   await validateRuntimeBundle("resources/agentpaas-runtime")
 }
+if (process.platform === "win32") {
+  if (process.arch !== "x64") throw new Error("Build the Windows Beta installer using x64 Bun")
+  const runtime = process.env.LAMBDA_AGENT_WINDOWS_RUNTIME
+  if (!runtime) throw new Error("Set LAMBDA_AGENT_WINDOWS_RUNTIME to the prepared Windows runtime directory")
+  process.env.LAMBDA_AGENT_WINDOWS_RUNTIME = resolve(runtime)
+  for (const file of ["git/cmd/git.exe", "git/LICENSE.txt", "ripgrep/rg.exe", "ripgrep/COPYING"]) {
+    if (!existsSync(join(runtime, file))) throw new Error(`Missing Windows runtime file: ${file}`)
+  }
+}
 await $`bun run build`
+const electronDist = process.platform === "win32" && process.env.LAMBDA_AGENT_ELECTRON_DIST
 const options = [
+  ...(electronDist ? [`--config.electronDist=${resolve(electronDist)}`] : []),
+  ...(process.platform === "win32" ? ["--win", "nsis", "--x64"] : []),
   ...(process.argv.includes("--dir") ? ["--dir"] : []),
   ...(unsigned && process.platform === "darwin" ? ["-c.mac.notarize=false", "-c.dmg.sign=false"] : []),
 ]

+ 1 - 7
packages/desktop/src/main/index.ts

@@ -400,13 +400,7 @@ const main = Effect.gen(function* () {
   const updateTimer = setInterval(() => void updater.check(), 10 * 60 * 1000)
   updateTimer.unref()
   app.once("will-quit", () => clearInterval(updateTimer))
-  yield* Effect.promise(() => startNetLog()).pipe(
-    Effect.catch((error) =>
-      Effect.sync(() => {
-        logger.warn("failed to start net log", error)
-      }),
-    ),
-  )
+  void startNetLog().catch((error) => logger.warn("failed to start net log", error))
 
   const loadingTask = yield* Effect.gen(function* () {
     logger.log("sidecar connection started", { version: SIDECAR_VERSION })

+ 8 - 1
packages/desktop/src/main/server.ts

@@ -1,7 +1,8 @@
-import { dirname, join } from "node:path"
+import { delimiter, dirname, join } from "node:path"
 import { fileURLToPath } from "node:url"
 import { app, utilityProcess } from "electron"
 import type { Details } from "electron"
+import { CHANNEL } from "./constants"
 import { getLogger } from "./logging"
 import { getUserShell, loadShellEnv } from "./shell-env"
 import { getStore } from "./store"
@@ -216,6 +217,12 @@ function createSidecarEnv(): Record<string, string> {
   )
   delete env.DEBUG
   if (process.platform === "linux") delete env.LD_PRELOAD
+  if (process.platform === "win32" && app.isPackaged) {
+    const runtime = join(process.resourcesPath, "windows-runtime")
+    const pathKey = Object.keys(env).find((key) => key.toLowerCase() === "path") ?? "Path"
+    env[pathKey] = [join(runtime, "git", "cmd"), join(runtime, "ripgrep"), env[pathKey]].filter(Boolean).join(delimiter)
+    if (CHANNEL === "beta") env.OPENCODE_DISABLE_LSP_DOWNLOAD ??= "true"
+  }
   return env
 }