DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.
feat(bundle): 离线包只随包必要资源,Git 不再作为启动前置条件
hairyff44e8d3613de
diff --git a/.github/actions/prepare-bundle-resources/action.yml b/.github/actions/prepare-bundle-resources/action.ymlindex 6ddce523..3d965bfb 100644--- a/.github/actions/prepare-bundle-resources/action.yml+++ b/.github/actions/prepare-bundle-resources/action.yml@@ -1,9 +1,9 @@name: Prepare offline bundle resourcesdescription: >-- Download and unpack the Node.js runtime, the packaged dsh core, pnpm (and MinGit- on Windows) into src-tauri/resources, then rewrite manifest.jsonc so every- bundled dependency resolves through `$Resources/...`. The resulting `tauri build`- produces an installer that needs no download on first launch.+ Download and unpack the Node.js runtime, the packaged dsh core and pnpm into+ src-tauri/resources, then rewrite manifest.jsonc so every bundled dependency+ resolves through `$Resources/...`. The resulting `tauri build` produces an+ installer that needs no download on first launch.inputs:platform:@@ -15,6 +15,13 @@ inputs:dsh-tag:description: deepseek-harness-pkg release tag bundled as the built-in corerequired: true+ bundle-git:+ description: >-+ Also bundle MinGit. Off by default: starting dsh needs no Git, only+ git-backed features (worktree, `github:` plugins) do, and an offline+ machine can never provision it afterwards.+ required: false+ default: 'false'runs:using: composite@@ -25,10 +32,18 @@ runs:PLATFORM: ${{ inputs.platform }}ARCH: ${{ inputs.arch }}DSH_TAG: ${{ inputs.dsh-tag }}+ BUNDLE_GIT: ${{ inputs.bundle-git }}GH_TOKEN: ${{ github.token }}run: |set -euo pipefail+ with_git=false+ if [ "$PLATFORM" = "windows" ] && [ "$BUNDLE_GIT" = "true" ]; then+ with_git=true+ fi+ git_flag=""+ [ "$with_git" = "true" ] && git_flag="--with-git"+workdir="$(mktemp -d)"trap 'rm -rf "$workdir"' EXIT@@ -115,7 +130,7 @@ runs:pnpm) pnpm_name="$name"; pnpm_url="$url"; pnpm_sha="$sha" ;;git) git_name="$name"; git_url="$url"; git_sha="$sha" ;;esac- done < <(node scripts/bundle-metadata.mjs --assets --platform "$PLATFORM" --arch "$ARCH")+ done < <(node scripts/bundle-metadata.mjs --assets --platform "$PLATFORM" --arch "$ARCH" $git_flag)# Node.js 运行时:摘要取自官方 SHASUMS256.txt,与 assets 同源同版本。fetch "$node_url" "${workdir}/${node_name}"@@ -145,8 +160,8 @@ runs:flatten "${workdir}/pnpm"install_tree "${workdir}/pnpm" "src-tauri/resources/pnpm"- # MinGit:仅 Windows 随包,摘要取自 constants.rs(内网环境补装必然失败,- # 系统 Git 缺失时它就是唯一可用的 Git)。+ # MinGit:默认不随包(`bundle-git: true` 才下载)。启动 dsh 不需要 Git,+ # 只有 git 托管的能力(worktree、`github:` 插件)依赖它。if [ -n "${git_name:-}" ]; thenfetch "$git_url" "${workdir}/${git_name}"verify "${workdir}/${git_name}" "$git_sha" "MinGit ${git_name}"@@ -155,7 +170,7 @@ runs:install_tree "${workdir}/git" "src-tauri/resources/git"fi- node scripts/bundle-metadata.mjs --manifest --platform "$PLATFORM" --arch "$ARCH"+ node scripts/bundle-metadata.mjs --manifest --platform "$PLATFORM" --arch "$ARCH" $git_flag- name: Verify bundled entriesshell: bash@@ -165,10 +180,14 @@ runs:set -euo pipefail# 入口路径必须与清单 `dependencies.<key>.entry` 一致:解压层级(flatten)# 或资产布局变化会让应用在启动时判定「依赖缺失」并转去联网下载。- entries="node/node.exe pnpm/bin/pnpm.cjs dsh/node_modules/@deepseek-ai/dsh/lib/bin.js"+ entries="pnpm/bin/pnpm.cjs dsh/node_modules/@deepseek-ai/dsh/lib/bin.js"if [ "$PLATFORM" != "windows" ]; then- entries="node/bin/node pnpm/bin/pnpm.cjs dsh/node_modules/@deepseek-ai/dsh/lib/bin.js"+ entries="node/bin/node $entries"else+ entries="node/node.exe $entries"+ fi+ # 清单没有指向 `$Resources/git` 时不能要求它存在(默认就不随包 MinGit)。+ if grep -q '"managedRoot": "$Resources/git"' src-tauri/resources/manifest.jsonc; thenentries="$entries git/cmd/git.exe"fimissing=0diff --git a/.github/workflows/build-bundle-windows.yml b/.github/workflows/build-bundle-windows.ymlindex ac080407..cd192b2f 100644--- a/.github/workflows/build-bundle-windows.yml+++ b/.github/workflows/build-bundle-windows.yml@@ -9,6 +9,11 @@ on:dsh_tag:required: truetype: string+ bundle_git:+ description: 随包 MinGit(默认关闭:启动 dsh 不需要 Git)+ required: false+ type: boolean+ default: falsesecrets:TAURI_SIGNING_PRIVATE_KEY:required: false@@ -22,7 +27,7 @@ jobs:build:name: Build offline bundle (windows)runs-on: windows-latest- # 离线包要下载 Node/dsh/MinGit 并压缩数百 MB 资源,远慢于普通构建。+ # 离线包要下载 Node/dsh 并压缩数百 MB 资源,远慢于普通构建。timeout-minutes: 180steps:- name: Checkout repository@@ -48,6 +53,7 @@ jobs:platform: windowsarch: x64dsh-tag: ${{ inputs.dsh_tag }}+ bundle-git: ${{ inputs.bundle_git }}# 内网机器上的 WebView2 只能靠安装包自带:默认的 downloadBootstrapper 会在# 安装时去微软下载运行时,白名单环境里直接失败。offlineInstaller 把完整的diff --git a/.github/workflows/release-bundle.yml b/.github/workflows/release-bundle.ymlindex 0518565f..7a918c15 100644--- a/.github/workflows/release-bundle.yml+++ b/.github/workflows/release-bundle.yml@@ -1,9 +1,10 @@name: Build & Release (Offline Bundle)# 离线安装包:在普通发布流程(release.yml)成功后追加一次带资源构建。-# 产物把 Node.js 运行时、推荐 dsh 内核、pnpm(Windows 另含 MinGit)随安装包分发,-# 并在构建期把 `resources/manifest.jsonc` 的托管根改写成 `$Resources/...`,首次-# 启动直接使用随包资源,全程不联网。+# 产物把 Node.js 运行时、推荐 dsh 内核、pnpm 随安装包分发,并在构建期把+# `resources/manifest.jsonc` 的托管根改写成 `$Resources/...`,首次启动直接使用+# 随包资源,全程不联网。只随包启动 dsh 必需的资源:MinGit 默认不携带(git 托管的+# 能力在真正使用时才需要,`bundle_git` 可显式开启)。## 手动触发有两条路:# - 留空 `tag`:试跑。构建当前 ref,发一个 `test-<ref>-<run>` 测试预发布,不碰任何@@ -32,6 +33,11 @@ on:required: falsedefault: ''type: string+ bundle_git:+ description: Windows 随包 MinGit(默认关闭:启动 dsh 不需要 Git)+ required: false+ default: false+ type: booleanpermissions:# 写权限只给真正上传产物的 finalize;prepare 与三个可复用构建只需要读。@@ -198,6 +204,7 @@ jobs:with:source_ref: ${{ needs.prepare.outputs.source_ref }}dsh_tag: ${{ needs.prepare.outputs.dsh_tag }}+ bundle_git: ${{ github.event_name == 'workflow_dispatch' && inputs.bundle_git || false }}secrets:TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}@@ -300,7 +307,7 @@ jobs:{echo "### Offline bundle assets"echo- echo "Bundled core: \`$DSH_TAG\` · resources mapped to \`\$Resources/{node,pnpm,dsh}\` (Windows also \`git\`)"+ echo "Bundled core: \`$DSH_TAG\` · resources mapped to \`\$Resources/{node,pnpm,dsh}\`"echofor asset in "${assets[@]}"; doecho "- \`$(basename "$asset")\`"diff --git a/README.en.md b/README.en.mdindex eb79be25..26bdf282 100644--- a/README.en.md+++ b/README.en.md@@ -91,7 +91,7 @@ The first run downloads the Node runtime and Harness core (if `dsh` is already i**System requirements:** Windows 10+ · macOS 10.15+ · Linux (AppImage / .deb) · network on first launch · Harness core **0.1.5-rc.1** or later-**Offline bundle (Windows / macOS):** Releases also ship `Deepseek.Harness.Desktop_Bundle_<version>.<ext>` — the Node runtime and Harness core (plus MinGit on Windows) are bundled in, so the **first launch needs no network**. Built for air-gapped / whitelisted machines (preset and community plugins still need network). The Linux bundle ships inside the `.deb`, whose `/usr/lib` resources are read-only, so the bundled core's directory permissions have to be fixed after a root install.+**Offline bundle (Windows / macOS):** Releases also ship `Deepseek.Harness.Desktop_Bundle_<version>.<ext>` — the Node runtime and Harness core are bundled in, so the **first launch needs no network**. Built for air-gapped / whitelisted machines (preset and community plugins still need network, and git-backed features such as worktree need a system Git). The Linux bundle ships inside the `.deb`, whose `/usr/lib` resources are read-only, so the bundled core's directory permissions have to be fixed after a root install.> **Linux Wayland note (PikaOS / GNOME Wayland / Ubuntu 22.04+):** AppImage may crash or render black on Wayland due to WebKitGTK; the app auto-fixes the common case. <details><summary>If it still crashes / renders black:</summary><br>**Prefer `.deb`** (verified on PikaOS 4 Wayland), or manually run `WEBKIT_DISABLE_COMPOSITING_MODE=1 WEBKIT_DISABLE_DMABUF_RENDERER=1 GDK_BACKEND=x11 ./AppImage`. If icons do not appear, copy the app's `hicolor` icons to `~/.local/share/icons` and run `update-desktop-database`.<br></details>>diff --git a/README.es.md b/README.es.mdindex b3008fdf..1b2516b9 100644--- a/README.es.md+++ b/README.es.md@@ -90,7 +90,7 @@ El primer arranque descarga el runtime de Node y el núcleo Harness (si `dsh` ya**Requisitos:** Windows 10+ · macOS 10.15+ · Linux (AppImage / .deb) · red en el primer arranque · núcleo Harness **0.1.5-rc.1** o superior-**Paquete sin conexión (Windows / macOS):** En Releases también está `Deepseek.Harness.Desktop_Bundle_<versión>.<ext>`: trae el runtime de Node y el núcleo Harness (y MinGit en Windows), así que **el primer arranque no necesita red**. Pensado para equipos sin internet o con lista blanca (los plugins preestablecidos y de la comunidad sí necesitan red). En Linux el paquete va dentro del `.deb`, cuyos recursos en `/usr/lib` son de solo lectura: hay que corregir los permisos de ese directorio después de instalarlo como root.+**Paquete sin conexión (Windows / macOS):** En Releases también está `Deepseek.Harness.Desktop_Bundle_<versión>.<ext>`: trae el runtime de Node y el núcleo Harness, así que **el primer arranque no necesita red**. Pensado para equipos sin internet o con lista blanca (los plugins preestablecidos y de la comunidad sí necesitan red, y las funciones basadas en git —como los worktrees— necesitan un Git del sistema). En Linux el paquete va dentro del `.deb`, cuyos recursos en `/usr/lib` son de solo lectura: hay que corregir los permisos de ese directorio después de instalarlo como root.> **Nota Wayland en Linux (PikaOS / GNOME Wayland / Ubuntu 22.04+):** el AppImage puede crashear o verse negro en Wayland por WebKitGTK; la app corrige sola el caso común. <details><summary>Si igual crashea / se ve negro:</summary><br>**Preferí el `.deb`** (verificado en PikaOS 4 Wayland), o ejecutá a mano `WEBKIT_DISABLE_COMPOSITING_MODE=1 WEBKIT_DISABLE_DMABUF_RENDERER=1 GDK_BACKEND=x11 ./AppImage`. Si no aparecen los iconos, copiá los iconos `hicolor` de la app a `~/.local/share/icons` y ejecutá `update-desktop-database`.<br></details>>diff --git a/README.md b/README.mdindex 6b00092d..a318519b 100644--- a/README.md+++ b/README.md@@ -86,7 +86,7 @@ brew install dsh-tauri/desktop/deepseek-harness**系统要求:** Windows 10+ · macOS 10.15+ · Linux(AppImage / .deb)· 首次运行需要网络 · Harness 内核 **0.1.5-rc.1** 或更高-**离线安装包(Windows / macOS):** Releases 里另有 `Deepseek.Harness.Desktop_Bundle_<版本>.<扩展名>`:Node 运行时与 Harness 内核(Windows 另含 MinGit)随包分发,**安装后首次启动无需联网**,适合内网 / 白名单环境(预设与社区插件仍需联网)。Linux 的随包资源在 `.deb` 的 `/usr/lib` 下,root 安装后需补齐该目录权限。+**离线安装包(Windows / macOS):** Releases 里另有 `Deepseek.Harness.Desktop_Bundle_<版本>.<扩展名>`:Node 运行时与 Harness 内核随包分发,**安装后首次启动无需联网**,适合内网 / 白名单环境(预设与社区插件仍需联网;git 相关能力如工作树需系统已装 Git)。Linux 的随包资源在 `.deb` 的 `/usr/lib` 下,root 安装后需补齐该目录权限。> **Linux Wayland 注意(PikaOS / GNOME Wayland / Ubuntu 22.04+):** AppImage 在 Wayland 下可能因 WebKitGTK 黑屏/崩溃,应用已自动处理常见情形。 <details><summary>若仍黑屏/崩溃:</summary><br>**改用 `.deb`**(已验证 PikaOS 4 Wayland),或手动 `WEBKIT_DISABLE_COMPOSITING_MODE=1 WEBKIT_DISABLE_DMABUF_RENDERER=1 GDK_BACKEND=x11 ./AppImage`。图标不显示时,将应用内 `hicolor` 图标复制到 `~/.local/share/icons` 并运行 `update-desktop-database`。<br></details>>diff --git a/scripts/bundle-metadata.d.mts b/scripts/bundle-metadata.d.mtsindex 1b81b732..fb6cab7c 100644--- a/scripts/bundle-metadata.d.mts+++ b/scripts/bundle-metadata.d.mts@@ -57,13 +57,15 @@ export function mingitAssetName(arch: BundleArch, version: string): stringexport function readBuildConstants(repo?: string): BundleConstants-export function bundleTargets(platform: BundlePlatform): string[]+export function bundleTargets(platform: BundlePlatform, options?: { withGit?: boolean }): string[]export function bundleAssets(input: {platform: BundlePlatformarch: BundleArchconstants: BundleConstantsdshTag: string+ /** 随包 MinGit(默认 false;Windows 且清单未被改写时才需要) */+ withGit?: boolean}): BundleAssetsexport function toAssetTable(assets: BundleAssets): string@@ -71,6 +73,7 @@ export function toAssetTable(assets: BundleAssets): stringexport function applyBundleManifest(input: {repo?: stringplatform: BundlePlatform+ withGit?: boolean}): { file: string, applied: string[] }export function findReleaseTag(releases: unknown, version: string): stringdiff --git a/scripts/bundle-metadata.mjs b/scripts/bundle-metadata.mjsindex b26a9114..16a82e35 100644--- a/scripts/bundle-metadata.mjs+++ b/scripts/bundle-metadata.mjs@@ -195,10 +195,16 @@ export function readBuildConstants(repo = process.cwd()) {}}-/** 随包依赖键(Windows 额外随包 MinGit,离线包不依赖系统 Git)。 */-export function bundleTargets(platform) {+/**+ * 随包依赖键。+ *+ * 默认只随包 Node / pnpm / 内核三项:MinGit 约 35 MiB,而绝大多数 Windows 机器已有+ * 可用的系统 Git,内网补装又必然失败(应用侧据「随包资源」构建放宽 Git 就绪判定,+ * 见 `config::dependencies::is_bundled_install`)。确有需要时用 `--with-git` 显式开启。+ */+export function bundleTargets(platform, { withGit = false } = {}) {const keys = ['node', 'pnpm', 'dsh']- if (platform === 'windows')+ if (platform === 'windows' && withGit)keys.push('git')return keys}@@ -210,7 +216,7 @@ export function bundleTargets(platform) {* 为需要单独下载的摘要来源(Node 官方 SHASUMS256.txt);dsh 的摘要在下载后经* GitHub Release API 读取(见 workflow)。*/-export function bundleAssets({ platform, arch, constants, dshTag }) {+export function bundleAssets({ platform, arch, constants, dshTag, withGit = false }) {const nodeName = nodeAssetName(platform, arch, constants.nodeVersion)const dshName = dshAssetName(platform, arch)const assets = {@@ -233,7 +239,7 @@ export function bundleAssets({ platform, arch, constants, dshTag }) {sha256Url: '',},}- if (platform === 'windows') {+ if (platform === 'windows' && withGit) {const name = mingitAssetName(arch, constants.mingitVersion)assets.git = {name,@@ -266,9 +272,10 @@ export function toAssetTable(assets) {* 安装留下的 AppData 路径,可能已被删除)不能盖过随包资源。** 改写结果直接写回 `src-tauri/resources/manifest.jsonc`(构建产物,不提交),- * 因此注释与缩进按 JSON 重新序列化。+ * 因此注释与缩进按 JSON 重新序列化。未随包的依赖(默认的 MinGit)保持清单原值,+ * 不能指向并不存在的 `$Resources/git`。*/-export function applyBundleManifest({ repo = process.cwd(), platform } = {}) {+export function applyBundleManifest({ repo = process.cwd(), platform, withGit = false } = {}) {if (!['windows', 'macos', 'linux'].includes(platform))throw bundleError(`platform must be windows|macos|linux, got ${JSON.stringify(platform)}`)const manifest = readManifest(repo)@@ -277,7 +284,7 @@ export function applyBundleManifest({ repo = process.cwd(), platform } = {}) {throw bundleError('manifest.jsonc is missing the dependencies section')const applied = []- for (const key of bundleTargets(platform)) {+ for (const key of bundleTargets(platform, { withGit })) {const spec = dependencies[key]if (!spec || typeof spec !== 'object')throw bundleError(`manifest.jsonc is missing dependencies.${key}`)@@ -334,13 +341,15 @@ function appendOutputs(outputPath, values) {}function parseArgs(argv) {- const args = { assets: false, manifest: false, platform: '', arch: '' }+ const args = { assets: false, manifest: false, platform: '', arch: '', withGit: false }for (let i = 0; i < argv.length; i += 1) {const arg = argv[i]if (arg === '--assets')args.assets = trueelse if (arg === '--manifest')args.manifest = true+ else if (arg === '--with-git')+ args.withGit = trueelse if (arg === '--platform')args.platform = argv[++i] ?? ''else if (arg === '--arch')@@ -367,13 +376,13 @@ async function main() {if (args.assets) {requirePlatformArch(args)const dshTag = requireString(process.env.DSH_TAG || '', 'DSH_TAG environment variable')- process.stdout.write(`${toAssetTable(bundleAssets({ platform: args.platform, arch: args.arch, constants, dshTag }))}\n`)+ process.stdout.write(`${toAssetTable(bundleAssets({ platform: args.platform, arch: args.arch, constants, dshTag, withGit: args.withGit }))}\n`)return}if (args.manifest) {requirePlatformArch(args)- const { file, applied } = applyBundleManifest({ repo, platform: args.platform })+ const { file, applied } = applyBundleManifest({ repo, platform: args.platform, withGit: args.withGit })process.stdout.write(`${file}\n${applied.map(line => ` ${line}`).join('\n')}\n`)return}diff --git a/src-tauri/resources/README.md b/src-tauri/resources/README.mdindex 8d3ec6b4..77a3ff70 100644--- a/src-tauri/resources/README.md+++ b/src-tauri/resources/README.md@@ -117,7 +117,13 @@ second set of installers that need no network on first launch. Its| `resources/node` | Node.js runtime (`node.exe` / `bin/node`) || `resources/pnpm` | pnpm distribution (`bin/pnpm.cjs`) || `resources/dsh` | packaged DeepSeek Harness core (`node_modules/@deepseek-ai/dsh/lib/bin.js`) |-| `resources/git` | MinGit — Windows only, so a blank machine needs no Git install |+| `resources/git` | MinGit — **not** bundled by default (`bundle_git` opt-in) |++Only what running `dsh` itself needs is bundled. Git is deliberately left out: it is not+required to start the harness, only git-backed features (worktree, `github:` plugins) are,+and an air-gapped machine can never provision it later. A bundled build therefore stops+treating Git as a startup prerequisite (see `config::dependencies::is_bundled_install`),+so the install screen is never entered for a download that cannot succeed.Every asset is SHA-256 verified before unpacking (Node against the official`SHASUMS256.txt`, the core against its GitHub release digest, pnpm/MinGit against the@@ -141,7 +147,7 @@ The rewrite only ever touches the build output — the committed manifest keeps`<app-data>/dependencies.json` (written by an earlier, non-bundled install and possiblypointing at deleted directories) from winning over the bundled copy.-No Rust code is involved: node/pnpm/git are only ever read, and the core is used in place,+No Rust code is involved: node/pnpm are only ever read, and the core is used in place,so the install directory must stay writable for the desktop's startup patches and pluginentry links — true for the per-user NSIS install, not for `/usr/lib/**` in the Linux deb(documented limitation). Community/preset plugins are still installed from the network;diff --git a/src-tauri/src/config/dependencies.rs b/src-tauri/src/config/dependencies.rsindex 4651bfdd..c01a7ddf 100644--- a/src-tauri/src/config/dependencies.rs+++ b/src-tauri/src/config/dependencies.rs@@ -193,6 +193,21 @@ pub fn active_root<R: Runtime>(app: &AppHandle<R>, key: &str) -> PathBuf {managed_root(app, key)}+/// 本次安装是否为「随包资源」构建:清单把核心托管根指向安装包资源目录+/// (`$Resources/...`,离线包构建 `.github/actions/prepare-bundle-resources` 的改写产物)。+///+/// 这类安装的运行时全部随安装包分发,运行期下载在离线机器上必然失败。启动就绪判定+/// 据此放宽「补不上的依赖」——它们不是启动 dsh 的前置条件。+#[cfg_attr(not(windows), allow(dead_code))] // 仅 Windows 的 Git 就绪判定使用+pub fn is_bundled_install<R: Runtime>(app: &AppHandle<R>) -> bool {+ let Some(root) = manifest::resource_root(app) else {+ return false;+ };+ let managed = managed_root(app, DEP_DSH);+ // 资源根自身不算:只有把某个依赖托管到 `$Resources/<name>` 才是随包构建。+ managed != root && managed.starts_with(&root)+}+/// 入口相对路径(相对依赖根):清单 `dependencies.<key>.entry`,未声明时用内置默认pub fn entry_relative<R: Runtime>(app: &AppHandle<R>, key: &str) -> PathBuf {let declared = manifest::dependency_spec(app, key)diff --git a/src-tauri/src/config/runtime.rs b/src-tauri/src/config/runtime.rsindex 7e7384e9..77af2373 100644--- a/src-tauri/src/config/runtime.rs+++ b/src-tauri/src/config/runtime.rs@@ -443,9 +443,16 @@ pub fn get_git_cmd_dir<R: Runtime>(_app_handle: &AppHandle<R>) -> Option<PathBuf}/// 当前环境是否已有可供插件 Git 依赖使用的 Git。+///+/// 随包资源构建(离线安装包)只随包运行 dsh 必需的 Node / pnpm / 内核,不随包 MinGit:+/// 启动 dsh 本身不需要 Git,而内网补装必然失败,把 Git 当成启动前置条件只会把应用卡在+/// 安装界面(见 [`dependencies::is_bundled_install`])。git 托管的能力(worktree、+/// `github:` 插件)在真正使用时给出明确失败。#[cfg(windows)]pub fn git_runtime_ready<R: Runtime>(app_handle: &AppHandle<R>) -> bool {- find_system_git_binary().is_some() || git_binary_works(&get_mingit_binary_path(app_handle))+ find_system_git_binary().is_some()+ || git_binary_works(&get_mingit_binary_path(app_handle))+ || dependencies::is_bundled_install(app_handle)}/// 非 Windows 平台不属于本次空白 Windows 环境的自动配置范围。diff --git a/test/bundle-metadata.test.ts b/test/bundle-metadata.test.tsindex 0cc94eb7..bc324711 100644--- a/test/bundle-metadata.test.ts+++ b/test/bundle-metadata.test.ts@@ -73,8 +73,8 @@ const constants: BundleConstants = {const DSH_TAG = 'dsh-0.1.5-rc.3-12345678901'-function assetsFor(platform: string, arch: string) {- return bundleMetadata.bundleAssets({ platform, arch, constants, dshTag: DSH_TAG })+function assetsFor(platform: string, arch: string, options: { withGit?: boolean } = {}) {+ return bundleMetadata.bundleAssets({ platform, arch, constants, dshTag: DSH_TAG, ...options })}describe('bundle metadata tag parsing', () => {@@ -117,7 +117,7 @@ describe('bundle asset names', () => {})describe('bundle asset resolution', () => {- it('pins every windows asset to a downloadable url', () => {+ it('pins every essentials asset to a downloadable url', () => {const assets = assetsFor('windows', 'x64')expect(assets.node.url).toBe('https://nodejs.org/dist/v22.22.0/node-v22.22.0-win-x64.zip')@@ -126,17 +126,24 @@ describe('bundle asset resolution', () => {`https://github.com/dsh-tauri-desk/deepseek-harness-pkg/releases/download/${DSH_TAG}/deepseek-harness-pkg-windows.zip`,)expect(assets.pnpm.url).toBe('https://registry.npmjs.org/pnpm/-/pnpm-11.7.0.tgz')- // 离线包不依赖系统 Git:Windows 随包 MinGit,摘要取自 constants.rs。- expect(assets.git?.url).toBe(- 'https://github.com/git-for-windows/git/releases/download/v2.53.0.windows.2/MinGit-2.53.0.2-64-bit.zip',- )- expect(assets.git?.sha256).toBe(constants.mingitX64Sha256)})- it('bundles MinGit on windows only', () => {- expect(bundleMetadata.bundleTargets('windows')).toEqual(['node', 'pnpm', 'dsh', 'git'])+ it('bundles MinGit only on request, and only on windows', () => {+ // 启动 dsh 不需要 Git:默认只随包必要品。+ expect(bundleMetadata.bundleTargets('windows')).toEqual(['node', 'pnpm', 'dsh'])expect(bundleMetadata.bundleTargets('macos')).toEqual(['node', 'pnpm', 'dsh'])+ expect(Object.keys(assetsFor('windows', 'x64')).sort()).toEqual(['dsh', 'node', 'pnpm'])expect(Object.keys(assetsFor('macos', 'arm64')).sort()).toEqual(['dsh', 'node', 'pnpm'])++ const withGit = assetsFor('windows', 'x64', { withGit: true })+ expect(bundleMetadata.bundleTargets('windows', { withGit: true })).toEqual(['node', 'pnpm', 'dsh', 'git'])+ expect(withGit.git?.url).toBe(+ 'https://github.com/git-for-windows/git/releases/download/v2.53.0.windows.2/MinGit-2.53.0.2-64-bit.zip',+ )+ expect(withGit.git?.sha256).toBe(constants.mingitX64Sha256)+ expect(assetsFor('windows', 'arm64', { withGit: true }).git?.sha256).toBe(constants.mingitArm64Sha256)+ // 非 Windows 平台没有 MinGit 可选。+ expect(Object.keys(assetsFor('linux', 'x64', { withGit: true })).sort()).toEqual(['dsh', 'node', 'pnpm'])})it('keeps empty sha256 fields in the asset table', () => {@@ -232,18 +239,39 @@ describe('bundle manifest rewrite', () => {'node -> $Resources/node','pnpm -> $Resources/pnpm','dsh -> $Resources/dsh',- 'git -> $Resources/git',])const manifest = JSON.parse(readFileSync(result.file, 'utf8'))const shipped = JSON.parse(bundleMetadata.stripJsonc(SHIPPED))- for (const [key, dir] of [['node', 'node'], ['pnpm', 'pnpm'], ['dsh', 'dsh'], ['git', 'git']]) {+ for (const [key, dir] of [['node', 'node'], ['pnpm', 'pnpm'], ['dsh', 'dsh']]) {expect(manifest.dependencies[key].managedRoot).toBe(`$Resources/${dir}`)expect(manifest.dependencies[key].overridable).toBe(false)// 入口形状由清单声明,改写托管根不得动它。expect(manifest.dependencies[key].entry).toEqual(shipped.dependencies[key].entry)}expect(manifest.engines.dsh.recommend).toBe('0.1.5-rc.3')+ // 未随包的 git 保持清单原值:不能指向并不存在的 `$Resources/git`。+ expect(manifest.dependencies.git.managedRoot).toBe('$AppData/dependencies/git')+ expect(manifest.dependencies.git.overridable).toBe(true)+ }+ finally {+ rmSync(repo, { recursive: true, force: true })+ }+ })++ it('moves git to $Resources only when MinGit is bundled', () => {+ const repo = tempRepo()+ try {+ const { file, applied } = bundleMetadata.applyBundleManifest({ repo, platform: 'windows', withGit: true })+ expect(applied).toEqual([+ 'node -> $Resources/node',+ 'pnpm -> $Resources/pnpm',+ 'dsh -> $Resources/dsh',+ 'git -> $Resources/git',+ ])+ const manifest = JSON.parse(readFileSync(file, 'utf8'))+ expect(manifest.dependencies.git.managedRoot).toBe('$Resources/git')+ expect(manifest.dependencies.git.overridable).toBe(false)}finally {rmSync(repo, { recursive: true, force: true })