docs: 安装置顶一键脚本;手动方式改为 npx dsh 命令链(自愈构建脚本拦截)

This commit is contained in:
Menghuan1918
2026-08-14 00:12:25 +08:00
parent 5a93f610d8
commit 1b7c8ba497
2 changed files with 44 additions and 40 deletions
+22 -20
View File
@@ -35,23 +35,9 @@ https://github.com/user-attachments/assets/23187822-047e-45cc-b480-fe997bd55b86
## 🚀 安装
前置:已安装 DSH(`dsh web` 可运行,含 `dsh plugin` 命令),Node.js ≥ 20、pnpm ≥ 10。插件已发布到 npm:**`dsh-better-sidebar@0.10.2`**(`@deepseek-ai/*` peer 依赖对齐宿主实际版本 `^0.1.0-rc.6` / `@deepseek-ai/cordis@^4.0.1`,同版本单实例)。包内声明了 `dsh.bundle.patch`(随包发布的 `cordis.patch.yml`),官方 CLI **一条命令完成安装 + 挂载**,不修改 DSH 源码。
前置:已安装 DSH(`dsh web` 可运行),Node.js ≥ 20、pnpm ≥ 10。插件已发布到 npm:**`dsh-better-sidebar@0.10.2`**(`@deepseek-ai/*` peer 依赖对齐宿主实际版本 `^0.1.0-rc.6` / `@deepseek-ai/cordis@^4.0.1`,同版本单实例)。包内声明了 `dsh.bundle.patch`(随包发布的 `cordis.patch.yml`),安装后由官方 CLI 自动挂载,不修改 DSH 源码。
### 官方 CLI 安装(推荐)
```sh
dsh plugin --profile web add dsh-better-sidebar
# 或(本机无 dsh 命令时)
npx -y --package @deepseek-ai/dsh dsh plugin --profile web add dsh-better-sidebar
# 或固定某版本
dsh plugin --profile web add dsh-better-sidebar@0.10.2
```
不带 `@<版本>` 时,pnpm 默认解析 npm 的 `latest` 标签,即最新发布版(当前 `0.10.2`)。命令自动完成:`pnpm add` 登记依赖到 `~/.dsh/profiles/web/package.json` → 识别包内 `dsh.bundle.patch`,把插件自动加进 `dsh.profile.bundles` → 下次启动自动挂载(无需手写 `cordis.patch.yml` 挂载行)。更新同理:重跑 `dsh plugin --profile web add dsh-better-sidebar` 即升到最新版。
> ⚠️ 首次在新 profile 上执行时,pnpm 11 的 `strict-dep-builds` 会拦截 node-pty/protobufjs 的构建脚本,命令会报 `Ignored build scripts`(包仍已安装、node-pty 预编译产物可直接用)。此时在 `~/.dsh/profiles/web` 执行 `pnpm approve-builds --all` 再重跑一次即可;`scripts/install.sh` 会自动处理(预写 allowBuilds + 清理旧挂载行)。
### 一键脚本(自动处理 allowBuilds / 旧挂载行)
### 一键安装(推荐)
```sh
curl -fsSL https://raw.githubusercontent.com/omdsh-dev/DSH-better-sidebar/main/scripts/install.sh | bash
@@ -59,15 +45,31 @@ curl -fsSL https://raw.githubusercontent.com/omdsh-dev/DSH-better-sidebar/main/s
# 装完自动重启 DSH: curl -fsSL <同上> | bash -s -- --restart
```
脚本自动完成:`pnpm add` 登记依赖到 `~/.dsh/profiles/web/package.json` → 预写 `allowBuilds`(node-pty/protobufjs,规避 pnpm 11 的构建脚本拦截)→ 识别包内 `dsh.bundle.patch`,把插件自动加进 `dsh.profile.bundles` 挂载 → 幂等清理旧的手动挂载行(防双挂载)。版本默认最新(`latest`),可传参;`--dry-run` 只预览不落盘。
### 手动安装(npx dsh + 命令链)
等价于上面脚本的一连串 bash 命令(全新 profile 首次装可能因构建脚本被拦,链里 `||` 分支会自动批准并重试一次):
```sh
cd ~/.dsh/profiles/web \
&& npx -y --package @deepseek-ai/dsh dsh plugin --profile web add dsh-better-sidebar \
|| (pnpm approve-builds --all \
&& npx -y --package @deepseek-ai/dsh dsh plugin --profile web add dsh-better-sidebar)
# 固定版本:把上面的 dsh-better-sidebar 换成 dsh-better-sidebar@0.10.2
```
不带 `@<版本>` 时,pnpm 解析 npm 的 `latest` 标签(最新发布版)。`dsh plugin add` 完成:`pnpm add` 登记依赖 → 识别 `dsh.bundle.patch` 自动注册到 `dsh.profile.bundles` → 下次启动自动挂载(无需手写 `cordis.patch.yml`)。
> ⚠️ pnpm 11 的两道供应链策略:① `strict-dep-builds` 拦截 node-pty/protobufjs 构建脚本(首次 `pnpm approve-builds --all` 一次即可,包其实已装上、node-pty 预编译产物可直接用);② `minimumReleaseAge` 拒绝 <24h 的新版本(pnpm 会自动补 `minimumReleaseAgeExclude`,重跑一次即可)。
### 更新
```sh
dsh plugin --profile web add dsh-better-sidebar@<新版>
dsh plugin --profile web add dsh-better-sidebar
```
或手动把 `~/.dsh/profiles/web/package.json` 里版本号改到新版(如 `"^0.10.2"`)后 `pnpm install`。随后重启 DSH 并硬刷新(Cmd/Ctrl+Shift+R)。
> 提示:若 pnpm 因 `minimumReleaseAge`(发布 <24h 的新版本)拒绝安装,会自动向 `~/.dsh/profiles/web/pnpm-workspace.yaml` 追加 `minimumReleaseAgeExclude` 条目;也可手动补一行 `dsh-better-sidebar@<版本>`。
或重跑一次一键脚本;也可手动把 `~/.dsh/profiles/web/package.json` 版本号改新版后 `pnpm install`。随后重启 DSH 并硬刷新(Cmd/Ctrl+Shift+R)。
<details>
<summary><b>从源码安装 / 开发(可选,替代 npm 方式)</b></summary>
+22 -20
View File
@@ -35,23 +35,9 @@ https://github.com/user-attachments/assets/23187822-047e-45cc-b480-fe997bd55b86
## 🚀 Installation
Prerequisites: DSH installed (`dsh web` works, including the `dsh plugin` command), Node.js ≥ 20, pnpm ≥ 10. The plugin is published to npm as **`dsh-better-sidebar@0.10.2`** (`@deepseek-ai/*` peers aligned with the host's actual versions `^0.1.0-rc.6` / `@deepseek-ai/cordis@^4.0.1`, single instance). The package declares `dsh.bundle.patch` (the shipped `cordis.patch.yml`), so the official CLI installs **and mounts in one command** — the DSH source is never modified.
Prerequisites: DSH installed (`dsh web` works), Node.js ≥ 20, pnpm ≥ 10. The plugin is published to npm as **`dsh-better-sidebar@0.10.2`** (`@deepseek-ai/*` peers aligned with the host's actual versions `^0.1.0-rc.6` / `@deepseek-ai/cordis@^4.0.1`, single instance). The package declares `dsh.bundle.patch` (the shipped `cordis.patch.yml`), so the official CLI mounts it after install — the DSH source is never modified.
### Official CLI install (recommended)
```sh
dsh plugin --profile web add dsh-better-sidebar
# or (no local dsh command):
npx -y --package @deepseek-ai/dsh dsh plugin --profile web add dsh-better-sidebar
# or pin a specific version:
dsh plugin --profile web add dsh-better-sidebar@0.10.2
```
Without `@<version>`, pnpm resolves npm's `latest` tag — the newest published release (currently `0.10.2`). The command: runs `pnpm add` to register the dependency in `~/.dsh/profiles/web/package.json`, detects the package's `dsh.bundle.patch`, auto-appends the plugin to `dsh.profile.bundles`, and the next boot mounts it — no hand-written `cordis.patch.yml` mount line. Update the same way: re-run `dsh plugin --profile web add dsh-better-sidebar` to get the latest.
> ⚠️ On a fresh profile, pnpm 11's `strict-dep-builds` blocks node-pty/protobufjs build scripts and the command reports `Ignored build scripts` (the package is still installed; node-pty's prebuilds work as-is). Fix: run `pnpm approve-builds --all` in `~/.dsh/profiles/web` and re-run. `scripts/install.sh` handles this automatically (pre-writes allowBuilds + cleans up the old mount line).
### One-click script (handles allowBuilds / old mount line)
### One-click install (recommended)
```sh
curl -fsSL https://raw.githubusercontent.com/omdsh-dev/DSH-better-sidebar/main/scripts/install.sh | bash
@@ -59,15 +45,31 @@ curl -fsSL https://raw.githubusercontent.com/omdsh-dev/DSH-better-sidebar/main/s
# Auto-restart DSH: curl -fsSL <same URL> | bash -s -- --restart
```
The script: runs `pnpm add` to register the dependency in `~/.dsh/profiles/web/package.json`, pre-writes `allowBuilds` (node-pty/protobufjs, to dodge pnpm 11's build-script block), detects the package's `dsh.bundle.patch`, auto-appends the plugin to `dsh.profile.bundles`, and idempotently cleans up the old hand-written mount line (to avoid double-mounting). Version defaults to latest (`latest`); `--dry-run` previews without writing.
### Manual install (npx dsh + command chain)
The same steps as a chain of bash commands (a fresh profile may hit the build-script block once; the `||` branch approves and retries):
```sh
cd ~/.dsh/profiles/web \
&& npx -y --package @deepseek-ai/dsh dsh plugin --profile web add dsh-better-sidebar \
|| (pnpm approve-builds --all \
&& npx -y --package @deepseek-ai/dsh dsh plugin --profile web add dsh-better-sidebar)
# Pin a version: replace dsh-better-sidebar with dsh-better-sidebar@0.10.2
```
Without `@<version>`, pnpm resolves npm's `latest` tag (the newest release). `dsh plugin add` runs `pnpm add` to register the dependency, detects `dsh.bundle.patch`, auto-appends the plugin to `dsh.profile.bundles`, and the next boot mounts it — no hand-written `cordis.patch.yml` mount line.
> ⚠️ pnpm 11's two supply-chain policies: ① `strict-dep-builds` blocks node-pty/protobufjs build scripts (run `pnpm approve-builds --all` once; the package is already installed and node-pty's prebuilds work as-is); ② `minimumReleaseAge` rejects releases younger than 24h (pnpm auto-appends a `minimumReleaseAgeExclude` entry — just re-run once).
### Updating
```sh
dsh plugin --profile web add dsh-better-sidebar@<new>
dsh plugin --profile web add dsh-better-sidebar
```
or bump the version range in `~/.dsh/profiles/web/package.json` (e.g. `"^0.10.2"`) and run `pnpm install`. Then restart DSH and hard-refresh (Cmd/Ctrl+Shift+R).
> Note: if pnpm rejects a too-fresh release via `minimumReleaseAge` (<24h old), it auto-appends a `minimumReleaseAgeExclude` entry to `~/.dsh/profiles/web/pnpm-workspace.yaml` — or add `dsh-better-sidebar@<version>` there manually.
or re-run the one-click script; or bump the version range in `~/.dsh/profiles/web/package.json` (e.g. `"^0.10.2"`) and run `pnpm install`. Then restart DSH and hard-refresh (Cmd/Ctrl+Shift+R).
<details>
<summary><b>Install from source / develop (optional — alternative to the npm flow)</b></summary>